OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Billboard.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_BILLBOARD
15 #define OSG_BILLBOARD 1
16 
17 #include <osg/Matrix>
18 #include <osg/Geode>
19 
20 namespace osg {
21 
26 class OSG_EXPORT Billboard : public Geode
27 {
28  public:
29 
30  enum Mode {
33  AXIAL_ROT
34  };
35 
36  Billboard();
37 
39  Billboard(const Billboard&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
40 
42 
44  void setMode(Mode mode);
46  inline Mode getMode() const { return _mode; }
47 
50  void setAxis(const Vec3& axis);
52  inline const Vec3& getAxis() const { return _axis; }
53 
55  void setNormal(const Vec3& normal);
57  inline const Vec3& getNormal() const { return _normal; }
58 
59 
61  inline void setPosition(unsigned int i,const Vec3& pos) { _positionList[i] = pos; }
63  inline const Vec3& getPosition(unsigned int i) const { return _positionList[i]; }
64 
66  typedef std::vector<Vec3> PositionList;
67 
69  inline void setPositionList(PositionList& pl) { _positionList=pl; }
70 
72  inline PositionList& getPositionList() { return _positionList; }
73 
75  inline const PositionList& getPositionList() const { return _positionList; }
76 
82  virtual bool addDrawable( Drawable *gset );
83 
89  virtual bool addDrawable(Drawable *gset,const Vec3& pos);
90 
95  virtual bool removeDrawable( Drawable *gset );
96 
97 
98  bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const;
99 
100  virtual BoundingSphere computeBound() const;
101 
102  protected:
103 
104  virtual ~Billboard();
105 
107  {
108  AXIAL_ROT_X_AXIS=AXIAL_ROT+1,
112  CACHE_DIRTY
113  };
114 
115 
120  PositionList _positionList;
121 
122  // used internally as cache of which what _axis is aligned to help
123  // decide which method of rotation to use.
126  void updateCache();
127 
128 };
129 
130 }
131 
132 #endif
#define OSG_EXPORT
Definition: Export.h:43
Matrix _rotateNormalToZAxis
Definition: Billboard.h:119
std::vector< Vec3 > PositionList
Definition: Billboard.h:66
void setPosition(unsigned int i, const Vec3 &pos)
Definition: Billboard.h:61
#define META_Node(library, name)
Definition: Node.h:59
const Vec3 & getNormal() const
Definition: Billboard.h:57
Mode getMode() const
Definition: Billboard.h:46
PositionList & getPositionList()
Definition: Billboard.h:72
void setPositionList(PositionList &pl)
Definition: Billboard.h:69
const PositionList & getPositionList() const
Definition: Billboard.h:75
const Vec3 & getPosition(unsigned int i) const
Definition: Billboard.h:63
Definition: AlphaFunc.h:19
PositionList _positionList
Definition: Billboard.h:120
const Vec3 & getAxis() const
Definition: Billboard.h:52