Hi,

There is my problem: I need to rotate a model on the 3 axis (X,Y and Z) I 
already have the angles corresponding of the rotation on the axis.

I try differents methods to have a good result
It doesnt follow the orientation of my Wiimote Motion plus (It s a project 
about manipulate a model looking like a stick with the wiimote)
The problem is that the angles are given with the wii basis and not the OSG 
basis.
Does someone have a way to modify osg::AXIS ?
here some code to explain my prob:


Code:

osg::Quat quat,quat2,quat3,quat4;
//quat = pat->getAttitude();

roll -= (mp->roll - ave_gyro_roll)/performance;
float r = osg::DegreesToRadians(roll);
pitch += (mp->pitch - ave_gyro_pitch)/performance;
float p = osg::DegreesToRadians(pitch);
yaw -= (mp->yaw - ave_gyro_yaw)/performance;
float y = osg::DegreesToRadians(yaw);
//pat->setPivotPoint(osg::Vec3f(0,0,0));
if(roll > 360   || roll <-360) roll =0;
if(pitch > 360  || pitch <-360) pitch =0;
if(yaw > 360    || yaw <-360) yaw =0;
if(fmodf(roll,90)<0.5)roll+=0.1;
if(fmodf(pitch,90)<0.5)pitch+=0.1;
if(fmodf(yaw,90)<0.5)yaw+=0.1;

quat2= osg::Quat(sin(r/2),0,0,cos(r/2));// axe X
quat3= osg::Quat(0,sin(p/2),0,cos(p/2));// axe Y
quat4= osg::Quat(0,0,sin(y/2),cos(y/2));// axe Z                                
                
quat = quat4*quat3*quat2;// multiplication des 3 quats
osg::Matrix mat;
quat.get(mat);

osg::Quat quat5(
(sin(r/2)*cos(p/2)*cos(y/2)-cos(r/2)*sin(p/2)*sin(y/2)), // X
(cos(r/2)*sin(p/2)*cos(y/2)-sin(r/2)*cos(p/2)*sin(y/2)), // Y
(cos(r/2)*cos(p/2)*sin(y/2)-sin(r/2)*sin(p/2)*cos(y/2)), // Z
(cos(r/2)*cos(p/2)*cos(y/2)-sin(r/2)*sin(p/2)*sin(y/2))  // W
);


//pat->computeLocalToWorldMatrix(mat,nv);
//_loadedModel.get()->traverse(*nv);
if(quat.zeroRotation==false)pat->setAttitude(quat); 
}




Thank you!

Cheers,
thomas[/code]

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to