Re: [osg-users] z-up camera position osgthirdpersonview
Hi Fabian, Eye coordinates in OpenGL and OSG are Y up, X to the right, Z out from the screen. Eye coordinates are in the screens frame of reference. Model coordinates in the OSG can be anything you want them to be, but... the OSG plugins and camera manipulators default to a *model* coordinate frame of Z up, Y to the north, X to the east. Key to remember is here we are talking about model coordinates, and north, east - in real world frame of reference. A common mistake in computer graphics is to try and tie the screen reference frame directly to the world - forcing the world's reference frame to be that of the eye/screen, once you do this you end up making lots of silly mistakes about managing coordinates. Another mistake is to get hung up with eye coordinates and how these map to world coordinates, almost all of the time you can totally ignore eye coordinates and just work in world or local object coordinate frame, the camera's themselves allow you to set their position in world coordinates - such as my using the setViewMatrixAsLookAt(..) method. Convenience methods like this will create all the correct transforms for you. Robert. On Sun, Sep 7, 2008 at 4:12 AM, Fabian Bützow [EMAIL PROTECTED] wrote: Hi, let me summarise my thoughts about the osg-opengl-coordinate system issue: (and please comment on that) Thinking in local coordinate systems, every geometry has its own coordinate system, starting in WCS (0,0,0). For each coordinate system is X east, Y north and Z up. When you add transformation nodes into the scenegraph between root and geometry, each transformation adds up to a model matrix(top-down) that transforms the coordinate system. (imagine: the geometry is drawn into that modified coordinate system) After that, the view Matrix of the camera is applied. (camera coordinates are in osg Z-up) Basically, that means that the local coordinates are transformed into the eye coordinates. Still, z is up?! (virtual camera is in origin, looking along positive y, right-hand-system) I found this quote from Robert: Once the scene is transformed into eye space by the View matrix of the Camera the coordinate system of the eye space is standard OpenGL, +ve Y up the screen, +ve X to the right, +Z out from the screen. And now im getting a little confused.. Now an addtional rotation (x, 90°) should be applied, to rotate the coordinate system from osg into X east, Y up, Z south. That would mean camera still looks along positive y.?? that would be strange when it comes to the viewing volume and the perspective division..? (Y non linear scaled??, something's wrong here..) see, im confused ;) im sure you can help me, cheers Fabian ___ 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] z-up camera position osgthirdpersonview
Hi everybody, i played a bit around with the osgthirdpersonview.. my goal was to draw an additional line for the up vector (Vec3(0.0, 0.0, 1.0))- hence i added the fllowing code to the example: camera-getViewMatrixAsLookAt(*eye, *center, *up); //gives the up vector //draws a line from origin to up vector (*v)[9].set(*up); GLushort idxLoops2[2] = {9, 0 }; geom-addPrimitiveSet( new osg::DrawElementsUShort( osg::PrimitiveSet::LINE_LOOP, 2, idxLoops2 ) ); This didnt bring the desired effect, and I disabled the inverse viewmatrix tranformation to see where the orginal viewfrustum would be drawn. Surpringsliy (for me ;)) the camera looks along the negative z-axis as in std opengl... My up vector however pointed still to z up (and not as expected to y north) what do i have to do to draw the upvector approprietly? cheers a nice weekend Fabian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] z-up camera position osgthirdpersonview
The geometric data for the view volume in osgthirdpersonview is in OpenGL eye coordinate space, and is transformed by the inverse modelview to put it into world (object) space. The up vector your code gets from the camera is already in world space. However, your code treats it like it's in eye space, and incorrectly back-transforms it (like the rest of the eye space view volume). So, you've made a mistake in your linear algebra. You'll need to rethink the coordinate spaces you are working with and fix your code accordingly. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fabian Bützow Sent: Saturday, September 06, 2008 3:16 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] z-up camera position osgthirdpersonview Hi everybody, i played a bit around with the osgthirdpersonview.. my goal was to draw an additional line for the up vector (Vec3(0.0, 0.0, 1.0))- hence i added the fllowing code to the example: camera-getViewMatrixAsLookAt(*eye, *center, *up); //gives the up vector //draws a line from origin to up vector (*v)[9].set(*up); GLushort idxLoops2[2] = {9, 0 }; geom-addPrimitiveSet( new osg::DrawElementsUShort( osg::PrimitiveSet::LINE_LOOP, 2, idxLoops2 ) ); This didnt bring the desired effect, and I disabled the inverse viewmatrix tranformation to see where the orginal viewfrustum would be drawn. Surpringsliy (for me ;)) the camera looks along the negative z-axis as in std opengl... My up vector however pointed still to z up (and not as expected to y north) what do i have to do to draw the upvector approprietly? cheers a nice weekend Fabian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce negraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] z-up camera position osgthirdpersonview
Hi, let me summarise my thoughts about the osg-opengl-coordinate system issue: (and please comment on that) Thinking in local coordinate systems, every geometry has its own coordinate system, starting in WCS (0,0,0). For each coordinate system is X east, Y north and Z up. When you add transformation nodes into the scenegraph between root and geometry, each transformation adds up to a model matrix(top-down) that transforms the coordinate system. (imagine: the geometry is drawn into that modified coordinate system) After that, the view Matrix of the camera is applied. (camera coordinates are in osg Z-up) Basically, that means that the local coordinates are transformed into the eye coordinates. Still, z is up?! (virtual camera is in origin, looking along positive y, right-hand-system) I found this quote from Robert: Once the scene is transformed into eye space by the View matrix of the Camera the coordinate system of the eye space is standard OpenGL, +ve Y up the screen, +ve X to the right, +Z out from the screen. And now im getting a little confused.. Now an addtional rotation (x, 90°) should be applied, to rotate the coordinate system from osg into X east, Y up, Z south. That would mean camera still looks along positive y.?? that would be strange when it comes to the viewing volume and the perspective division..? (Y non linear scaled??, something's wrong here..) see, im confused ;) im sure you can help me, cheers Fabian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org