Hi,

with OSG 2.8.2 we were able to create a cube like this and set polygon
mode to LINE. And it would show up as the outline
of a box with no diagonals in the faces.

With OSG 3.0.0 the same code produces a box that now contains diagonal
lines, as if the quads are now actually tesselated
into triangles.

Is there any compatibility flag that would allow us to get the old
behavior back?

Code snippets follow:

static osg::Geode* createCube(float fRadius,osg::Vec3 vPosition,
osg::Vec4 color)
{
    // create a cube shape
    osg::Box *bCube = new osg::Box(vPosition,fRadius);
    // create a container that makes the cube drawable
    osg::ShapeDrawable *sdCube = new osg::ShapeDrawable(bCube);
    sdCube->setColor(color);
    // create a geode object to as a container for our drawable cube object
    osg::Geode* geodeCube = new osg::Geode();
    // add our drawable cube to the geode container
    geodeCube->addDrawable(sdCube);
    return(geodeCube);
}

    if (m_wireframeCube == NULL) m_wireframeCube = createCube(1.0,
osg::Vec3(0.0, 0.0, 0.5), osg::Vec4(0.5f, 0.5f, 0.5f, 1.0f));

    //
    // Wireframe box
    //
    osg::StateSet *state2 = new osg::StateSet();
    state2->setMode( GL_LIGHTING, osg::StateAttribute::PROTECTED |
osg::StateAttribute::OFF );

    m_transform2 = new osg::MatrixTransform;
    m_transform2->setMatrix(osg::Matrix::scale(m_width, m_width,
m_height) * osg::Matrix::translate(position));

    osg::PolygonMode *polyModeObj;
    if ( !(polyModeObj = dynamic_cast< osg::PolygonMode* >(
state2->getAttribute( osg::StateAttribute::POLYGONMODE ))) ) {
        state2->setAttribute( new osg::PolygonMode(
osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE ));
    } else polyModeObj->setMode( osg::PolygonMode::FRONT_AND_BACK,
osg::PolygonMode::LINE );

    osg::LineWidth *lineWidthObj;
    if ( !(lineWidthObj = dynamic_cast< osg::LineWidth* >(
state2->getAttribute( osg::StateAttribute::LINEWIDTH ))) ) {
        state2->setAttribute( new osg::LineWidth( 2.0f ) );
    } else lineWidthObj->setWidth( 2.0f );

    m_transform2->addChild(m_wireframeCube);

    m_transform2->setStateSet(state2);
    addChild(m_transform2);
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to