Thank You Robert,
That "SetCreaseAngle" solves the problem, secondly and more important why
manually created object is not recognized by the PolytopeInteresctor ? Is there
any preliminary settings that I'm missing to configure?
Regards,Date: Tue, 2 Sep 2014 14:47:33 +0100
From: [email protected]
To: [email protected]
Subject: Re: [osg-users] Creating Geometry Manually
HI Sonya,
If you are using osgUtil::SmoothingVisitor you won't need to assign the normals
as the smoothing visitor will do this for. By default the smoothing visitor
will smooth edges as you have see in your picture, this is a natural
consequence of the vertices at the edges being adjacent to several triangles
each with their own orientation, but as there is only one normal per vertex is
direction is an average of all the normals that share that vertex.
In recent versions of the OSG osgUtil::SmoothingVisitor has a new feature
setCreateAngle(double angle), which.. copying and pasting the inline docs:
/// set the maximum angle, in radians, at which angle between adjacent
triangles that normals are smoothed
/// for edges that greater the shared vertices are duplicated
void setCreaseAngle(double angle) { _creaseAngle = angle; }
So just add this and set an angle such as :
osgUtil::SmoothingVisitor sv;
sv.setCreateAngle(osg::inDegrees(90.0)); // note inDegrees converts a angle
in degrees in to radians.
sv.smooth(*geometry);
Robert.
On 2 September 2014 13:53, Sonya Blade <[email protected]> wrote:
Dear All,
I'm trying to create arbitray shape by manually entering the vertices normals
and indices of object.
For this I use the following pseudo algorithm for object creation, but the
resulting shape edges are
not discernible as shown in the attached snapshot (marked with purple ellipse).
Also manually created object is not recognized by the Intersectors while the
"T" shaped object is recognized.
osg::Node * CreatObject()
{ // VERTICES osg::Vec3Array* obj_vertices = new osg::Vec3Array;
obj_vertices->push_back(osg::Vec3d(-3.0000, 4.0000, -0.0000));
...... /// NORMALS osg::Vec3d vec1, vec2, vec3;
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array; vec1[0] = 0;
vec1[1] = 0; vec1[3] =-1;
....
normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);
normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);
normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);normals->push_back(vec1);
............
// INDICES osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
geom->setVertexArray( obj_vertices ); geom->addPrimitiveSet( indices.get() );
geom->setNormalArray(normals.get());
geom->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON);
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
osgUtil::SmoothingVisitor::smooth( *geom ); osg::ref_ptr<osg::Geode>
I_object = new osg::Geode; I_object->addDrawable( geom.get() );
scene_ALL->addChild(I_object);}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org