Hi,
I think you need a matrix that makes a conversion from "Y up" to "Z up". Here
is some code that I use for setting the camera manually:
osg::Matrixd cameraMatrix;
osg::Matrixd cameraRotation;
osg::Matrixd cameraTrans;
cameraRotation.makeRotate(
osg::DegreesToRadians(0.0), osg::Vec3(0,1,0),
// roll
osg::DegreesToRadians(-15.0), osg::Vec3(1,0,0),
// pitch
osg::DegreesToRadians(-90.0), osg::Vec3(0,0,1));
// yaw
cameraTrans.makeTranslate(-1000, 0, 300);
cameraMatrix = cameraRotation*cameraTrans;
// The view matrix is the inverse of the camera position matrix.
cameraMatrix.invert(cameraMatrix);
// Conversion to OpenGL "Y up" standard.
osg::Matrixd rotationToYUp;
rotationToYUp.makeRotate(-M_PI/2.0, osg::Vec3(1.0, 0.0, 0.0));
cameraMatrix = cameraMatrix*rotationToYUp;
camera->setViewMatrix(cameraMatrix);
Regards,
Asa
-----Ursprungligt meddelande-----
Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] För Tueller, Shayne R Civ
USAF AFMC 519 SMXS/MXDEC
Skickat: den 24 juni 2008 00:22
Till: OpenSceneGraph Users
Ämne: Re: [osg-users] camera view matrix problems...
Paul,
I was assuming that setViewMatrix() behaved the same way as the OpenGL
modelview matrix, that is, world to eye.
I tried negating the translation part which seems to have moved me to the right
place but I'm facing straight down on top of my terrain (azimuth view) with my
orientation setting at (0.0, 0.0, 0.0). When I change the orientation angles to
something other than 0.0, nothing shows up again.
I'm confused...
All I want to do is fix my camera position and orientation...heading around z,
pitch around x, and roll around y. It can't be that hard can it?
-Shayne
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Martz
Sent: Monday, June 23, 2008 4:13 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] camera view matrix problems...
The OpenGL view matrix is an inverse transform. Try negating the translation.
-Paul
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tueller, Shayne R Civ USAF AFMC 519
SMXS/MXDEC
Sent: Monday, June 23, 2008 3:44 PM
To: [email protected]
Subject: [osg-users] camera view matrix problems...
I'm attempting to explicitly set the view matrix for a camera in
osgViewer. I'm not using viewer->run() so I'm not using the default camera
manipulator. Here's the code I'm using:
osg::Matrixf vm;
vm.setRotate(osg::Quat(0.0, osg::Vec3(0.0, 0.0, 1.0),
0.0, osg::Vec3(1.0,
0.0, 0.0),
0.0, osg::Vec3(0.0,
1.0, 0.0)));
vm.setTrans(osg::Vec3f(eyex, eyey, eyez));
viewer->getCamera()->setViewMatrix(vm);
I'm expecting to see a view of the terrain that is centered around
(eyex, eyey, eyez) and I see nothing. Can someone tell me what I'm doing wrong
in the code above?
Thanks,
-Shayne
P.S. When I use the command:
viewer->setViewMatrixAsLookAt()
with the same eye point (with lookat and up vectors), I can see the
terrain as expected.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org