Hi Nick, You post is a bit too much of jumble of different clues for me to know what might be going on.
The best I can do is pass on the fact that there was a bug fix to OSG-3.2 that addressed the fact that the Camera's StateSet was being incorrectly cleared which is now fixed, allowing the Viewer Camera StateSet to be applied as you set it. Previously the osgUtil::SceneView object that was being used to manage the rendering backend was overriding the viewer's Camera's StateSet and applying it's own defaults hiding the fact that the viewer's Camera's StateSet might have been cleared and not retaining sufficient state to render the scene appropriately. Most applications will be unaffected by this change as the View by default sets up the default Camera's StateSet by calling StateSet::setGlobalDefaults() but if your application creates it's own osg::Camera and applies this to the View then it's StateSet will be empty and not have any of the global defaults that one usually requires for rendering. The solution is to either just reuse the View's Camera rather than replace it, or to call setGlobalDefaults() to your View's Camera when you set it up. Problems caused by this change are of the form that the original application viewer setup code contained the a bug that was hidden by a bug in SceneView, when that bug was fixed the viewer setup code bug is revealed. Robert. On 18 December 2013 05:00, Nick Modly <[email protected]> wrote: > Hi, > > I have a simple scene where I create a textured quad, and then add some > simple objects to it (spheres, lines, etc). Using the ubuntu distro OSG > (3.0.0 I believe), this was working fine. When I upgraded to 3.3.0, adding > the new objects now seems to overwrite the colors in the texture - for > example, if I have an image showing on the quad, and add a green(0, 1, 0, > 1) line to the scene, the image becomes a greenscale version of itself. If > i continue to add objects of other colors, the most recently added > object/color takes precedence. > > I tracked this down to commit eb7929b85ad87316a2437da03b4bb810cded7366: > Added SceneView::Options enum enetries APPLY_GLOBAL_DEFAULTS and > CLEAR_GLOBAL_STATESET to control whether a _globalStateSet->clear() and > _globalStateSet->setGlobalDefaults() should be called. > osgViewer::Renderer doesn't use these enum settings so now no longer has a > calls StateSet::clear() or StateSet::setGlobalDefaults() on the > osg::Camera's StateSet. Previously these were being called and breaking > the ability to attached state to Camera's StateSet. > > I am inheriting CompositeViewer, so it seems to me that with the removal > of StateSet::Clear() in osgViewer, some behavior has changed that is > allowing the stateset of the texture to get overwritten when new objects > are added. Likely, there is a bug in my program that was hidden by the old > behavior. So here are some snippets. > > > Code: > > //Setting up the texture > m_texture = new osg::Texture2D(img); > m_texture->setResizeNonPowerOfTwoHint(false); > m_texture->setDataVariance(osg::Object::DYNAMIC); > m_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); > m_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); > m_texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); > m_texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); > > //setting up the quad > int w = m_quad_size.x(); > int h = m_quad_size.y(); > osg::Vec3Array* vertices = new osg::Vec3Array; > vertices->push_back( osg::Vec3(-w/2, 0, h/2) ); // front left > vertices->push_back( osg::Vec3(w/2, 0, h/2) ); // front right > vertices->push_back( osg::Vec3(w/2, 0, -h/2) ); // back right > vertices->push_back( osg::Vec3(-w/2, 0, -h/2) ); // back left > > osg::Vec2Array *texcoord = new osg::Vec2Array; > texcoord->push_back(osg::Vec2(0.0, 0.0)); > texcoord->push_back(osg::Vec2(1.0, 0.0)); > texcoord->push_back(osg::Vec2(1.0, 1.0)); > texcoord->push_back(osg::Vec2(0.0, 1.0)); > > osg::Geometry *geom = new osg::Geometry; > geom->setVertexArray(vertices); > geom->setTexCoordArray(0, texcoord); > geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4)); > > osg::Geode *geode = new osg::Geode; > geode->addDrawable(geom); > geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, > osg::StateAttribute::ON); > > //Creating a line to add > osg::ref_ptr<osg::Geode> geode = new osg::Geode; > osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry(); > osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(2); > (*vertices)[0].set(p1[0], p1[1], p1[2]); > (*vertices)[1].set(p2[0], p2[1], p2[2]); > geometry->setVertexArray(vertices); > osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array; > colors->push_back(color); > geometry->setColorArray(colors); > geometry->setColorBinding(osg::Geometry::BIND_OVERALL); > osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array; > normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f)); > geometry->setNormalArray(normals); > geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); > geometry->addPrimitiveSet(new > osg::DrawArrays(osg::PrimitiveSet::LINES,0,2)); > geometry->setUseDisplayList(false); > osg::ref_ptr<osg::StateSet> state = new osg::StateSet(); > if (no_depth_test) { > state->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); > } > state->setRenderBinDetails(100, "RenderBin"); > geode->setStateSet(state); > geode->addDrawable(geometry); > > > > > > The quad and the line are both children of an osg::Group that is set as > the osgViewer::View's scenedata. > > Thank you! > > Cheers, > Nick > Code: > > > > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=57705#57705 > > > > > > _______________________________________________ > 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

