Hi, Michael
Your normals is not correct. With that geometry you should have normals like 
(0,0,+\-1) for top-bottom, and (0,+\-1,0) with (+\-1,0,0) for sides, i dont get 
where you got those numbers for normals.

Cheers,
Sergey.

05.06.2012, 18:09, "Michael Schanne" <michael.scha...@gmail.com>:
> Hi,
>
> I am trying to draw a shape that is basically a hollow box with a tick mark 
> on one side extending into the center (screenshot attached).  I attempted to 
> do it by drawing QUAD_STRIPS for the outer and inner faces, and QUADS for the 
> top and bottom faces.  My problem is, seams are clearly visible on the top of 
> the model where the quads join together.  At first I thought I made a mistake 
> with the normal vectors, but I double checked them and I think the math is 
> correct.  Is there a better way to accomplish what I am trying to do?
>
> Here's the code:
>
> Code:
> osg::Node* drawModel() {
>
>         osg::Geode *myGeode = new osg::Geode;
>
>         osg::Geometry *myGeom = new osg::Geometry;
>         myGeode->addDrawable(myGeom);
>
>         // VERTICES
>         osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
>
>         // sides
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.0));
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.1));
>
>         vertices->push_back( osg::Vec3(  1.0, -1.0, 0.0));
>         vertices->push_back( osg::Vec3(  1.0, -1.0, 0.1));
>
>         vertices->push_back( osg::Vec3(  1.0,  1.0, 0.0));
>         vertices->push_back( osg::Vec3(  1.0,  1.0, 0.1));
>
>         vertices->push_back( osg::Vec3( -1.0,  1.0, 0.0));
>         vertices->push_back( osg::Vec3( -1.0,  1.0, 0.1));
>
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.0));
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.1));
>
>         // top face
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.1));
>         vertices->push_back( osg::Vec3( -1.0,  1.0, 0.1));
>         vertices->push_back( osg::Vec3( -0.8,  1.0, 0.1));
>         vertices->push_back( osg::Vec3( -0.8, -1.0, 0.1));
>
>         vertices->push_back( osg::Vec3( -0.8,  0.8, 0.1));
>         vertices->push_back( osg::Vec3( -0.8,  1.0, 0.1));
>         vertices->push_back( osg::Vec3(  0.8,  1.0, 0.1));
>         vertices->push_back( osg::Vec3(  0.8,  0.8, 0.1));
>
>         vertices->push_back( osg::Vec3(  0.8,  1.0, 0.1));
>         vertices->push_back( osg::Vec3(  1.0,  1.0, 0.1));
>         vertices->push_back( osg::Vec3(  1.0, -1.0, 0.1));
>         vertices->push_back( osg::Vec3(  0.8, -1.0, 0.1));
>
>         vertices->push_back( osg::Vec3( -0.8, -1.0, 0.1));
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.8, -0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.8, -1.0, 0.1));
>
>         vertices->push_back( osg::Vec3( -0.1, -0.8, 0.1));
>         vertices->push_back( osg::Vec3( -0.1,  0.0, 0.1));
>         vertices->push_back( osg::Vec3(  0.1,  0.0, 0.1));
>         vertices->push_back( osg::Vec3(  0.1, -0.8, 0.1));
>
>         // bottom face
>         vertices->push_back( osg::Vec3( -1.0, -1.0, 0.0));
>         vertices->push_back( osg::Vec3( -1.0,  1.0, 0.0));
>         vertices->push_back( osg::Vec3( -0.8,  1.0, 0.0));
>         vertices->push_back( osg::Vec3( -0.8, -1.0, 0.0));
>
>         vertices->push_back( osg::Vec3( -0.8,  0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.8,  1.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.8,  1.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.8,  0.8, 0.0));
>
>         vertices->push_back( osg::Vec3(  0.8,  1.0, 0.0));
>         vertices->push_back( osg::Vec3(  1.0,  1.0, 0.0));
>         vertices->push_back( osg::Vec3(  1.0, -1.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.8, -1.0, 0.0));
>
>         vertices->push_back( osg::Vec3( -0.8, -1.0, 0.0));
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.0));
>         vertices->push_back( osg::Vec3(  0.8, -0.8, 0.0));
>         vertices->push_back( osg::Vec3(  0.8, -1.0, 0.0));
>
>         vertices->push_back( osg::Vec3( -0.1, -0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.1,  0.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.1,  0.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.1, -0.8, 0.0));
>
>         // inner faces
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.1));
>         vertices->push_back( osg::Vec3( -0.8,  0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.8,  0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.8,  0.8, 0.0));
>         vertices->push_back( osg::Vec3(  0.8,  0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.8, -0.8, 0.0));
>         vertices->push_back( osg::Vec3(  0.8, -0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.1, -0.8, 0.0));
>         vertices->push_back( osg::Vec3(  0.1, -0.8, 0.1));
>         vertices->push_back( osg::Vec3(  0.1,  0.0, 0.0));
>         vertices->push_back( osg::Vec3(  0.1,  0.0, 0.1));
>         vertices->push_back( osg::Vec3( -0.1,  0.0, 0.0));
>         vertices->push_back( osg::Vec3( -0.1,  0.0, 0.1));
>         vertices->push_back( osg::Vec3( -0.1, -0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.1, -0.8, 0.1));
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.0));
>         vertices->push_back( osg::Vec3( -0.8, -0.8, 0.1));
>
>         myGeom->setVertexArray(vertices);
>         myGeom->addPrimitiveSet(new osg::DrawArrays( 
> osg::PrimitiveSet::QUAD_STRIP, 0, 10 ));
>         myGeom->addPrimitiveSet(new osg::DrawArrays( 
> osg::PrimitiveSet::QUADS, 10, 40 ));
>         myGeom->addPrimitiveSet(new osg::DrawArrays( 
> osg::PrimitiveSet::QUAD_STRIP, 50, 18 ));
>
>         // NORMALS
>         osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array;
>         // sides
>         normals->push_back(osg::Vec3( -1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0,  1.0));
>         normals->push_back(osg::Vec3(  1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0, -1.0,  1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0,  1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0,  1.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0,  1.0));
>
>         // top face
>         normals->push_back(osg::Vec3( -1.0, -1.0, 1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, 2.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, 2.0));
>
>         normals->push_back(osg::Vec3(  1.0, -1.0, 1.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, 2.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, 2.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0, 1.0));
>
>         normals->push_back(osg::Vec3(  0.0,  1.0, 2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3(  1.0, -1.0, 1.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, 2.0));
>
>         normals->push_back(osg::Vec3(  0.0, -1.0, 2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, 2.0));
>
>         normals->push_back(osg::Vec3( -1.0,  1.0, 2.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, 1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, 2.0));
>
>         // bottom face
>         normals->push_back(osg::Vec3( -1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, -2.0));
>
>         normals->push_back(osg::Vec3(  1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  0.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0, -1.0));
>
>         normals->push_back(osg::Vec3(  0.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0, -1.0, -1.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, -2.0));
>
>         normals->push_back(osg::Vec3(  0.0, -1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  0.0, -1.0, -2.0));
>
>         normals->push_back(osg::Vec3( -1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0, -2.0));
>
>         // inner faces
>         normals->push_back(osg::Vec3(  1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0,  2.0));
>
>         normals->push_back(osg::Vec3(  1.0, -1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0, -1.0,  2.0));
>
>         normals->push_back(osg::Vec3( -1.0, -1.0, -2.0));
>         normals->push_back(osg::Vec3( -1.0, -1.0,  2.0));
>
>         normals->push_back(osg::Vec3( -1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0,  2.0));
>
>         normals->push_back(osg::Vec3(  1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0,  2.0));
>
>         normals->push_back(osg::Vec3(  1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0,  1.0));
>
>         normals->push_back(osg::Vec3( -1.0,  1.0, -1.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0,  1.0));
>
>         normals->push_back(osg::Vec3( -1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3( -1.0,  1.0,  2.0));
>
>         normals->push_back(osg::Vec3(  1.0,  1.0, -2.0));
>         normals->push_back(osg::Vec3(  1.0,  1.0,  2.0));
>
>         for (unsigned int i = 0; i < normals->getNumElements(); i++)
>         {
>                 (*normals)[i].normalize();
>         }
>
>         myGeom->setNormalArray(normals);
>         myGeom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
>
>         osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
>         colors->push_back( osg::Vec4(1.0, 1.0, 1.0, 1.0));
>
>         myGeom->setColorArray(colors);
>         myGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
>
>         return myGeode;
> }
>
> I also included the .osg file for reference.
>
> ...
>
> Thank you!
>
> Cheers,
> Michael
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=48052#48052
>
> Attachments:
> http://forum.openscenegraph.org//files/model_491.osg
> http://forum.openscenegraph.org//files/model_148.jpg
>
> _______________________________________________
> 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