本文整理汇总了C++中MeshBuilder::addTriangle方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBuilder::addTriangle方法的具体用法?C++ MeshBuilder::addTriangle怎么用?C++ MeshBuilder::addTriangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder::addTriangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillModelMesh
static int fillModelMesh( MeshBuilder& builder , mstudiotexture_t& texDesc , short* tri , Vector3 vtxPos[] , uint8* vtxBone )
{
int numTri = 0;
float fs = 1.0f / texDesc.width;
float ft = 1.0f / texDesc.height;
int base = 0;
if ( vtxBone )
{
while (1)
{
short nEle = *(tri++);
if ( nEle == 0)
break;
if ( nEle < 0 )
{
//triangle fan
nEle = -nEle;
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int start = base++;
tri += 4;
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int prev = base++;
tri += 4;
for( int n = 2 ; n < nEle ; ++n )
{
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int cur = base++;
builder.addTriangle( start , cur , prev );
++numTri;
prev = cur;
tri += 4;
}
}
else
{
//triangle strip
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int prev2 = base++;
tri += 4;
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int prev = base++;
tri += 4;
for( int n = 2 ; n < nEle ; ++n )
{
builder.setPosition( vtxPos[ tri[0] ] );
builder.setBlendIndices( vtxBone[ tri[0] ] + 1 );
builder.setTexCoord( 0 , fs * tri[2] , ft * tri[3] );
builder.addVertex();
int cur = base++;
if ( n % 2 == 0 )
builder.addTriangle( prev2 , cur , prev );
else
builder.addTriangle( prev2 , prev , cur );
++numTri;
prev2 = prev;
prev = cur;
tri += 4;
}
}
}
}
else //vtxBone
{
while (1)
{
short nEle = *(tri++);
if ( nEle == 0)
break;
if ( nEle < 0 )
//.........这里部分代码省略.........