I'm using the Delaunay class to triangulate some polygonal data. I am seeing
some aberrations when using the Linux version and those issues do not show up
on the Windows version. I am using self-built 64 bit versions of OSG 3.0.1 on
each platform. A colleague is using pre-built binary 64 bit versions and gets
the same issues on Linux
Following is an example, any ideas why this is happening? Possible fixes?
Example : Create a regularly spaced grid of points (XY) with random Z values.
Use the Delaunay to create triangulated geometry. Add to a geode and save to an
IVE file
Here is the source code used, not sure it will compile but it's basically what
was used to generate these models
Code:
void CreateGrid()
{
unsigned int rows=256, cols=256;
unsigned int size = rows * cols;
std::vector<float32> grid_data( 512 * 512 );
osg::Vec3Array* points = new osg::Vec3Array(size);
double mean = 0.0, stddev=0.5;
int32_t seed=7993;
GaussianRandomSequence randgen( seed, mean, stddev );
std::generate( grid_data.begin(), grid_data.end(), randgen );
osg::Vec3 point;
unsigned index = 0;
for( unsigned i=0; i<rows; i++ )
{
point.y() = i;
for( unsigned j=0; j<cols; j++ )
{
point.x() = j;
point.z() = ftop_data[index];
(*points).at(index) = point;
++index;
}
}// end for
osg::ref_ptr<osgUtil::DelaunayTriangulator> triangulator = new
osgUtil::DelaunayTriangulator( points );
triangulator->setOutputNormalArray( new osg::Vec3Array() );
ASSERT( triangulator->triangulate( ) );
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
geometry->addPrimitiveSet( triangulator->getTriangles() );
geometry->setVertexArray( triangulator->getInputPointArray() );
geometry->setNormalArray( triangulator->getOutputNormalArray() );
geometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
geometry->setTexCoordArray( 0, new osg::Vec2Array( size ) );
osg::ref_ptr<osg::Vec4Array> rColors = new osg::Vec4Array();
osg::Vec4 color( 1, 1, 1, 1 );
rColors->push_back( color );
geometry->setColorArray( rColors );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
osg::ref_ptr<osg::Geode> surfGeode = new osg::Geode();
surfGeode->addDrawable( geometry );
osgDB::writeNodeFile( *surfGeode.get(), "surface.ive" );
}
Here is a picture of the generated surface :
[Image: http://www.3rdm.biz/files/delaunay/Surface.jpg ]
Looking at the backfaces of the model created on Linux
you can see holes :
[Image: http://www.3rdm.biz/files/delaunay/Back-Linux.jpg ]
Zoom in on the Linux model holes :
[Image: http://www.3rdm.biz/files/delaunay/Back-Linux_Zoom.jpg ]
Now look at the Windows model backfaces ... NO HOLES! :
[Image: http://www.3rdm.biz/files/delaunay/Back-Windows.jpg ]
------------------------
things are more like they are now than they have ever been before
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=57895#57895
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org