2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* 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
|
2003-01-22 00:45:36 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-01-22 00:45:36 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-22 00:45:36 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
#ifndef OSG_SHAPE
|
|
|
|
#define OSG_SHAPE 1
|
|
|
|
|
|
|
|
#include <osg/Object>
|
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Quat>
|
|
|
|
#include <osg/Plane>
|
|
|
|
#include <osg/Array>
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
2015-04-13 18:43:56 +08:00
|
|
|
// forward declare visitors.
|
2002-10-30 21:27:15 +08:00
|
|
|
class ShapeVisitor;
|
|
|
|
class ConstShapeVisitor;
|
|
|
|
|
|
|
|
|
|
|
|
/** META_StateAttribute macro define the standard clone, isSameKindAs,
|
|
|
|
* className and getType methods.
|
2012-03-22 01:36:20 +08:00
|
|
|
* Use when subclassing from Object to make it more convenient to define
|
|
|
|
* the standard pure virtual methods which are required for all Object
|
2002-10-30 21:27:15 +08:00
|
|
|
* subclasses.*/
|
|
|
|
#define META_Shape(library,name) \
|
2016-08-23 18:08:25 +08:00
|
|
|
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; } \
|
2002-10-30 21:27:15 +08:00
|
|
|
virtual const char* libraryName() const { return #library; } \
|
|
|
|
virtual const char* className() const { return #name; } \
|
2016-08-23 18:08:25 +08:00
|
|
|
virtual void accept(ShapeVisitor& sv) { sv.apply(*this); } \
|
|
|
|
virtual void accept(ConstShapeVisitor& csv) const { csv.apply(*this); }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
/** Base class for all shape types.
|
2002-10-30 21:27:15 +08:00
|
|
|
* Shapes are used to either for culling and collision detection or
|
|
|
|
* to define the geometric shape of procedurally generate Geometry.
|
|
|
|
*/
|
2005-04-12 01:14:17 +08:00
|
|
|
class OSG_EXPORT Shape : public Object
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
Shape() {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
|
|
|
Shape(const Shape& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Object(sa,copyop) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
/** Clone the type of an attribute, with Object* return type.
|
|
|
|
Must be defined by derived classes.*/
|
|
|
|
virtual Object* cloneType() const = 0;
|
|
|
|
|
|
|
|
/** Clone an attribute, with Object* return type.
|
|
|
|
Must be defined by derived classes.*/
|
|
|
|
virtual Object* clone(const CopyOp&) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/** return true if this and obj are of the same kind of object.*/
|
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Shape*>(obj)!=NULL; }
|
|
|
|
|
|
|
|
/** return the name of the attribute's library.*/
|
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
|
|
|
|
|
|
|
/** return the name of the attribute's class type.*/
|
|
|
|
virtual const char* className() const { return "Shape"; }
|
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
/** accept a non const shape visitor which can be used on non const shape objects.
|
2002-10-30 21:27:15 +08:00
|
|
|
Must be defined by derived classes.*/
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual void accept(ShapeVisitor&)=0;
|
|
|
|
|
|
|
|
/** accept a const shape visitor which can be used on const shape objects.
|
2002-10-30 21:27:15 +08:00
|
|
|
Must be defined by derived classes.*/
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual void accept(ConstShapeVisitor&) const =0;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual ~Shape();
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2004-09-03 03:10:33 +08:00
|
|
|
// forward declarations of Shape types.
|
2002-10-30 21:27:15 +08:00
|
|
|
class Sphere;
|
|
|
|
class Box;
|
|
|
|
class Cone;
|
|
|
|
class Cylinder;
|
2004-03-03 04:33:00 +08:00
|
|
|
class Capsule;
|
2002-10-30 21:27:15 +08:00
|
|
|
class InfinitePlane;
|
|
|
|
|
|
|
|
class TriangleMesh;
|
|
|
|
class ConvexHull;
|
|
|
|
class HeightField;
|
|
|
|
|
|
|
|
class CompositeShape;
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT ShapeVisitor
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
ShapeVisitor() {}
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~ShapeVisitor();
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2008-06-05 21:46:19 +08:00
|
|
|
virtual void apply(Shape&) {}
|
2005-11-18 01:44:48 +08:00
|
|
|
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&) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT ConstShapeVisitor
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
ConstShapeVisitor() {}
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~ConstShapeVisitor();
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2008-06-05 21:46:19 +08:00
|
|
|
virtual void apply(const Shape&) {}
|
2005-11-18 01:44:48 +08:00
|
|
|
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&) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual void apply(const TriangleMesh&) {}
|
|
|
|
virtual void apply(const ConvexHull&) {}
|
|
|
|
virtual void apply(const HeightField&) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual void apply(const CompositeShape&) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT Sphere : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
Sphere():
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(0.0f,0.0f,0.0f),
|
|
|
|
_radius(1.0f) {}
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Sphere(const Vec3& center,float radius):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_radius(radius) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
Sphere(const Sphere& sphere,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
|
|
|
Shape(sphere,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
protected:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~Sphere();
|
2005-11-18 01:44:48 +08:00
|
|
|
|
|
|
|
Vec3 _center;
|
|
|
|
float _radius;
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT Box : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
Box():
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(0.0f,0.0f,0.0f),
|
|
|
|
_halfLengths(0.5f,0.5f,0.5f) {}
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Box(const Vec3& center,float width):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_halfLengths(width*0.5f,width*0.5f,width*0.5f) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Box(const Vec3& center,float lengthX,float lengthY, float lengthZ):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_halfLengths(lengthX*0.5f,lengthY*0.5f,lengthZ*0.5f) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
Box(const Box& box,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Shape(box,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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); }
|
2012-03-22 01:36:20 +08:00
|
|
|
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~Box();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
Vec3 _center;
|
|
|
|
Vec3 _halfLengths;
|
|
|
|
Quat _rotation;
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT Cone : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
Cone():
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(0.0f,0.0f,0.0f),
|
|
|
|
_radius(1.0f),
|
|
|
|
_height(1.0f) {}
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Cone(const Vec3& center,float radius,float height):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_radius(radius),
|
|
|
|
_height(height) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
Cone(const Cone& cone,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Shape(cone,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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); }
|
2012-03-22 01:36:20 +08:00
|
|
|
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
inline float getBaseOffsetFactor() const { return 0.25f; }
|
|
|
|
inline float getBaseOffset() const { return -getBaseOffsetFactor()*getHeight(); }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~Cone();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
Vec3 _center;
|
|
|
|
float _radius;
|
|
|
|
float _height;
|
|
|
|
|
|
|
|
Quat _rotation;
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT Cylinder : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
Cylinder():
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(0.0f,0.0f,0.0f),
|
|
|
|
_radius(1.0f),
|
|
|
|
_height(1.0f) {}
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Cylinder(const Vec3& center,float radius,float height):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_radius(radius),
|
|
|
|
_height(height) {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
Cylinder(const Cylinder& cylinder,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Shape(cylinder,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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); }
|
2012-03-22 01:36:20 +08:00
|
|
|
bool zeroRotation() const { return _rotation.zeroRotation(); }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~Cylinder();
|
2005-11-18 01:44:48 +08:00
|
|
|
|
|
|
|
Vec3 _center;
|
|
|
|
float _radius;
|
|
|
|
float _height;
|
|
|
|
Quat _rotation;
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT Capsule : public Shape
|
2004-03-03 04:33:00 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2004-03-03 04:33:00 +08:00
|
|
|
Capsule():
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(0.0f,0.0f,0.0f),
|
|
|
|
_radius(1.0f),
|
|
|
|
_height(1.0f) {}
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Capsule(const Vec3& center,float radius,float height):
|
2005-11-18 01:44:48 +08:00
|
|
|
_center(center),
|
|
|
|
_radius(radius),
|
|
|
|
_height(height) {}
|
2004-03-03 04:33:00 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
Capsule(const Capsule& capsule,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2004-03-03 04:33:00 +08:00
|
|
|
Shape(capsule,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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); }
|
2012-03-22 01:36:20 +08:00
|
|
|
bool zeroRotation() const { return _rotation.zeroRotation(); }
|
2004-03-03 04:33:00 +08:00
|
|
|
|
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~Capsule();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
Vec3 _center;
|
|
|
|
float _radius;
|
|
|
|
float _height;
|
|
|
|
Quat _rotation;
|
2004-03-03 04:33:00 +08:00
|
|
|
};
|
|
|
|
|
2016-06-24 16:46:19 +08:00
|
|
|
/** Deprecated. */
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT InfinitePlane : public Shape, public Plane
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2005-11-18 01:44:48 +08:00
|
|
|
InfinitePlane() {}
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
InfinitePlane(const InfinitePlane& plane,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-12-06 17:44:11 +08:00
|
|
|
Shape(plane,copyop),
|
|
|
|
Plane(plane) {}
|
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
META_Shape(osg, InfinitePlane);
|
|
|
|
|
2002-12-06 17:44:11 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~InfinitePlane();
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2016-06-24 16:46:19 +08:00
|
|
|
/** Deprecated. */
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT TriangleMesh : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
TriangleMesh() {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
TriangleMesh(const TriangleMesh& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Shape(mesh,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_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(); }
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~TriangleMesh();
|
2005-11-18 01:44:48 +08:00
|
|
|
|
|
|
|
ref_ptr<Vec3Array> _vertices;
|
|
|
|
ref_ptr<IndexArray> _indices;
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2016-06-24 16:46:19 +08:00
|
|
|
/** Deprecated. */
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT ConvexHull : public TriangleMesh
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
ConvexHull() {}
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
ConvexHull(const ConvexHull& hull,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
TriangleMesh(hull,copyop) {}
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2016-09-12 22:49:35 +08:00
|
|
|
META_Shape(osg, ConvexHull);
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~ConvexHull();
|
2002-10-30 21:27:15 +08:00
|
|
|
};
|
|
|
|
|
2005-04-12 01:14:17 +08:00
|
|
|
class OSG_EXPORT HeightField : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2007-03-30 03:42:07 +08:00
|
|
|
HeightField();
|
|
|
|
|
|
|
|
HeightField(const HeightField& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
META_Shape(osg, HeightField);
|
2003-10-28 00:07:21 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
typedef std::vector<float> HeightList;
|
2003-10-29 19:11:17 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
void allocate(unsigned int numColumns,unsigned int numRows);
|
2003-10-29 19:11:17 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
inline unsigned int getNumColumns() const { return _columns; }
|
|
|
|
inline unsigned int getNumRows() const { return _rows; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
inline void setOrigin(const Vec3& origin) { _origin = origin; }
|
|
|
|
inline const Vec3& getOrigin() const { return _origin; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
inline void setXInterval(float dx) { _dx = dx; }
|
|
|
|
inline float getXInterval() const { return _dx; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
inline void setYInterval(float dy) { _dy = dy; }
|
|
|
|
inline float getYInterval() const { return _dy; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2007-03-30 03:42:07 +08:00
|
|
|
/** Get the FloatArray height data.*/
|
2016-08-23 18:08:25 +08:00
|
|
|
FloatArray* getFloatArray() { return _heights.get(); }
|
2007-03-30 03:42:07 +08:00
|
|
|
|
2009-07-24 22:45:44 +08:00
|
|
|
/** Get the const FloatArray height data.*/
|
2016-08-23 18:08:25 +08:00
|
|
|
const FloatArray* getFloatArray() const { return _heights.get(); }
|
2007-03-30 03:42:07 +08:00
|
|
|
|
2008-06-27 20:44:41 +08:00
|
|
|
HeightList& getHeightList() { return _heights->asVector(); }
|
2007-03-30 03:42:07 +08:00
|
|
|
|
2008-06-27 20:44:41 +08:00
|
|
|
const HeightList& getHeightList() const { return _heights->asVector(); }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2004-01-19 05:59:20 +08:00
|
|
|
/** Set the height of the skirt to render around the edge of HeightField.
|
2012-03-22 01:36:20 +08:00
|
|
|
* The skirt is used as a means of disguising edge boundaries between adjacent HeightField,
|
2004-09-03 03:10:33 +08:00
|
|
|
* particularly of ones with different resolutions.*/
|
2004-01-19 05:59:20 +08:00
|
|
|
void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2004-01-19 05:59:20 +08:00
|
|
|
/** Get the height of the skirt to render around the edge of HeightField.*/
|
|
|
|
float getSkirtHeight() const { return _skirtHeight; }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2004-01-19 05:59:20 +08:00
|
|
|
/** Set the width in number of cells in from the edge that the height field should be rendered from.
|
|
|
|
* This exists to allow gradient and curvature continutity to be maintained between adjacent HeightField, where
|
|
|
|
* the border cells will overlap adjacent HeightField.*/
|
|
|
|
void setBorderWidth(unsigned int borderWidth) { _borderWidth = borderWidth; }
|
|
|
|
|
|
|
|
/** Get the width in number of cells in from the edge that the height field should be rendered from.*/
|
|
|
|
unsigned int getBorderWidth() const { return _borderWidth; }
|
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
inline void setRotation(const Quat& quat) { _rotation = quat; }
|
|
|
|
inline const Quat& getRotation() const { return _rotation; }
|
|
|
|
inline Matrix computeRotationMatrix() const { return Matrix(_rotation); }
|
2012-03-22 01:36:20 +08:00
|
|
|
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
|
|
|
/* set a single height point in the height field */
|
|
|
|
inline void setHeight(unsigned int c,unsigned int r,float value)
|
|
|
|
{
|
2007-03-30 03:42:07 +08:00
|
|
|
(*_heights)[c+r*_columns] = value;
|
2005-11-18 01:44:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get address of single height point in the height field, allows user to change. */
|
|
|
|
inline float& getHeight(unsigned int c,unsigned int r)
|
|
|
|
{
|
2007-03-30 03:42:07 +08:00
|
|
|
return (*_heights)[c+r*_columns];
|
2005-11-18 01:44:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get value of single height point in the height field, not editable. */
|
|
|
|
inline float getHeight(unsigned int c,unsigned int r) const
|
|
|
|
{
|
2007-03-30 03:42:07 +08:00
|
|
|
return (*_heights)[c+r*_columns];
|
2005-11-18 01:44:48 +08:00
|
|
|
}
|
|
|
|
|
2004-01-19 05:59:20 +08:00
|
|
|
inline Vec3 getVertex(unsigned int c,unsigned int r) const
|
|
|
|
{
|
|
|
|
return Vec3(_origin.x()+getXInterval()*(float)c,
|
|
|
|
_origin.y()+getYInterval()*(float)r,
|
2012-03-22 01:36:20 +08:00
|
|
|
_origin.z()+(*_heights)[c+r*_columns]);
|
2004-01-19 05:59:20 +08:00
|
|
|
}
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2003-10-28 00:07:21 +08:00
|
|
|
Vec3 getNormal(unsigned int c,unsigned int r) const;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-07-02 16:11:55 +08:00
|
|
|
Vec2 getHeightDelta(unsigned int c,unsigned int r) const;
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
virtual ~HeightField();
|
|
|
|
|
2007-03-30 03:42:07 +08:00
|
|
|
unsigned int _columns,_rows;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
Vec3 _origin; // _origin is the min value of the X and Y coordinates.
|
2007-03-30 03:42:07 +08:00
|
|
|
float _dx;
|
|
|
|
float _dy;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2007-03-30 03:42:07 +08:00
|
|
|
float _skirtHeight;
|
|
|
|
unsigned int _borderWidth;
|
2004-01-19 05:59:20 +08:00
|
|
|
|
2007-03-30 03:42:07 +08:00
|
|
|
Quat _rotation;
|
2016-08-23 18:08:25 +08:00
|
|
|
ref_ptr<FloatArray> _heights;
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-31 18:36:11 +08:00
|
|
|
};
|
|
|
|
|
2003-10-29 19:11:17 +08:00
|
|
|
typedef HeightField Grid;
|
|
|
|
|
2003-10-28 00:07:21 +08:00
|
|
|
|
2016-06-24 16:46:19 +08:00
|
|
|
/** Deprecated. */
|
2009-01-28 17:21:46 +08:00
|
|
|
class OSG_EXPORT CompositeShape : public Shape
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
2003-10-29 19:11:17 +08:00
|
|
|
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
typedef std::vector< ref_ptr<Shape> > ChildList;
|
|
|
|
|
|
|
|
CompositeShape() {}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
CompositeShape(const CompositeShape& cs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-10-30 21:27:15 +08:00
|
|
|
Shape(cs,copyop),
|
2005-11-18 01:44:48 +08:00
|
|
|
_children(cs._children) {}
|
|
|
|
|
|
|
|
META_Shape(osg, CompositeShape);
|
|
|
|
|
|
|
|
/** Set the shape that encloses all of the children.*/
|
|
|
|
void setShape(Shape* shape) { _shape = shape; }
|
|
|
|
|
|
|
|
/** Get the shape that encloses all of the children.*/
|
|
|
|
Shape* getShape() { return _shape.get(); }
|
|
|
|
|
|
|
|
/** Get the const shape that encloses all of the children.*/
|
|
|
|
const Shape* getShape() const { return _shape.get(); }
|
|
|
|
|
|
|
|
/** Get the number of children of this composite shape.*/
|
2009-01-30 18:55:28 +08:00
|
|
|
unsigned int getNumChildren() const { return static_cast<unsigned int>(_children.size()); }
|
2005-11-18 01:44:48 +08:00
|
|
|
|
|
|
|
/** Get a child.*/
|
|
|
|
Shape* getChild(unsigned int i) { return _children[i].get(); }
|
|
|
|
|
|
|
|
/** Get a const child.*/
|
|
|
|
const Shape* getChild(unsigned int i) const { return _children[i].get(); }
|
|
|
|
|
|
|
|
/** Add a child to the list.*/
|
|
|
|
void addChild(Shape* shape) { _children.push_back(shape); }
|
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
template<class T> void addChild( const ref_ptr<T>& child ) { addChild(child.get()); }
|
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
/** remove a child from the list.*/
|
|
|
|
void removeChild(unsigned int i) { _children.erase(_children.begin()+i); }
|
|
|
|
|
|
|
|
/** find the index number of child, if child is not found then it returns getNumChildren(),
|
2012-03-22 01:36:20 +08:00
|
|
|
* so should be used in similar style to STL's result!=end().*/
|
2005-11-18 01:44:48 +08:00
|
|
|
unsigned int findChildNo(Shape* shape) const
|
2012-03-22 01:36:20 +08:00
|
|
|
{
|
2002-11-11 16:04:40 +08:00
|
|
|
for (unsigned int childNo=0;childNo<_children.size();++childNo)
|
|
|
|
{
|
|
|
|
if (_children[childNo]==shape) return childNo;
|
|
|
|
}
|
2009-01-30 18:55:28 +08:00
|
|
|
return static_cast<unsigned int>(_children.size()); // node not found.
|
2002-11-11 16:04:40 +08:00
|
|
|
|
|
|
|
}
|
2005-11-18 01:44:48 +08:00
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-28 17:21:46 +08:00
|
|
|
virtual ~CompositeShape();
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
ref_ptr<Shape> _shape;
|
|
|
|
ChildList _children;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-08-18 04:34:32 +08:00
|
|
|
|
|
|
|
/** Describe several hints that can be passed to a Tessellator (like the one used
|
|
|
|
* by \c ShapeDrawable) as a mean to try to influence the way it works.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2017-08-16 00:23:49 +08:00
|
|
|
/** Convenience class for populating an Geomtry with vertex, normals, texture coords and primitives that can render a Shape. */
|
2016-08-18 04:34:32 +08:00
|
|
|
class OSG_EXPORT BuildShapeGeometryVisitor : public ConstShapeVisitor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
BuildShapeGeometryVisitor(Geometry* geometry, const TessellationHints* hints);
|
2016-08-18 04:34:32 +08:00
|
|
|
|
|
|
|
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) { _normals->push_back(Vec3(x,y,z)); }
|
|
|
|
void TexCoord2f(float x, float y) { _texcoords->push_back(Vec2(x,y)); }
|
|
|
|
void Vertex(const Vec3f& v) { _vertices->push_back(v); }
|
|
|
|
void Vertex3f(float x, float y, float z) { _vertices->push_back(Vec3(x,y,z)); }
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
void setMatrix(const Matrixd& m);
|
2016-08-18 04:34:32 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2016-08-23 18:08:25 +08:00
|
|
|
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);
|
|
|
|
|
2002-10-30 21:27:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|