Changeset 13041 for OpenSceneGraph/trunk/include/osg/Shape
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/Shape (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/Shape
r11869 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 30 30 /** META_StateAttribute macro define the standard clone, isSameKindAs, 31 31 * className and getType methods. 32 * Use when subclassing from Object to make it more convenient to define 33 * the standard pure virtual methods which are required for all Object 32 * Use when subclassing from Object to make it more convenient to define 33 * the standard pure virtual methods which are required for all Object 34 34 * subclasses.*/ 35 35 #define META_Shape(library,name) \ … … 42 42 virtual void accept(osg::ConstShapeVisitor& csv) const { csv.apply(*this); } 43 43 44 /** Base class for all shape types. 44 /** Base class for all shape types. 45 45 * Shapes are used to either for culling and collision detection or 46 46 * to define the geometric shape of procedurally generate Geometry. … … 51 51 52 52 Shape() {} 53 54 Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 53 54 Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 55 55 Object(sa,copyop) {} 56 56 57 57 /** Clone the type of an attribute, with Object* return type. 58 58 Must be defined by derived classes.*/ … … 82 82 83 83 protected: 84 84 85 85 virtual ~Shape(); 86 86 }; … … 103 103 { 104 104 public: 105 105 106 106 ShapeVisitor() {} 107 107 virtual ~ShapeVisitor(); … … 125 125 { 126 126 public: 127 127 128 128 ConstShapeVisitor() {} 129 129 virtual ~ConstShapeVisitor(); … … 202 202 _halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {} 203 203 204 Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 204 Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 205 205 Shape(box,copyop), 206 206 _center(box._center), … … 227 227 inline const Quat& getRotation() const { return _rotation; } 228 228 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } 229 inline bool zeroRotation() const { return _rotation.zeroRotation(); } 230 231 protected: 232 229 inline bool zeroRotation() const { return _rotation.zeroRotation(); } 230 231 protected: 232 233 233 virtual ~Box(); 234 234 235 235 Vec3 _center; 236 236 Vec3 _halfLengths; … … 255 255 _height(height) {} 256 256 257 Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 257 Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 258 258 Shape(cone,copyop), 259 259 _center(cone._center), … … 285 285 inline const Quat& getRotation() const { return _rotation; } 286 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 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 294 virtual ~Cone(); 295 295 296 296 Vec3 _center; 297 297 float _radius; … … 315 315 _height(height) {} 316 316 317 Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 317 Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 318 318 Shape(cylinder,copyop), 319 319 _center(cylinder._center), … … 345 345 inline const Quat& getRotation() const { return _rotation; } 346 346 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } 347 bool zeroRotation() const { return _rotation.zeroRotation(); } 348 349 protected: 350 347 bool zeroRotation() const { return _rotation.zeroRotation(); } 348 349 protected: 350 351 351 virtual ~Cylinder(); 352 352 … … 371 371 _height(height) {} 372 372 373 Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 373 Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 374 374 Shape(capsule,copyop), 375 375 _center(capsule._center), … … 401 401 inline const Quat& getRotation() const { return _rotation; } 402 402 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } 403 bool zeroRotation() const { return _rotation.zeroRotation(); } 404 405 protected: 406 403 bool zeroRotation() const { return _rotation.zeroRotation(); } 404 405 protected: 406 407 407 virtual ~Capsule(); 408 408 409 409 Vec3 _center; 410 410 float _radius; … … 418 418 InfinitePlane() {} 419 419 420 InfinitePlane(const InfinitePlane& plane,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 420 InfinitePlane(const InfinitePlane& plane,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 421 421 Shape(plane,copyop), 422 422 Plane(plane) {} … … 425 425 426 426 protected: 427 427 428 428 virtual ~InfinitePlane(); 429 429 }; … … 434 434 { 435 435 public: 436 436 437 437 TriangleMesh() {} 438 438 439 TriangleMesh(const TriangleMesh& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 439 TriangleMesh(const TriangleMesh& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 440 440 Shape(mesh,copyop), 441 441 _vertices(mesh._vertices), … … 455 455 456 456 protected: 457 457 458 458 virtual ~TriangleMesh(); 459 459 … … 466 466 { 467 467 public: 468 468 469 469 ConvexHull() {} 470 470 471 ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 471 ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 472 472 TriangleMesh(hull,copyop) {} 473 473 … … 475 475 476 476 protected: 477 477 478 478 virtual ~ConvexHull(); 479 479 }; … … 482 482 { 483 483 public: 484 484 485 485 HeightField(); 486 486 487 487 HeightField(const HeightField& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY); 488 488 489 489 META_Shape(osg, HeightField); 490 490 … … 504 504 inline void setYInterval(float dy) { _dy = dy; } 505 505 inline float getYInterval() const { return _dy; } 506 506 507 507 /** Get the FloatArray height data.*/ 508 508 osg::FloatArray* getFloatArray() { return _heights.get(); } … … 516 516 517 517 /** Set the height of the skirt to render around the edge of HeightField. 518 * The skirt is used as a means of disguising edge boundaries between adjacent HeightField, 518 * The skirt is used as a means of disguising edge boundaries between adjacent HeightField, 519 519 * particularly of ones with different resolutions.*/ 520 520 void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; } … … 534 534 inline const Quat& getRotation() const { return _rotation; } 535 535 inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } 536 inline bool zeroRotation() const { return _rotation.zeroRotation(); } 536 inline bool zeroRotation() const { return _rotation.zeroRotation(); } 537 537 538 538 /* set a single height point in the height field */ … … 558 558 return Vec3(_origin.x()+getXInterval()*(float)c, 559 559 _origin.y()+getYInterval()*(float)r, 560 _origin.z()+(*_heights)[c+r*_columns]); 560 _origin.z()+(*_heights)[c+r*_columns]); 561 561 } 562 562 … … 566 566 567 567 protected: 568 568 569 569 virtual ~HeightField(); 570 570 … … 591 591 592 592 593 593 594 594 typedef std::vector< ref_ptr<Shape> > ChildList; 595 595 596 596 CompositeShape() {} 597 597 598 CompositeShape(const CompositeShape& cs,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 598 CompositeShape(const CompositeShape& cs,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 599 599 Shape(cs,copyop), 600 600 _children(cs._children) {} … … 627 627 628 628 /** find the index number of child, if child is not found then it returns getNumChildren(), 629 * so should be used in similar style to STL's result!=end().*/ 629 * so should be used in similar style to STL's result!=end().*/ 630 630 unsigned int findChildNo(Shape* shape) const 631 { 631 { 632 632 for (unsigned int childNo=0;childNo<_children.size();++childNo) 633 633 { … … 639 639 640 640 protected: 641 641 642 642 virtual ~CompositeShape(); 643 643
