Thanks Jason,
true, I was using ShapeDrawables. However, I was already working on converting
the geometries to use osg::Geometry. I have not done the cylinders yet; however
I have converted the cubes, and, unfortunately the results are exactly the
same. The code used to generate the cube geometry is pretty basic. Here it is:
Code:
osg::Geometry* CCubicPore::createCubeGeometry( const osg::Vec3& halfLengths, const
osg::Vec4& color)
{
const float xMin( -halfLengths[ 0 ] );
const float xMax( halfLengths[ 0 ] );
const float yMin( -halfLengths[ 1 ] );
const float yMax( halfLengths[ 1 ] );
const float zMin( -halfLengths[ 2 ] );
const float zMax( halfLengths[ 2 ] );
osg::Geometry* cube = new osg::Geometry();
osg::ref_ptr< osg::Vec3Array> vertices = osg::ref_ptr<
osg::Vec3Array>( new osg::Vec3Array );
osg::ref_ptr< osg::Vec3Array> normals = osg::ref_ptr< osg::Vec3Array>(
new osg::Vec3Array );
osg::ref_ptr< osg::Vec4Array> colors = osg::ref_ptr< osg::Vec4Array>(
new osg::Vec4Array );
// front face
vertices->push_back( osg::Vec3(xMin,yMin,zMax) );
vertices->push_back( osg::Vec3(xMax,yMin,zMax) );
vertices->push_back( osg::Vec3(xMax,yMax,zMax) );
vertices->push_back( osg::Vec3(xMin,yMax,zMax) );
normals->push_back( osg::Vec3( 0.0, 0.0, -1.0 ) );
// back face
vertices->push_back( osg::Vec3(xMax,yMin,zMin) );
vertices->push_back( osg::Vec3(xMin,yMin,zMin) );
vertices->push_back( osg::Vec3(xMin,yMax,zMin) );
vertices->push_back( osg::Vec3(xMax,yMax,zMin) );
normals->push_back( osg::Vec3( 0.0, 0.0, 1.0 ) );
// left
vertices->push_back( osg::Vec3(xMin,yMax,zMax) );
vertices->push_back( osg::Vec3(xMin,yMax,zMin) );
vertices->push_back( osg::Vec3(xMin,yMin,zMin) );
vertices->push_back( osg::Vec3(xMin,yMin,zMax) );
normals->push_back( osg::Vec3( -1.0, 0.0, 0.0 ) );
// right
vertices->push_back( osg::Vec3(xMax,yMax,zMin) );
vertices->push_back( osg::Vec3(xMax,yMax,zMax) );
vertices->push_back( osg::Vec3(xMax,yMin,zMax) );
vertices->push_back( osg::Vec3(xMax,yMin,zMin) );
normals->push_back( osg::Vec3( 1.0, 0.0, 0.0 ) );
// bottom
vertices->push_back( osg::Vec3(xMax,yMin,zMax) );
vertices->push_back( osg::Vec3(xMin,yMin,zMax) );
vertices->push_back( osg::Vec3(xMin,yMin,zMin) );
vertices->push_back( osg::Vec3(xMax,yMin,zMin) );
normals->push_back( osg::Vec3( 0.0, -1.0, 0.0 ) );
// top
vertices->push_back( osg::Vec3(xMax,yMax,zMax) );
vertices->push_back( osg::Vec3(xMax,yMax,zMin) );
vertices->push_back( osg::Vec3(xMin,yMax,zMin) );
vertices->push_back( osg::Vec3(xMin,yMax,zMax) );
normals->push_back( osg::Vec3( 0.0, 1.0, 0.0 ) );
cube->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0,
vertices->size() ) );
cube->setVertexArray( vertices );
cube->setTexCoordArray( 0, vertices );
cube->setNormalArray( normals );
cube->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
colors->push_back( color );
cube->setColorArray( colors );
cube->setColorBinding( osg::Geometry::BIND_OVERALL );
return cube;
}
then I use osg::PositionAttitudeTransform to move the cubes to the correct
position.
Cheers,
Maurizio
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47295#47295
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org