27class ConstShapeVisitor;
35#define META_Shape(library,name) \
36 virtual Object* cloneType() const { return new name(); } \
37 virtual Object* clone(const CopyOp& copyop) const { return new name (*this,copyop); } \
38 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
39 virtual const char* libraryName() const { return #library; } \
40 virtual const char* className() const { return #name; } \
41 virtual void accept(ShapeVisitor& sv) { sv.apply(*this); } \
42 virtual void accept(ConstShapeVisitor& csv) const { csv.apply(*this); }
73 virtual const char*
className()
const {
return "Shape"; }
151 _center(0.0f,0.0f,0.0f),
159 Shape(sphere,copyop),
160 _center(sphere._center),
161 _radius(sphere._radius) {}
165 inline bool valid()
const {
return _radius>=0.0f; }
167 inline void set(
const Vec3& center,
float radius)
176 inline void setRadius(
float radius) { _radius = radius; }
193 _center(0.0f,0.0f,0.0f),
194 _halfLengths(0.5f,0.5f,0.5f) {}
198 _halfLengths(width*0.5f,width*0.5f,width*0.5f) {}
200 Box(
const Vec3& center,
float lengthX,
float lengthY,
float lengthZ):
202 _halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {}
206 _center(box._center),
207 _halfLengths(box._halfLengths),
208 _rotation(box._rotation) {}
212 inline bool valid()
const {
return _halfLengths.x()>=0.0f; }
217 _halfLengths = halfLengths;
248 _center(0.0f,0.0f,0.0f),
252 Cone(
const Vec3& center,
float radius,
float height):
259 _center(cone._center),
260 _radius(cone._radius),
261 _height(cone._height),
262 _rotation(cone._rotation) {}
266 inline bool valid()
const {
return _radius>=0.0f; }
268 inline void set(
const Vec3& center,
float radius,
float height)
278 inline void setRadius(
float radius) { _radius = radius; }
281 inline void setHeight(
float height) { _height = height; }
290 inline float getBaseOffset()
const {
return -getBaseOffsetFactor()*getHeight(); }
308 _center(0.0f,0.0f,0.0f),
318 Shape(cylinder,copyop),
319 _center(cylinder._center),
320 _radius(cylinder._radius),
321 _height(cylinder._height),
322 _rotation(cylinder._rotation) {}
326 inline bool valid()
const {
return _radius>=0.0f; }
328 inline void set(
const Vec3& center,
float radius,
float height)
338 inline void setRadius(
float radius) { _radius = radius; }
341 inline void setHeight(
float height) { _height = height; }
364 _center(0.0f,0.0f,0.0f),
374 Shape(capsule,copyop),
375 _center(capsule._center),
376 _radius(capsule._radius),
377 _height(capsule._height),
378 _rotation(capsule._rotation) {}
382 inline bool valid()
const {
return _radius>=0.0f; }
384 inline void set(
const Vec3& center,
float radius,
float height)
394 inline void setRadius(
float radius) { _radius = radius; }
397 inline void setHeight(
float height) { _height = height; }
441 _vertices(mesh._vertices),
442 _indices(mesh._indices) {}
494 void allocate(
unsigned int numColumns,
unsigned int numRows);
540 inline void setHeight(
unsigned int c,
unsigned int r,
float value)
542 (*_heights)[c+r*_columns] = value;
548 return (*_heights)[c+r*_columns];
552 inline float getHeight(
unsigned int c,
unsigned int r)
const
554 return (*_heights)[c+r*_columns];
559 return Vec3(_origin.x()+getXInterval()*(
float)c,
560 _origin.y()+getYInterval()*(
float)r,
561 _origin.z()+(*_heights)[c+r*_columns]);
602 _children(cs._children) {}
616 unsigned int getNumChildren()
const {
return static_cast<unsigned int>(_children.size()); }
630 void removeChild(
unsigned int i) { _children.erase(_children.begin()+i); }
636 for (
unsigned int childNo=0;childNo<_children.size();++childNo)
638 if (_children[childNo]==shape)
return childNo;
640 return static_cast<unsigned int>(_children.size());
Binding
The scope of applicability of the values in this array.
Definition Array:130
@ BIND_OVERALL
Definition Array:133
const Vec3 & getHalfLengths() const
Definition Shape:224
const Vec3 & getCenter() const
Definition Shape:221
Vec3 _center
Definition Shape:235
void setCenter(const Vec3 ¢er)
Definition Shape:220
bool zeroRotation() const
Definition Shape:229
Box(const Box &box, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:204
void setRotation(const Quat &quat)
Definition Shape:226
Quat _rotation
Definition Shape:237
void set(const Vec3 ¢er, const Vec3 &halfLengths)
Definition Shape:214
const Quat & getRotation() const
Definition Shape:227
Box(const Vec3 ¢er, float lengthX, float lengthY, float lengthZ)
Definition Shape:200
Box()
Definition Shape:192
Box(const Vec3 ¢er, float width)
Definition Shape:196
Matrix computeRotationMatrix() const
Definition Shape:228
Vec3 _halfLengths
Definition Shape:236
bool valid() const
Definition Shape:212
void setHalfLengths(const Vec3 &halfLengths)
Definition Shape:223
ref_ptr< Vec3Array > _vertices
Definition Shape:797
Matrixd _inverse
Definition Shape:804
void Vertex(const Vec3f &v)
ref_ptr< Vec3Array > _normals
Definition Shape:798
const TessellationHints * _hints
Definition Shape:795
virtual void apply(const Sphere &)
SphereHalf
Definition Shape:788
ref_ptr< Vec2Array > _texcoords
Definition Shape:799
virtual void apply(const Cone &)
void TexCoord(const Vec2f &tc)
Definition Shape:773
void Normal3f(float x, float y, float z)
Definition Shape:771
virtual void apply(const ConvexHull &)
virtual void apply(const HeightField &)
virtual void apply(const CompositeShape &)
BuildShapeGeometryVisitor(Geometry *geometry, const TessellationHints *hints)
void TexCoord2f(float x, float y)
Definition Shape:774
virtual void apply(const Capsule &)
virtual void apply(const InfinitePlane &)
void drawCylinderBody(unsigned int numSegments, float radius, float height)
Geometry * _geometry
Definition Shape:794
void Normal(const Vec3f &v)
Definition Shape:770
Matrixd _matrix
Definition Shape:803
virtual void apply(const Cylinder &)
void setMatrix(const Matrixd &m)
virtual void apply(const Box &)
void Vertex3f(float x, float y, float z)
Definition Shape:777
unsigned int _start_index
Definition Shape:802
virtual void apply(const TriangleMesh &)
GLenum _mode
Definition Shape:801
void drawHalfSphere(unsigned int numSegments, unsigned int numRows, float radius, SphereHalf which, float zOffset=0.0f)
const Quat & getRotation() const
Definition Shape:401
void setRadius(float radius)
Definition Shape:394
Matrix computeRotationMatrix() const
Definition Shape:402
void setHeight(float height)
Definition Shape:397
bool zeroRotation() const
Definition Shape:403
bool valid() const
Definition Shape:382
float _radius
Definition Shape:410
Capsule(const Vec3 ¢er, float radius, float height)
Definition Shape:368
void set(const Vec3 ¢er, float radius, float height)
Definition Shape:384
Quat _rotation
Definition Shape:412
const Vec3 & getCenter() const
Definition Shape:392
void setCenter(const Vec3 ¢er)
Definition Shape:391
float getRadius() const
Definition Shape:395
Capsule()
Definition Shape:363
Capsule(const Capsule &capsule, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:373
float getHeight() const
Definition Shape:398
Vec3 _center
Definition Shape:409
void setRotation(const Quat &quat)
Definition Shape:400
float _height
Definition Shape:411
ChildList _children
Definition Shape:649
CompositeShape()
Definition Shape:598
void setShape(Shape *shape)
Definition Shape:607
Shape * getShape()
Definition Shape:610
std::vector< ref_ptr< Shape > > ChildList
Definition Shape:596
virtual ~CompositeShape()
const Shape * getShape() const
Definition Shape:613
unsigned int findChildNo(Shape *shape) const
Definition Shape:634
void addChild(Shape *shape)
Definition Shape:625
void removeChild(unsigned int i)
Definition Shape:630
CompositeShape(const CompositeShape &cs, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:600
void addChild(const ref_ptr< T > &child)
Definition Shape:627
const Shape * getChild(unsigned int i) const
Definition Shape:622
META_Shape(osg, CompositeShape)
ref_ptr< Shape > _shape
Definition Shape:648
unsigned int getNumChildren() const
Definition Shape:616
Shape * getChild(unsigned int i)
Definition Shape:619
float getHeight() const
Definition Shape:282
float _radius
Definition Shape:297
bool valid() const
Definition Shape:266
Vec3 _center
Definition Shape:296
float getBaseOffset() const
Definition Shape:290
const Vec3 & getCenter() const
Definition Shape:276
Quat _rotation
Definition Shape:300
float getBaseOffsetFactor() const
Definition Shape:289
void setRadius(float radius)
Definition Shape:278
void setHeight(float height)
Definition Shape:281
bool zeroRotation() const
Definition Shape:287
const Quat & getRotation() const
Definition Shape:285
Cone(const Cone &cone, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:257
Matrix computeRotationMatrix() const
Definition Shape:286
float _height
Definition Shape:298
float getRadius() const
Definition Shape:279
void set(const Vec3 ¢er, float radius, float height)
Definition Shape:268
Cone()
Definition Shape:247
void setRotation(const Quat &quat)
Definition Shape:284
Cone(const Vec3 ¢er, float radius, float height)
Definition Shape:252
void setCenter(const Vec3 ¢er)
Definition Shape:275
virtual void apply(const ConvexHull &)
Definition Shape:140
virtual void apply(const Sphere &)
Definition Shape:132
virtual ~ConstShapeVisitor()
ConstShapeVisitor()
Definition Shape:128
virtual void apply(const Cylinder &)
Definition Shape:135
virtual void apply(const Box &)
Definition Shape:133
virtual void apply(const HeightField &)
Definition Shape:141
virtual void apply(const Capsule &)
Definition Shape:136
virtual void apply(const CompositeShape &)
Definition Shape:143
virtual void apply(const InfinitePlane &)
Definition Shape:137
virtual void apply(const Cone &)
Definition Shape:134
virtual void apply(const TriangleMesh &)
Definition Shape:139
virtual void apply(const Shape &)
Definition Shape:131
ConvexHull()
Definition Shape:470
ConvexHull(const ConvexHull &hull, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:472
META_Shape(osg, ConvexHull)
@ SHALLOW_COPY
Definition CopyOp:47
void setRadius(float radius)
Definition Shape:338
META_Shape(osg, Cylinder)
void set(const Vec3 ¢er, float radius, float height)
Definition Shape:328
float _height
Definition Shape:355
Vec3 _center
Definition Shape:353
float _radius
Definition Shape:354
bool valid() const
Definition Shape:326
Matrix computeRotationMatrix() const
Definition Shape:346
float getHeight() const
Definition Shape:342
const Quat & getRotation() const
Definition Shape:345
Cylinder()
Definition Shape:307
void setHeight(float height)
Definition Shape:341
void setCenter(const Vec3 ¢er)
Definition Shape:335
void setRotation(const Quat &quat)
Definition Shape:344
float getRadius() const
Definition Shape:339
Quat _rotation
Definition Shape:356
Cylinder(const Cylinder &cylinder, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:317
const Vec3 & getCenter() const
Definition Shape:336
Cylinder(const Vec3 ¢er, float radius, float height)
Definition Shape:312
bool zeroRotation() const
Definition Shape:347
std::vector< float > HeightList
Definition Shape:492
float getXInterval() const
Definition Shape:503
Quat _rotation
Definition Shape:581
Vec3 _origin
Definition Shape:574
void setRotation(const Quat &quat)
Definition Shape:534
ref_ptr< FloatArray > _heights
Definition Shape:582
float _skirtHeight
Definition Shape:578
HeightField(const HeightField &mesh, const CopyOp ©op=CopyOp::SHALLOW_COPY)
unsigned int getNumRows() const
Definition Shape:497
void setBorderWidth(unsigned int borderWidth)
Definition Shape:529
void setOrigin(const Vec3 &origin)
Definition Shape:499
const FloatArray * getFloatArray() const
Definition Shape:512
float & getHeight(unsigned int c, unsigned int r)
Definition Shape:546
void allocate(unsigned int numColumns, unsigned int numRows)
float getYInterval() const
Definition Shape:506
bool zeroRotation() const
Definition Shape:537
META_Shape(osg, HeightField)
unsigned int _borderWidth
Definition Shape:579
void setSkirtHeight(float skirtHeight)
Definition Shape:521
Vec3 getVertex(unsigned int c, unsigned int r) const
Definition Shape:557
unsigned int getNumColumns() const
Definition Shape:496
void setYInterval(float dy)
Definition Shape:505
float _dx
Definition Shape:575
HeightList & getHeightList()
Definition Shape:514
unsigned int getBorderWidth() const
Definition Shape:532
Matrix computeRotationMatrix() const
Definition Shape:536
float getSkirtHeight() const
Definition Shape:524
const HeightList & getHeightList() const
Definition Shape:516
Vec3 getNormal(unsigned int c, unsigned int r) const
void setHeight(unsigned int c, unsigned int r, float value)
Definition Shape:540
Vec2 getHeightDelta(unsigned int c, unsigned int r) const
const Quat & getRotation() const
Definition Shape:535
float _dy
Definition Shape:576
const Vec3 & getOrigin() const
Definition Shape:500
FloatArray * getFloatArray()
Definition Shape:509
float getHeight(unsigned int c, unsigned int r) const
Definition Shape:552
void setXInterval(float dx)
Definition Shape:502
unsigned int _columns
Definition Shape:572
InfinitePlane(const InfinitePlane &plane, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:421
InfinitePlane()
Definition Shape:419
META_Shape(osg, InfinitePlane)
A plane class. It can be used to represent an infinite plane.
Definition Plane:34
virtual void apply(Cylinder &)
Definition Shape:113
virtual void apply(Capsule &)
Definition Shape:114
ShapeVisitor()
Definition Shape:106
virtual void apply(TriangleMesh &)
Definition Shape:117
virtual void apply(Cone &)
Definition Shape:112
virtual void apply(CompositeShape &)
Definition Shape:121
virtual void apply(InfinitePlane &)
Definition Shape:115
virtual void apply(ConvexHull &)
Definition Shape:118
virtual void apply(Shape &)
Definition Shape:109
virtual void apply(Sphere &)
Definition Shape:110
virtual void apply(HeightField &)
Definition Shape:119
virtual void apply(Box &)
Definition Shape:111
virtual const char * libraryName() const
Definition Shape:70
virtual void accept(ShapeVisitor &)=0
virtual bool isSameKindAs(const Object *obj) const
Definition Shape:67
Shape(const Shape &sa, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:54
virtual Object * clone(const CopyOp &) const =0
virtual void accept(ConstShapeVisitor &) const =0
virtual Object * cloneType() const =0
virtual const char * className() const
Definition Shape:73
Shape()
Definition Shape:52
float _radius
Definition Shape:184
bool valid() const
Definition Shape:165
const Vec3 & getCenter() const
Definition Shape:174
Vec3 _center
Definition Shape:183
float getRadius() const
Definition Shape:177
Sphere(const Sphere &sphere, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:158
Sphere(const Vec3 ¢er, float radius)
Definition Shape:154
void set(const Vec3 ¢er, float radius)
Definition Shape:167
void setRadius(float radius)
Definition Shape:176
void setCenter(const Vec3 ¢er)
Definition Shape:173
Sphere()
Definition Shape:150
A concrete array holding elements of type T.
Definition Array:243
unsigned int getTargetNumFaces() const
Definition Shape:703
void setDetailRatio(float ratio)
Definition Shape:699
bool getCreateTop() const
Definition Shape:718
bool getCreateBottom() const
Definition Shape:724
void setCreateFrontFace(bool on)
Definition Shape:705
void setTargetNumFaces(unsigned int target)
Definition Shape:702
void setCreateTextureCoords(bool on)
Definition Shape:714
bool getCreateBody() const
Definition Shape:721
TessellationHints()
Definition Shape:661
bool _createTextureCoords
Definition Shape:739
TessellationMode _TessellationMode
Definition Shape:731
bool _createTop
Definition Shape:741
bool getCreateBackFace() const
Definition Shape:709
unsigned int _targetNumFaces
Definition Shape:734
void setTessellationMode(TessellationMode mode)
Definition Shape:696
bool _createBody
Definition Shape:742
TessellationMode getTessellationMode() const
Definition Shape:697
~TessellationHints()
Definition Shape:728
TessellationHints(const TessellationHints &tess, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:674
void setCreateBody(bool on)
Definition Shape:720
bool _createBackFace
Definition Shape:737
bool getCreateTextureCoords() const
Definition Shape:715
bool getCreateNormals() const
Definition Shape:712
TessellationMode
Definition Shape:691
@ USE_TARGET_NUM_FACES
Definition Shape:693
@ USE_SHAPE_DEFAULTS
Definition Shape:692
bool _createBottom
Definition Shape:743
void setCreateBackFace(bool on)
Definition Shape:708
META_Object(osg, TessellationHints)
void setCreateNormals(bool on)
Definition Shape:711
float _detailRatio
Definition Shape:733
void setCreateTop(bool on)
Definition Shape:717
void setCreateBottom(bool on)
Definition Shape:723
bool getCreateFrontFace() const
Definition Shape:706
float getDetailRatio() const
Definition Shape:700
bool _createNormals
Definition Shape:738
bool _createFrontFace
Definition Shape:736
void setVertices(Vec3Array *vertices)
Definition Shape:447
META_Shape(osg, TriangleMesh)
void setIndices(IndexArray *indices)
Definition Shape:452
ref_ptr< Vec3Array > _vertices
Definition Shape:460
const IndexArray * getIndices() const
Definition Shape:454
TriangleMesh()
Definition Shape:437
TriangleMesh(const TriangleMesh &mesh, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Definition Shape:439
ref_ptr< IndexArray > _indices
Definition Shape:461
const Vec3Array * getVertices() const
Definition Shape:449
IndexArray * getIndices()
Definition Shape:453
Vec3Array * getVertices()
Definition Shape:448
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
HeightField Grid
Definition Shape:586
OSG_EXPORT Geometry * convertShapeToGeometry(const Shape &shape, const TessellationHints *hints)
#define NULL
Definition osg/Export:55
#define OSG_EXPORT
Definition osg/Export:39