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);
scene.attachChild(box);
You would do:
TriMesh box = new TriMesh();
Box.buildTriMesh(box, min, max);
scene.attachChild(box);
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);
roundedBox.tessellate(3);
scene.attachChild(box);
scene.attachChild(roundedBox);
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?