本文整理汇总了C++中Chunk::DrawObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ Chunk::DrawObjects方法的具体用法?C++ Chunk::DrawObjects怎么用?C++ Chunk::DrawObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chunk
的用法示例。
在下文中一共展示了Chunk::DrawObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawLandscapeTopDown
void DrawLandscapeTopDown(StageOneShader *shader, int width, int height, bool forceload, DL_Type dlType) {
if (!Model::gPlayer.KnownPosition())
return;
ChunkCoord player_cc;
Model::gPlayer.GetChunkCoord(&player_cc);
int verticallimit = (height+CHUNK_SIZE-1)/CHUNK_SIZE/2;
int horisontallimit = (width+CHUNK_SIZE-1)/CHUNK_SIZE/2;
// Draw all visible chunks. Chunks that are not loaded will trigger a reload from the server. The top chunks
// should be loaded first, as they affect the lighting on the chunks below.
for (int dz = verticallimit; dz >= -verticallimit; dz--) for (int dx = -horisontallimit; dx <= horisontallimit; dx++) for (int dy = -horisontallimit; dy <= horisontallimit; dy++) {
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
ChunkCoord cc;
cc.x = player_cc.x + dx;
cc.y = player_cc.y + dy;
cc.z = player_cc.z + dz;
Chunk *cp = ChunkFind(&cc, forceload);
if (cp == 0)
continue;
shader->Model(modelMatrix);
// Draw the chunk
if (!cp->IsDirty() && cp->fChunkObject && cp->fChunkObject->Empty()) {
// This chunk exists, is updated, but contains nothing.
continue;
}
cp->Draw(shader, 0, dlType);
cp->DrawObjects(shader, dx, dy, dz, true);
}
}
示例2: DrawLandscapeForShadows
void DrawLandscapeForShadows(StageOneShader *shader) {
if (!Model::gPlayer.KnownPosition())
return;
ChunkCoord player_cc;
Model::gPlayer.GetChunkCoord(&player_cc);
// Draw all visible chunks. Chunks that are not loaded will trigger a reload from the server. The top chunks
// should be loaded first, as they affect the lighting on the chunks below.
for (auto it=sShadowChunks.begin() ; it != sShadowChunks.end(); it++ ) {
Chunk *cp = ChunkFind(&(*it), true);
if (!cp->IsDirty() && cp->fChunkObject && cp->fChunkObject->Empty()) {
// This chunk exists, is updated, but contains nothing.
continue;
}
int dx = cp->cc.x - player_cc.x;
int dy = cp->cc.y - player_cc.y;
int dz = cp->cc.z - player_cc.z;
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
shader->Model(modelMatrix);
cp->Draw(shader, 0, DL_NoTransparent);
cp->DrawObjects(shader, dx, dy, dz, true);
}
}
示例3: DrawLandscape
//.........这里部分代码省略.........
break;
ChunkCoord cc;
cc.x = player_cc.x + dx;
cc.y = player_cc.y + dy;
cc.z = player_cc.z + dz;
// If we have come this far, a null pointer is no longer accepted. The chunk is needed. Either we get
// the real chunk, or an empty one.
Chunk *cp = ChunkFind(&cc, true);
if (dlType == DL_Picking) {
// Picking mode. Throw away the previous triangles, and replace it with special triangles used
// for the picking mode. These contain colour information to allow identification of cubes.
cp->fChunkBlocks->TestJellyBlockTimeout(true);
cp->PushTriangles(ChunkObject::Make(cp, true, dx, dy, dz)); // Stash away the old triangles for quick restore
gChunkShaderPicking.Model(modelMatrix);
} else {
cp->fChunkBlocks->TestJellyBlockTimeout(false);
shader->Model(modelMatrix);
}
if (dlType == DL_NoTransparent)
AddChunkToShadowList(cp);
// Draw the chunk
cp->Draw(shader, &gChunkShaderPicking, dlType);
if (dlType == DL_Picking) {
// Picking mode. Restore the normal triangles again.
cp->PopTriangles();
}
if (dlType == DL_NoTransparent) {
cp->DrawObjects(shader, dx, dy, dz, false);
}
if (dlType == DL_OnlyTransparent) {
unsigned char tx, ty, tz;
if (gMode.CommunicationAllowed() && Model::gSuperChunkManager.GetTeleport(&tx, &ty, &tz, &cp->cc)) {
double diffX = double(Model::gPlayer.x)/BLOCK_COORD_RES - cc.x*CHUNK_SIZE - tx - 0.5;
double diffY = double(Model::gPlayer.y)/BLOCK_COORD_RES - cc.y*CHUNK_SIZE - ty - 0.5;
double diffZ = double(Model::gPlayer.z)/BLOCK_COORD_RES - cc.z*CHUNK_SIZE - tz - PLAYER_HEIGHT*2;
double d2 = diffX*diffX + diffY*diffY + diffZ*diffZ;
if (diffX < 1.5 && diffX > -1.5 && diffY < 1.5 && diffY > -1.5 && diffZ < 3.0 && diffZ > 0.0)
insideAnyTeleport = true;
// printf("%.2f, %.2f, %.2f\n", diffX, diffY, diffZ);
if (gMode.Get() == GameMode::GAME) {
// When in teleport mode, the teleports are drawn elsewhere.
float x = (float)tx + dx*CHUNK_SIZE + 0.5f;
float y = (float)tz + dz*CHUNK_SIZE + 0.5f;
float z = -(float)ty - dy*CHUNK_SIZE - 0.5f;
gDrawObjectList.emplace_back(glm::vec3(x, y+2, z), BT_Teleport);
// gMsgWindow.Add("chunk::DrawObjects Teleport at %f,%f,%f\n", x, y, z);
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(x, y, z));
glBindTexture(GL_TEXTURE_2D, GameTexture::Teleport);
modelMatrix = glm::scale(modelMatrix, glm::vec3(4.0f, 4.0f, 4.0f));
modelMatrix = glm::rotate(modelMatrix, 45.0f, glm::vec3(0,1,0));
shader->Model(modelMatrix);
gLantern.Draw();
}
if (d2 < distanceToNearTP2) {
TPPosition.x = diffX;
TPPosition.y = diffY;
TPPosition.z = diffZ;
distanceToNearTP2 = d2;
}