本文整理汇总了C++中TriangleMesh::AddTriangle方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleMesh::AddTriangle方法的具体用法?C++ TriangleMesh::AddTriangle怎么用?C++ TriangleMesh::AddTriangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleMesh
的用法示例。
在下文中一共展示了TriangleMesh::AddTriangle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvexDecompResult
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
{
TriangleMesh* trimesh = new TriangleMesh();
SimdVector3 localScaling(6.f,6.f,6.f);
//export data to .obj
printf("ConvexResult\n");
if (mOutputFile)
{
fprintf(mOutputFile,"## Hull Piece %d with %d vertices and %d triangles.\r\n", mHullCount, result.mHullVcount, result.mHullTcount );
fprintf(mOutputFile,"usemtl Material%i\r\n",mBaseCount);
fprintf(mOutputFile,"o Object%i\r\n",mBaseCount);
for (unsigned int i=0; i<result.mHullVcount; i++)
{
const float *p = &result.mHullVertices[i*3];
fprintf(mOutputFile,"v %0.9f %0.9f %0.9f\r\n", p[0], p[1], p[2] );
}
//calc centroid, to shift vertices around center of mass
centroids[numObjects] = SimdVector3(0,0,0);
if ( 1 )
{
const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullTcount; i++)
{
unsigned int index0 = *src++;
unsigned int index1 = *src++;
unsigned int index2 = *src++;
SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]);
SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]);
SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
centroids[numObjects] += vertex0;
centroids[numObjects]+= vertex1;
centroids[numObjects]+= vertex2;
}
}
centroids[numObjects] *= 1.f/(float(result.mHullTcount) * 3);
if ( 1 )
{
const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullTcount; i++)
{
unsigned int index0 = *src++;
unsigned int index1 = *src++;
unsigned int index2 = *src++;
SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]);
SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]);
SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
vertex0 -= centroids[numObjects];
vertex1 -= centroids[numObjects];
vertex2 -= centroids[numObjects];
trimesh->AddTriangle(vertex0,vertex1,vertex2);
index0+=mBaseCount;
index1+=mBaseCount;
index2+=mBaseCount;
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
}
}
shapeIndex[numObjects] = numObjects;
shapePtr[numObjects++] = new ConvexTriangleMeshShape(trimesh);
mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
}
}
示例2: main
//.........这里部分代码省略.........
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
centroids[numObjects] += vertex0;
centroids[numObjects]+= vertex1;
centroids[numObjects]+= vertex2;
}
}
centroids[numObjects] *= 1.f/(float(result.mHullTcount) * 3);
if ( 1 )
{
const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullTcount; i++)
{
unsigned int index0 = *src++;
unsigned int index1 = *src++;
unsigned int index2 = *src++;
SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]);
SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]);
SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
vertex0 -= centroids[numObjects];
vertex1 -= centroids[numObjects];
vertex2 -= centroids[numObjects];
trimesh->AddTriangle(vertex0,vertex1,vertex2);
index0+=mBaseCount;
index1+=mBaseCount;
index2+=mBaseCount;
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
}
}
shapeIndex[numObjects] = numObjects;
shapePtr[numObjects++] = new ConvexTriangleMeshShape(trimesh);
mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
}
}
int mBaseCount;
int mHullCount;
FILE* mOutputFile;
};
if (tcount)
{
numObjects = 1; //always have the ground object first
TriangleMesh* trimesh = new TriangleMesh();
SimdVector3 localScaling(6.f,6.f,6.f);
示例3: initPhysics
//.........这里部分代码省略.........
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
centroid += vertex0;
centroid += vertex1;
centroid += vertex2;
}
}
centroid *= 1.f/(float(result.mHullTcount) * 3);
if ( 1 )
{
const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullTcount; i++)
{
unsigned int index0 = *src++;
unsigned int index1 = *src++;
unsigned int index2 = *src++;
SimdVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]);
SimdVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]);
SimdVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
vertex0 -= centroid;
vertex1 -= centroid;
vertex2 -= centroid;
trimesh->AddTriangle(vertex0,vertex1,vertex2);
index0+=mBaseCount;
index1+=mBaseCount;
index2+=mBaseCount;
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
}
}
bool isDynamic = true;
float mass = 1.f;
CollisionShape* convexShape = new ConvexTriangleMeshShape(trimesh);
SimdTransform trans;
trans.setIdentity();
trans.setOrigin(centroid);
m_convexDemo->LocalCreatePhysicsObject(isDynamic, mass, trans,convexShape);
mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
}
}
int mBaseCount;
int mHullCount;
FILE* mOutputFile;
};
if (tcount)
{
TriangleMesh* trimesh = new TriangleMesh();