Nesting meshes within a container

Hi
I’m looking for pointers on how best to build a 3D ‘scene’ of various meshes which attach to parents/children and can therefore be controlled by transforming the parent etc.

I thought this was possible using the ofNode class but I can’t figure how to add mesh data to an existing node. Is it possible? Could anyone point me in the right direction or towards a relevant doc for how to build complex 3D scenes in oF please?

Thanks!

Hello @sjd, in the example folder there is examples/3d/ofNodeExample. You can chain ofPrimitive together using setParent. Each ofPrimitive inherits from a node. For exampe, if you have a box, and you want to add a sphere as a child, you do as follows:

sphere.setParent(box).

now if you move the box, the sphere will move with it.

Have a look there and feel free to ask if it is not clear

If you want to use your custom mesh, I will suggest you to have a look at the paragraph of3dPrimitive here http://openframeworks.cc/ofBook/chapters/advanced_graphics.html#d

Thanks @edapx - I think of3DPrimitive is what I want.

I’m loading a model using ofxAssimpModelLoader and can display that model correctly but it doesn’t seem to inherit from ofNode so I can’t attach it to a parent etc.

However I think I can copy the data over to my of3DPrimitive instance’s mesh.

Do you know of any automated (api) way of copying all vertex, index and normal data from one mesh instance to another? Or do I have to do it all manually using loops?

Thanks again

If your class inherits from of3DPrimitive (as I would suggest you), just:

getMesh() = yourMesh;

Awesome, that does it!
Thanks