Пример #1
0
	void chunk::buildRender() {
		//assert(Empty == false);

#ifdef NEWORLD_DEBUG_CONSOLE_OUTPUT
		if (pblocks == nullptr || pbrightness == nullptr){
			DebugWarning("Empty pointer when building vertex buffers!");
			return;
		}
#endif
		//建立chunk显示列表
		int x, y, z;
		for (x = -1; x <= 1; x++) {
			for (y = -1; y <= 1; y++) {
				for (z = -1; z <= 1; z++) {
					if (x == 0 && y == 0 && z == 0) continue;
					if (chunkOutOfBound(cx + x, cy + y, cz + z))  continue;
					if (!chunkLoaded(cx + x, cy + y, cz + z)) return;
				}
			}
		}
		
		rebuiltChunks++;
		updatedChunks++;

		if (renderBuilt == false){
			renderBuilt = true;
			loadAnim = cy * 16.0f + 16.0f;
		}
		
		if (MergeFace) ChunkRenderer::mergeFaceRender(this);
		else ChunkRenderer::renderChunk(this);

		updated = false;

	}
Пример #2
0
void ChunkCache::gotChunk(int x,int z)
{
	emit chunkLoaded(x,z);
}
Пример #3
0
	void chunk::buildlists(){
		if (isEmptyChunk) return;
		//建立chunk显示列表
		int x, y, z;
		for (x = -1; x != 2; x++) {
			for (y = -1; y != 2; y++) {
				for (z = -1; z != 2; z++) {
					if (x == 0 && y == 0 && z == 0) continue;
					if (chunkOutOfBound(cx + x, cy + y, cz + z))  continue;
					if (!chunkLoaded(cx + x, cy + y, cz + z)) return;
				}
			}
		}
                
		rebuiltChunks++;
		updatedChunks++;
		if (!isBuilt) {
			isBuilt = true;
			loadAnim = cy * 16 + 16;
			glGenBuffersARB(3, vbuffer);
		}

		renderer::Init();
		glBindTexture(GL_TEXTURE_2D, BlockTextures);
		for (x = 0; x != 16; x++) {
			for (y = 0; y != 16; y++) {
				for (z = 0; z != 16; z++) {
					if (pblocks[x][y][z] == blocks::AIR) continue;
					if (!BlockInfo(pblocks[x][y][z]).isTranslucent())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[0], vertexes[0]);
		
		renderer::Init();
		glBindTexture(GL_TEXTURE_2D, BlockTextures);
		for (x = 0; x != 16; x++){
			for (y = 0; y != 16; y++){
				for (z = 0; z != 16; z++){
					if (pblocks[x][y][z] == blocks::AIR) continue;
					if (BlockInfo(pblocks[x][y][z]).isTranslucent() && BlockInfo(pblocks[x][y][z]).isSolid())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[1], vertexes[1]);

		renderer::Init();
		glBindTexture(GL_TEXTURE_2D, BlockTextures);
		for (x = 0; x != 16; x++){
			for (y = 0; y != 16; y++){
				for (z = 0; z != 16; z++){
					if (pblocks[x][y][z] == blocks::AIR) continue;
					if (!BlockInfo(pblocks[x][y][z]).isSolid())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[2], vertexes[2]);
		updated = false;

	}
Пример #4
0
	void chunk::buildRender(){
		if (Empty) return;
#ifdef NEWORLD_DEBUG_CONSOLE_OUTPUT
		if (pblocks == nullptr || pbrightness == nullptr){
			DebugWarning("Empty pointer when building vertex buffers!");
			return;
		}
#endif
		//建立chunk显示列表
		int x, y, z;
		for (x = -1; x <= 1; x++) {
			for (y = -1; y <= 1; y++) {
				for (z = -1; z <= 1; z++) {
					if (x == 0 && y == 0 && z == 0) continue;
					if (chunkOutOfBound(cx + x, cy + y, cz + z))  continue;
					if (!chunkLoaded(cx + x, cy + y, cz + z)) return;
				}
			}
		}
		
		rebuiltChunks++;
		updatedChunks++;

		if (renderBuilt == false){
			renderBuilt = true;
			loadAnim = cy * 16.0f + 16.0f;
		}

		renderer::Init();
		for (x = 0; x < 16; x++) {
			for (y = 0; y < 16; y++) {
				for (z = 0; z < 16; z++) {
					if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue;
					if (!BlockInfo(pblocks[x*256 + y*16 + z]).isTranslucent())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[0], vertexes[0]);
		
		renderer::Init();
		for (x = 0; x < 16; x++){
			for (y = 0; y < 16; y++){
				for (z = 0; z < 16; z++){
					if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue;
					if (BlockInfo(pblocks[x*256 + y*16 + z]).isTranslucent() && BlockInfo(pblocks[x*256 + y*16 + z]).isSolid())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[1], vertexes[1]);

		renderer::Init();
		for (x = 0; x < 16; x++){
			for (y = 0; y < 16; y++){
				for (z = 0; z < 16; z++){
					if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue;
					if (!BlockInfo(pblocks[x*256 + y*16 + z]).isSolid())
						renderblock(x, y, z, this);
				}
			}
		}
		renderer::Flush(vbuffer[2], vertexes[2]);
		updated = false;

	}