[osg-users] How to texture map Box/Sphere/Cone/Capsule/Cylinder
Paul Leopard
paul.leopard at gmail.com
Mon Aug 7 12:14:19 PDT 2017
Trying to map a simple, uniform texture onto an osg::Shape instance and not finding a way to get a hold on the underlying osg::Geometry so I can call setTexCoordArray(...) on it ...
How would I do so?
example code :
osg::ref_ptr<osg::Sphere> rShape = new osg::Sphere( center, radius );
osg::ref_ptr<osg::ShapeDrawable> rDrawable = new osg::ShapeDrawable( rShape );
pGeom = rDrawable->asGeometry(); // returns NULL
rGeode->addDrawable( rDrawable );
rBaseNode->addChild( rGeode );
osg::ref_ptr<osg::Texture2D> rOSGTexture = CreateTexture( ... );
osg::Vec2 texCoords[] =
{
osg::Vec2(0,1),
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1)
};
int numTexCoords = sizeof(texCoords)/sizeof(osg::Vec2);
pGeom->setTexCoordArray(0,new osg::Vec2Array(numTexCoords,texCoords)); // NULL POINTER PASSED HERE
------------------------
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=71377#71377
More information about the osg-users
mailing list