[osg-users] Quaternion problem

Steven Saunderson osgforum at tevs.eu
Tue Mar 17 03:17:06 PDT 2009


Hi Antonin,

I may be getting way out of my depth here but when I saw your problem this morning it looked very similar to a problem I had just recently.

Looking at your original post :


Antonin Linares wrote:
> 
> //get height and normal under the tank 
> osg::Vec3f pos = 
> lsi->getFirstIntersection()->getWorldIntersectionPoint(); 
> osg::Vec3f normal = 
> lsi->getFirstIntersection()->getWorldIntersectionNormal(); 
> 
> //Set up height 
> pat->setPosition(pos);

All looks fine so far


Antonin Linares wrote:
> //Set up alignment with terrain 
> float rotation; 
> osg::Vec3f origine; 
> pat->getAtitude().getRotate(rotation, origine); 
> 
> if((origine*normal) != 0){ 
> osg::Quat corect; 
> corect.makeRotation(origine, normal); 
> 
> pat->setAtitude(corect);


I don't understand why you have the getAtitude() here.  It will return a quat and the .getRotate will convert the value into an angle and vector.  But what quat value is it converting ?

What happens if you always calculate "corect" as you are doing and then apply "rot" in the setAtitude call (i.e. pat->setAtitude (rot * corect) ) ?

//Set up alignment with terrain 
float rotation; 
osg::Vec3f origine (0,0,1); 
osg::Quat corect; 
corect.makeRotation(origine, normal); 

// I'm not sure where you get rotation from ??????

osg::Quat rot(rotation, origine); 
pat->setAtitude(rot*corect);

I hope this helps or entices someone more knowledgeable to assist here.

------------------------
-- Steven Saunderson

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








More information about the osg-users mailing list