[osg-users] Orient a node to face another

Paul Leopard paul.leopard at gmail.com
Wed Oct 2 07:47:28 PDT 2019


Hi,

What would be the best approach to solve the following problem where I need one node to be updated through a callback to face another node? I understand how to get a node to face the screen with a billboard but that's not the problem here... 

Here is the problem:

I've got a satellite node that is a child of a PAT and currently, I am updating that PAT position only to orbit the satellite around a planet node. I want to update the satellite PAT rotation also so that the satellite Z-Axis always faces the planet node origin. So, I need to compute the proper rotation Quat …


Code:

Quat GetRotation( const Vec3& tgtPos, const Vec3& subjectPos )
{
Quat ret = what?;
return Quat;
}

Vec3 targetPosition(...);
Vec3 satellitePosition(...);
Quat rotation = GetRotation( satellitePosition, targetPosition );

satellitePAT->setPosition( satellitePosition );
satellitePAT->setRotation( rotation );




What would be the best approach for the calculations in GetRotation(...)  using OSG functions? I can work out the math on my own but I'd like to know if there are any cool OSG utilities to do this.

Thank you!

Cheers,
Paul

------------------------
things are more like they are now than they have ever been before

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







More information about the osg-users mailing list