Dbool RenderModule::FrustumCulling(const BaseFace& currentface) { Duint faceSize = currentface.vecIndex.size(); Dbool isCulling = false; Dfloat boundary = 1.0f + cc_frustum_bias.Float(); for( Duint i = 0; i < faceSize; ++i ) { Dint index = currentface.vecIndex[ i ]; Vector3 Vertex = m_trasnformVertex[ index - 1 ]; if( Vertex.x < -boundary || boundary < Vertex.x || Vertex.y < -boundary || boundary < Vertex.y || Vertex.z < -boundary || boundary < Vertex.z ) { //시야 범위를 넘어감 즉, 제외 됨 isCulling = true; } else { isCulling = false; } } return isCulling; }
EXTERN_FORM DLL_API Dvoid __cdecl coold_UpdateCamera(Dint x, Dint y, Dint clickState, Dbool front, Dbool back, Dbool left, Dbool right, Dbool up, Dbool down) { if (cc_use_camera.Bool()) { MoveKey moveKey = { front, back, left, right, up, down }; GETSINGLE(Camera).UpdateCamera(x, y, clickState, moveKey, g_matView, g_matPers); } }
Dvoid RenderModule::Render( ) { if( m_pMesh == nullptr ) return; vector<BaseFace>* pvecFace = m_pMesh->GetVectorFace(); for( Dint faceNum = 0; faceNum < (Dint)pvecFace->size(); ++faceNum ) { BaseFace currentFace = (*pvecFace)[ faceNum ]; //projection frustum culling if( cc_use_frustumcull.Bool() && FrustumCulling(currentFace) ) { continue; } m_vecLine.clear(); m_edgeTable.clear(); m_activeTable.clear(); CreatePointsToLines(pvecFace, faceNum, m_vecLine); //backspace culling if( cc_use_backspacecull.Bool() && !BackSpaceCulling(m_vecLine) ) { continue; } auto unusualValue = STD_FIND_IF(m_vecLine, [] (const Line& line) { //모든 요소의 y 값이 같은지 체크 return line.beginVertex.y != line.endVertex.y; }); if( unusualValue != end(m_vecLine) ) { CreateEdgeTable(m_vecLine, m_edgeTable); CreateChainTable(m_vecLine, m_activeTable); DrawFace(m_activeTable, m_edgeTable, MixDotColor( currentFace.color )); } } }
EXTERN_FORM DLL_API Dvoid __cdecl coold_SetViewFactor(Dfloat* eye, Dfloat* lookat, Dfloat* up) { //시점 이동 if (!cc_use_camera.Bool()) { if (cc_x_eye.Bool()) eye[0] += cc_x_eye.Float(); if (cc_y_eye.Bool()) eye[1] += cc_y_eye.Float(); if (cc_z_eye.Bool()) eye[2] += cc_z_eye.Float(); g_matView = TransformHelper::CreateView(Vector3(eye), Vector3(lookat), Vector3(up)); } }
EXTERN_FORM DLL_API Dvoid __cdecl coold_SetTransform(Dint transformType, const Dfloat* matrix4x4) { //월드만 넘겨 받는다. switch( transformType ) { case 0: //World { Matrix44 matWorld(matrix4x4); g_matWorld = matWorld.Transpose(); //원점 기준으로 이동 if (cc_x_move.Bool()) g_matWorld[12] = cc_x_move.Float(); if (cc_y_move.Bool()) g_matWorld[13] = cc_y_move.Float(); if (cc_z_move.Bool()) g_matWorld[14] = cc_z_move.Float(); } break; default: break; } }
EXTERN_FORM DLL_API Dvoid __cdecl coold_SetPerspectiveFactor(Dfloat fovY, Dfloat aspect, Dfloat zn, Dfloat zf) { if ( !cc_use_camera.Bool() ) g_matPers = TransformHelper::CreatePerspective(kPI / fovY, aspect, zn + cc_adjust_zn.Float(), zf + cc_adjust_zf.Float()); }
g_renderModule->RenderBegin(Mesh.second); g_renderModule->RenderEnd(); } } if ( threadUse ) g_pThreadManager->WaitAllThreadWorking(); //─────────────────────────────────────────────────────────────────────────────────── //이 부분은 시리얼 동작한다. SerializeTask(threadUse); //─────────────────────────────────────────────────────────────────────────────────── } static VariableCommand cc_x_move("cc_x_move", "0"); static VariableCommand cc_y_move("cc_y_move", "0"); static VariableCommand cc_z_move("cc_z_move", "0"); EXTERN_FORM DLL_API Dvoid __cdecl coold_SetTransform(Dint transformType, const Dfloat* matrix4x4) { //월드만 넘겨 받는다. switch( transformType ) { case 0: //World { Matrix44 matWorld(matrix4x4); g_matWorld = matWorld.Transpose(); //원점 기준으로 이동 if (cc_x_move.Bool()) g_matWorld[12] = cc_x_move.Float(); if (cc_y_move.Bool()) g_matWorld[13] = cc_y_move.Float(); if (cc_z_move.Bool()) g_matWorld[14] = cc_z_move.Float();