Example #1
0
	GeometryPtr Mesh::getGeometry()
	{
		GeometryPtr g = Geometry::createTriangleGeometry();


		AttributePtr positions = g->getAttr( "P" );

		static std::map<Mesh::PointHandle, int> g_pointIndices;

		g_pointIndices.clear();


		for( PointList::iterator it = m_points.begin(); it != m_points.end(); ++it )
		{
			PointHandle p = *it;
			g_pointIndices[p] = positions->appendElement( p->pos );
		}
		for( FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it )
		{
			FaceHandle f = *it;
			if( f->vertices.size() == 3 )
				g->addTriangle( g_pointIndices[f->vertices[0]->point], g_pointIndices[f->vertices[1]->point], g_pointIndices[f->vertices[2]->point] );
		}
		return g;
	}