Re: [osg-users] QuadBuffer Stereo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/06/2011 11:51 AM, Robert Osfield wrote: Does: osgviewer --stereo QUAD_BUFFER cow.osg Work on your system? Do you have any other applications that are working with quad buffer stereo on your system? Robert. If this doesn't work, the xorg.conf needs to be configured correctly for stereo - see Nvidia's documentation for the correct lines. Ubuntu (probably no distro) configures stereo out of the box. Regards, Jan -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org/ iD8DBQFNMaIjn11XseNj94gRAtqYAKDWcZm0zJ7Wb01gT9BFrwlaeQA9GwCfW1WA 7FbKn4fWRWxYrkUifLDs+FE= =xVKJ -END PGP SIGNATURE- ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Clearing window client area.
Hi Guy, I guess I could have been a little clearer in my description. So here's an example that should help: You're right, the description you gave this time makes things a lot clearer. The camera will only clear its viewport. And that makes sense, since the camera should only ever affect pixels inside its viewport... Even though after swap buffers, the context's clear() method is called as you've seen (good that you went to look at the code BTW, great initiative), the context does not do any clear because, as you can see in the doc of GraphicsContext::setClearMask() : Set the clear mask used in glClear(). Defaults to 0 - so no clear is done by default by the GraphicsContext, instead the Camera's attached the GraphicsContext will do the clear. GraphicsContext::setClearMask() is useful for when the Camera's Viewports don't conver the whole context, so the context will fill in the gaps. So there you have it, a solution to your problem :-) (note, [...] the Camera's attached the GraphicsContext [...] should read [...] the Cameras attached to the GraphicsContext [...], I should probably submit that correction to Robert :-) ) Note that if you set the context's clear mask to a non-zero value, you could then set the camera's clear mask to 0. No sense in clearing the whole context, and then clearing the camera's viewport a second time... Unless you want them cleared to a different color, or to clear different parts of the buffer. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Clearing window client area.
Now I understand! That makes perfect sense to me now. I tried calling GraphicContext::setClearMask(GL_COLOR_BUFFER_BIT) in my app and now it works as expected. Thanks... your the best. Guy -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35663#35663 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] transpose() and osg_NormalViewMatrix
I am submitting a code patch for possible inclusion into the OSG code repository. The patch is against the OSG trunk, as updated this morning. It's just a couple of very small changes but, from reading some old posts on the message board, I thought that the changes might be useful to other OSG users as well. The changes are: - Add a transpose() function to Matrixf and Matrixd - Add two new osg global glsl uniforms: osg_NormalViewMatrix and osg_NormalViewMatrixInverse If you prefer that I submit these changes in a different format, I'd be happy to do that as well. Thanks, Rob Index: include/osg/Matrixd === --- include/osg/Matrixd (revision 12090) +++ include/osg/Matrixd (working copy) @@ -249,6 +249,7 @@ value_type angle2, const Vec3d axis2, value_type angle3, const Vec3d axis3); inline static Matrixd rotate( const Quat quat); +inline static Matrixd transpose( const Matrixd matrix ); inline static Matrixd inverse( const Matrixd matrix); inline static Matrixd orthoNormal(const Matrixd matrix); /** Create an orthographic projection matrix. @@ -511,6 +512,17 @@ return m; } +inline Matrixd Matrixd::transpose( const Matrixd matrix ) +{ + Matrixd m; + for( int c = 0 ; c 4 ; c++ ) { +for( int r = 0 ; r 4 ; r++ ) { + m(c,r) = matrix(r,c); +} + } + return m; +} + inline Matrixd Matrixd::inverse( const Matrixd matrix) { Matrixd m; Index: include/osg/Matrixf === --- include/osg/Matrixf (revision 12090) +++ include/osg/Matrixf (working copy) @@ -249,6 +249,7 @@ value_type angle2, const Vec3d axis2, value_type angle3, const Vec3d axis3); inline static Matrixf rotate( const Quat quat); +inline static Matrixf transpose( const Matrixf matrix ); inline static Matrixf inverse( const Matrixf matrix); inline static Matrixf orthoNormal(const Matrixf matrix); @@ -623,6 +624,17 @@ return m; } +inline Matrixf Matrixf::transpose( const Matrixf matrix ) +{ + Matrixf m; + for( int c = 0 ; c 4 ; c++ ) { +for( int r = 0 ; r 4 ; r++ ) { + m(c,r) = matrix(r,c); +} + } + return m; +} + inline Matrixf Matrixf::inverse( const Matrixf matrix) { Matrixf m; Index: src/osgUtil/SceneView.cpp === --- src/osgUtil/SceneView.cpp (revision 12090) +++ src/osgUtil/SceneView.cpp (working copy) @@ -38,6 +38,15 @@ #define GL_BACK_RIGHT 0x0403 #endif +static osg::Matrix3 toNormalMatrix( const osg::Matrix mat ) +{ + osg::Matrix normVMat = osg::Matrix::orthoNormal( osg::Matrix::transpose( osg::Matrix::inverse( mat ) ) ); + osg::Matrix3 normalViewMatrix3x3( normVMat(0,0), normVMat(0,1), normVMat(0,2), +normVMat(1,0), normVMat(1,1), normVMat(1,2), +normVMat(2,0), normVMat(2,1), normVMat(2,2) ); + return normalViewMatrix3x3; +} + static const GLubyte patternVertEven[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, @@ -417,12 +426,18 @@ { osg::Uniform* uniform = _localStateSet-getOrCreateUniform(osg_ViewMatrix,osg::Uniform::FLOAT_MAT4); uniform-set(getViewMatrix()); +osg::Uniform* uniformNorm = _localStateSet-getOrCreateUniform(osg_NormalViewMatrix,osg::Uniform::FLOAT_MAT3); +uniformNorm-set(toNormalMatrix(getViewMatrix())); } if (_activeUniforms VIEW_MATRIX_INVERSE_UNIFORM) { osg::Uniform* uniform = _localStateSet-getOrCreateUniform(osg_ViewMatrixInverse,osg::Uniform::FLOAT_MAT4); -uniform-set(osg::Matrix::inverse(getViewMatrix())); +osg::Matrix inverseViewMatrix = osg::Matrix::inverse(getViewMatrix()); +uniform-set(inverseViewMatrix); +osg::Uniform* uniformNorm = _localStateSet-getOrCreateUniform(osg_NormalViewMatrixInverse,osg::Uniform::FLOAT_MAT3); +osg::Matrix3 m = toNormalMatrix(inverseViewMatrix); +uniformNorm-set(m); } } ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transpose() and osg_NormalViewMatrix
On 1/15/2011 3:43 PM, Rob Radtke wrote: - Add a transpose() function to Matrixf and Matrixd Rather than a transpose() function, I wonder if anyone else would be interested in seeing support for two different operator*() methods to handle vector/matrix multiply, namely: osg::Vec4 v; osg::Matrix m; vec4 vprime = v * m; // multiply the row vector by the row-major matrix, // as currently supported by OSG. vprime = m * v; // effectively multiply the vector by the matrix transpose. In the second case, each element of vprime would be computed as: vprime.x = dot( m.column0, v ); vprime.y = dot( m.column1, v ); vprime.z = dot( m.column2, v ); vprime.w = dot( m.column3, v ); Similarly, GLSL uses order to do essentially the same thing, however, GLSL uses column major matrices (as per OpenGL spec, math texts, etc), so the ordering is reversed, that is: vec4 vprime = m * v; // multiply column vector by column-major matrix vprime = v * m; // effectively multiply the vector by the matrix transpose. If we were to do this in OSG, it would make it a bit easier to multiply an instance of the osg::Plane class by a matrix, we could just define an operator*() for that, like we would do for Vec4. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transpose() and osg_NormalViewMatrix
Hi Paul, Rob, Rather than a transpose() function, I wonder if anyone else would be interested in seeing support for two different operator*() methods to handle vector/matrix multiply, namely: [...] Maybe I'm missing something, but aren't M*V and V*M already defined precisely to help with multiplying by a matrix or its transpose? See the code for the Matrixf and Matrixd classes, as well as this page: http://www.openscenegraph.org/projects/osg/wiki/Support/Maths/MatrixTransformations Quote which is apparently from Robert a while ago: begin quote V' = V*M and M* V are defined the first, as Don points out is the standard one you should use, and the later is just for special occasions... And the special occasion is when you'd want to do V' = V* Mtranspose where you only have M to hand and would have to do a transpose of M. This can be rewritten V' = M * V; The particular time when you'll do this would be when transforming normals and planes by the inverse transpose. This is done all the time in the cull traversal, where the inverse just happens to be the accumulated modelview matrix. This is all a bit crafty, but certainly helps remove all those extra ops in transposing. end quote J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org