[osg-users] How to texture map Box/Sphere/Cone/Capsule/Cylinder

Robert Osfield robert.osfield at gmail.com
Tue Aug 8 00:41:54 PDT 2017


Hi Paul,

Only in git master and recent 3.5.x dev series does ShapeDrawable subclass
from osg::Geometry.  For older releases (3.4.0 and before) ShapeDrawable
computes the coordinates on the fly so there isn't any coords you can get
and modify.

As a general note, ShapeDrawable is a convenience class for visualizing
shapes in a very basic way, it's not a general purpose tool.

Robert.


On 7 August 2017 at 20:14, Paul Leopard <paul.leopard at gmail.com> wrote:

> 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
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170808/1a09fcf8/attachment.htm>


More information about the osg-users mailing list