2009/11/26 Jim Brooks <jimbl...@gmail.com> > This is very basic.... > > This test-code snippet is supposed to create a simple square with a > normal vector (or vectors). > After rotating it around with the trackball manipulator, the square is > never culled. > Same behavior on OSG 2.6 and 2.8. >
Culling is not enabled by default, you have to explicitly enable it. With OpenGL, normal vectors have nothing to do with culling, they are only used for lighting purposes; culling is determined by the primitive vertices and the sign of the area they give after projection to screen(ish) coordinates. > > Also, having trouble with with a dome composed of squares constructed > similarly. > No matter how the normal vectors are assigned, every square is culled > when the viewpoint is inside the dome (the opposite is needed). > Is OSG computing normal vectors after the app sets them? > No, OSG never computes normals for you. For your dome you either need to swap the vertex order, or change the culling mode: http://www.opengl.org/sdk/docs/man/xhtml/glCullFace.xml Can't recall the OSG equivalent at the mo, you'll have to look it up. > // Normal vectors. > const osg::Vec3f crossProduct = ((*vertexs)[0]) ^ ((*vertexs)[1]); > This is wrong. You are doing the crossproduct of 2 vertices, not 2 vectors. You want: osg::Vec3Array& vx = *vertexs.get(); osg::Vec3f crossProduct = (vx[2] - vx[1]) ^ (vx[1] - vx[0]); The rest looks OK though. Btw, the plural of vertex is vertices, not vertexs. -- http://www.ssTk.co.uk
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org