本文整理汇总了C++中Poly::AddVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::AddVertex方法的具体用法?C++ Poly::AddVertex怎么用?C++ Poly::AddVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::AddVertex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Rectangle
static Poly Rectangle(const float X1, const float Y1, const float X2, const float Y2)
{
Poly poly;
poly.Begin(GL_TRIANGLE_FAN);
poly.AddVertex(X1, Y1, 0);
poly.AddVertex(X2, Y1, 0);
poly.AddVertex(X2, Y2, 0);
poly.AddVertex(X1, Y2, 0);
poly.End();
return poly;
}
示例2: SplitPoly
void Poly::SplitPoly ( Poly *pPoly_, Poly **ppFront_, Poly **ppBack_ )
{
Plane::eCP *pCP = new Plane::eCP[ pPoly_->GetNumberOfVertices ( ) ];
//
// Classify all points
//
for ( int i = 0; i < pPoly_->GetNumberOfVertices ( ); i++ )
{
pCP[ i ] = plane.ClassifyPoint ( pPoly_->verts[ i ].p );
}
//
// Build fragments
//
Poly *pFront = new Poly;
Poly *pBack = new Poly;
pFront->TextureID = pPoly_->TextureID;
pBack->TextureID = pPoly_->TextureID;
pFront->plane = pPoly_->plane;
pBack->plane = pPoly_->plane;
for ( i = 0; i < pPoly_->GetNumberOfVertices ( ); i++ )
{
//
// Add point to appropriate list
//
switch ( pCP[ i ] )
{
case Plane::eCP::FRONT:
{
pFront->AddVertex ( pPoly_->verts[ i ] );
} break;
case Plane::eCP::BACK:
{
pBack->AddVertex ( pPoly_->verts[ i ] );
} break;
case Plane::eCP::ONPLANE:
{
pFront->AddVertex ( pPoly_->verts[ i ] );
pBack->AddVertex ( pPoly_->verts[ i ] );
} break;
}
//
// Check if edges should be split
//
int iNext = i + 1;
bool bIgnore = false;
if ( i == ( pPoly_->GetNumberOfVertices ( ) - 1 ) )
{
iNext = 0;
}
if ( ( pCP[ i ] == Plane::eCP::ONPLANE ) && ( pCP[ iNext ] != Plane::eCP::ONPLANE ) )
{
bIgnore = true;
}
else if ( ( pCP[ iNext ] == Plane::eCP::ONPLANE ) && ( pCP[ i ] != Plane::eCP::ONPLANE ) )
{
bIgnore = true;
}
if ( ( !bIgnore ) && ( pCP[ i ] != pCP[ iNext ] ) )
{
Vertex v; // New vertex created by splitting
double p; // Percentage between the two points
plane.GetIntersection ( pPoly_->verts[ i ].p, pPoly_->verts[ iNext ].p, v.p, p );
v.tex[ 0 ] = pPoly_->verts[ iNext ].tex[ 0 ] - pPoly_->verts[ i ].tex[ 0 ];
v.tex[ 1 ] = pPoly_->verts[ iNext ].tex[ 1 ] - pPoly_->verts[ i ].tex[ 1 ];
v.tex[ 0 ] = pPoly_->verts[ i ].tex[ 0 ] + ( p * v.tex[ 0 ] );
v.tex[ 1 ] = pPoly_->verts[ i ].tex[ 1 ] + ( p * v.tex[ 1 ] );
pFront->AddVertex ( v );
pBack->AddVertex ( v );
}
}
delete [] pCP;
pFront->CalculatePlane ( );
pBack->CalculatePlane ( );
*ppFront_ = pFront;
*ppBack_ = pBack;
}