Hi Brain,

It really sounds like you models and state are messed up, you
shouldn't need to go round forcing state on to models if they are set
up correctly in the first place.  These two lines shout out problems
to me:

         ss->setMode(GL_TEXTURE_COORD_ARRAY,
osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
         ss->setMode(GL_VERTEX_ARRAY, osg::StateAttribute::OVERRIDE |
osg::StateAttribute::OFF);

osg::Geometry manages vertex arrays completely, you should never set
these manually yourselves, if you do then you'll be screwing up
osg::Geometry rendering and resulting in undefined results.

The above settings are most likely hiding as well as causing problems
in the in your osg::Geometry.  I suspect you are adding bugs in you
database attempt to fix bugs database.  As for OVERRIDE, is this is
not a topic covered in the the QuickStartGuide?

Robert.


On Nov 17, 2007 11:24 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> Hi Robert,
>
> Thanks for the tips.  One way that we have combatted this issue is to force 
> the same basic StateSet on all the models.  This works in some cases, but in 
> others it does not.  For example, we do the following stateset changes on 
> each model:
>
>         osg::StateSet* ss = Model->GetOSGNode()->getOrCreateStateSet();
>         ss->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::ON);
>         ss->setMode(GL_LIGHT0, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::ON);
>         ss->setMode(GL_LIGHT1, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
>         ss->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::ON);
>         ss->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
>         ss->setTextureMode(2, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
>         ss->setTextureMode(3, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
>         ss->setMode(GL_TEXTURE_COORD_ARRAY, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::ON);
>         ss->setMode(GL_VERTEX_ARRAY, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
>         ss->setMode( GL_CULL_FACE, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF );
>         ss->setRenderingHint( osg::StateSet::OPAQUE_BIN );
>         ss->setMode(GL_ALPHA_BITS, 8);
>         osg::AlphaFunc* alphafunc = new osg::AlphaFunc;
>         osg::BlendFunc* blendfunc = new osg::BlendFunc;
>         alphafunc->setFunction(osg::AlphaFunc::GREATER,0.08f);
>         
> blendfunc->setFunction(osg::BlendFunc::SRC_ALPHA,osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
>         ss->setAttributeAndModes(alphafunc, osg::StateAttribute::ON);
>         ss->setAttributeAndModes(blendfunc, osg::StateAttribute::OFF);
>
> I wasn't the one who decided on these values, so I don't really know if they 
> are necessary or not.  I do know that if they are removed, then our rendering 
> is worse than ever.  However, to me it seems that if the model's file is set 
> up correctly, then very little StateSet manipulation would have to occur.  Is 
> this a correct assumption?
>
> Also, there is a bit of confusion in my office as to what effects OVERRIDE 
> and PROTECTED have on a node.  It's my understanding that if OVERRIDE is used 
> on a node, then each of that node's children will be forced to use that state 
> unless they have specifically set another value for that state as being 
> PROTECTED.
>
> Thanks,
> Brian
>
>
>  On Sat Nov 17  6:26 , 'Robert Osfield' <[EMAIL PROTECTED]> sent:
>
>
> >Hi Brian,
> >
> >State leakage in the OSG normally suggests that your osg::Geometry
> >don't have tex coordinates, normals or colour arrays assigned to them
> >so they are just inheriting them from what was last sent to OpenGL, if
> >you add more models then the draw order will jump around and your ill
> >conditioned models will inherit a far wider range of state, exactly
> >what they'll inherit will change from frame to frame.
> >
> >To fix it you have to find out what models are poorly conditioned and
> >are missing required arrays - if a particular model has a problem then
> >convert this one to .osg and have a browse through it to see what
> >arrays are present and which ones are missing.
> >
> >Robert.
> >
> >On Nov 17, 2007 10:17 AM, Brian [EMAIL PROTECTED]> wrote:
> >> Hi,
> >>
> >> I have a scene in which I am rendering various models on top of a terrain 
> >> database.  Without modifying any of the model's statesets, the scene 
> >> renders horribly (textures missing from some models but not others, 
> >> polygons for some models are rendered incorrectly shooting out in all 
> >> directions, etc.)  However, if I load them separately into the viewer 
> >> application, they render perfectly fine.  Does anyone have any tips for 
> >> finding the perfect stateset so my models and terrain can render 
> >> correctly?  The models themselves are in IVE format.  I had thought that I 
> >> might be able to convert them all to the OSG format, and then I could 
> >> modify the statesets for all the models to a "standard" setting, but I 
> >> don't know if that would work or be advisable.  This route would take a 
> >> great deal of time, and I would like to avoid it if at all possible.
> >>
> >> Any help would be greatly appreciated.
> >>
> >> Thanks,
> >> Brian
> >>
> >> _______________________________________________
> >> 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
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to