本文整理汇总了C++中TriangleBuffer::GetIndices方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleBuffer::GetIndices方法的具体用法?C++ TriangleBuffer::GetIndices怎么用?C++ TriangleBuffer::GetIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleBuffer
的用法示例。
在下文中一共展示了TriangleBuffer::GetIndices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Modify
void VertexNormalsModifier::Modify(TriangleBuffer& Buffer)
{
const IndexContainer& Indices = Buffer.GetIndices();
VertexContainer& Vertices = Buffer.GetVertices();
if( this->Compute == VertexNormalsModifier::CM_Triangle ) {
for( Whole Index = 0 ; Index < Indices.size() ; Index += 3 )
{
Vector3 v1 = Vertices[Indices[Index]].Position;
Vector3 v2 = Vertices[Indices[Index+1]].Position;
Vector3 v3 = Vertices[Indices[Index+2]].Position;
Vector3 VertNormal = (v2-v1).CrossProduct(v3-v1).GetNormal();
Vertices[Indices[Index]].Normal = VertNormal;
Vertices[Indices[Index+1]].Normal = VertNormal;
Vertices[Indices[Index+2]].Normal = VertNormal;
}
}else if( this->Compute == VertexNormalsModifier::CM_Vertex ) {
std::vector< std::vector<Vector3> > TempNormals;
TempNormals.resize(Vertices.size());
for( Whole Index = 0 ; Index < Indices.size() ; Index += 3 )
{
Vector3 v1 = Vertices[Indices[Index]].Position;
Vector3 v2 = Vertices[Indices[Index+1]].Position;
Vector3 v3 = Vertices[Indices[Index+2]].Position;
Vector3 VertNormal = (v2-v1).CrossProduct(v3-v1);
TempNormals[Indices[Index]].push_back(VertNormal);
TempNormals[Indices[Index+1]].push_back(VertNormal);
TempNormals[Indices[Index+2]].push_back(VertNormal);
}
for( Whole CurrVertex = 0 ; CurrVertex < Vertices.size() ; ++CurrVertex )
{
Vector3 VertNormal(0.0,0.0,0.0);
for( Whole CurrNormal = 0 ; CurrNormal < TempNormals[CurrVertex].size() ; ++CurrNormal )
{
VertNormal += TempNormals[CurrVertex][CurrNormal];
}
Vertices[CurrVertex].Normal = VertNormal.GetNormal();
}
}
}