Пример #1
0
	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 ));
			}
		}	
		
	}
void SceneManager::LightSpaceCulling(Camera * camera, DirectionalLight * light)
{
	bool sunMotion = light->transform->GetMotionState();
	// Update Camera BoundingBox if camera has moved or the sun direction is changed
	bool change = camera->transform->GetMotionState() || sunMotion;
	if (change) {
		camera->UpdateBoundingBox(light);
	}

	for (auto obj : activeObjects) {
		if (obj->aabb && (sunMotion || obj->transform->GetMotionState())) {
			obj->aabb->Update(light->transform->GetWorldRotation());
		}
	}

	FrustumCulling(camera);

	// TODO - should move this somwhere else
	// Keep tracking of lighting object in scene somewhere ?!
	light->transform->ClearMotionState();
}
Пример #3
0
	void	RenderWindow::Show()
	{
		ShowWindow(m_hWnd,SW_HIDE);
		UpdateWindow(m_hWnd);
		MSG		msg;
		Timer	t;
		t.Init();
		float fTimeSinceLastFrame=0.0f;
		while(!m_bQuit)
		{
			if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
			{
				if(msg.message==WM_QUIT)
				{
					cout<<"quit message "<<endl;
					break;
				}
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else
			{
				//frustun culling then
				fTimeSinceLastFrame+=t.GetElapsedTime(true);
				if(fTimeSinceLastFrame>0.033f)
				{
					fTimeSinceLastFrame=0.0f;
					FrustumCulling();
					m_pRenderWindow->RenderOneFrame();
					SwapBuffers(m_hDC);
				}
				else
				{
					Sleep((0.033f-fTimeSinceLastFrame)*1000);
				}
			}
		}
	}