Hi Thomas,

I really not sure what the problem is.  Is it simply that the Wiimote
has a different orientation of X, Y, Z? Is it left or right hand rule?
 Either way this should be a straight forward issue of just setting up
the rotations in the correct order, and if required adding an extra
rotation to account for any difference is orientation of different
coordinate frames.

If it's that you want to change the OSG' default coordinate frame from
Z up, Y north, X east then just change the Camera's View matrix to the
direction your want.  Personally I'd just set up the Wiimote reading
code to come in an appropriate orientation for the OSG's coordinate
frame as most of the model loaders all important data with Z up.

As for the specifics, I know nothing about the Wiimote interface and
conventions, you should by now so I have to defer to you on sorting it
out.

Robert.


On Thu, Jan 21, 2010 at 3:45 PM, Thomas Simon <[email protected]> wrote:
> 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
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to