Hello oF users,
I’m currently working on a simple 3D scene editor with oF, and with that kind of software, one of the first questions that I cannot seem to answer properly is : “what’s the best way to store all the objects of the scene ?” .
What I’d really like to do is a kind of wrapper object that has all the properties / methods of a normal 3D primitive, with some stuff along like a list of the materials or shaders to apply to this primitive. It would feel much more intuitive to me to have all of these gathered in the same object than to have separate lists of each.
I tried some things like coding a sort of wrapper that inherits of3dPrimitive, but since of3dPrimitive is the base class, it makes the objects impossible to use “as is” (you can’t call setRadius on an of3dPrimitive…). My C++ is a bit rusty with things like inheritance and I know it can be tricky sometimes, I also tried something with templates but no more luck.
For the moment I just have a vector of of3dPrimitives * that lets me use the common functions to all primitives. I’d like not to have to cast every object every time I want to interact with it… In the future I’d also like to be able to import external 3D meshes ; is there a way to put 3D meshes (e.g. ofMesh obtained with Assimp) and 3D primitives in the same container ? I was thinking of storing just the ofMesh of the primitives, but since I don’t know how to re-create a primitive from an ofMesh, I would be at a loss…
So, what is the best way to store 3D objects in a scene ? Is it a good idea to wrap them in order to store more data about them (materials/shaders to use) ? Is there a convenient way to deal with both ofMesh (external 3d objects) and of3dPrimitives ?
Thank you for your help