Ejemplo n.º 1
0
void World::RenderChunks() {
	for(int i = 0; i < m_vpChunksToRender.size(); i++) {
		Chunk* pChunk = m_vpChunksToRender[i];
		if(pChunk->MeshBuilt()) {
			pChunk->Render();
		}
	}
}
Ejemplo n.º 2
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();
}
Ejemplo n.º 3
0
void ChunkManager::Render() {
	if (m_textureId != -1) {
		m_renderer->BindTextureToShader(m_textureId, 0);
	}
	m_renderer->PushMatrix();
		m_chunkMapMutex.lock();
		std::map<ChunkCoordKey, Chunk*>::iterator it;
		for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
			Chunk* chunk = it->second;
			if (chunk->IsLoaded()) {

				glm::vec3 chunkCenter = chunk->GetCenter();
				float chunkSize = Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE;

				if (m_renderer->CubeInFrustum(chunkCenter, chunkSize, chunkSize, chunkSize)) {
					chunk->Render();
				}
			}
		}
		m_chunkMapMutex.unlock();
	m_renderer->PopMatrix();
}
Ejemplo 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();
}