本文整理汇总了C++中Loader::loadToVao方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::loadToVao方法的具体用法?C++ Loader::loadToVao怎么用?C++ Loader::loadToVao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::loadToVao方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateTerrain
RawModel Terrain::generateTerrain(Loader &loader, std::string heightMapFile){
RawImageData heightMap = loader.loadRawImageData(heightMapFile);
processHeightMap(heightMap);
vertex_count = heightMap.getHeight();
heights.resize(vertex_count, std::vector<float>(vertex_count, 0));
std::vector<float> normals;
std::vector<float> textureCoords;
std::vector<int> indices;
for (int i = 0; i < vertex_count; i++) {
for (int j = 0; j < vertex_count; j++){
vertices.push_back((float)j / ((float)vertex_count - 1) * size);
float height = getHeight(j, i);
heights[j][i] = height;
vertices.push_back( height );
vertices.push_back((float)i / ((float)vertex_count - 1) * size);
glm::vec3 normal = calculateNormal(j, i);
normals.push_back( normal.x );
normals.push_back( normal.y );
normals.push_back( normal.z );
textureCoords.push_back((float)j / ((float)vertex_count - 1));
textureCoords.push_back((float)i / ((float)vertex_count - 1));
}
}
for (int gz = 0; gz < vertex_count - 1; gz++){
for (int gx = 0; gx < vertex_count - 1; gx++){
int topLeft = (gz*vertex_count) + gx;
int topRight = topLeft + 1;
int bottomLeft = ((gz + 1)*vertex_count) + gx;
int bottomRight = bottomLeft + 1;
indices.push_back( topLeft );
indices.push_back( bottomLeft );
indices.push_back( topRight );
indices.push_back( topRight );
indices.push_back( bottomLeft );
indices.push_back( bottomRight );
}
}
return loader.loadToVao(vertices, textureCoords, normals, indices);
}