
236 V 3D Engine Design
By parsing the vertex and index buffer of a mesh and filling into a data
structured like the above one, it is really easy to start doing queries on the mesh.
For instance, the following snippet finds all neighboring faces of a given face:
List<Face> GetNeighbors ( Face face )
{
List<Face> neighbors = new List<Face >() ;
if ( face . edge . opposite != null)
{
neighbors . Add( face . edge . opposite . face );
}
if ( face . edge . next . opposite != null)
{
neighbors . Add( face . edge . next . opposite . face );
}
if ( face . edge . next . next . opposite != null)
{
neighbors . Add( face . edge . next . next . opposite . face );
}
return neighbors ...