Hi Frie, osg::ShapeDrawable was never intended with this type of usage, it's just a convenience for the occasional visualization the shape primitives. osg::Geometry is the class intended for general usage in the scene graph and is designed around OpenGL fast paths so you can achieve the better performance using osg::Geometry.
The use of Transform's to place instances of geometries in the scene graph is also something that scales well, if you have perhaps a thousands instances then this will perform OK, but if you have then's of thousands then it won't scale well at all because of the CPU overhead. For a more scalable solution use vertex shaders and geometry instancing. Finally we the issue how to have individual colours for each Geometry. You can push the colour manage up in to an osg::Material and have an individual StateSet with Material assigned to each Transform/Group. This would work but would have the CPU overhead mentioned above as well as a GPU overhead with changing state. Now what solution is best will depend very much on just how many geometry instances you want to place in your scene. If it's just a few Transform+StateSet/Material would work fine. Simply having different osg::Geometry would work fine too. For simple geometries the CPU+GPU memory overhead isn't very high so duplicating them will not be an issue. If you do need lots of instances then look at using the GPU more actively, the osgforest example has a range of options of how to implement lots of instances of trees, one of these approach might suit your task. Robert. On 6 August 2014 00:17, Friederike Schneemann < [email protected]> wrote: > Hi, > > I use osg for the first time to create a low level visualization to show > the position of tracked objects in a 3D world. > > To make it memory efficient I created a tree structure with multiple > transformation matrices which are all pointing to the same Geode, which > contains the ShapeDrawables representing my object. > > I thought this makes sense, as I can get multiple instances of the objects > at different positions. So far this works very well for me. > > But now, I want to extend this by showing every object in an other color, > (currently I set the color via the setColor(..)-Function of the > ShapeDrawable, so all instances of the object have the same color). > > Is there a node type which I could add e.g. after the transformation > matrix and before pointing to the drawable, so I can change the color of > the object. > > For illustration, this is what my tree structure looks like: > > root -> MatrixTransform1 -> GEODE -> ShapeDrawable1 (setShape() & setColor) > root -> MatrixTransform1 -> GEODE -> ShapeDrawable2 (setShape() & setColor) > root -> MatrixTransform2 -> GEODE -> ShapeDrawable1 (setShape() & setColor) > root -> MatrixTransform2 -> GEODE -> ShapeDrawable2 (setShape() & setColor) > ... > > I already googled and searched the forum but couldn't find anything > related to this. > > Thank you! > > Cheers, > Frie > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=60547#60547 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

