[osg-users] second newbie question reiterated withdrawLi(UNCLASSIFIED)

Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC Shayne.Tueller at HILL.af.mil
Thu Mar 12 16:08:59 PDT 2009


Are you rendering with lighting enabled or disabled? 

I notice that along with setting the color array, you are setting a normal
array in your code below. Normally (no pun intended) you supply a normal
array if lighting is enabled...

-Shayne

-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Konkle,
Daniel T AMRDEC/Dynetics
Sent: Thursday, March 12, 2009 10:40 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] second newbie question reiterated
withdrawLi(UNCLASSIFIED)

Classification:  UNCLASSIFIED 
Caveats: NONE

If i remove the matrix transform that performs the rotation for the the
right triangle, i get the correct color on my triangle.

i don't understand why.  help.

> -----Original Message-----
> From: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-
> bounces at lists.openscenegraph.org] On Behalf Of Konkle, Daniel T
> AMRDEC/Dynetics
> Sent: Thursday, March 12, 2009 11:35 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] second newbie question reiterated
> withdrawLin(UNCLASSIFIED)
> 
> Classification:  UNCLASSIFIED
> Caveats: NONE
> 
> I thought that this code in drawLines sets the color.
> 
> The strange thing is that the first triangle that I draw is the wrong
> color and the second triangle is the correct color and they are both
> drawn from the same geode.
> 
> i'm totally confused.
> 
> >     // pass the created vertex array to the points geometry object.
> >     linesGeom->setVertexArray(vertices);
> >
> >     // set the colors as before, plus using the above
> >     osg::Vec4Array* colors = new osg::Vec4Array;
> >     colors->push_back(osg::Vec4( colorVec[colorIndex][0],
> > colorVec[colorIndex][1],
> >         colorVec[colorIndex][2], colorVec[colorIndex][3]));
> >
> >     linesGeom->setColorArray(colors);
> >     linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
> >
> 
> 
> > -----Original Message-----
> > From: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-
> > bounces at lists.openscenegraph.org] On Behalf Of Tomlinson, Gordon
> > Sent: Thursday, March 12, 2009 11:11 AM
> > To: OpenSceneGraph Users
> > Subject: Re: [osg-users] second newbie question reiterated
> > withdrawLine(UNCLASSIFIED)
> >
> > You do not show how you set the color and material on the triangles
> > If this is not specified then you will pickup what ever the last
> color
> > and/or material that was used by Opengl
> >
> >
> > Gordon
> > Product Manager 3d
> > __________________________________________________________
> > Gordon Tomlinson
> > Email  : gtomlinson @ overwatch.textron.com
> > __________________________________________________________
> >
> >
> > -----Original Message-----
> > From: osg-users-bounces at lists.openscenegraph.org
> > [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
> > Konkle,
> > Daniel T AMRDEC/Dynetics
> > Sent: Thursday, March 12, 2009 12:04 PM
> > To: OpenSceneGraph Users
> > Subject: [osg-users] second newbie question reiterated with
> > drawLine(UNCLASSIFIED)
> >
> > Classification:  UNCLASSIFIED
> > Caveats: NONE
> >
> >
> > Any insight would be welcome.
> >
> > So I'm drawing several triangles on my scene.
> >
> > here is the code that draws the first 2.
> >
> > I'm reusing the first same geode.
> >
> > The strange thing is that the 'right triangle' is a different color
> > (black)
> > than the 'left triangle' (light green)
> >
> > I'm actually drawing 2 others and they are black too.
> >
> > I need them to be green.
> >
> > Can anyone tell me what I'm doing wrong?  It makes no sense to me.
> >
> > Danny
> >
> >
> >      osg::Vec3Array* tri = new osg::Vec3Array;
> >      tri->push_back(osg::Vec3(0.0f, -0.1f, depth));
> >     tri->push_back(osg::Vec3(0.1f, 0.0f, depth));
> >     tri->push_back(osg::Vec3(0.0f, 0.1f, depth));
> >
> >      osg::ref_ptr<osg::Geode> triangle = new osg::Geode();
> >     triangle->addDrawable( drawLines( tri, 0 ) );
> >
> >      // right triangle
> >     {
> >
> >        osg::ref_ptr<osg::MatrixTransform> translate = new
> > osg::MatrixTransform;
> >        osg::Matrix tran_mat = osg::Matrix::translate(
> hud_aspect,0.0f,
> > 0.0f );
> >        translate->setMatrix( tran_mat );
> >
> >        osg::ref_ptr<osg::MatrixTransform> rotate = new
> > osg::MatrixTransform;
> >        osg::Matrix rot_mat = osg::Matrix::rotate( M_PI, 0.0f, 0.0f,
> > 1.0f);
> >        rotate->setMatrix( rot_mat );
> >
> >        camera->addChild(translate.get());
> >        translate->addChild( rotate.get() );
> >        rotate->addChild( triangle.get() );;
> >     }
> >
> >     // left triangle
> >     {
> >        osg::Matrix m;
> >        osg::ref_ptr<osg::MatrixTransform> mt = new
> > osg::MatrixTransform;
> >        m.makeTranslate( -hud_aspect, 0.0f, 0.0f );
> >        mt->setMatrix( m );
> >        camera->addChild(mt.get());
> >        mt->addChild( triangle.get() );.
> >     }
> >
> >
> > // create LINES
> > osg::Geometry * drawLines( osg::Vec3Array * vertices, int colorIndex
> )
> > {
> >     // create Geometry object to store all the vertices and lines
> > primitive.
> >     osg::Geometry* linesGeom = new osg::Geometry();
> >
> >     // pass the created vertex array to the points geometry object.
> >     linesGeom->setVertexArray(vertices);
> >
> >     // set the colors as before, plus using the above
> >     osg::Vec4Array* colors = new osg::Vec4Array;
> >     colors->push_back(osg::Vec4( colorVec[colorIndex][0],
> > colorVec[colorIndex][1],
> >         colorVec[colorIndex][2], colorVec[colorIndex][3]));
> >
> >     linesGeom->setColorArray(colors);
> >     linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
> >
> >
> >     // set the normal in the same way color.
> >     osg::Vec3Array* normals = new osg::Vec3Array;
> >     normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
> >     linesGeom->setNormalArray(normals);
> >     linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
> >
> >
> >     // This time we simply use primitive, and hardwire the number of
> > coords to use
> >     // since we know up front,
> >     //linesGeom->addPrimitiveSet(new
> > osg::DrawArrays(osg::PrimitiveSet::LINES,0,vertices->size()));
> >     linesGeom->addPrimitiveSet(new
> > osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,vertices->size()));
> >     osg::StateSet* stateset = linesGeom->getOrCreateStateSet();
> >     stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
> >     stateset->setAttribute(new
> > osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON);
> >     stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> >     stateset->setRenderBinDetails(11, "RenderBin");
> >
> >     // add the points geometry to the geode.
> >     return linesGeom;
> > }
> >
> >
> > Classification:  UNCLASSIFIED
> > Caveats: NONE
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> > openscenegraph.or
> > g
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> > openscenegraph.org
> Classification:  UNCLASSIFIED
> Caveats: NONE
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org
Classification:  UNCLASSIFIED 
Caveats: NONE

_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6028 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090312/2490e8e8/attachment-0003.bin>


More information about the osg-users mailing list