本文整理汇总了C++中Mesh::AddVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::AddVertices方法的具体用法?C++ Mesh::AddVertices怎么用?C++ Mesh::AddVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::AddVertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
//.........这里部分代码省略.........
norms.push_back(z);
}
//v-t-n
if (sLine[0] == 'f')
{
vector<string> parts = split(sLine, ' ');
string a = parts[1];
string b = parts[2];
string c = parts[3];
vector<string> partsFaceOne = split(a, '/');
vector<string> partsFaceTwo = split(b, '/');
vector<string> partsFaceThree = split(c, '/');
tridata td;
//v
td.v[0] = stoi(partsFaceOne[0]);
td.v[1] = stoi(partsFaceTwo[0]);
td.v[2] = stoi(partsFaceThree[0]);
//t
td.t[0] = stoi(partsFaceOne[1]);
td.t[1] = stoi(partsFaceTwo[1]);
td.t[2] = stoi(partsFaceThree[1]);
//n
td.n[0] = stoi(partsFaceOne[2]);
td.n[1] = stoi(partsFaceTwo[2]);
td.n[2] = stoi(partsFaceThree[2]);
indices.push_back(td.v[0] - 1);
indices.push_back(td.v[1] - 1);
indices.push_back(td.v[2] - 1);
for (int i = 0; i < 3; i++)
{
//current pos
Vector3 position = Vector3(Vertexes.at(td.v[i] - 1).position.x, Vertexes.at(td.v[i] - 1).position.y, Vertexes.at(td.v[i] - 1).position.z);
int texCoordIndex = td.t[i] - 1;
Vector3 texCoord = texc.at(texCoordIndex);
for (int j = 0; j < Vertexes.size(); j++)
{
if (Vertexes.at(j).position == position)
{
Vertexes.at(j).texCoord = Vector3(texCoord.x, texCoord.y, 0);
}
}
}
//get 3 normals
Vector3 NormalA = normals[td.n[0] - 1];
Vector3 NormalB = normals[td.n[1] - 1];
Vector3 NormalC = normals[td.n[2] - 1];
//Calculate final normal
Vector3 finalNormal = calculateNormal(NormalA, NormalB, NormalC);
//push the final calculated normal
norms.push_back(finalNormal.x);
norms.push_back(finalNormal.y);
norms.push_back(finalNormal.z);
triangles.push_back(td);
}
}
file.close();
}
vector<float> okay;
vector<float> indokay;
int um = Vertexes.size();
for (int i = 0; i < Vertexes.size(); i++)
{
okay.push_back(Vertexes.at(i).position.x);
okay.push_back(Vertexes.at(i).position.y);
okay.push_back(Vertexes.at(i).position.z);
//tex
okay.push_back(Vertexes.at(i).texCoord.x);
okay.push_back(Vertexes.at(i).texCoord.y);
//vertices.push_back(Vertexes.at(i).texCoord.x);
//vertices.push_back(Vertexes.at(i).texCoord.y);
indokay.push_back(Vertexes.at(i).index);
}
//TODO http://assimp.sourceforge.net/lib_html/install.html
newMesh->AddVertices(okay, indices);
return newMesh;
}