Esempio n. 1
0
// Rendering
void ChunkManager::Render(bool shadowRender)
{
	if (shadowRender == false)
	{
		m_numChunksRender = 0;
	}

	m_pRenderer->StartMeshRender();

	// Store cull mode
	CullMode cullMode = m_pRenderer->GetCullMode();

	if (m_wireframeRender)
	{
		m_pRenderer->SetLineWidth(1.0f);
		m_pRenderer->SetRenderMode(RM_WIREFRAME);
	}
	else
	{
		m_pRenderer->SetRenderMode(RM_SOLID);
	}

	m_pRenderer->PushMatrix();
		m_ChunkMapMutexLock.lock();
		typedef map<ChunkCoordKeys, Chunk*>::iterator it_type;
		for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
		{
			Chunk* pChunk = iterator->second;

			if (pChunk != NULL && pChunk->IsCreated())
			{
				vec3 chunkCenter = pChunk->GetPosition() + vec3((Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE) - Chunk::BLOCK_RENDER_SIZE, (Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE) - Chunk::BLOCK_RENDER_SIZE, (Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE) - Chunk::BLOCK_RENDER_SIZE);

				if (shadowRender == true || m_pRenderer->SphereInFrustum(VoxGame::GetInstance()->GetDefaultViewport(), chunkCenter, Chunk::CHUNK_RADIUS))
				{
					pChunk->Render();

					if (shadowRender == false)
					{
						m_numChunksRender++;
					}
				}
			}
		}
		m_ChunkMapMutexLock.unlock();
	m_pRenderer->PopMatrix();

	// Restore cull mode
	m_pRenderer->SetCullMode(cullMode);

	m_pRenderer->EndMeshRender();
}
Esempio n. 2
0
void ChunkManager::Render2D(Camera* pCamera, unsigned int viewport, unsigned int font)
{
	m_ChunkMapMutexLock.lock();
	typedef map<ChunkCoordKeys, Chunk*>::iterator it_type;
	for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
	{
		Chunk* pChunk = iterator->second;

		if (pChunk != NULL && pChunk->IsCreated())
		{
			pChunk->Render2D(pCamera, viewport, font);
		}
	}
	m_ChunkMapMutexLock.unlock();
}
Esempio n. 3
0
void ChunkManager::RenderDebug()
{
	m_pRenderer->SetRenderMode(RM_SOLID);

	m_ChunkMapMutexLock.lock();
	typedef map<ChunkCoordKeys, Chunk*>::iterator it_type;
	for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
	{
		Chunk* pChunk = iterator->second;

		if (pChunk != NULL && pChunk->IsCreated())
		{
			pChunk->RenderDebug();
		}
	}
	m_ChunkMapMutexLock.unlock();
}
Esempio n. 4
0
// Rendering
void ChunkManager::Render()
{
	m_pRenderer->StartMeshRender();

	// Store cull mode
	CullMode cullMode = m_pRenderer->GetCullMode();

	if (m_wireframeRender)
	{
		m_pRenderer->SetLineWidth(1.0f);
		m_pRenderer->SetRenderMode(RM_WIREFRAME);
	}
	else
	{
		m_pRenderer->SetRenderMode(RM_SOLID);
	}

	m_pRenderer->PushMatrix();
		m_ChunkMapMutexLock.lock();
		typedef map<ChunkCoordKeys, Chunk*>::iterator it_type;
		for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
		{
			Chunk* pChunk = iterator->second;

			if (pChunk != NULL && pChunk->IsCreated())
			{
				pChunk->Render();
			}
		}
		m_ChunkMapMutexLock.unlock();
	m_pRenderer->PopMatrix();

	// Restore cull mode
	m_pRenderer->SetCullMode(cullMode);

	m_pRenderer->EndMeshRender();
}