triangle mesh note


Making triangle meshes without including source code
From Ben Schroeder:
I've found a way to create triangle meshes from a PBRT Shape plugin 
without having to copy the class into your source. It's based on how the 
built-in NURBS surface works.

The key is to use the "MakeShape" function. Including "dynload.h" gives 
you access to this. A call to MakeShape looks something like

        MakeShape("trianglemesh", o2w, reverseOrientation, paramSet)

where paramSet is a ParamSet object, filled with the points, vertex 
indices, etc, to make the mesh. There is an example of how to make a 
ParamSet at the end of NURBS::Refine, found in shapes/nurbs.cpp.

There is a caveat: MakeShape returns a Reference, not a 
TriangleMesh* or even a Shape*, so you will have to pass 
References around in your code instead of pointers. Also, you 
won't be able to do anything TriangleMesh-specific with the returned 
object. However, this should still work fine for use in your own Refine 
method, which should just need to create the mesh and pass it back.

Last updated 9/9/05