[osg-users] [osgPlugins] Updating vertices properly + pick only one Geometry object

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Sat Nov 14 12:14:41 PST 2009


Hi Bart,

> 1. My current project is developing a cloth simulation and it is working. The model consists of particles connected with springs. To visualize everything I use a Geometry object representing a triangle mesh, which I update every time step by first calling the dirtyDisplayList() function. This is not a very clean solution, but OSG is rather big and not everything has been documented,  so perhaps one of you know where I should be looking for a cleaner solution. 

Well, I don't think there's anything "cleaner" than that, but more 
efficient probably: For dynamic geometry, you should disable display 
lists and use vertex buffer objects.

> There is osgParticle and osgAnimation, though I get the impression that osgParticle has been designed for unconnected particles.

Indeed osgParticle is for unconnected particle simulations like rain, 
dust, splashes, fire, smoke...

osgAnimation is for keyframe animation, skinning, etc. Not really what 
you're looking for.

I think you're doing it right, generating the geometry yourself so you 
have good control over it. So if you use VBOs instead of display lists 
it'll be faster, and I think you'll be fine.

> 2. I want to select particles with the mouse using a pick operation and this is working now for all objects in the scene. I only need to pick the cloth's particles, but how do I let OSG only do intersection tests on the cloth's geometry? 

Set the geometry's node mask to some non-zero value A, other objects' 
node masks to some other non-zero value B which does not contain A 
(bitwise), and set your intersection visitor's traversal mask to A.

For example, set the node mask on the geometry you want pickable to 2, 
and the node mask on the other geometry to ~2 (or 4, or 8, or whatever 
does not bitwise contain 2). Then set the node mask on your intersection 
visitor to 2.

Any traversal in OSG uses node masks to know whether to continue 
traversing down the graph. The mask of the current node is bitwise-anded 
with the visitor's traversal mask, and if the result is not 0 then it 
will traverse into the node's children. So the above has two implications:

A) since your intersection visitor's node mask matches the pickable 
node's mask (bitwise) but not the unpickable nodes', it will only 
consider the pickable node in its intersection tests.

B) since the default traversal mask is 0xFFFFFFFF (i.e. all bits set), 
all nodes will still be rendered since the only way to get a bitwise-and 
value of 0 when the traversal mask is 0xFFFFFFFF would be to set the 
node mask to 0 too.

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/


More information about the osg-users mailing list