Hello Joel,

It seems apparent that I need to multiply the osg_Vertex vector in my vertex 
shader with the model matrix for that geometry (via a uniform updated every 
frame, or at least whenever the geometry is transformed).  The only function 
that I've found that may get the model matrix is getModelMatrix() in the 
IntersectionVisitor class.

You need to accumulate the matrices from the root of your graph to the drawables, and provide this to your vertex shader so it can transform your vertices.

There are many ways you could do this. One would be to subclass the osgUtil::CullVisitor class, and whenever your custom CullVisitor gets to a Transform node, instead of applying the accumulated matrix to the fixed pipeline state, it would set a Uniform so that the accumulated matrix is available to your shader. You then set an instance of your custom CullVisitor on your viewer (I think), and it will use it in the cull traversal instead of the stock CullVisitor.

There are other, perhaps less intrusive but potentially slower ways: putting callbacks on all Transform nodes, or creating another visitor that runs each frame after the update traversal, or something like that. But I think the custom CullVisitor way is the cleanest. Others (Robert?) can correct me if I'm wrong.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                    http://whitestar02.dyndns-web.com/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to