Thank you all for your replies, Much appreciated.

I understand about how 3D graphics works in regards to coordinate systems and 
such and i understand how I want the scene to act and work, its just getting 
the code to actually make this happen. Going about applying the two transforms 
to my sphere is where i am stuck because i dont have a firm grasp with the OSG 
language.

For example, below rotates a sphere that is originally placed as 10,0,0 around 
0,0,0 (imagine that is where a sun is placed), whilst it is doing that i also 
need it to rotate on its own central axis. As it will be spinning on its own 
XYZ which will change as it rotates i choose its current XYZ postion as the 
point on which to rotate using the getCenter() method, still cant get it 
working though.


Code:

PositionAttitudeTransform *rotate_planetFive = new PositionAttitudeTransform;
rotate_planetFive->addChild( geode_planetFive );
rotate_planetFive->setUpdateCallback( new 
AnimationPathCallback(osg::Vec3(0,0,0), osg::Z_AXIS, inDegrees(45.0f)) ); 
//ROTATE AROUND THE SUN

Vec3 central_point = primitive_planetFive->getCenter(); //GET THE CURRENT 
LOCATION OF THE CIRCLE WHILST IS ROTATES

PositionAttitudeTransform *rotate_planetFiver = new PositionAttitudeTransform;
rotate_planetFiver->addChild( geode_planetFive );
rotate_planetFiver->setUpdateCallback( new 
AnimationPathCallback(osg::Vec3(central_point), osg::Z_AXIS, inDegrees(45.0f)) 
); //USING THE SPHERE CURRENT LOCATION, ROTATE AROUND IT.




Doing this and, as expected, two spheres are shown, one that stays at its 
original location and just spins and another that "orbits" around 0,0,0.

Now I need to combine both of the transforms onto a single sphere, but i just 
cant figure out the code for that. I tried this:

Code:

PositionAttitudeTransform *rotate_planetFive = new PositionAttitudeTransform;
rotate_planetFive->addChild( geode_planetFive );
rotate_planetFive->setUpdateCallback( new 
AnimationPathCallback(osg::Vec3(0,0,0), osg::Z_AXIS, inDegrees(45.0f)) ); 
//ROTATE AROUND THE SUN
Vec3 central_point = primitive_planetFive->getCenter(); //GET THE CURRENT 
LOCATION OF THE CIRCLE WHILST IS ROTATES
rotate_planetFive->setUpdateCallback( new 
AnimationPathCallback(osg::Vec3(central_point), osg::Z_AXIS, inDegrees(45.0f)) 
);



But that doesnt work, it only applies the second setUpdateCallback() when i 
need both to run.

Sorry if it seems I am posting excessively, I just get a little bit obsessive 
when I cant get the coding correct, Apologies.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=24203#24203





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to