Michael, Position and orientation of the ownship on a VPB sphere has been discussed at length on this forum. You should have no problem finding what you need to do.
Check out http://forum.openscenegraph.org/viewtopic.php?p=40200#40200 for more info. For an arbitrary entity (aircraft or otherwise), the transform needs to be different. -Shayne -----Original Message----- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of michael bosse Sent: Saturday, July 09, 2011 11:29 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] VirtualPlanetBuilder database and rotations for viewmatrix Hi everyone, I am working on a little toy flight sim type program using the blue marble data with virtual planet builder, built with --geocentric in wgs84. I have managed to integrate some basic physics, and I set up an eye-point above the vehicle facing down with north always up in my view. I want to have a mode where the view is actually at the eyepoint of the aircraft and matches its rotations. This is where I am having problems... The data I have are the euler angles and position (xyx). I've tried a number of approachesto manually set the viewmatrix, but so far, I haven't had much luck. I'll outline what i have tried below. At first I tried using a make look at, but I couldn't figure out what the parameters other than eye should be, so I moved on to setting up the matrix myself. First I tried building the rotation matrix by setting it like you would the model matrix, but I realized that it should actually be the inverse of that. I then tried taking the rotation matrix of the aircraft and the translation of the aircraft, and applying them like they do in flightgear, which is : double phi, theta, psi; // given in radians osg::Vec3d position ( x, y, z ); // gcc meters osg::Quat Qeul = makeEulerQuat( phi, theta, psi ); // same function used for drawing the model which works... osg::Matrixd viewMatrix ( osg::Matrixd::translate( -position ) * osg::Matrixd::rotate( Qeul.inverse() ) ); getCamera()->setViewMatrix(viewMatrix); I'm stuck on this one, I haven't been able to get the camera to look correct in any orientation other than top down (because I know how to set up makelookat for that ;)). This must be a fairly common problem, perhaps there is an FAQ or an example I missed that spells it out. Anyone have any idea what I am doing wrong? Thank you!, michael ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41287#41287 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org