[osg-users] Quaternion problem

J.P. Delport jpdelport at csir.co.za
Tue Mar 17 07:44:52 PDT 2009


Hi,

yes, try to store your angle manually. We have something similar, an 
object has yaw, pitch & roll, but we modify it depending on where on the 
globe it is:

lori = quat made from object r,p,y

// Make offset quat from position on globe
qoff = mScenario->getOrientationOffsetFromLLH(i_dLat, i_dLong, i_dAltitude);

lori = lori * qoff;

mModelTransform->setAttitude(lori);

cheers
jp

Antonin Linares wrote:
> Hi Steven,
> 
> Maybe, i'm not clear, I want to keep the current yaw angle, and change 
> pitch and roll by the terrain normal.
> So i use getRotate to find my previous yaw angle, like you Steven, i 
> thinks thats not the solution. Maybe i need to store this yaw angle in 
> custom data.
> 
> Hi JP i use osg 2.8 an getRotate seem to returns angle and vector.
> 
> Antonin Linares
> 
> 
> 
> Steven Saunderson a écrit :
>> 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
>>
>>
>>
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>   
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.




More information about the osg-users mailing list