2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2005-01-27 21:15:21 +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.
|
2005-01-27 21:15:21 +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
|
2005-01-27 21:15:21 +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
|
|
|
|
2002-11-06 18:46:34 +08:00
|
|
|
#ifndef OSG_SHAPEDRAWABLE
|
|
|
|
#define OSG_SHAPEDRAWABLE 1
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2016-08-18 04:34:32 +08:00
|
|
|
#include <osg/Geometry>
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
2005-01-27 21:15:21 +08:00
|
|
|
|
|
|
|
/** Allow the use of <tt>Shape</tt>s as <tt>Drawable</tt>s, so that they can
|
|
|
|
* be rendered with reduced effort. The implementation of \c ShapeDrawable is
|
|
|
|
* not geared to efficiency; it's better to think of it as a convenience to
|
|
|
|
* render <tt>Shape</tt>s easily (perhaps for test or debugging purposes) than
|
|
|
|
* as the right way to render basic shapes in some efficiency-critical section
|
|
|
|
* of code.
|
|
|
|
*/
|
2016-08-18 04:34:32 +08:00
|
|
|
class OSG_EXPORT ShapeDrawable : public osg::Geometry
|
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
|
|
|
|
2005-01-27 21:15:21 +08:00
|
|
|
ShapeDrawable(Shape* shape, TessellationHints* hints=0);
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
template<class T> ShapeDrawable(const ref_ptr<T>& shape, TessellationHints* hints=0):
|
|
|
|
_tessellationHints(hints) { setShape(shape.get()); }
|
|
|
|
|
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);
|
2005-01-27 21:15:21 +08:00
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new ShapeDrawable(); }
|
2005-01-27 21:15:21 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new ShapeDrawable(*this,copyop); }
|
2002-11-06 18:46:34 +08:00
|
|
|
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
|
|
|
|
2016-08-18 04:34:32 +08:00
|
|
|
virtual void setShape(Shape* shape);
|
|
|
|
|
2005-01-27 21:15:21 +08:00
|
|
|
/** Set the color of the shape.*/
|
2005-10-02 03:27:52 +08:00
|
|
|
void setColor(const Vec4& color);
|
2005-01-27 21:15:21 +08:00
|
|
|
|
|
|
|
/** Get the color of the shape.*/
|
2003-04-17 04:02:15 +08:00
|
|
|
const Vec4& getColor() const { return _color; }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-10-02 03:27:52 +08:00
|
|
|
void setTessellationHints(TessellationHints* hints);
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2005-01-27 21:15:21 +08:00
|
|
|
TessellationHints* getTessellationHints() { return _tessellationHints.get(); }
|
|
|
|
const TessellationHints* getTessellationHints() const { return _tessellationHints.get(); }
|
2002-10-30 21:27:15 +08:00
|
|
|
|
2016-08-18 04:34:32 +08:00
|
|
|
/** method to invoke to rebuild the geometry that renders the shape.*/
|
|
|
|
void build();
|
2005-05-12 22:03:22 +08:00
|
|
|
|
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();
|
2005-01-27 21:15:21 +08:00
|
|
|
|
2003-04-17 04:02:15 +08:00
|
|
|
Vec4 _color;
|
|
|
|
|
2005-01-27 21:15:21 +08:00
|
|
|
ref_ptr<TessellationHints> _tessellationHints;
|
2002-10-30 21:27:15 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|