ModelNode animation

classic Classic list List threaded Threaded
7 messages Options
aef aef
Reply | Threaded
Open this post in threaded view
|

ModelNode animation

Hello,
I am using osgEarth to show a 3d model of a quadcopter drone flying over the terrain. I was wondering whether it is possible to make the model's propellers spin while the drone is flying (and, eventually, what is the best/recommended way to do that).
I can explode the model in Blender and separate the propelles from the frame but I don't know if the right way to animate them is to assign every propeller to a different ModelNode and move/rotate them on the map independently (it seems quite a complex task) or if there's a way to create an animated model and import it in a single ModelNode.

After all, I don't need to control the spinning, it would be just good to be able to import two different models of the drone: one "static" model and another one with the spinning propellers.

Thank you for your help!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

This is more of an OpenSceneGraph question. You would set up your model (in the modeling software) so each rotor geometry is in a separate scene graph group under a transform. Then you app can locate those transforms and update them each frame -- perhaps with an UpdateCallback, or in the frame loop. Good luck!
Glenn Waldron / Pelican Mapping
aef aef
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

Hi Glenn!
Ok, I see. But do you think that it is better for me to use "ModelNode"s or generic "osg::Node"s for the rotors?
I found the two alternatives here: http://docs.osgearth.org/en/osgearth-2.4/faq.html
I was asking for a suggestion about which one is easier to use.

Thank you again!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

ModelNode is an osgEarth construct that was originally part of our Annotations/Symbology framework. It's purpose was to support external models in earth files.

In your case, it doesn't buy you anything extra that you can't get with stock OSG nodes, placed under a GeoTransform to locate it of the earth.
Glenn Waldron / Pelican Mapping
aef aef
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

The first part is done: here.
Tomorrow I am going to place it under a GeoTransform.
Thanks!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

Beautiful!
Glenn Waldron / Pelican Mapping
aef aef
Reply | Threaded
Open this post in threaded view
|

Re: ModelNode animation

Hi, sorry for the delay. I had, at first, to rescale the drone's frame and the propellers.
Then, I implemented the following steps to place the osg::Node:

GeoPoint point(geographicSRS, 12.973203f, 41.547404f, 30.0f, AltitudeMode::ALTMODE_RELATIVE);
osg::Matrix matrix;
point.createLocalToWorld( matrix );
myMatrixTransform->setMatrix( matrix );


but there's something wrong with the altitude.
If I place both the ModelNode and the osg::Node at the same GeoPoint, the altitude of the ModelNode is correct while the osg::Node is way lower that the ModelNode.
Now, I am studying the SimpleModelSource class to understand what I did wrong...