本文整理汇总了C++中Triangle::FindVertexIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangle::FindVertexIndex方法的具体用法?C++ Triangle::FindVertexIndex怎么用?C++ Triangle::FindVertexIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Triangle
的用法示例。
在下文中一共展示了Triangle::FindVertexIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//=============================================================================
// That we're passing in a visitation key is actually a sign that there's
// a more fundamental bug going on.
SurfaceMesh::Vertex* SurfaceMesh::Edge::FindAdjacentVertex( VertexType vertexType, int visitationKey ) const
{
// Which vertex are we pivoting about?
Vertex* pivotVertex = 0;
if( vertexType == CCW_VERTEX )
pivotVertex = vertex[0];
else if( vertexType == CW_VERTEX )
pivotVertex = vertex[1];
assert->Condition( pivotVertex != 0, "Null pivot vertex!" );
// Find the last triangle we can find while winding about that vertex
// in the desired direction.
bool windingTriangleFound = false;
Triangle* windingTriangle = triangle;
do
{
if( windingTriangle->visitationKey == visitationKey )
break;
windingTriangle->visitationKey = visitationKey;
int vertexIndex = windingTriangle->FindVertexIndex( pivotVertex );
int triangleIndex = -1;
if( vertexType == CCW_VERTEX )
triangleIndex = ( vertexIndex + 2 ) % 3;
else if( vertexType == CW_VERTEX )
triangleIndex = vertexIndex;
Triangle* adjacentTriangle = windingTriangle->adjacentTriangle[ triangleIndex ];
if( !adjacentTriangle )
windingTriangleFound = true;
else
windingTriangle = adjacentTriangle;
}
while( !windingTriangleFound );
// Return null if the edge doesn't have such a vertex.
if( !windingTriangleFound )
return 0;
// Return the correct vertex of the found triangle.
int vertexIndex = windingTriangle->FindVertexIndex( pivotVertex );
if( vertexType == CCW_VERTEX )
vertexIndex = ( vertexIndex + 2 ) % 3;
else if( vertexType == CW_VERTEX )
vertexIndex = ( vertexIndex + 1 ) % 3;
return windingTriangle->vertex[ vertexIndex ];
}
示例2:
//=============================================================================
void SurfaceMesh::PathConnectedComponent::CalculateVertexNormals( void )
{
for( Vertex* vertex = ( Vertex* )vertexList.LeftMost(); vertex; vertex = ( Vertex* )vertex->Right() )
{
Zero( vertex->normal );
double triangleCount = 0.0;
for( Triangle* triangle = ( Triangle* )triangleList.LeftMost(); triangle; triangle = ( Triangle* )triangle->Right() )
{
if( triangle->FindVertexIndex( vertex ) != -1 )
{
triangleCount += 1.0;
Add( vertex->normal, vertex->normal, triangle->normal );
}
}
Scale( vertex->normal, vertex->normal, 1.0 / triangleCount );
Normalize( vertex->normal, vertex->normal );
}
}