Rendering basic shapes
OSG provides an osg::ShapeDrawable
class, which inherits from the osg::Drawable
base class, to render basic geometry shapes quickly with plain parameters. An osg::ShapeDrawable
instance always includes an osg::Shape
object to indicate the specified geometry's type and properties.
The setShape()
method is usually used to allocate and set a shape. For example:
shapeDrawable->setShape( new osg::Box(osg::Vec3(1.0f, 0.0f, 0.0f), 10.0f, 10.0f, 5.0f) );
It will assign a box with a center point at (1.0, 0.0, 0.0) in its local coordinate space, width and height of 10
, and depth of 5
. Here, the class osg::Vec3
represents a three-element vector in OSG. Other predefined classes such as osg::Vec2
and osg::Vec4
will also help when defining ...
Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.