本文整理汇总了C++中Mesh::AddFace方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::AddFace方法的具体用法?C++ Mesh::AddFace怎么用?C++ Mesh::AddFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::AddFace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddFaceToMesh
void MeshUtility::AddFaceToMesh(Mesh& mesh, std::size_t p1PositionIndex, std::size_t p2PositionIndex, std::size_t p3PositionIndex, std::size_t p1TextureCoordIndex, std::size_t p2TextureCoordIndex, std::size_t p3TextureCoordIndex)
{
Mesh::face_t face;
face.push_back( MeshVertexIndexer(p1PositionIndex, p1TextureCoordIndex, 0, 0) );
face.push_back( MeshVertexIndexer(p2PositionIndex, p2TextureCoordIndex, 0, 0) );
face.push_back( MeshVertexIndexer(p3PositionIndex, p3TextureCoordIndex, 0, 0) );
mesh.AddFace(face);
}
示例2: InitMesh
void Model::InitMesh(const aiMesh* mesh)
{
MeshInfo* meshInfo = new MeshInfo;
meshInfo->NumVertices = mesh->mNumVertices;
meshInfo->NumIndices = mesh->mNumFaces * 3;
Mesh* modelMesh = new Mesh(this, meshInfo);
/*READ VERTS INTO MODEL MESH*/
size_t numVerts = mesh->mNumVertices;
for(size_t i = 0; i < numVerts; i++)
{
aiVector3D vertex = mesh->mVertices[i];
aiVector3D tangent = aiVector3D(0.0f);
if(mesh->HasTangentsAndBitangents()) {
tangent = mesh->mTangents[i];
}
aiVector3D normal(0.0f);
float u = 0.0f;
float v = 0.0f;
if(mesh->HasNormals()) {
normal = mesh->mNormals[i];
}
if(mesh->HasTextureCoords(0)) {
aiVector3D uvs = mesh->mTextureCoords[0][i];
u = uvs.x;
v = uvs.y;
}
meshInfo->Vertices.push_back(Vec3(vertex.x, vertex.y, vertex.z));
modelMesh->AddVertex(vertex.x, vertex.y, vertex.z,
normal.x, normal.y, normal.z,
u, v,
tangent.x, tangent.y, tangent.z);
}
/*READ FACES INTO MODEL MESH*/
size_t numFaces = mesh->mNumFaces;
for(size_t i = 0; i < numFaces; i++)
{
aiFace face = mesh->mFaces[i];
modelMesh->AddFace(face.mIndices[0],
face.mIndices[1],
face.mIndices[2]);
}
/*INITIALIZE MESH*/
modelMesh->Init();
/*ADD MODELMESH TO COLLECTION*/
m_meshes.push_back(modelMesh);
}