Hi Fred You can check if issue is somehow related to bounds calculation by using setCullingActive(false) on your node or geometry.
Cheers, Sergey. 26.03.2011, 12:24, "Fred Smith" <[email protected]>: > There must be something I'm missing. > > Below is a repro of my problem. This is a modification of the > osgvertexattributes sample, from the trunk. > > Copy/paste the following code after createSimpleTestModel: > > Code: > class MyCallback : public osg::Drawable::ComputeBoundingBoxCallback > { > public: > MyCallback() {} > virtual osg::BoundingBox computeBound(const osg::Drawable& drawable) const > { > osg::BoundingBox box(0, 0, 0, 1, 0, 1); > return box; > } > }; > > osg::Node* createSimpleTestModelATTRIBS() > { > osg::Group* group = new osg::Group; > > osg::Geode* geode = new osg::Geode; > group->addChild(geode); > > osg::Geometry* geometry = new osg::Geometry; > geometry->setUseDisplayList(false); > geode->addDrawable(geometry); > > osg::Vec3Array* vertices = new osg::Vec3Array; > vertices->setName("in_vertex"); > vertices->push_back(osg::Vec3(0.0,0.0,0.0)); > vertices->push_back(osg::Vec3(0.0,0.0,1.0)); > vertices->push_back(osg::Vec3(1.0,0.0,0.0)); > vertices->push_back(osg::Vec3(1.0,0.0,1.0)); > //geometry->setVertexArray(vertices); > geometry->setVertexAttribArray(6, vertices); > geometry->setVertexAttribNormalize(6, false); > geometry->setVertexAttribBinding(6, osg::Geometry::BIND_PER_VERTEX); > > geometry->setComputeBoundingBoxCallback(new MyCallback()); > > geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4)); > > char vertexShaderSource[] = > "#version 150\n" > "in vec3 in_vertex;\n" > "uniform mat4 osg_ModelViewProjectionMatrix;\n" > "void main(void)\n" > "{\n" > " gl_Position = osg_ModelViewProjectionMatrix * vec4(in_vertex, > 1.0);\n" > "}\n"; > > char fragmentShaderSource[] = > "#version 150\n" > "out vec4 out_fragcolor;\n" > "void main(void)\n" > "{\n" > " out_fragcolor = vec4(1.0, 1.0, 0.0, 1.0);\n" > "}\n"; > > osg::Program* program = new osg::Program; > program->addShader(new osg::Shader(osg::Shader::VERTEX, > vertexShaderSource)); > program->addShader(new osg::Shader(osg::Shader::FRAGMENT, > fragmentShaderSource)); > > program->addBindAttribLocation(std::string("in_vertex"), 6); > > geometry->getOrCreateStateSet()->setAttribute(program); > > return group; > } > > Now modify main() so that it reads: > > Code: > > bool runConvertToVertexAttributes = true; // Note: true here > if (arguments.read("--simple") || arguments.read("--s")) > { > loadedModel = createSimpleTestModelATTRIBS(); // change the function > name > } > > // [...] > > if (runConvertToVertexAttributes) > { > // switch on the uniforms that track the modelview and projection > matrices > osgViewer::Viewer::Windows windows; > viewer.getWindows(windows); > for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); > itr != windows.end(); > ++itr) > { > (*itr)->getState()->setUseModelViewAndProjectionUniforms(true); > // Comment out this line (I don't think I need, so I do not use > it) > //(*itr)->getState()->setUseVertexAttributeAliasing(true); > } > } > > Result: nothing shows up. > Expected: we should see a square. > > Now uncomment the setVertexArray line when building the geometry. You will > see the square. > > Cheers, > Fred > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=37903#37903 > > _______________________________________________ > 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

