Hi,
I didn't try to follow your code, but here's and overview of how we do it:
Have a camera/manipulator makeLookAt command that takes eye, center and
up vectors. (These can be converted to the osg manipulators' distance,
rotation, center).
Have a transformation matrix from ECEF coords to local coords. Assume
the camera is positioned/rotated in ECEF.
In the local coords calculate eye, center, up. Convert to ECEF using the
transformation matrix and stick into makeLookAt.
jp
Allen Saucier wrote:
Hi,
I am having some extreme difficulty in rotating my viewing camera 90 degrees with respect
to a "local" coordinate system.
Local coordinate system: (in geocentric measure)
mine is at the edge of the earth; i.e. i'm using a spherical earth. here is
how I compute the local axes:
fuctionName ( osg::PositionAttitudeTransform pax )
{
osg::vec3d objectLocation = pax->getPosition(); // where x,y,z are -678468.2,
-5405095.0, 3682910.3
osg:;quat qOrient = pax->getAttitude();
osg::vec3d up(0,0,1); // z axis of the earth or World coordinates
osg::vec3d x_axis = up ^ objectLocaction;
osg::vec3d y_axis = objectLocaction ^ x_axis;
x_axis.normalize();
y_axis.normalize();
osg::Quat qRotAboutAxisByDegree;
qRotAboutAxisByDegree.makeRotate( osg::DegreesToRadians(-90.), objectLocaction);
osg::Quat qNewOrient = qOrient * qRotAboutAxisByDegree;
s_mtxdIrCamPosOrientOri = osg::matrix::rotate(qNewOrient) *
osg::matrix::translate(objectLocation);
}
1. I know for a fact that the pax is set correctly with position & attitude
because my objects are being placed on my terrain, which is georeferenced terrain,
correctly; i.e. they are perpendicular w/ the terrain and sit nicely on it.
2. the above code snippet actually works for rotation about the "local" Z axis
and I am looking straight down at my terrain; i.e. directly down the local Z axis.
3. I want to rotate the camera "up" 90 degrees and be looking down the positive
X axis.
4. I have tried replacing
qRotAboutAxisByDegree.makeRotate( osg::DegreesToRadians(-90.), objectLocaction);
with
qRotAboutAxisByDegree.makeRotate( osg::DegreesToRadians(-90.), x_axis);
and I get the camera rotated about some axis I am NOT sure of and I am looking
at the terrain from a peculiar angle, though I know not what angle.
5. I am using the TerrainManipulator as my scene matrix manipulator, if that
helps.
Would someone please give me insight as to how to do this? I would be greatly
appreciative as the solution is totally eluding me. :O
...
Thank you!
Thank you very much.
Cheers,
Allen
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=25471#25471
_______________________________________________
osg-users mailing list
osg-users@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.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org