예제 #1
0
void MetavoxelSystem::render() {
    // update the frustum
    ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
    _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(),
        viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(),
        viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight());
    
    RenderVisitor renderVisitor(getLOD());
    guideToAugmented(renderVisitor);
}
void SceneManager::render(ViewPort*vp)
{


	_AUTO_BENCHMARK(m_renderBI);
	traceFunction(eScene);

	if(!getDevice() || !vp || !vp->getCamera())
		return;

	getDevice()->set3DMode();

	if(m_debugDrawManager)
	{
		//prepare debug draw manager primitives
		m_debugDrawManager->StartDraw(vp->getCamera());
	}
	video::IRenderTarget* renderTarget;
	if(vp ){
		if(vp->getCamera())
			m_activeCamera=vp->getCamera();
		if(vp->getRenderTarget() )
			renderTarget=vp->getRenderTarget();
	}

	if(vp){
		//math::rectf rc=vp->getAbsViewPort();
		//getDevice()->setViewportRect(rc);
	}

	RenderPassList passes;
	/*
	{
		RenderPassList::iterator passIt=m_shadowPasses.begin();
		for (;passIt!=m_shadowPasses.end();++passIt)
			passes.push_back(*passIt);
	}
	{
		RenderPassList::iterator passIt=m_passes.begin();
		for (;passIt!=m_passes.end();++passIt)
			passes.push_back(*passIt);
	}
	*/
	_collectPasses(passes);
	vp->getCamera()->GetRenderPasses(passes);

	IViewNode*oldVN=0;
	RenderPassList::iterator passIt=passes.begin();
	for (;passIt!=passes.end();++passIt)
	{
		if(!(*passIt)->IsEnabled())
			continue;
		m_currentPass=*passIt;
		m_currentPass->setActiveCamera(m_activeCamera);

		m_currentPass->beginPass(this,vp);

		RequestToRenderVisitor preRenderVisitor(m_currentPass);
		RenderSceneVisitor renderVisitor(m_currentPass);

		m_renderManager->clear();
		m_jobsThreadsManager->Reset();
		OnVisit(&preRenderVisitor);
	//	m_jobsThreadsManager->BeginProcessing();
		//	if(oldFrust!=m_activeFrustrum)
		{

			m_renderManager->startSorting();
			oldVN=m_activeViewnode;
		}


		getDevice()->clearBuffer(video::EDB_DEPTH);
		_setupLightsToRender(m_currentPass);

//		m_jobsThreadsManager->EndProcessing();
		m_renderManager->endSorting();

		if(m_activeCamera)
			m_activeCamera->render(m_currentPass);
		m_renderManager->renderAll(m_currentPass);
		//OnVisit(&renderVisitor);
		m_currentPass->endPass();
	}
	m_currentPass=0;

	m_renderManager->clear();

	m_lightNodesToRender.clear();

	if(m_debugDrawManager)
	{
		//draw primitives
		m_debugDrawManager->EndDraw();
	}
	
	//update camera view
//	if(ActiveCamera)
//		ActiveCamera->updateView();

	
}