[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:

[...]
if(lsi->containIntersection())
{
    //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);

    //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);     
       //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.

Thanks




More information about the osg-users mailing list