예제 #1
0
파일: map.cpp 프로젝트: pmprog/Overrun
void Map::Render( Camera* View )
{
	Vector2 pts[4];
	for( int y = 0; y < MapHeight; y++ )
	{
		for( int x = 0; x < MapWidth; x++ )
		{
			pts[0].X = x * CurGame->TileSize;
			pts[1].X = x * CurGame->TileSize;
			pts[2].X = (x + 1) * CurGame->TileSize;
			pts[3].X = (x + 1) * CurGame->TileSize;
			pts[0].Y = y * CurGame->TileSize;
			pts[1].Y = (y + 1) * CurGame->TileSize;
			pts[2].Y = y * CurGame->TileSize;
			pts[3].Y = (y + 1) * CurGame->TileSize;
			View->AbsoluteToCameraOffset( &pts[0], &pts[0] );
			View->AbsoluteToCameraOffset( &pts[1], &pts[1] );
			View->AbsoluteToCameraOffset( &pts[2], &pts[2] );
			View->AbsoluteToCameraOffset( &pts[3], &pts[3] );
			RenderGround( x, y, (Vector2*)&pts );
		}
	}
	for( std::vector<Unit*>::iterator i = Units.begin(); i != Units.end(); i++ )
	{
		Unit* u = (*i);
		u->Render( View );
	}
	for(std::vector<Building*>::iterator i = Buildings.begin(); i != Buildings.end(); i++ )
	{
		Building* b = (Building*)(*i);
		b->Render( View );
	}
}
예제 #2
0
void ModelViewerRender::Render()
{
	if(!m_bInitilized) return ;//haven't initialized

	m_pDevice->getTimer()->tick();
	// Work out a frame delta time.
	const double frameDeltaTime = m_pDevice->getTimer()->GetElapsedTime() / 1000.0; // Time in seconds
	m_pRenderDevice->setRenderDeviceTime(m_pDevice->getTimer()->getTime(), frameDeltaTime);
	
	// notify the model current frame changed
	if(m_pMF1FileResource!=NULL&&m_pDynamicModel!=NULL)
		CModelControlDlg::NotifyPlayFrameChanged((int)(m_pDynamicModel->getAnimPlayedTime()/ISGPInstanceManager::DefaultSecondsPerFrame));
		
	m_pCamera->Update((float)frameDeltaTime);
	if(m_pDynamicModel!=NULL) m_pDynamicModel->update((float)frameDeltaTime);
	if(m_pStaticModel!=NULL) m_pStaticModel->update((float)frameDeltaTime);
	// update internal Camera position
	m_pRenderDevice->setViewMatrix3D( m_pCamera->GetRight(),m_pCamera->GetUp(),m_pCamera->GetDir(),m_pCamera->GetPos() );
	// calculate fps
	CalFPS(frameDeltaTime);
	
	ModelViewerConfig* pConfig=ModelViewerConfig::GetInstance();
	if(pConfig->m_bShowWireframe) glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
	else glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

	m_pRenderDevice->setClearColor(pConfig->m_BkgndColor[0],pConfig->m_BkgndColor[1],\
		pConfig->m_BkgndColor[2],pConfig->m_BkgndColor[3]);

	m_pRenderDevice->beginScene(true,true,false);
	// render ground
	if(pConfig->m_bShowGround) RenderGround();
	// render model
	if(pConfig->m_bShowMesh)
	{
		if(m_pDynamicModel!=NULL) m_pDynamicModel->render();
		if(m_pStaticModel!=NULL) m_pStaticModel->render();
	}
	// render boundingbox
	if(pConfig->m_bShowBoundingBox&&m_pModelMF1!=NULL)
		RenderBoundingBox(m_pModelMF1->m_MeshAABBox);
	// render bones
	if(pConfig->m_bShowBones)
	{
		if(m_pDynamicModel!=NULL) RenderBones();
	}
	// render normals
	if(pConfig->m_bShowNormalLines)
	{
		if(m_pDynamicModel!=NULL) RenderDynamicNormals();
		if(m_pStaticModel!=NULL) RenderStaticNormals();
	}
	// render mesh box
	int meshcount=pConfig->m_bBoxShowVector.size();
	for(int i=0;i<meshcount&&m_pModelMF1!=NULL;++i)
	{
		// render mesh box
		if(pConfig->m_bBoxShowVector[i]==TRUE)
			RenderBoundingBox(m_pModelMF1->m_pLOD0Meshes[i].m_bbox);
	}
	
	// render coordinate axis
	RenderCoordinateAxis();
	
	// flush:draw objects
	m_pRenderDevice->FlushRenderBatch();

	// render attachment
	if(pConfig->m_bShowAttachment&&m_pModelMF1!=NULL) RenderAttachments();
	// render particle emitter
	if(pConfig->m_bShowParticleEmitter&&m_pModelMF1!=NULL) RenderParticleEmitter();
	m_pRenderDevice->FlushEditorLinesRenderBatch(true);

	m_pRenderDevice->BeginRenderText();
	RenderCoordinateLabel();
	RenderFPS();
	m_pRenderDevice->EndRenderText();

	m_pRenderDevice->endScene();
}