Re: [osg-users] (no subject)

2011-12-03 Thread Sebastian Messerschmidt

Hello Michael,

I guess with instancing you mean not loading the geometry more than once.
By default, when loading a let's say openflight database OSG will load 
every external, even it has been encountered before.

There are 2 options you can try.
1, Set up a readFileCallback and cache the model yourself
2. use the osgDB caching:

osgDB::ReaderWriter::Options* opt = 
osgDB::Registry::instance()-getOptions();

if (opt == NULL)
{
opt = new osgDB::ReaderWriter::Options();
}
// setup caching
opt-setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);

also you might consider using sharing of states and textures:

osgDB::SharedStateManager::ShareMode mode = 
osgDB::SharedStateManager::SHARE_ALL;
mode = static_castosgDB::SharedStateManager::ShareMode(mode | 
osgDB::SharedStateManager::SHARE_STATESETS | 
osgDB::SharedStateManager::SHARE_TEXTURES);
osgDB::Registry::instance()-getOrCreateSharedStateManager()-setShareMode(mode); 



For a real instancing/pseudo-instancing or different methods to draw 
massive amounts of trees you might also want to take a look into the 
osgforest example.


P.S. Please provide a subject, as it might raise your chances to appear 
on the readers radar ;-)


cheers
Sebastian


Hi Everyone,
I'm trying to implement a fairly dense forested area and simply adding
in a bunch of osg::MatrixTransform nodes predictably causes the cull to
crash. I could try reorganizing the scene around an oct-tree as was
suggested by a previous discussion on this topic, but for draw
performance reasons, since each tree is the same model, I would like to
use the new draw instanced arb. I see that osgdrawinstanced has been
referenced in many similar threads, but osgdrawinstanced creates its
geometry on the fly, and in doing so can quite easily use the command
syntax for instancing. I am trying to apply the technique to a loaded
model and there is no obvious easy method.

My question is this, if I load a file using

osgDB::readNodeFile(somefile.osg);

How would I set it up for instanced drawing?

My guess is that I would need to write a node-visitor that collects all
of the geometry -  drawables and sets them up to use the instanced call
overload instead of the default. I have tried doing this, but my
implementation has gotten pretty complex, and I want to make sure there
isn't a more simple way I have overlooked.

Thank you very much for your time.

Michael A Bosse'

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Draw Instanced Help

2011-12-03 Thread Paul Martz

On 12/2/2011 8:04 PM, michael.a.bo...@l-3com.com wrote:

My question is this, if I load a file using

osgDB::readNodeFile(somefile.osg);

How would I set it up for instanced drawing?

My guess is that I would need to write a node-visitor that collects all
of the geometry -  drawables and sets them up to use the instanced call
overload instead of the default. I have tried doing this, but my
implementation has gotten pretty complex, and I want to make sure there
isn't a more simple way I have overlooked.


Yes, you'd need to write a NodeVisitor. It would have an apply(Geode) that 
iterates over each Drawable. If the Drawable is a Geometry, the code would 
further iterate over each PrimitiveSet and call setNumInstances() on each one. 
It really just boils down to a pair of nested loops. This doesn't seem 
particularly complex, so I wonder if you might be doing something different that 
is complicating things. Your description of what you're doing is pretty vague, 
so it's hard to tell.

   -Paul





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org