OpenSceneGraph 3.6.5
Shape
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_SHAPE
15#define OSG_SHAPE 1
16
17#include <osg/Object>
18#include <osg/Vec3>
19#include <osg/Quat>
20#include <osg/Plane>
21#include <osg/Array>
22
23namespace osg {
24
25// forward declare visitors.
26class ShapeVisitor;
27class ConstShapeVisitor;
28
29
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); }
43
48class OSG_EXPORT Shape : public Object
49{
50 public:
51
52 Shape() {}
53
54 Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
55 Object(sa,copyop) {}
56
59 virtual Object* cloneType() const = 0;
60
63 virtual Object* clone(const CopyOp&) const = 0;
64
65
67 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Shape*>(obj)!=NULL; }
68
70 virtual const char* libraryName() const { return "osg"; }
71
73 virtual const char* className() const { return "Shape"; }
74
77 virtual void accept(ShapeVisitor&)=0;
78
81 virtual void accept(ConstShapeVisitor&) const =0;
82
83 protected:
84
85 virtual ~Shape();
86};
87
88// forward declarations of Shape types.
89class Sphere;
90class Box;
91class Cone;
92class Cylinder;
93class Capsule;
94class InfinitePlane;
95
96class TriangleMesh;
97class ConvexHull;
98class HeightField;
99
100class CompositeShape;
101
103{
104 public:
105
107 virtual ~ShapeVisitor();
108
109 virtual void apply(Shape&) {}
110 virtual void apply(Sphere&) {}
111 virtual void apply(Box&) {}
112 virtual void apply(Cone&) {}
113 virtual void apply(Cylinder&) {}
114 virtual void apply(Capsule&) {}
115 virtual void apply(InfinitePlane&) {}
116
117 virtual void apply(TriangleMesh&) {}
118 virtual void apply(ConvexHull&) {}
119 virtual void apply(HeightField&) {}
120
121 virtual void apply(CompositeShape&) {}
122};
123
125{
126 public:
127
130
131 virtual void apply(const Shape&) {}
132 virtual void apply(const Sphere&) {}
133 virtual void apply(const Box&) {}
134 virtual void apply(const Cone&) {}
135 virtual void apply(const Cylinder&) {}
136 virtual void apply(const Capsule&) {}
137 virtual void apply(const InfinitePlane&) {}
138
139 virtual void apply(const TriangleMesh&) {}
140 virtual void apply(const ConvexHull&) {}
141 virtual void apply(const HeightField&) {}
142
143 virtual void apply(const CompositeShape&) {}
144};
145
146class OSG_EXPORT Sphere : public Shape
147{
148 public:
149
151 _center(0.0f,0.0f,0.0f),
152 _radius(1.0f) {}
153
154 Sphere(const Vec3& center,float radius):
155 _center(center),
156 _radius(radius) {}
157
158 Sphere(const Sphere& sphere,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
159 Shape(sphere,copyop),
160 _center(sphere._center),
161 _radius(sphere._radius) {}
162
164
165 inline bool valid() const { return _radius>=0.0f; }
166
167 inline void set(const Vec3& center,float radius)
168 {
169 _center = center;
170 _radius = radius;
171 }
172
173 inline void setCenter(const Vec3& center) { _center = center; }
174 inline const Vec3& getCenter() const { return _center; }
175
176 inline void setRadius(float radius) { _radius = radius; }
177 inline float getRadius() const { return _radius; }
178
179 protected:
180
181 virtual ~Sphere();
182
184 float _radius;
185
186};
187
188class OSG_EXPORT Box : public Shape
189{
190 public:
191
193 _center(0.0f,0.0f,0.0f),
194 _halfLengths(0.5f,0.5f,0.5f) {}
195
196 Box(const Vec3& center,float width):
197 _center(center),
198 _halfLengths(width*0.5f,width*0.5f,width*0.5f) {}
199
200 Box(const Vec3& center,float lengthX,float lengthY, float lengthZ):
201 _center(center),
202 _halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {}
203
204 Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
205 Shape(box,copyop),
206 _center(box._center),
208 _rotation(box._rotation) {}
209
211
212 inline bool valid() const { return _halfLengths.x()>=0.0f; }
213
214 inline void set(const Vec3& center,const Vec3& halfLengths)
215 {
216 _center = center;
217 _halfLengths = halfLengths;
218 }
219
220 inline void setCenter(const Vec3& center) { _center = center; }
221 inline const Vec3& getCenter() const { return _center; }
222
223 inline void setHalfLengths(const Vec3& halfLengths) { _halfLengths = halfLengths; }
224 inline const Vec3& getHalfLengths() const { return _halfLengths; }
225
226 inline void setRotation(const Quat& quat) { _rotation = quat; }
227 inline const Quat& getRotation() const { return _rotation; }
228 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
229 inline bool zeroRotation() const { return _rotation.zeroRotation(); }
230
231 protected:
232
233 virtual ~Box();
234
238
239};
240
241
242
243class OSG_EXPORT Cone : public Shape
244{
245 public:
246
248 _center(0.0f,0.0f,0.0f),
249 _radius(1.0f),
250 _height(1.0f) {}
251
252 Cone(const Vec3& center,float radius,float height):
253 _center(center),
254 _radius(radius),
255 _height(height) {}
256
257 Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
258 Shape(cone,copyop),
259 _center(cone._center),
260 _radius(cone._radius),
261 _height(cone._height),
262 _rotation(cone._rotation) {}
263
265
266 inline bool valid() const { return _radius>=0.0f; }
267
268 inline void set(const Vec3& center,float radius, float height)
269 {
270 _center = center;
271 _radius = radius;
272 _height = height;
273 }
274
275 inline void setCenter(const Vec3& center) { _center = center; }
276 inline const Vec3& getCenter() const { return _center; }
277
278 inline void setRadius(float radius) { _radius = radius; }
279 inline float getRadius() const { return _radius; }
280
281 inline void setHeight(float height) { _height = height; }
282 inline float getHeight() const { return _height; }
283
284 inline void setRotation(const Quat& quat) { _rotation = quat; }
285 inline const Quat& getRotation() const { return _rotation; }
286 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
287 inline bool zeroRotation() const { return _rotation.zeroRotation(); }
288
289 inline float getBaseOffsetFactor() const { return 0.25f; }
290 inline float getBaseOffset() const { return -getBaseOffsetFactor()*getHeight(); }
291
292 protected:
293
294 virtual ~Cone();
295
297 float _radius;
298 float _height;
299
301};
302
304{
305 public:
306
308 _center(0.0f,0.0f,0.0f),
309 _radius(1.0f),
310 _height(1.0f) {}
311
312 Cylinder(const Vec3& center,float radius,float height):
313 _center(center),
314 _radius(radius),
315 _height(height) {}
316
317 Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
318 Shape(cylinder,copyop),
319 _center(cylinder._center),
320 _radius(cylinder._radius),
321 _height(cylinder._height),
322 _rotation(cylinder._rotation) {}
323
325
326 inline bool valid() const { return _radius>=0.0f; }
327
328 inline void set(const Vec3& center,float radius, float height)
329 {
330 _center = center;
331 _radius = radius;
332 _height = height;
333 }
334
335 inline void setCenter(const Vec3& center) { _center = center; }
336 inline const Vec3& getCenter() const { return _center; }
337
338 inline void setRadius(float radius) { _radius = radius; }
339 inline float getRadius() const { return _radius; }
340
341 inline void setHeight(float height) { _height = height; }
342 inline float getHeight() const { return _height; }
343
344 inline void setRotation(const Quat& quat) { _rotation = quat; }
345 inline const Quat& getRotation() const { return _rotation; }
346 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
347 bool zeroRotation() const { return _rotation.zeroRotation(); }
348
349 protected:
350
351 virtual ~Cylinder();
352
354 float _radius;
355 float _height;
357};
358
360{
361 public:
362
364 _center(0.0f,0.0f,0.0f),
365 _radius(1.0f),
366 _height(1.0f) {}
367
368 Capsule(const Vec3& center,float radius,float height):
369 _center(center),
370 _radius(radius),
371 _height(height) {}
372
373 Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
374 Shape(capsule,copyop),
375 _center(capsule._center),
376 _radius(capsule._radius),
377 _height(capsule._height),
378 _rotation(capsule._rotation) {}
379
381
382 inline bool valid() const { return _radius>=0.0f; }
383
384 inline void set(const Vec3& center,float radius, float height)
385 {
386 _center = center;
387 _radius = radius;
388 _height = height;
389 }
390
391 inline void setCenter(const Vec3& center) { _center = center; }
392 inline const Vec3& getCenter() const { return _center; }
393
394 inline void setRadius(float radius) { _radius = radius; }
395 inline float getRadius() const { return _radius; }
396
397 inline void setHeight(float height) { _height = height; }
398 inline float getHeight() const { return _height; }
399
400 inline void setRotation(const Quat& quat) { _rotation = quat; }
401 inline const Quat& getRotation() const { return _rotation; }
402 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
403 bool zeroRotation() const { return _rotation.zeroRotation(); }
404
405 protected:
406
407 virtual ~Capsule();
408
410 float _radius;
411 float _height;
413};
414
416class OSG_EXPORT InfinitePlane : public Shape, public Plane
417{
418 public:
420
422 Shape(plane,copyop),
423 Plane(plane) {}
424
426
427 protected:
428
429 virtual ~InfinitePlane();
430};
431
434{
435 public:
436
438
440 Shape(mesh,copyop),
441 _vertices(mesh._vertices),
442 _indices(mesh._indices) {}
443
445
446
447 void setVertices(Vec3Array* vertices) { _vertices = vertices; }
448 Vec3Array* getVertices() { return _vertices.get(); }
449 const Vec3Array* getVertices() const { return _vertices.get(); }
450
451
452 void setIndices(IndexArray* indices) { _indices = indices; }
453 IndexArray* getIndices() { return _indices.get(); }
454 const IndexArray* getIndices() const { return _indices.get(); }
455
456 protected:
457
458 virtual ~TriangleMesh();
459
462
463};
464
467{
468 public:
469
471
473 TriangleMesh(hull,copyop) {}
474
476
477 protected:
478
479 virtual ~ConvexHull();
480};
481
483{
484 public:
485
487
489
491
492 typedef std::vector<float> HeightList;
493
494 void allocate(unsigned int numColumns,unsigned int numRows);
495
496 inline unsigned int getNumColumns() const { return _columns; }
497 inline unsigned int getNumRows() const { return _rows; }
498
499 inline void setOrigin(const Vec3& origin) { _origin = origin; }
500 inline const Vec3& getOrigin() const { return _origin; }
501
502 inline void setXInterval(float dx) { _dx = dx; }
503 inline float getXInterval() const { return _dx; }
504
505 inline void setYInterval(float dy) { _dy = dy; }
506 inline float getYInterval() const { return _dy; }
507
509 FloatArray* getFloatArray() { return _heights.get(); }
510
512 const FloatArray* getFloatArray() const { return _heights.get(); }
513
514 HeightList& getHeightList() { return _heights->asVector(); }
515
516 const HeightList& getHeightList() const { return _heights->asVector(); }
517
521 void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; }
522
524 float getSkirtHeight() const { return _skirtHeight; }
525
529 void setBorderWidth(unsigned int borderWidth) { _borderWidth = borderWidth; }
530
532 unsigned int getBorderWidth() const { return _borderWidth; }
533
534 inline void setRotation(const Quat& quat) { _rotation = quat; }
535 inline const Quat& getRotation() const { return _rotation; }
536 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
537 inline bool zeroRotation() const { return _rotation.zeroRotation(); }
538
539 /* set a single height point in the height field */
540 inline void setHeight(unsigned int c,unsigned int r,float value)
541 {
542 (*_heights)[c+r*_columns] = value;
543 }
544
545 /* Get address of single height point in the height field, allows user to change. */
546 inline float& getHeight(unsigned int c,unsigned int r)
547 {
548 return (*_heights)[c+r*_columns];
549 }
550
551 /* Get value of single height point in the height field, not editable. */
552 inline float getHeight(unsigned int c,unsigned int r) const
553 {
554 return (*_heights)[c+r*_columns];
555 }
556
557 inline Vec3 getVertex(unsigned int c,unsigned int r) const
558 {
559 return Vec3(_origin.x()+getXInterval()*(float)c,
560 _origin.y()+getYInterval()*(float)r,
561 _origin.z()+(*_heights)[c+r*_columns]);
562 }
563
564 Vec3 getNormal(unsigned int c,unsigned int r) const;
565
566 Vec2 getHeightDelta(unsigned int c,unsigned int r) const;
567
568 protected:
569
570 virtual ~HeightField();
571
572 unsigned int _columns,_rows;
573
574 Vec3 _origin; // _origin is the min value of the X and Y coordinates.
575 float _dx;
576 float _dy;
577
579 unsigned int _borderWidth;
580
583
584};
585
587
588
591{
592 public:
593
594
595
596 typedef std::vector< ref_ptr<Shape> > ChildList;
597
599
601 Shape(cs,copyop),
602 _children(cs._children) {}
603
605
607 void setShape(Shape* shape) { _shape = shape; }
608
610 Shape* getShape() { return _shape.get(); }
611
613 const Shape* getShape() const { return _shape.get(); }
614
616 unsigned int getNumChildren() const { return static_cast<unsigned int>(_children.size()); }
617
619 Shape* getChild(unsigned int i) { return _children[i].get(); }
620
622 const Shape* getChild(unsigned int i) const { return _children[i].get(); }
623
625 void addChild(Shape* shape) { _children.push_back(shape); }
626
627 template<class T> void addChild( const ref_ptr<T>& child ) { addChild(child.get()); }
628
630 void removeChild(unsigned int i) { _children.erase(_children.begin()+i); }
631
634 unsigned int findChildNo(Shape* shape) const
635 {
636 for (unsigned int childNo=0;childNo<_children.size();++childNo)
637 {
638 if (_children[childNo]==shape) return childNo;
639 }
640 return static_cast<unsigned int>(_children.size()); // node not found.
641
642 }
643
644 protected:
645
647
650
651};
652
653
658{
659 public:
660
663 _detailRatio(1.0f),
664 _targetNumFaces(100),
665 _createFrontFace(true),
666 _createBackFace(false),
667 _createNormals(true),
669 _createTop(true),
670 _createBody(true),
671 _createBottom(true) {}
672
673
686
688
689
695
698
699 inline void setDetailRatio(float ratio) { _detailRatio = ratio; }
700 inline float getDetailRatio() const { return _detailRatio; }
701
702 inline void setTargetNumFaces(unsigned int target) { _targetNumFaces=target; }
703 inline unsigned int getTargetNumFaces() const { return _targetNumFaces; }
704
705 inline void setCreateFrontFace(bool on) { _createFrontFace=on; }
706 inline bool getCreateFrontFace() const { return _createFrontFace; }
707
708 inline void setCreateBackFace(bool on) { _createBackFace=on; }
709 inline bool getCreateBackFace() const { return _createBackFace; }
710
711 inline void setCreateNormals(bool on) { _createNormals=on; }
712 inline bool getCreateNormals() const { return _createNormals; }
713
714 inline void setCreateTextureCoords(bool on) { _createTextureCoords=on; }
715 inline bool getCreateTextureCoords() const { return _createTextureCoords; }
716
717 inline void setCreateTop(bool on) { _createTop=on; }
718 inline bool getCreateTop() const { return _createTop; }
719
720 inline void setCreateBody(bool on) { _createBody=on; }
721 inline bool getCreateBody() const { return _createBody; }
722
723 inline void setCreateBottom(bool on) { _createBottom=on; }
724 inline bool getCreateBottom() const { return _createBottom; }
725
726 protected:
727
729
730
732
734 unsigned int _targetNumFaces;
735
740
744
745};
746
747// forward declare;
748class Geometry;
749
752{
753 public:
754
756
757 virtual void apply(const Sphere&);
758 virtual void apply(const Box&);
759 virtual void apply(const Cone&);
760 virtual void apply(const Cylinder&);
761 virtual void apply(const Capsule&);
762 virtual void apply(const InfinitePlane&);
763
764 virtual void apply(const TriangleMesh&);
765 virtual void apply(const ConvexHull&);
766 virtual void apply(const HeightField&);
767
768 virtual void apply(const CompositeShape&);
769
770 void Normal(const Vec3f& v) { _normals->push_back(v); }
771 void Normal3f(float x, float y, float z) { Normal(Vec3(x,y,z)); }
772
773 void TexCoord(const Vec2f& tc) { _texcoords->push_back(tc); }
774 void TexCoord2f(float x, float y) { TexCoord(Vec2(x,y)); }
775
776 void Vertex(const Vec3f& v);
777 void Vertex3f(float x, float y, float z) { Vertex(Vec3(x,y,z)); }
778
779 void setMatrix(const Matrixd& m);
780
781 void Begin(GLenum mode);
782 void End();
783
784protected:
785
786 BuildShapeGeometryVisitor& operator = (const BuildShapeGeometryVisitor&) { return *this; }
787
789
790 // helpers for apply( Cylinder | Sphere | Capsule )
791 void drawCylinderBody(unsigned int numSegments, float radius, float height);
792 void drawHalfSphere(unsigned int numSegments, unsigned int numRows, float radius, SphereHalf which, float zOffset = 0.0f);
793
796
800
801 GLenum _mode;
802 unsigned int _start_index;
805};
806
808
809extern OSG_EXPORT Geometry* convertShapeToGeometry(const Shape& shape, const TessellationHints* hints, const Vec4& color, Array::Binding colorBinding=Array::BIND_OVERALL);
810
811}
812
813#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec2f Vec2
Definition Vec2:21
TemplateArray< Vec3, Array::Vec3ArrayType, 3, GL_FLOAT > Vec3Array
Definition Array:449
Vec3f Vec3
Definition Vec3:21
TemplateArray< GLfloat, Array::FloatArrayType, 1, GL_FLOAT > FloatArray
Definition Array:421
HeightField Grid
Definition Shape:586
Matrixd Matrix
Definition Matrix:27
Vec4f Vec4
Definition Vec4:21
OSG_EXPORT Geometry * convertShapeToGeometry(const Shape &shape, const TessellationHints *hints)
Binding
The scope of applicability of the values in this array.
Definition Array:130
@ BIND_OVERALL
Definition Array:133
Definition Array:320
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Geometry:31
Definition Matrixd:27
Object()
Construct an object.
Definition Object:69
Plane()
Default constructor.
Definition Plane:58
A quaternion class.
Definition Quat:30
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for all shape types.
Definition Shape:49
virtual const char * libraryName() const
return the name of the attribute's library.
Definition Shape:70
virtual ~Shape()
virtual void accept(ShapeVisitor &)=0
accept a non const shape visitor which can be used on non const shape objects.
virtual bool isSameKindAs(const Object *obj) const
return true if this and obj are of the same kind of object.
Definition Shape:67
Shape(const Shape &sa, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:54
virtual Object * clone(const CopyOp &) const =0
Clone an attribute, with Object* return type.
virtual void accept(ConstShapeVisitor &) const =0
accept a const shape visitor which can be used on const shape objects.
virtual Object * cloneType() const =0
Clone the type of an attribute, with Object* return type.
virtual const char * className() const
return the name of the attribute's class type.
Definition Shape:73
Shape()
Definition Shape:52
Definition Shape:103
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 ~ShapeVisitor()
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
Definition Shape:125
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
Definition Shape:147
float _radius
Definition Shape:184
virtual ~Sphere()
bool valid() const
Definition Shape:165
META_Shape(osg, Sphere)
const Vec3 & getCenter() const
Definition Shape:174
Vec3 _center
Definition Shape:183
float getRadius() const
Definition Shape:177
Sphere(const Sphere &sphere, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:158
Sphere(const Vec3 &center, float radius)
Definition Shape:154
void set(const Vec3 &center, float radius)
Definition Shape:167
void setRadius(float radius)
Definition Shape:176
void setCenter(const Vec3 &center)
Definition Shape:173
Sphere()
Definition Shape:150
Definition Shape:189
const Vec3 & getHalfLengths() const
Definition Shape:224
const Vec3 & getCenter() const
Definition Shape:221
Vec3 _center
Definition Shape:235
void setCenter(const Vec3 &center)
Definition Shape:220
bool zeroRotation() const
Definition Shape:229
Box(const Box &box, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:204
void setRotation(const Quat &quat)
Definition Shape:226
Quat _rotation
Definition Shape:237
void set(const Vec3 &center, const Vec3 &halfLengths)
Definition Shape:214
const Quat & getRotation() const
Definition Shape:227
Box(const Vec3 &center, float lengthX, float lengthY, float lengthZ)
Definition Shape:200
Box()
Definition Shape:192
Box(const Vec3 &center, 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
META_Shape(osg, Box)
virtual ~Box()
Definition Shape:244
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
virtual ~Cone()
void setRadius(float radius)
Definition Shape:278
void setHeight(float height)
Definition Shape:281
bool zeroRotation() const
Definition Shape:287
META_Shape(osg, Cone)
const Quat & getRotation() const
Definition Shape:285
Cone(const Cone &cone, const CopyOp &copyop=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 &center, float radius, float height)
Definition Shape:268
Cone()
Definition Shape:247
void setRotation(const Quat &quat)
Definition Shape:284
Cone(const Vec3 &center, float radius, float height)
Definition Shape:252
void setCenter(const Vec3 &center)
Definition Shape:275
Definition Shape:304
void setRadius(float radius)
Definition Shape:338
META_Shape(osg, Cylinder)
void set(const Vec3 &center, 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
virtual ~Cylinder()
Cylinder()
Definition Shape:307
void setHeight(float height)
Definition Shape:341
void setCenter(const Vec3 &center)
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 &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:317
const Vec3 & getCenter() const
Definition Shape:336
Cylinder(const Vec3 &center, float radius, float height)
Definition Shape:312
bool zeroRotation() const
Definition Shape:347
Definition Shape:360
META_Shape(osg, Capsule)
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
virtual ~Capsule()
Capsule(const Vec3 &center, float radius, float height)
Definition Shape:368
void set(const Vec3 &center, float radius, float height)
Definition Shape:384
Quat _rotation
Definition Shape:412
const Vec3 & getCenter() const
Definition Shape:392
void setCenter(const Vec3 &center)
Definition Shape:391
float getRadius() const
Definition Shape:395
Capsule()
Definition Shape:363
Capsule(const Capsule &capsule, const CopyOp &copyop=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
Deprecated.
Definition Shape:417
InfinitePlane(const InfinitePlane &plane, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:421
InfinitePlane()
Definition Shape:419
META_Shape(osg, InfinitePlane)
virtual ~InfinitePlane()
Deprecated.
Definition Shape:434
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 &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:439
ref_ptr< IndexArray > _indices
Definition Shape:461
const Vec3Array * getVertices() const
Definition Shape:449
virtual ~TriangleMesh()
IndexArray * getIndices()
Definition Shape:453
Vec3Array * getVertices()
Definition Shape:448
Deprecated.
Definition Shape:467
ConvexHull()
Definition Shape:470
virtual ~ConvexHull()
ConvexHull(const ConvexHull &hull, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:472
META_Shape(osg, ConvexHull)
Definition Shape:483
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 &copyop=CopyOp::SHALLOW_COPY)
unsigned int getNumRows() const
Definition Shape:497
void setBorderWidth(unsigned int borderWidth)
Set the width in number of cells in from the edge that the height field should be rendered from.
Definition Shape:529
virtual ~HeightField()
void setOrigin(const Vec3 &origin)
Definition Shape:499
const FloatArray * getFloatArray() const
Get the const FloatArray height data.
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
unsigned int _rows
Definition Shape:572
META_Shape(osg, HeightField)
unsigned int _borderWidth
Definition Shape:579
void setSkirtHeight(float skirtHeight)
Set the height of the skirt to render around the edge of HeightField.
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
Get the width in number of cells in from the edge that the height field should be rendered from.
Definition Shape:532
Matrix computeRotationMatrix() const
Definition Shape:536
float getSkirtHeight() const
Get the height of the skirt to render around the edge of HeightField.
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()
Get the FloatArray height data.
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
Deprecated.
Definition Shape:591
ChildList _children
Definition Shape:649
CompositeShape()
Definition Shape:598
void setShape(Shape *shape)
Set the shape that encloses all of the children.
Definition Shape:607
Shape * getShape()
Get the shape that encloses all of the children.
Definition Shape:610
std::vector< ref_ptr< Shape > > ChildList
Definition Shape:596
virtual ~CompositeShape()
const Shape * getShape() const
Get the const shape that encloses all of the children.
Definition Shape:613
unsigned int findChildNo(Shape *shape) const
find the index number of child, if child is not found then it returns getNumChildren(),...
Definition Shape:634
void addChild(Shape *shape)
Add a child to the list.
Definition Shape:625
void removeChild(unsigned int i)
remove a child from the list.
Definition Shape:630
CompositeShape(const CompositeShape &cs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Shape:600
void addChild(const ref_ptr< T > &child)
Definition Shape:627
const Shape * getChild(unsigned int i) const
Get a const child.
Definition Shape:622
META_Shape(osg, CompositeShape)
ref_ptr< Shape > _shape
Definition Shape:648
unsigned int getNumChildren() const
Get the number of children of this composite shape.
Definition Shape:616
Shape * getChild(unsigned int i)
Get a child.
Definition Shape:619
Describe several hints that can be passed to a Tessellator (like the one used by ShapeDrawable) as a ...
Definition Shape:658
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 &copyop=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
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
@ SphereBottomHalf
Definition Shape:788
@ SphereTopHalf
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)
General purpose float pair.
Definition Vec2f:29
General purpose float triple for use as vertices, vectors and normals.
Definition Vec3f:29
#define NULL
Definition Export:55
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.