本文整理汇总了C++中Polyline::getVertexIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyline::getVertexIterator方法的具体用法?C++ Polyline::getVertexIterator怎么用?C++ Polyline::getVertexIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyline
的用法示例。
在下文中一共展示了Polyline::getVertexIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TriangleMesh
TriangleMesh*
MeshSweeper::makeSphere(const vec3& center, REAL radius, int mers)
//[]----------------------------------------------------[]
//| Make sphere |
//[]----------------------------------------------------[]
{
if (mers < 6)
mers = 6;
int sections = mers;
int nv = sections * mers + 2; // number of vertices (and normals)
int nt = 2 * mers * sections; // number of triangles
TriangleMesh::Arrays data;
data.vertices = new vec3[data.numberOfVertices = nv];
data.normals = new vec3[data.numberOfNormals = nv];
data.triangles = new TriangleMesh::Triangle[data.numberOfTriangles = nt];
{
Polyline arc = makeArc(center, radius, vec3(0, 0, 1), 180, sections + 1);
Polyline::VertexIterator vit = arc.getVertexIterator();
vec3* vertex = data.vertices;
vec3* normal = data.normals;
REAL invRadius = Math::inverse<REAL>(radius);
*normal = ((*vertex = (vit++).position) - center) * invRadius;
mat4 rot = mat4::rotation(*normal, REAL(360) / mers, center);
vertex++;
normal++;
for (int s = 0; s < sections; s++)
{
vec3 p = *vertex = (vit++).position;
*normal = (p - center) * invRadius;
vertex++;
normal++;
for (int m = 1; m < mers; m++)
{
*vertex = p = rot.transform3x4(p);
*normal = (p - center) * invRadius;
vertex++;
normal++;
}
}
*normal = ((*vertex = (vit++).position) - center) * invRadius;
}
TriangleMesh::Triangle* triangle = data.triangles;
for (int i = 1; i <= mers; i++)
{
int j = i % mers + 1;
triangle->setVertices(0, i, j);
triangle++;
}
for (int s = 1; s < sections; s++)
for (int m = 0, b = (s - 1) * mers + 1; m < mers;)
{
int i = b + m;
int k = b + ++m % mers;
int j = i + mers;
int l = k + mers;
triangle->setVertices(i, j, k);
triangle[1].setVertices(k, j, l);
triangle += 2;
}
for (int m = 0, b = (sections - 1) * mers + 1, j = nv - 1; m < mers;)
{
int i = b + m;
int k = b + ++m % mers;
triangle->setVertices(i, j, k);
triangle++;
}
return new TriangleMesh(data);
}