[osg-users] Quaternion problem

Antonin Linares Antonin.Linares at onera.fr
Mon Mar 16 05:25:54 PDT 2009

Hi osg users

I use an intersectionVisitor to place tank model on my terrain
i made something like that:

    //get height and normal under the tank
    osg::Vec3f pos = 
    osg::Vec3f normal = 

    //Set up height

    //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);
       //here it's cool my tank was perfectly aligned with terrain but i 
loose it's orientation
       //so i test to do
       osg::Quat rot(rotation, normal);
       pat->setAtitude(corect*rot);   //the tank was well oriented but 
no more aligned with my terrain             
I looking for any idea to make my tank aligned with the terrain but 
keeping it's previous orientation.


More information about the osg-users mailing list