f612924a45
copy constructor which takes an optional Cloner object, and the old osg::Object::clone() has changed so that it now requires a Cloner as paramter. This is passed on to the copy constructor to help control the shallow vs deep copying. The old functionality of clone() which was clone of type has been renamed to cloneType(). Updated all of the OSG to work with these new conventions, implemention all the required copy constructors etc. A couple of areas will do shallow copies by design, a couple of other still need to be updated to do either shallow or deep. Neither of the shallow or deep copy operations have been tested yet, only the old functionality of the OSG has been checked so far, such running the viewer on various demo datasets. Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which was not checking that Group didn't have have any attached StateSet's, Callbacks or UserData. These checks have now been added, which fixes a bug which was revealled by the new osgscribe demo, this related to removal of group acting as state decorator. method
112 lines
3.9 KiB
Plaintext
112 lines
3.9 KiB
Plaintext
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
//as published by the Free Software Foundation.
|
|
|
|
#ifndef OSG_BILLBOARD
|
|
#define OSG_BILLBOARD 1
|
|
|
|
#include <osg/Matrix>
|
|
#include <osg/Geode>
|
|
|
|
namespace osg {
|
|
|
|
/** Billboard - a Geode which orientates its child osg::Drawable's to face
|
|
the eye point. Typical uses are for trees, or particle explosions.
|
|
*/
|
|
class SG_EXPORT Billboard : public Geode
|
|
{
|
|
public:
|
|
|
|
enum Mode {
|
|
POINT_ROT_EYE,
|
|
POINT_ROT_WORLD,
|
|
AXIAL_ROT
|
|
};
|
|
|
|
Billboard();
|
|
|
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
|
Billboard(const Billboard&,const Cloner& cloner=ShallowCopy());
|
|
|
|
META_Node(Billboard);
|
|
|
|
/** Set the billboard rotation mode. */
|
|
void setMode(const Mode mode);
|
|
/** Get the billboard rotation mode. */
|
|
inline const Mode getMode() const { return _mode; }
|
|
|
|
/** Set the axis about which all the billboard's drawable rotate. */
|
|
void setAxis(const Vec3& axis);
|
|
/** Get the axis about which all the billboard's drawable rotate. */
|
|
inline const Vec3& getAxis() const { return _axis; }
|
|
|
|
|
|
/** Set the position of specified drawable. */
|
|
inline void setPos(int i,const Vec3& pos) { _positionList[i] = pos; }
|
|
/** Get the position of specified drawable. */
|
|
inline const Vec3& getPos(int i) const { return _positionList[i]; }
|
|
|
|
/** PositionList represents a list of pivot points for each drawable.*/
|
|
typedef std::vector<Vec3> PositionList;
|
|
|
|
/** Get the PositionList from the billboard.*/
|
|
inline PositionList& getPositionList() { return _positionList; }
|
|
|
|
/** Get a const PositionList from the billboard.*/
|
|
inline const PositionList& getPositionList() const { return _positionList; }
|
|
|
|
/** Add Drawable to Billboard with default position(0,0,0);
|
|
* If gset not NULL and is not contained in Billboard then increment its
|
|
* reference count, and dirty the bounding box to cause it to recompute on
|
|
* next getBound() and return true for success. Otherwise return false.
|
|
*/
|
|
virtual const bool addDrawable( Drawable *gset );
|
|
|
|
/** Add Drawable to Geode at position pos.
|
|
* If gset not NULL and is not contained in Billboard then increment its
|
|
* reference count, and dirty the bounding box to cause it to recompute on
|
|
* next getBound() and return true for success. Otherwise return false.
|
|
*/
|
|
virtual const bool addDrawable(Drawable *gset,const Vec3& pos);
|
|
|
|
/** Remove Drawable and associated position from Billboard.
|
|
* If gset is contained in Billboard then remove it from the geoset
|
|
* list and decrement its reference count, and dirty the
|
|
* bounding box to cause it to recompute on next getBound() and
|
|
* return true for success. If gset is not found then return false
|
|
* and do not the reference count of gset is left unchanged.
|
|
*/
|
|
virtual const bool removeDrawable( Drawable *gset );
|
|
|
|
void calcTransform(const Vec3& eye_local, const Vec3& up_local, const Vec3& pos_local,Matrix& mat) const;
|
|
|
|
protected:
|
|
|
|
virtual ~Billboard();
|
|
|
|
virtual const bool computeBound() const;
|
|
|
|
enum AxisAligned
|
|
{
|
|
AXIAL_ROT_X_AXIS=AXIAL_ROT+1,
|
|
AXIAL_ROT_Y_AXIS,
|
|
AXIAL_ROT_Z_AXIS,
|
|
};
|
|
|
|
|
|
Mode _mode;
|
|
Vec3 _axis;
|
|
PositionList _positionList;
|
|
|
|
// used internally as cache of which what _axis is aligned to help
|
|
// deicde which method of rotation to use.
|
|
int _cachedMode;
|
|
|
|
void setCachedMode();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|