I got it working!!! In case anyone is interested, this is what I did.
I took a local point on the -Z axis of the entity. localX = 0, localY=0, localZ=-1; Converted it to World Coordinates (wX, wY, wZ), subtracted the center of the entity in world coordinates. Wx -= entityXWorld; Wy -= entityYWorld; Wz -= entityZWorld; And used that for my UP vector osg::Vec3 up(Wx,Wy,Wz); What I think is happening is that my UP vector is attached to the top of my entity now. When the entity rolls, my UP vector rolls with it. Works good :) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cysneros, Nelson SPAWAR Sent: Thursday, February 28, 2008 10:35 AM To: OpenSceneGraph Users Subject: [osg-users] Calculating Up Vector I'm having a problem trying to calculate the UP vector of a node as it makes a 360 roll. I'm setting the camera viewpoint like this: //Update View osg::Vec3 eye( cameraX, cameraY, cameraZ); osg::Vec3 center(nodeX,nodeY,nodeZ); osg::Vec3 up(nodeX,nodeY,nodeZ); viewer->getCamera()->setViewMatrixAsLookAt(eye,center,up); Which works great in a geoCentric system. I can place a node anywhere on the earth and it will be right side up. Now the node wants to make a 360 roll and we want the camera to roll with it. Not sure how to calculate the UP vector in this case. I tried something like this: osg::Matrix rotX, rotY, rotZ, transXYZ; rotX.makeRotate(myNode->getXRotation(), osg::Vec3(1,0,0)); rotY.makeRotate(myNode->getYRotation(), osg::Vec3(0,1,0)); rotZ.makeRotate(myNode->getZRotation(), osg::Vec3(0,0,1)); up = eye ^ center;//cross product osg::Vec3 up2; up2 = up * rotZ * rotY * rotX; viewer->getCamera()->setViewMatrixAsLookAt(eye,center,up2); Does not work... Any suggestions? Thanks _______________________________________________ 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