本文整理汇总了C++中Loader::createModel方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::createModel方法的具体用法?C++ Loader::createModel怎么用?C++ Loader::createModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::createModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Water::Water(Loader loader)
{
float positions[] = { -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f };
int indices[] = { 0, 1, 3, 3, 1, 2 };
// create a ground-plane that is 2x2 meters and scale it so it becomes 100x100 meters.
waterplane = loader.createModel(positions, 12, indices, 6);
Mat4 scaleMatrix;
scaleMatrix.loadScale(150, 1, 150);
waterplane.setModelMatrix(scaleMatrix);
dudvTexture = loader.loadBMPtexture("water_dudv.bmp");
normalTexture = loader.loadBMPtexture("water_nomal.bmp");
shader.createShader("waterVertexShader.glsl", "waterFragmentShader.glsl");
reflectionFrameBuffer = FrameBufferUtilities::createBuffer();
reflectionTexture = FrameBufferUtilities::createTextureAttachment(REFLECTION_WIDTH, REFLECTION_HEIGHT);
reflectionDepthBuffer = FrameBufferUtilities::createDepthBufferAttachment(REFLECTION_WIDTH, REFLECTION_HEIGHT);
FrameBufferUtilities::unbindCurrentBuffer();
refractionFrameBuffer = FrameBufferUtilities::createBuffer();
refractionTexture = FrameBufferUtilities::createTextureAttachment(REFRACTION_WIDTH, REFRACTION_HEIGHT);
refractionDepthTexture = FrameBufferUtilities::createDepthTextureAttachment(REFRACTION_WIDTH, REFRACTION_HEIGHT);
FrameBufferUtilities::unbindCurrentBuffer();
double waterheight = 0;
reflection_clip_plane = Vec4{ 0, 1, 0, -waterheight + 0.05 };
refraction_clip_plane = Vec4{ 0, -1, 0, -waterheight };
}
示例2: loadLODlevel
void TerrainChunk::loadLODlevel(Loader loader, int level)
{
const int numberOfVertices[] = { NUMBER_OF_VERTICES , NUMBER_OF_VERTICES / 2 + 1, NUMBER_OF_VERTICES / 4 + 1 };
int indices[(NUMBER_OF_VERTICES - 1) * (NUMBER_OF_VERTICES - 1) * 6];
float positions[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 3];
float textureCoords[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 2];
float normals[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 3];
int indicesIndex = 0, positionIndex = 0, textureCoordIndex = 0, normalIndex = 0;
for (int x = 0; x < numberOfVertices[level]; x++)
{
for (int z = 0; z < numberOfVertices[level]; z++)
{
float localVertexPosX = (float)(x * SIZE) / (float)(numberOfVertices[level] - 1);
float localVertexPosZ = (float)(z * SIZE) / (float)(numberOfVertices[level] - 1);
double height = TerrainHeightGenerator::getHeight(pos.x + localVertexPosX, pos.z + localVertexPosZ);
if (x == 0 || z == 0 || x == numberOfVertices[level] - 1 || z == numberOfVertices[level] - 1)
{
if (level == 1)
height -= 0.15;
else if (level == 2)
height -= 0.30;
}
positions[positionIndex++] = pos.x + localVertexPosX;
positions[positionIndex++] = (float)height;
positions[positionIndex++] = pos.z + localVertexPosZ;
float texCoordU = (float)(x) / (float)(numberOfVertices[level] - 1);
float texCoordV = (float)(z) / (float)(numberOfVertices[level] - 1);
textureCoords[textureCoordIndex++] = texCoordU;
textureCoords[textureCoordIndex++] = texCoordV;
Vec3 normal = TerrainHeightGenerator::getNormal(pos.x + localVertexPosX, pos.z + localVertexPosZ);
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
}
for (int x = 0; x < numberOfVertices[level] - 1; x++)
{
for (int z = 0; z < numberOfVertices[level] - 1; z++)
{
int topLeft = (z * numberOfVertices[level]) + x;
int topRight = topLeft + 1;
int bottomLeft = ((z + 1) * numberOfVertices[level]) + x;
int bottomRight = bottomLeft + 1;
indices[indicesIndex++] = topLeft;
indices[indicesIndex++] = bottomLeft;
indices[indicesIndex++] = topRight;
indices[indicesIndex++] = topRight;
indices[indicesIndex++] = bottomLeft;
indices[indicesIndex++] = bottomRight;
}
}
models[level] = loader.createModel(positions, positionIndex, textureCoords, textureCoordIndex, normals, normalIndex, indices, indicesIndex);
}