2002-10-30 21:27:15 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
#ifndef OSG_SHAPEDRAWABLE
|
|
|
|
#define OSG_SHAPEDRAWABLE 1
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
#include <osg/Drawable>
|
|
|
|
#include <osg/Vec2>
|
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Vec4>
|
|
|
|
#include <osg/Array>
|
|
|
|
#include <osg/PrimitiveSet>
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
class TessellationHints : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TessellationHints():
|
|
|
|
_TessellationMode(USE_SHAPE_DEFAULTS),
|
|
|
|
_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),
|
|
|
|
_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 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) { _createFrontFace=on; }
|
|
|
|
inline bool getCreateBackFace() const { return _createFrontFace; }
|
|
|
|
|
|
|
|
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;
|
|
|
|
unsigned int _targetNumFaces;
|
|
|
|
|
|
|
|
bool _createFrontFace;
|
|
|
|
bool _createBackFace;
|
|
|
|
bool _createNormals;
|
|
|
|
bool _createTextureCoords;
|
|
|
|
|
|
|
|
bool _createTop;
|
|
|
|
bool _createBody;
|
|
|
|
bool _createBottom;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
class SG_EXPORT ShapeDrawable : public Drawable
|
2002-10-30 21:27:15 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
ShapeDrawable();
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
ShapeDrawable(Shape* shape);
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
2002-11-06 18:46:34 +08:00
|
|
|
ShapeDrawable(const ShapeDrawable& pg,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
virtual Object* cloneType() const { return osgNew ShapeDrawable(); }
|
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return osgNew ShapeDrawable(*this,copyop); }
|
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ShapeDrawable*>(obj)!=NULL; }
|
2002-10-30 21:27:15 +08:00
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
2002-11-06 18:46:34 +08:00
|
|
|
virtual const char* className() const { return "ShapeDrawable"; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
void setTessellationHints(TessellationHints* hints) { _tessellationHints = hints; }
|
|
|
|
TessellationHints* getTessellationHints() { return _tessellationHints.get(); }
|
|
|
|
const TessellationHints* getTessellationHints() const { return _tessellationHints.get(); }
|
|
|
|
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
/** draw ShapeDrawable directly ignoring an OpenGL display list which could be attached.
|
2002-10-30 21:27:15 +08:00
|
|
|
* This is the internal draw method which does the drawing itself,
|
2002-11-06 18:46:34 +08:00
|
|
|
* and is the method to override when deriving from ShapeDrawable for user-drawn objects.
|
2002-10-30 21:27:15 +08:00
|
|
|
*/
|
2002-11-06 23:43:11 +08:00
|
|
|
virtual void drawImplementation(State& state) const;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
/** return false, osg::ProceduralGeoemtry does not support accept(AttributeFunctor&).*/
|
|
|
|
virtual bool supports(AttributeFunctor&) const { return false; }
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
/** return true, osg::ShapeDrawable does support accept(ConstAttributeFunctor&).*/
|
2002-11-06 18:24:33 +08:00
|
|
|
virtual bool supports(ConstAttributeFunctor&) const { return true; }
|
|
|
|
|
|
|
|
/** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
|
|
|
|
virtual void accept(ConstAttributeFunctor& af) const;
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
/** return true, osg::ShapeDrawable does support accept(PrimitiveFunctor&) .*/
|
2002-11-06 18:24:33 +08:00
|
|
|
virtual bool supports(PrimitiveFunctor&) const { return true; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
|
2002-11-06 18:24:33 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& pf) const;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
ShapeDrawable& operator = (const ShapeDrawable&) { return *this;}
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
virtual ~ShapeDrawable();
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
virtual bool computeBound() const;
|
|
|
|
|
|
|
|
ref_ptr<TessellationHints> _tessellationHints;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|