[osg-users] Constructing normals for osg::DrawElements

Alberto Luaces aluaces at udc.es
Tue Sep 18 02:50:29 PDT 2007


Hi,

I think you can specify a normal per polygon using Geometry::setNormalBinding 
and the parameter BIND_PER_PRIMITIVE.

Alberto

El Tuesday 18 September 2007 11:15:07 Cervantes Pintor Pedro escribió:
> Hi,
>
>
> I'm constructing a geometric object by hand. The way I'm doing it, is
> vertex by vertex and then polygon by polygon.
>
> Something like:
> ---------------
> osg::Geometry *myObject = new osg::Geometry;
> osg::Vec3Array *vertex = new osg::Vec3Array;
> osg::DrawElementsUInt quads = new
> osg::DrawElementsUInt(osg::PrimitiveSet::QUADS); osg::DrawElementsUInt tris
> = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES);
>
> populateVertex (vertex);
> populateQUADS (quads);
> populateTRIS (tris);
>
> geometry->setVertexArray(vertex);
> geometry->addPrimitiveSet (quads);
> geometry->addPrimitiveSet (tris);
>
> geometry->dirtyDisplayList();
>
> ----------------
> So far this works fine but now I want to add the normals for each Quad and
> each Triangle. But I still don't understand how to add the normals array
> for them.
>
> I guess is not with geometry->setNormalArray(normals) because this will add
> only one array and i have two arrays of polygons, so i still need a way to
> specify a normal for each polygon.
>
> I haven't found an example that works like this, so if anyone can point me
> to the solution it will be very much appreciated.
>
> Thanks in advance to all answers !
> Cheers.





More information about the osg-users mailing list