Shape
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_SHAPE
#define OSG_SHAPE 1
#include <osg/Object>
#include <osg/Vec3>
#include <osg/Quat>
#include <osg/Plane>
#include <osg/Array>
namespace osg {
// forward declare visitors.
class ShapeVisitor;
class ConstShapeVisitor;
#define META_Shape(library,name) \
virtual Object* cloneType() const { return new name(); } \
virtual Object* clone(const CopyOp& copyop) const { return new name (*this,copyop); } \
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
virtual const char* libraryName() const { return #library; } \
virtual const char* className() const { return #name; } \
virtual void accept(ShapeVisitor& sv) { sv.apply(*this); } \
virtual void accept(ConstShapeVisitor& csv) const { csv.apply(*this); }
class OSG_EXPORT Shape : public Object
{
public:
Shape() {}
Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Object(sa,copyop) {}
virtual Object* cloneType() const = 0;
virtual Object* clone(const CopyOp&) const = 0;
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Shape*>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "Shape"; }
virtual void accept(ShapeVisitor&)=0;
virtual void accept(ConstShapeVisitor&) const =0;
protected:
virtual ~Shape();
};
// forward declarations of Shape types.
class Sphere;
class Box;
class Cone;
class Cylinder;
class Capsule;
class InfinitePlane;
class TriangleMesh;
class ConvexHull;
class HeightField;
class CompositeShape;
class OSG_EXPORT ShapeVisitor
{
public:
ShapeVisitor() {}
virtual ~ShapeVisitor();
virtual void apply(Shape&) {}
virtual void apply(Sphere&) {}
virtual void apply(Box&) {}
virtual void apply(Cone&) {}
virtual void apply(Cylinder&) {}
virtual void apply(Capsule&) {}
virtual void apply(InfinitePlane&) {}
virtual void apply(TriangleMesh&) {}
virtual void apply(ConvexHull&) {}
virtual void apply(HeightField&) {}
virtual void apply(CompositeShape&) {}
};
class OSG_EXPORT ConstShapeVisitor
{
public:
ConstShapeVisitor() {}
virtual ~ConstShapeVisitor();
virtual void apply(const Shape&) {}
virtual void apply(const Sphere&) {}
virtual void apply(const Box&) {}
virtual void apply(const Cone&) {}
virtual void apply(const Cylinder&) {}
virtual void apply(const Capsule&) {}
virtual void apply(const InfinitePlane&) {}
virtual void apply(const TriangleMesh&) {}
virtual void apply(const ConvexHull&) {}
virtual void apply(const HeightField&) {}
virtual void apply(const CompositeShape&) {}
};
class OSG_EXPORT Sphere : public Shape
{
public:
Sphere():
_center(0.0f,0.0f,0.0f),
_radius(1.0f) {}
Sphere(const Vec3& center,float radius):
_center(center),
_radius(radius) {}
Sphere(const Sphere& sphere,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(sphere,copyop),
_center(sphere._center),
_radius(sphere._radius) {}
META_Shape(osg, Sphere);
inline bool valid() const { return _radius>=0.0f; }
inline void set(const Vec3& center,float radius)
{
_center = center;
_radius = radius;
}
inline void setCenter(const Vec3& center) { _center = center; }
inline const Vec3& getCenter() const { return _center; }
inline void setRadius(float radius) { _radius = radius; }
inline float getRadius() const { return _radius; }
protected:
virtual ~Sphere();
Vec3 _center;
float _radius;
};
class OSG_EXPORT Box : public Shape
{
public:
Box():
_center(0.0f,0.0f,0.0f),
_halfLengths(0.5f,0.5f,0.5f) {}
Box(const Vec3& center,float width):
_center(center),
_halfLengths(width*0.5f,width*0.5f,width*0.5f) {}
Box(const Vec3& center,float lengthX,float lengthY, float lengthZ):
_center(center),
_halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {}
Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(box,copyop),
_center(box._center),
_halfLengths(box._halfLengths),
_rotation(box._rotation) {}
META_Shape(osg, Box);
inline bool valid() const { return _halfLengths.x()>=0.0f; }
inline void set(const Vec3& center,const Vec3& halfLengths)
{
_center = center;
_halfLengths = halfLengths;
}
inline void setCenter(const Vec3& center) { _center = center; }
inline const Vec3& getCenter() const { return _center; }
inline void setHalfLengths(const Vec3& halfLengths) { _halfLengths = halfLengths; }
inline const Vec3& getHalfLengths() const { return _halfLengths; }
inline void setRotation(const Quat& quat) { _rotation = quat; }
inline const Quat& getRotation() const { return _rotation; }
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
protected:
virtual ~Box();
Vec3 _center;
Vec3 _halfLengths;
Quat _rotation;
};
class OSG_EXPORT Cone : public Shape
{
public:
Cone():
_center(0.0f,0.0f,0.0f),
_radius(1.0f),
_height(1.0f) {}
Cone(const Vec3& center,float radius,float height):
_center(center),
_radius(radius),
_height(height) {}
Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(cone,copyop),
_center(cone._center),
_radius(cone._radius),
_height(cone._height),
_rotation(cone._rotation) {}
META_Shape(osg, Cone);
inline bool valid() const { return _radius>=0.0f; }
inline void set(const Vec3& center,float radius, float height)
{
_center = center;
_radius = radius;
_height = height;
}
inline void setCenter(const Vec3& center) { _center = center; }
inline const Vec3& getCenter() const { return _center; }
inline void setRadius(float radius) { _radius = radius; }
inline float getRadius() const { return _radius; }
inline void setHeight(float height) { _height = height; }
inline float getHeight() const { return _height; }
inline void setRotation(const Quat& quat) { _rotation = quat; }
inline const Quat& getRotation() const { return _rotation; }
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
inline float getBaseOffsetFactor() const { return 0.25f; }
inline float getBaseOffset() const { return -getBaseOffsetFactor()*getHeight(); }
protected:
virtual ~Cone();
Vec3 _center;
float _radius;
float _height;
Quat _rotation;
};
class OSG_EXPORT Cylinder : public Shape
{
public:
Cylinder():
_center(0.0f,0.0f,0.0f),
_radius(1.0f),
_height(1.0f) {}
Cylinder(const Vec3& center,float radius,float height):
_center(center),
_radius(radius),
_height(height) {}
Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(cylinder,copyop),
_center(cylinder._center),
_radius(cylinder._radius),
_height(cylinder._height),
_rotation(cylinder._rotation) {}
META_Shape(osg, Cylinder);
inline bool valid() const { return _radius>=0.0f; }
inline void set(const Vec3& center,float radius, float height)
{
_center = center;
_radius = radius;
_height = height;
}
inline void setCenter(const Vec3& center) { _center = center; }
inline const Vec3& getCenter() const { return _center; }
inline void setRadius(float radius) { _radius = radius; }
inline float getRadius() const { return _radius; }
inline void setHeight(float height) { _height = height; }
inline float getHeight() const { return _height; }
inline void setRotation(const Quat& quat) { _rotation = quat; }
inline const Quat& getRotation() const { return _rotation; }
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
bool zeroRotation() const { return _rotation.zeroRotation(); }
protected:
virtual ~Cylinder();
Vec3 _center;
float _radius;
float _height;
Quat _rotation;
};
class OSG_EXPORT Capsule : public Shape
{
public:
Capsule():
_center(0.0f,0.0f,0.0f),
_radius(1.0f),
_height(1.0f) {}
Capsule(const Vec3& center,float radius,float height):
_center(center),
_radius(radius),
_height(height) {}
Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(capsule,copyop),
_center(capsule._center),
_radius(capsule._radius),
_height(capsule._height),
_rotation(capsule._rotation) {}
META_Shape(osg, Capsule);
inline bool valid() const { return _radius>=0.0f; }
inline void set(const Vec3& center,float radius, float height)
{
_center = center;
_radius = radius;
_height = height;
}
inline void setCenter(const Vec3& center) { _center = center; }
inline const Vec3& getCenter() const { return _center; }
inline void setRadius(float radius) { _radius = radius; }
inline float getRadius() const { return _radius; }
inline void setHeight(float height) { _height = height; }
inline float getHeight() const { return _height; }
inline void setRotation(const Quat& quat) { _rotation = quat; }
inline const Quat& getRotation() const { return _rotation; }
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
bool zeroRotation() const { return _rotation.zeroRotation(); }
protected:
virtual ~Capsule();
Vec3 _center;
float _radius;
float _height;
Quat _rotation;
};
class OSG_EXPORT InfinitePlane : public Shape, public Plane
{
public:
InfinitePlane() {}
InfinitePlane(const InfinitePlane& plane,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(plane,copyop),
Plane(plane) {}
META_Shape(osg, InfinitePlane);
protected:
virtual ~InfinitePlane();
};
class OSG_EXPORT TriangleMesh : public Shape
{
public:
TriangleMesh() {}
TriangleMesh(const TriangleMesh& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(mesh,copyop),
_vertices(mesh._vertices),
_indices(mesh._indices) {}
META_Shape(osg, TriangleMesh);
void setVertices(Vec3Array* vertices) { _vertices = vertices; }
Vec3Array* getVertices() { return _vertices.get(); }
const Vec3Array* getVertices() const { return _vertices.get(); }
void setIndices(IndexArray* indices) { _indices = indices; }
IndexArray* getIndices() { return _indices.get(); }
const IndexArray* getIndices() const { return _indices.get(); }
protected:
virtual ~TriangleMesh();
ref_ptr<Vec3Array> _vertices;
ref_ptr<IndexArray> _indices;
};
class OSG_EXPORT ConvexHull : public TriangleMesh
{
public:
ConvexHull() {}
ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
TriangleMesh(hull,copyop) {}
META_Shape(osg, ConvexHull);
protected:
virtual ~ConvexHull();
};
class OSG_EXPORT HeightField : public Shape
{
public:
HeightField();
HeightField(const HeightField& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Shape(osg, HeightField);
typedef std::vector<float> HeightList;
void allocate(unsigned int numColumns,unsigned int numRows);
inline unsigned int getNumColumns() const { return _columns; }
inline unsigned int getNumRows() const { return _rows; }
inline void setOrigin(const Vec3& origin) { _origin = origin; }
inline const Vec3& getOrigin() const { return _origin; }
inline void setXInterval(float dx) { _dx = dx; }
inline float getXInterval() const { return _dx; }
inline void setYInterval(float dy) { _dy = dy; }
inline float getYInterval() const { return _dy; }
FloatArray* getFloatArray() { return _heights.get(); }
const FloatArray* getFloatArray() const { return _heights.get(); }
HeightList& getHeightList() { return _heights->asVector(); }
const HeightList& getHeightList() const { return _heights->asVector(); }
void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; }
float getSkirtHeight() const { return _skirtHeight; }
void setBorderWidth(unsigned int borderWidth) { _borderWidth = borderWidth; }
unsigned int getBorderWidth() const { return _borderWidth; }
inline void setRotation(const Quat& quat) { _rotation = quat; }
inline const Quat& getRotation() const { return _rotation; }
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
/* set a single height point in the height field */
inline void setHeight(unsigned int c,unsigned int r,float value)
{
(*_heights)[c+r*_columns] = value;
}
/* Get address of single height point in the height field, allows user to change. */
inline float& getHeight(unsigned int c,unsigned int r)
{
return (*_heights)[c+r*_columns];
}
/* Get value of single height point in the height field, not editable. */
inline float getHeight(unsigned int c,unsigned int r) const
{
return (*_heights)[c+r*_columns];
}
inline Vec3 getVertex(unsigned int c,unsigned int r) const
{
return Vec3(_origin.x()+getXInterval()*(float)c,
_origin.y()+getYInterval()*(float)r,
_origin.z()+(*_heights)[c+r*_columns]);
}
Vec3 getNormal(unsigned int c,unsigned int r) const;
Vec2 getHeightDelta(unsigned int c,unsigned int r) const;
protected:
virtual ~HeightField();
unsigned int _columns,_rows;
Vec3 _origin; // _origin is the min value of the X and Y coordinates.
float _dx;
float _dy;
float _skirtHeight;
unsigned int _borderWidth;
Quat _rotation;
ref_ptr<FloatArray> _heights;
};
typedef HeightField Grid;
class OSG_EXPORT CompositeShape : public Shape
{
public:
typedef std::vector< ref_ptr<Shape> > ChildList;
CompositeShape() {}
CompositeShape(const CompositeShape& cs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Shape(cs,copyop),
_children(cs._children) {}
META_Shape(osg, CompositeShape);
void setShape(Shape* shape) { _shape = shape; }
Shape* getShape() { return _shape.get(); }
const Shape* getShape() const { return _shape.get(); }
unsigned int getNumChildren() const { return static_cast<unsigned int>(_children.size()); }
Shape* getChild(unsigned int i) { return _children[i].get(); }
const Shape* getChild(unsigned int i) const { return _children[i].get(); }
void addChild(Shape* shape) { _children.push_back(shape); }
template<class T> void addChild( const ref_ptr<T>& child ) { addChild(child.get()); }
void removeChild(unsigned int i) { _children.erase(_children.begin()+i); }
unsigned int findChildNo(Shape* shape) const
{
for (unsigned int childNo=0;childNo<_children.size();++childNo)
{
if (_children[childNo]==shape) return childNo;
}
return static_cast<unsigned int>(_children.size()); // node not found.
}
protected:
virtual ~CompositeShape();
ref_ptr<Shape> _shape;
ChildList _children;
};
class TessellationHints : public Object
{
public:
TessellationHints():
_TessellationMode(USE_SHAPE_DEFAULTS),
_detailRatio(1.0f),
_targetNumFaces(100),
_createFrontFace(true),
_createBackFace(false),
_createNormals(true),
_createTextureCoords(false),
_createTop(true),
_createBody(true),
_createBottom(true) {}
TessellationHints(const TessellationHints& tess, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Object(tess,copyop),
_TessellationMode(tess._TessellationMode),
_detailRatio(tess._detailRatio),
_targetNumFaces(tess._targetNumFaces),
_createFrontFace(tess._createFrontFace),
_createBackFace(tess._createBackFace),
_createNormals(tess._createNormals),
_createTextureCoords(tess._createTextureCoords),
_createTop(tess._createTop),
_createBody(tess._createBody),
_createBottom(tess._createBottom) {}
META_Object(osg,TessellationHints);
enum TessellationMode
{
USE_SHAPE_DEFAULTS,
USE_TARGET_NUM_FACES
};
inline void setTessellationMode(TessellationMode mode) { _TessellationMode=mode; }
inline TessellationMode getTessellationMode() const { return _TessellationMode; }
inline void setDetailRatio(float ratio) { _detailRatio = ratio; }
inline float getDetailRatio() const { return _detailRatio; }
inline void setTargetNumFaces(unsigned int target) { _targetNumFaces=target; }
inline unsigned int getTargetNumFaces() const { return _targetNumFaces; }
inline void setCreateFrontFace(bool on) { _createFrontFace=on; }
inline bool getCreateFrontFace() const { return _createFrontFace; }
inline void setCreateBackFace(bool on) { _createBackFace=on; }
inline bool getCreateBackFace() const { return _createBackFace; }
inline void setCreateNormals(bool on) { _createNormals=on; }
inline bool getCreateNormals() const { return _createNormals; }
inline void setCreateTextureCoords(bool on) { _createTextureCoords=on; }
inline bool getCreateTextureCoords() const { return _createTextureCoords; }
inline void setCreateTop(bool on) { _createTop=on; }
inline bool getCreateTop() const { return _createTop; }
inline void setCreateBody(bool on) { _createBody=on; }
inline bool getCreateBody() const { return _createBody; }
inline void setCreateBottom(bool on) { _createBottom=on; }
inline bool getCreateBottom() const { return _createBottom; }
protected:
~TessellationHints() {}
TessellationMode _TessellationMode;
float _detailRatio;
unsigned int _targetNumFaces;
bool _createFrontFace;
bool _createBackFace;
bool _createNormals;
bool _createTextureCoords;
bool _createTop;
bool _createBody;
bool _createBottom;
};
// forward declare;
class Geometry;
class OSG_EXPORT BuildShapeGeometryVisitor : public ConstShapeVisitor
{
public:
BuildShapeGeometryVisitor(Geometry* geometry, const TessellationHints* hints);
virtual void apply(const Sphere&);
virtual void apply(const Box&);
virtual void apply(const Cone&);
virtual void apply(const Cylinder&);
virtual void apply(const Capsule&);
virtual void apply(const InfinitePlane&);
virtual void apply(const TriangleMesh&);
virtual void apply(const ConvexHull&);
virtual void apply(const HeightField&);
virtual void apply(const CompositeShape&);
void Normal(const Vec3f& v) { _normals->push_back(v); }
void Normal3f(float x, float y, float z) { Normal(Vec3(x,y,z)); }
void TexCoord(const Vec2f& tc) { _texcoords->push_back(tc); }
void TexCoord2f(float x, float y) { TexCoord(Vec2(x,y)); }
void Vertex(const Vec3f& v);
void Vertex3f(float x, float y, float z) { Vertex(Vec3(x,y,z)); }
void setMatrix(const Matrixd& m);
void Begin(GLenum mode);
void End();
protected:
BuildShapeGeometryVisitor& operator = (const BuildShapeGeometryVisitor&) { return *this; }
enum SphereHalf { SphereTopHalf, SphereBottomHalf };
// helpers for apply( Cylinder | Sphere | Capsule )
void drawCylinderBody(unsigned int numSegments, float radius, float height);
void drawHalfSphere(unsigned int numSegments, unsigned int numRows, float radius, SphereHalf which, float zOffset = 0.0f);
Geometry* _geometry;
const TessellationHints* _hints;
ref_ptr<Vec3Array> _vertices;
ref_ptr<Vec3Array> _normals;
ref_ptr<Vec2Array> _texcoords;
GLenum _mode;
unsigned int _start_index;
Matrixd _matrix;
Matrixd _inverse;
};
extern OSG_EXPORT Geometry* convertShapeToGeometry(const Shape& shape, const TessellationHints* hints);
extern OSG_EXPORT Geometry* convertShapeToGeometry(const Shape& shape, const TessellationHints* hints, const Vec4& color, Array::Binding colorBinding=Array::BIND_OVERALL);
}
#endif
Array
Object
Plane
Quat
Vec3
osg::Array::Binding
Binding
The scope of applicability of the values in this array.
Definition Array:130
osg::Array::BIND_OVERALL
@ BIND_OVERALL
Definition Array:133
osg::Box
Definition Shape:189
osg::Box::getHalfLengths
const Vec3 & getHalfLengths() const
Definition Shape:224
osg::Box::getCenter
const Vec3 & getCenter() const
Definition Shape:221
osg::Box::_center
Vec3 _center
Definition Shape:235
osg::Box::setCenter
void setCenter(const Vec3 &center)
Definition Shape:220
osg::Box::zeroRotation
bool zeroRotation() const
Definition Shape:229
osg::Box::Box
Box(const Box &box, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:204
osg::Box::setRotation
void setRotation(const Quat &quat)
Definition Shape:226
osg::Box::_rotation
Quat _rotation
Definition Shape:237
osg::Box::set
void set(const Vec3 &center, const Vec3 &halfLengths)
Definition Shape:214
osg::Box::getRotation
const Quat & getRotation() const
Definition Shape:227
osg::Box::Box
Box(const Vec3 &center, float lengthX, float lengthY, float lengthZ)
Definition Shape:200
osg::Box::Box
Box()
Definition Shape:192
osg::Box::Box
Box(const Vec3 &center, float width)
Definition Shape:196
osg::Box::computeRotationMatrix
Matrix computeRotationMatrix() const
Definition Shape:228
osg::Box::_halfLengths
Vec3 _halfLengths
Definition Shape:236
osg::Box::valid
bool valid() const
Definition Shape:212
osg::Box::setHalfLengths
void setHalfLengths(const Vec3 &halfLengths)
Definition Shape:223
osg::Box::META_Shape
META_Shape(osg, Box)
osg::Box::~Box
virtual ~Box()
osg::BuildShapeGeometryVisitor::_vertices
ref_ptr< Vec3Array > _vertices
Definition Shape:797
osg::BuildShapeGeometryVisitor::_inverse
Matrixd _inverse
Definition Shape:804
osg::BuildShapeGeometryVisitor::Vertex
void Vertex(const Vec3f &v)
osg::BuildShapeGeometryVisitor::_normals
ref_ptr< Vec3Array > _normals
Definition Shape:798
osg::BuildShapeGeometryVisitor::_hints
const TessellationHints * _hints
Definition Shape:795
osg::BuildShapeGeometryVisitor::Begin
void Begin(GLenum mode)
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const Sphere &)
osg::BuildShapeGeometryVisitor::SphereHalf
SphereHalf
Definition Shape:788
osg::BuildShapeGeometryVisitor::SphereBottomHalf
@ SphereBottomHalf
Definition Shape:788
osg::BuildShapeGeometryVisitor::SphereTopHalf
@ SphereTopHalf
Definition Shape:788
osg::BuildShapeGeometryVisitor::_texcoords
ref_ptr< Vec2Array > _texcoords
Definition Shape:799
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const Cone &)
osg::BuildShapeGeometryVisitor::TexCoord
void TexCoord(const Vec2f &tc)
Definition Shape:773
osg::BuildShapeGeometryVisitor::End
void End()
osg::BuildShapeGeometryVisitor::Normal3f
void Normal3f(float x, float y, float z)
Definition Shape:771
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const ConvexHull &)
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const HeightField &)
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const CompositeShape &)
osg::BuildShapeGeometryVisitor::BuildShapeGeometryVisitor
BuildShapeGeometryVisitor(Geometry *geometry, const TessellationHints *hints)
osg::BuildShapeGeometryVisitor::TexCoord2f
void TexCoord2f(float x, float y)
Definition Shape:774
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const Capsule &)
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const InfinitePlane &)
osg::BuildShapeGeometryVisitor::drawCylinderBody
void drawCylinderBody(unsigned int numSegments, float radius, float height)
osg::BuildShapeGeometryVisitor::_geometry
Geometry * _geometry
Definition Shape:794
osg::BuildShapeGeometryVisitor::Normal
void Normal(const Vec3f &v)
Definition Shape:770
osg::BuildShapeGeometryVisitor::_matrix
Matrixd _matrix
Definition Shape:803
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const Cylinder &)
osg::BuildShapeGeometryVisitor::setMatrix
void setMatrix(const Matrixd &m)
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const Box &)
osg::BuildShapeGeometryVisitor::Vertex3f
void Vertex3f(float x, float y, float z)
Definition Shape:777
osg::BuildShapeGeometryVisitor::_start_index
unsigned int _start_index
Definition Shape:802
osg::BuildShapeGeometryVisitor::apply
virtual void apply(const TriangleMesh &)
osg::BuildShapeGeometryVisitor::_mode
GLenum _mode
Definition Shape:801
osg::BuildShapeGeometryVisitor::drawHalfSphere
void drawHalfSphere(unsigned int numSegments, unsigned int numRows, float radius, SphereHalf which, float zOffset=0.0f)
osg::Capsule
Definition Shape:360
osg::Capsule::META_Shape
META_Shape(osg, Capsule)
osg::Capsule::getRotation
const Quat & getRotation() const
Definition Shape:401
osg::Capsule::setRadius
void setRadius(float radius)
Definition Shape:394
osg::Capsule::computeRotationMatrix
Matrix computeRotationMatrix() const
Definition Shape:402
osg::Capsule::setHeight
void setHeight(float height)
Definition Shape:397
osg::Capsule::zeroRotation
bool zeroRotation() const
Definition Shape:403
osg::Capsule::valid
bool valid() const
Definition Shape:382
osg::Capsule::_radius
float _radius
Definition Shape:410
osg::Capsule::~Capsule
virtual ~Capsule()
osg::Capsule::Capsule
Capsule(const Vec3 &center, float radius, float height)
Definition Shape:368
osg::Capsule::set
void set(const Vec3 &center, float radius, float height)
Definition Shape:384
osg::Capsule::_rotation
Quat _rotation
Definition Shape:412
osg::Capsule::getCenter
const Vec3 & getCenter() const
Definition Shape:392
osg::Capsule::setCenter
void setCenter(const Vec3 &center)
Definition Shape:391
osg::Capsule::getRadius
float getRadius() const
Definition Shape:395
osg::Capsule::Capsule
Capsule()
Definition Shape:363
osg::Capsule::Capsule
Capsule(const Capsule &capsule, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:373
osg::Capsule::getHeight
float getHeight() const
Definition Shape:398
osg::Capsule::_center
Vec3 _center
Definition Shape:409
osg::Capsule::setRotation
void setRotation(const Quat &quat)
Definition Shape:400
osg::Capsule::_height
float _height
Definition Shape:411
osg::CompositeShape
Definition Shape:591
osg::CompositeShape::_children
ChildList _children
Definition Shape:649
osg::CompositeShape::CompositeShape
CompositeShape()
Definition Shape:598
osg::CompositeShape::setShape
void setShape(Shape *shape)
Definition Shape:607
osg::CompositeShape::getShape
Shape * getShape()
Definition Shape:610
osg::CompositeShape::ChildList
std::vector< ref_ptr< Shape > > ChildList
Definition Shape:596
osg::CompositeShape::~CompositeShape
virtual ~CompositeShape()
osg::CompositeShape::getShape
const Shape * getShape() const
Definition Shape:613
osg::CompositeShape::findChildNo
unsigned int findChildNo(Shape *shape) const
Definition Shape:634
osg::CompositeShape::addChild
void addChild(Shape *shape)
Definition Shape:625
osg::CompositeShape::removeChild
void removeChild(unsigned int i)
Definition Shape:630
osg::CompositeShape::CompositeShape
CompositeShape(const CompositeShape &cs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:600
osg::CompositeShape::addChild
void addChild(const ref_ptr< T > &child)
Definition Shape:627
osg::CompositeShape::getChild
const Shape * getChild(unsigned int i) const
Definition Shape:622
osg::CompositeShape::META_Shape
META_Shape(osg, CompositeShape)
osg::CompositeShape::_shape
ref_ptr< Shape > _shape
Definition Shape:648
osg::CompositeShape::getNumChildren
unsigned int getNumChildren() const
Definition Shape:616
osg::CompositeShape::getChild
Shape * getChild(unsigned int i)
Definition Shape:619
osg::Cone
Definition Shape:244
osg::Cone::getHeight
float getHeight() const
Definition Shape:282
osg::Cone::_radius
float _radius
Definition Shape:297
osg::Cone::valid
bool valid() const
Definition Shape:266
osg::Cone::_center
Vec3 _center
Definition Shape:296
osg::Cone::getBaseOffset
float getBaseOffset() const
Definition Shape:290
osg::Cone::getCenter
const Vec3 & getCenter() const
Definition Shape:276
osg::Cone::_rotation
Quat _rotation
Definition Shape:300
osg::Cone::getBaseOffsetFactor
float getBaseOffsetFactor() const
Definition Shape:289
osg::Cone::~Cone
virtual ~Cone()
osg::Cone::setRadius
void setRadius(float radius)
Definition Shape:278
osg::Cone::setHeight
void setHeight(float height)
Definition Shape:281
osg::Cone::zeroRotation
bool zeroRotation() const
Definition Shape:287
osg::Cone::META_Shape
META_Shape(osg, Cone)
osg::Cone::getRotation
const Quat & getRotation() const
Definition Shape:285
osg::Cone::Cone
Cone(const Cone &cone, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:257
osg::Cone::computeRotationMatrix
Matrix computeRotationMatrix() const
Definition Shape:286
osg::Cone::_height
float _height
Definition Shape:298
osg::Cone::getRadius
float getRadius() const
Definition Shape:279
osg::Cone::set
void set(const Vec3 &center, float radius, float height)
Definition Shape:268
osg::Cone::Cone
Cone()
Definition Shape:247
osg::Cone::setRotation
void setRotation(const Quat &quat)
Definition Shape:284
osg::Cone::Cone
Cone(const Vec3 &center, float radius, float height)
Definition Shape:252
osg::Cone::setCenter
void setCenter(const Vec3 &center)
Definition Shape:275
osg::ConstShapeVisitor
Definition Shape:125
osg::ConstShapeVisitor::apply
virtual void apply(const ConvexHull &)
Definition Shape:140
osg::ConstShapeVisitor::apply
virtual void apply(const Sphere &)
Definition Shape:132
osg::ConstShapeVisitor::~ConstShapeVisitor
virtual ~ConstShapeVisitor()
osg::ConstShapeVisitor::ConstShapeVisitor
ConstShapeVisitor()
Definition Shape:128
osg::ConstShapeVisitor::apply
virtual void apply(const Cylinder &)
Definition Shape:135
osg::ConstShapeVisitor::apply
virtual void apply(const Box &)
Definition Shape:133
osg::ConstShapeVisitor::apply
virtual void apply(const HeightField &)
Definition Shape:141
osg::ConstShapeVisitor::apply
virtual void apply(const Capsule &)
Definition Shape:136
osg::ConstShapeVisitor::apply
virtual void apply(const CompositeShape &)
Definition Shape:143
osg::ConstShapeVisitor::apply
virtual void apply(const InfinitePlane &)
Definition Shape:137
osg::ConstShapeVisitor::apply
virtual void apply(const Cone &)
Definition Shape:134
osg::ConstShapeVisitor::apply
virtual void apply(const TriangleMesh &)
Definition Shape:139
osg::ConstShapeVisitor::apply
virtual void apply(const Shape &)
Definition Shape:131
osg::ConvexHull
Definition Shape:467
osg::ConvexHull::ConvexHull
ConvexHull()
Definition Shape:470
osg::ConvexHull::~ConvexHull
virtual ~ConvexHull()
osg::ConvexHull::ConvexHull
ConvexHull(const ConvexHull &hull, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:472
osg::ConvexHull::META_Shape
META_Shape(osg, ConvexHull)
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Cylinder
Definition Shape:304
osg::Cylinder::setRadius
void setRadius(float radius)
Definition Shape:338
osg::Cylinder::META_Shape
META_Shape(osg, Cylinder)
osg::Cylinder::set
void set(const Vec3 &center, float radius, float height)
Definition Shape:328
osg::Cylinder::_height
float _height
Definition Shape:355
osg::Cylinder::_center
Vec3 _center
Definition Shape:353
osg::Cylinder::_radius
float _radius
Definition Shape:354
osg::Cylinder::valid
bool valid() const
Definition Shape:326
osg::Cylinder::computeRotationMatrix
Matrix computeRotationMatrix() const
Definition Shape:346
osg::Cylinder::getHeight
float getHeight() const
Definition Shape:342
osg::Cylinder::getRotation
const Quat & getRotation() const
Definition Shape:345
osg::Cylinder::~Cylinder
virtual ~Cylinder()
osg::Cylinder::Cylinder
Cylinder()
Definition Shape:307
osg::Cylinder::setHeight
void setHeight(float height)
Definition Shape:341
osg::Cylinder::setCenter
void setCenter(const Vec3 &center)
Definition Shape:335
osg::Cylinder::setRotation
void setRotation(const Quat &quat)
Definition Shape:344
osg::Cylinder::getRadius
float getRadius() const
Definition Shape:339
osg::Cylinder::_rotation
Quat _rotation
Definition Shape:356
osg::Cylinder::Cylinder
Cylinder(const Cylinder &cylinder, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:317
osg::Cylinder::getCenter
const Vec3 & getCenter() const
Definition Shape:336
osg::Cylinder::Cylinder
Cylinder(const Vec3 &center, float radius, float height)
Definition Shape:312
osg::Cylinder::zeroRotation
bool zeroRotation() const
Definition Shape:347
osg::Geometry
Definition Geometry:31
osg::HeightField
Definition Shape:483
osg::HeightField::HeightList
std::vector< float > HeightList
Definition Shape:492
osg::HeightField::getXInterval
float getXInterval() const
Definition Shape:503
osg::HeightField::_rotation
Quat _rotation
Definition Shape:581
osg::HeightField::_origin
Vec3 _origin
Definition Shape:574
osg::HeightField::setRotation
void setRotation(const Quat &quat)
Definition Shape:534
osg::HeightField::_heights
ref_ptr< FloatArray > _heights
Definition Shape:582
osg::HeightField::_skirtHeight
float _skirtHeight
Definition Shape:578
osg::HeightField::HeightField
HeightField(const HeightField &mesh, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::HeightField::getNumRows
unsigned int getNumRows() const
Definition Shape:497
osg::HeightField::setBorderWidth
void setBorderWidth(unsigned int borderWidth)
Definition Shape:529
osg::HeightField::~HeightField
virtual ~HeightField()
osg::HeightField::setOrigin
void setOrigin(const Vec3 &origin)
Definition Shape:499
osg::HeightField::getFloatArray
const FloatArray * getFloatArray() const
Definition Shape:512
osg::HeightField::getHeight
float & getHeight(unsigned int c, unsigned int r)
Definition Shape:546
osg::HeightField::allocate
void allocate(unsigned int numColumns, unsigned int numRows)
osg::HeightField::getYInterval
float getYInterval() const
Definition Shape:506
osg::HeightField::zeroRotation
bool zeroRotation() const
Definition Shape:537
osg::HeightField::_rows
unsigned int _rows
Definition Shape:572
osg::HeightField::META_Shape
META_Shape(osg, HeightField)
osg::HeightField::_borderWidth
unsigned int _borderWidth
Definition Shape:579
osg::HeightField::setSkirtHeight
void setSkirtHeight(float skirtHeight)
Definition Shape:521
osg::HeightField::getVertex
Vec3 getVertex(unsigned int c, unsigned int r) const
Definition Shape:557
osg::HeightField::getNumColumns
unsigned int getNumColumns() const
Definition Shape:496
osg::HeightField::setYInterval
void setYInterval(float dy)
Definition Shape:505
osg::HeightField::_dx
float _dx
Definition Shape:575
osg::HeightField::HeightField
HeightField()
osg::HeightField::getHeightList
HeightList & getHeightList()
Definition Shape:514
osg::HeightField::getBorderWidth
unsigned int getBorderWidth() const
Definition Shape:532
osg::HeightField::computeRotationMatrix
Matrix computeRotationMatrix() const
Definition Shape:536
osg::HeightField::getSkirtHeight
float getSkirtHeight() const
Definition Shape:524
osg::HeightField::getHeightList
const HeightList & getHeightList() const
Definition Shape:516
osg::HeightField::getNormal
Vec3 getNormal(unsigned int c, unsigned int r) const
osg::HeightField::setHeight
void setHeight(unsigned int c, unsigned int r, float value)
Definition Shape:540
osg::HeightField::getHeightDelta
Vec2 getHeightDelta(unsigned int c, unsigned int r) const
osg::HeightField::getRotation
const Quat & getRotation() const
Definition Shape:535
osg::HeightField::_dy
float _dy
Definition Shape:576
osg::HeightField::getOrigin
const Vec3 & getOrigin() const
Definition Shape:500
osg::HeightField::getFloatArray
FloatArray * getFloatArray()
Definition Shape:509
osg::HeightField::getHeight
float getHeight(unsigned int c, unsigned int r) const
Definition Shape:552
osg::HeightField::setXInterval
void setXInterval(float dx)
Definition Shape:502
osg::HeightField::_columns
unsigned int _columns
Definition Shape:572
osg::IndexArray
Definition Array:320
osg::InfinitePlane
Definition Shape:417
osg::InfinitePlane::InfinitePlane
InfinitePlane(const InfinitePlane &plane, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:421
osg::InfinitePlane::InfinitePlane
InfinitePlane()
Definition Shape:419
osg::InfinitePlane::META_Shape
META_Shape(osg, InfinitePlane)
osg::InfinitePlane::~InfinitePlane
virtual ~InfinitePlane()
osg::Matrixd
Definition Matrixd:27
osg::Object::Object
Object()
Definition Object:69
osg::Plane::Plane
Plane()
Default constructor.
Definition Plane:58
osg::Quat
Definition Quat:30
osg::ShapeVisitor
Definition Shape:103
osg::ShapeVisitor::apply
virtual void apply(Cylinder &)
Definition Shape:113
osg::ShapeVisitor::apply
virtual void apply(Capsule &)
Definition Shape:114
osg::ShapeVisitor::ShapeVisitor
ShapeVisitor()
Definition Shape:106
osg::ShapeVisitor::apply
virtual void apply(TriangleMesh &)
Definition Shape:117
osg::ShapeVisitor::apply
virtual void apply(Cone &)
Definition Shape:112
osg::ShapeVisitor::apply
virtual void apply(CompositeShape &)
Definition Shape:121
osg::ShapeVisitor::apply
virtual void apply(InfinitePlane &)
Definition Shape:115
osg::ShapeVisitor::~ShapeVisitor
virtual ~ShapeVisitor()
osg::ShapeVisitor::apply
virtual void apply(ConvexHull &)
Definition Shape:118
osg::ShapeVisitor::apply
virtual void apply(Shape &)
Definition Shape:109
osg::ShapeVisitor::apply
virtual void apply(Sphere &)
Definition Shape:110
osg::ShapeVisitor::apply
virtual void apply(HeightField &)
Definition Shape:119
osg::ShapeVisitor::apply
virtual void apply(Box &)
Definition Shape:111
osg::Shape
Definition Shape:49
osg::Shape::libraryName
virtual const char * libraryName() const
Definition Shape:70
osg::Shape::~Shape
virtual ~Shape()
osg::Shape::accept
virtual void accept(ShapeVisitor &)=0
osg::Shape::isSameKindAs
virtual bool isSameKindAs(const Object *obj) const
Definition Shape:67
osg::Shape::Shape
Shape(const Shape &sa, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:54
osg::Shape::clone
virtual Object * clone(const CopyOp &) const =0
osg::Shape::accept
virtual void accept(ConstShapeVisitor &) const =0
osg::Shape::cloneType
virtual Object * cloneType() const =0
osg::Shape::className
virtual const char * className() const
Definition Shape:73
osg::Shape::Shape
Shape()
Definition Shape:52
osg::Sphere
Definition Shape:147
osg::Sphere::_radius
float _radius
Definition Shape:184
osg::Sphere::~Sphere
virtual ~Sphere()
osg::Sphere::valid
bool valid() const
Definition Shape:165
osg::Sphere::META_Shape
META_Shape(osg, Sphere)
osg::Sphere::getCenter
const Vec3 & getCenter() const
Definition Shape:174
osg::Sphere::_center
Vec3 _center
Definition Shape:183
osg::Sphere::getRadius
float getRadius() const
Definition Shape:177
osg::Sphere::Sphere
Sphere(const Sphere &sphere, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:158
osg::Sphere::Sphere
Sphere(const Vec3 &center, float radius)
Definition Shape:154
osg::Sphere::set
void set(const Vec3 &center, float radius)
Definition Shape:167
osg::Sphere::setRadius
void setRadius(float radius)
Definition Shape:176
osg::Sphere::setCenter
void setCenter(const Vec3 &center)
Definition Shape:173
osg::Sphere::Sphere
Sphere()
Definition Shape:150
osg::TessellationHints
Definition Shape:658
osg::TessellationHints::getTargetNumFaces
unsigned int getTargetNumFaces() const
Definition Shape:703
osg::TessellationHints::setDetailRatio
void setDetailRatio(float ratio)
Definition Shape:699
osg::TessellationHints::getCreateTop
bool getCreateTop() const
Definition Shape:718
osg::TessellationHints::getCreateBottom
bool getCreateBottom() const
Definition Shape:724
osg::TessellationHints::setCreateFrontFace
void setCreateFrontFace(bool on)
Definition Shape:705
osg::TessellationHints::setTargetNumFaces
void setTargetNumFaces(unsigned int target)
Definition Shape:702
osg::TessellationHints::setCreateTextureCoords
void setCreateTextureCoords(bool on)
Definition Shape:714
osg::TessellationHints::getCreateBody
bool getCreateBody() const
Definition Shape:721
osg::TessellationHints::TessellationHints
TessellationHints()
Definition Shape:661
osg::TessellationHints::_createTextureCoords
bool _createTextureCoords
Definition Shape:739
osg::TessellationHints::_TessellationMode
TessellationMode _TessellationMode
Definition Shape:731
osg::TessellationHints::_createTop
bool _createTop
Definition Shape:741
osg::TessellationHints::getCreateBackFace
bool getCreateBackFace() const
Definition Shape:709
osg::TessellationHints::_targetNumFaces
unsigned int _targetNumFaces
Definition Shape:734
osg::TessellationHints::setTessellationMode
void setTessellationMode(TessellationMode mode)
Definition Shape:696
osg::TessellationHints::_createBody
bool _createBody
Definition Shape:742
osg::TessellationHints::getTessellationMode
TessellationMode getTessellationMode() const
Definition Shape:697
osg::TessellationHints::~TessellationHints
~TessellationHints()
Definition Shape:728
osg::TessellationHints::TessellationHints
TessellationHints(const TessellationHints &tess, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:674
osg::TessellationHints::setCreateBody
void setCreateBody(bool on)
Definition Shape:720
osg::TessellationHints::_createBackFace
bool _createBackFace
Definition Shape:737
osg::TessellationHints::getCreateTextureCoords
bool getCreateTextureCoords() const
Definition Shape:715
osg::TessellationHints::getCreateNormals
bool getCreateNormals() const
Definition Shape:712
osg::TessellationHints::TessellationMode
TessellationMode
Definition Shape:691
osg::TessellationHints::USE_TARGET_NUM_FACES
@ USE_TARGET_NUM_FACES
Definition Shape:693
osg::TessellationHints::USE_SHAPE_DEFAULTS
@ USE_SHAPE_DEFAULTS
Definition Shape:692
osg::TessellationHints::_createBottom
bool _createBottom
Definition Shape:743
osg::TessellationHints::setCreateBackFace
void setCreateBackFace(bool on)
Definition Shape:708
osg::TessellationHints::META_Object
META_Object(osg, TessellationHints)
osg::TessellationHints::setCreateNormals
void setCreateNormals(bool on)
Definition Shape:711
osg::TessellationHints::_detailRatio
float _detailRatio
Definition Shape:733
osg::TessellationHints::setCreateTop
void setCreateTop(bool on)
Definition Shape:717
osg::TessellationHints::setCreateBottom
void setCreateBottom(bool on)
Definition Shape:723
osg::TessellationHints::getCreateFrontFace
bool getCreateFrontFace() const
Definition Shape:706
osg::TessellationHints::getDetailRatio
float getDetailRatio() const
Definition Shape:700
osg::TessellationHints::_createNormals
bool _createNormals
Definition Shape:738
osg::TessellationHints::_createFrontFace
bool _createFrontFace
Definition Shape:736
osg::TriangleMesh
Definition Shape:434
osg::TriangleMesh::setVertices
void setVertices(Vec3Array *vertices)
Definition Shape:447
osg::TriangleMesh::META_Shape
META_Shape(osg, TriangleMesh)
osg::TriangleMesh::setIndices
void setIndices(IndexArray *indices)
Definition Shape:452
osg::TriangleMesh::_vertices
ref_ptr< Vec3Array > _vertices
Definition Shape:460
osg::TriangleMesh::getIndices
const IndexArray * getIndices() const
Definition Shape:454
osg::TriangleMesh::TriangleMesh
TriangleMesh()
Definition Shape:437
osg::TriangleMesh::TriangleMesh
TriangleMesh(const TriangleMesh &mesh, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:439
osg::TriangleMesh::_indices
ref_ptr< IndexArray > _indices
Definition Shape:461
osg::TriangleMesh::getVertices
const Vec3Array * getVertices() const
Definition Shape:449
osg::TriangleMesh::~TriangleMesh
virtual ~TriangleMesh()
osg::TriangleMesh::getIndices
IndexArray * getIndices()
Definition Shape:453
osg::TriangleMesh::getVertices
Vec3Array * getVertices()
Definition Shape:448
osg::Vec2f
Definition Vec2f:29
osg::Vec3f
Definition Vec3f:29
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osg
Definition AlphaFunc:19
osg::Vec2
Vec2f Vec2
Definition Vec2:21
osg::Vec3Array
TemplateArray< Vec3, Array::Vec3ArrayType, 3, GL_FLOAT > Vec3Array
Definition Array:449
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::FloatArray
TemplateArray< GLfloat, Array::FloatArrayType, 1, GL_FLOAT > FloatArray
Definition Array:421
osg::Grid
HeightField Grid
Definition Shape:586
osg::Matrix
Matrixd Matrix
Definition Matrix:27
osg::Vec4
Vec4f Vec4
Definition Vec4:21
osg::convertShapeToGeometry
OSG_EXPORT Geometry * convertShapeToGeometry(const Shape &shape, const TessellationHints *hints)
NULL
#define NULL
Definition osg/Export:55
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39