Design Question

Ok, I’m now working on Bezier Meshes and it led to a revelation.

I want to system to treat Bezier Meshes and Tri Meshes the same (the only difference being the user can tessellate the bezier mesh). This led to me having BezierMesh extend TriMesh. Which then led to the thought of generating these tri meshes, such as model loading. I think the only thing you should work with is a TriMesh (or BezierMesh). That is, you don’t put boxes or pyramids or models into the scenegraph, just trimeshes. However, you’d use boxes or pyramids or models to BUILD the tri mesh. So, instead of

Box box = new Box(min, max);

You would do:

TriMesh box = new TriMesh();
Box.buildTriMesh(box, min, max);

This would mean Box is now just a utility class that sets the values of the passed TriMesh.

Why would this be good? Because now the system only has TriMeshes to work with and I could do the following:

TriMesh box = new TriMesh();
BezierMesh roundedBox = new BezierMesh();
Box.buildTriMesh(box, min, max);
Box.buildTriMesh(roundedBox, min, max);

Meaning ANYTHING could be set as a BezierMesh. Terrain could be loaded as a BezierMesh making for smooth rolling terrain, models if you wanted to do something funky... etc. And absolutely no extra code will have to be written.

Anyone see any drawbacks to this?

Ok, I still plan on that design. It’s going to take a bit longer though, so it won’t make it into 0.4. Bezier Mesh works off Bezier Patches and a patch must be a 4x4 mesh (just they way the Bezier works), so that would mean making a Bezier Mesh out of multiple Bezier Patches (which is doable), which would mean building multiple bezier patches out of a model or terrain or whatever, (which is doable). These things will take time, and there are other things I want to get done first. So, the initial release will allow a bezier mesh be made from a single patch. I will then go back an add the enhancements at a later date.

I think this would be nice design. Objects for rendering should simply extend the TriMesh-class like:

class Box extends TriMesh

Than you could add the box directly to the scene-graph.

scene.attachChild(new Box(min,max));

It could also be considered to design a TriMesh-Interface, so that the renderer can render all objects that implement this interface. But this could also lead to less performance or a to complex implementation. But this way you could renderer different TriMesh implementations with
the same renderer.

That is the current design as it stands now. My proposal was trying to figure out a way to have TriMesh and BezierMesh interchangable. So, you could make a standard box (TriMesh) or a lumpy box (BezierMesh). As it stands now, (Box extends TriMesh) box can only be a TriMesh. Does that make sense?