Hello,

 I've playing aorund with some examples on the "OpenSceneGraph 3 Cookbook" by 
Wang and Quian. Specifically, with Chapter 10's "Playing with delaunay 
triangulator".

 Here is the official repository code (with one small modification -commented-)


Code:
int main(int argc, char** argv)
{
        osg::ref_ptr<osg::Vec3Array> va = new osg::Vec3Array(9);
        (*va)[0].set(-5.0f, -5.0f, 0.4f);
        (*va)[1].set(1.0f, -5.6f, 0.0f);
        (*va)[2].set(5.0f, -4.0f, -0.5f);
        (*va)[3].set(-6.2f, 0.0f, 4.2f);
        (*va)[4].set(-1.0f, -0.5f, 4.8f);
        (*va)[5].set(4.3f, 1.0f, 3.0f);
        (*va)[6].set(-4.8f, 5.4f, 0.3f);
        (*va)[7].set(0.6f, 5.1f, -0.8f);
        (*va)[8].set(5.2f, 4.5f, 0.1f);

        osg::ref_ptr<osgUtil::DelaunayTriangulator> dt = new 
osgUtil::DelaunayTriangulator;
        dt->setInputPointArray(va.get());
        dt->setOutputNormalArray(new osg::Vec3Array);
        dt->triangulate();

        osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
        geometry->setVertexArray(dt->getInputPointArray());
        geometry->setNormalArray(dt->getOutputNormalArray());
        geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); // 
original code setted osg::Geometry::BIND_PER_PRIMITIVE.
        geometry->addPrimitiveSet(dt->getTriangles());

        osg::ref_ptr<osg::Geode> geode = new osg::Geode;
        geode->addDrawable(geometry.get());

        osgViewer::Viewer viewer;
        viewer.setSceneData(geode.get());

        return viewer.run();
}



So in the book, they show the following a snapshot of the result of the example 
(attached). The image shows that the "material/color" is responsive to "depth" 
(sorry if I'm using wrong terms).

But when I compile and run the example, the result is no responsive to "depth". 
Clearly it responds to light, as the bottom looks black and when I rotate it 
the surface color begins to show. For instance, I cannot differentiate between 
the faces as is shown on the books snapshot (see attachment).

So my question is really basic. What I'm doing wrong? or what I'm missing?
Bottomline is, how can I create a basic colored material that responds to the 
default light on a osg::Viewer as shown in the book?  


Thank you!

Cheers,

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75803#75803




Attachments: 
http://forum.openscenegraph.org//files/my_result_121.jpg
http://forum.openscenegraph.org//files/forum_osg_1_466.png


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to