Kaiser, Hagen (CT) wrote:

It is in radians.
But do you know something about those diffent Up-Vectors?
Well, the default "camera" orientation for OpenGL (i.e. when the model-view matrix is the identity matrix) is to have the camera at the origin, with Y being up, and the camera looking down the negative Z-axis. This also applies to the MatrixManipulator classes. So if a manipulator returns the identity matrix the view will have Y up. However, the manipulator classes in OSG seem to default (i.e. home position when pressing the space bar) to return a matrix in which Z is up. So the matrix they return includes as a first step a rotation around the X around by 90 degrees to turn Y up in Z up. More confusing is the fact that the _inverse matrix_ returned by a matrix manipulator is actually used as the model-view matrix.

Hmm, I hope I got this all correct, it's so easy to make a mistake with this stuff...

BTW, you don't have to use a matrix manipulator, as it seems you want full control over the view orientation (and assuming mouse interaction is unwanted). In that case you can do

viewer->getCamera()->setViewMatrix(...)

within the frame loop and set your desired model-view matrix there.

Paul



-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Paul Melis
Gesendet: Freitag, 6. Juni 2008 16:36
An: OpenSceneGraph Users
Betreff: Re: [osg-users] Positioning the viewers camera

Kaiser, Hagen (CT) wrote:

Thanks for the idea,
But that doesnt seem to bring me any furhter.
Coordinates are somthing like 500, -5,50 so making this all minus
brings me so far away, that i cant see anything anymore
This is what I found in atutorial about that problem:

To position a camera manually, we can use the viewer class setViewByMatrix() method. This call should be placed between the viewer.update and viewer.frame calls within the simulation loop. The following guidelines are useful:

   * Producer and all classes below osgGA::MatrixManipulator (in
     terms of abstraction) use 'Y' up coordinates. All others
     -including the Viewer class matrix manipulators - use 'Z' up.
   * The inverse of a position/orientation matrix can be used to
     orient a camera.

This correseponds to my makeTranslate call, I think.

Just a check: is the rotation value you apply in degrees or radians? makeRotate() expects a value in radians...

Paul

------------------------------------------------------------------------
*Von:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *Im Auftrag von *Alejandro Segovia
*Gesendet:* Freitag, 6. Juni 2008 16:24
*An:* OpenSceneGraph Users
*Betreff:* Re: [osg-users] Positioning the viewers camera

Hello,

On Fri, Jun 6, 2008 at 11:10 AM, Kaiser, Hagen (CT) <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:


   Hello everyone,
   I am desparately trying to position a viewers camera manually and
   correctly.
   My give data give me a Position Vector a RotationAxis and a
   Rotation Angle.
   And a float that is named fieldofView.
   Here is how I implement it:
   osgGA::TrackballManipulator* man =
   (osgGA::TrackballManipulator*)this->viewer->getCameraManipulator();
   osg::Matrix trans;
   trans.makeTranslate(osg::Vec3(position.x(),position.y(),position.z()));
   osg::Matrix rot;
   rot.makeRotate(Angle,osg::Vec3(Axis.x,Axis.y,Axis.z)));
   osg::Matrix cam = rot*trans;
   this->viewer->setByMatrix(cam)
   }
   But I never get the right position or rotation.
   After testing around, I noticed the following:
   Changing
   trans.makeTranslate(...
   to trans.makeTranslate(osg::Vec3(position.x,* -position.z,
   position.y*));

Have you tried making a translation of (-x, -y, -z) instead? Remember that placing the camera at some point P is actually applying a translation of -P to the whole world.

cam = rot*trans seems fine.

Let me know how it went.

Alejandro.-

--
[EMAIL PROTECTED]
http://varrojo.linuxuruguay.org

------------------------------------------------------------------------

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to