<div dir="ltr">Hi Paul,<br><div><br></div><div>you subtract the two input vectors and by this you get the direction from one to the other, then normalize and make the Quaternion to rotate the axis (in the code bellow is Y-forward) to the normalized vector. Something like this:</div><div><br></div><div>osg::Quat GetRotation(const osg::Vec3& tgtPos, const osg::Vec3& subjectPos)<br> {<br><br> osg::Vec3 v = tgtPos - subjectPos;<br> v.normalize();<br><br> osg::Quat ret;<br> ret.makeRotate(osg::Vec3(0, 1, 0), v);<br><br> return Quat;<br> }<br><br></div><div>Nick</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 6:04 PM Paul Leopard <<a href="mailto:paul.leopard@gmail.com">paul.leopard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
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... <br>
<br>
Here is the problem:<br>
<br>
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 …<br>
<br>
<br>
Code:<br>
<br>
Quat GetRotation( const Vec3& tgtPos, const Vec3& subjectPos )<br>
{<br>
Quat ret = what?;<br>
return Quat;<br>
}<br>
<br>
Vec3 targetPosition(...);<br>
Vec3 satellitePosition(...);<br>
Quat rotation = GetRotation( satellitePosition, targetPosition );<br>
<br>
satellitePAT->setPosition( satellitePosition );<br>
satellitePAT->setRotation( rotation );<br>
<br>
<br>
<br>
<br>
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.<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Paul<br>
<br>
------------------------<br>
things are more like they are now than they have ever been before<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=76770#76770" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=76770#76770</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">trajce nikolov nick<br></div>