source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreBillboard.h @ 1092

Revision 1092, 7.1 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26#ifndef __Billboard_H__
27#define __Billboard_H__
28
29#include "OgrePrerequisites.h"
30
31#include "OgreVector3.h"
32#include "OgreColourValue.h"
33
34
35namespace Ogre {
36
37    /** A billboard is a primitive which always faces the camera in every frame.
38        @remarks
39            Billboards can be used for special effects or some other trickery which requires the
40            triangles to always facing the camera no matter where it is. Ogre groups billboards into
41            sets for efficiency, so you should never create a billboard on it's own (it's ok to have a
42            set of one if you need it).
43        @par
44            Billboards have their geometry generated every frame depending on where the camera is. It is most
45            beneficial for all billboards in a set to be identically sized since Ogre can take advantage of this and
46            save some calculations - useful when you have sets of hundreds of billboards as is possible with special
47            effects. You can deviate from this if you wish (example: a smoke effect would probably have smoke puffs
48            expanding as they rise, so each billboard will legitimately have it's own size) but be aware the extra
49            overhead this brings and try to avoid it if you can.
50        @par
51            Billboards are just the mechanism for rendering a range of effects such as particles. It is other classes
52            which use billboards to create their individual effects, so the methods here are quite generic.
53        @see
54            BillboardSet
55    */
56
57    class _OgreExport Billboard
58    {
59        friend class BillboardSet;
60        friend class BillboardParticleRenderer;
61    protected:
62        bool mOwnDimensions;
63        Real mWidth;
64        Real mHeight;
65    public:
66        // Note the intentional public access to main internal variables used at runtime
67        // Forcing access via get/set would be too costly for 000's of billboards
68        Vector3 mPosition;
69        // NB direction only relevant for rendering when billboard type = BBT_ORIENTED_SELF
70        Vector3 mDirection;
71        BillboardSet* mParentSet;
72        ColourValue mColour;
73        Radian mRotation;
74
75        /** Default constructor.
76        */
77        Billboard();
78
79        /** Default destructor.
80        */
81        ~Billboard();
82
83        /** Normal constructor as called by BillboardSet.
84        */
85        Billboard(const Vector3& position, BillboardSet* owner, const ColourValue& colour = ColourValue::White);
86
87        /** Get the rotation of the billboard.
88            @remarks
89                This rotation is relative to the center of the billboard.
90        */
91        const Radian& getRotation(void) const { return mRotation; }
92
93        /** Set the rotation of the billboard.
94            @remarks
95                This rotation is relative to the center of the billboard.
96        */
97        void setRotation(const Radian& rotation);
98
99        /** Set the position of the billboard.
100            @remarks
101                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
102                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
103        */
104        void setPosition(const Vector3& position);
105
106        /** Set the position of the billboard.
107            @remarks
108                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
109                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
110        */
111        void setPosition(Real x, Real y, Real z);
112
113        /** Get the position of the billboard.
114            @remarks
115                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
116                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
117        */
118        const Vector3& getPosition(void) const;
119
120        /** Sets the width and height for this billboard.
121            @remarks
122                Note that it is most efficient for every billboard in a BillboardSet to have the same dimensions. If you
123                choose to alter the dimensions of an individual billboard the set will be less efficient. Do not call
124                this method unless you really need to have different billboard dimensions within the same set. Otherwise
125                just call the BillboardSet::setDefaultDimensions method instead.
126        */
127        void setDimensions(Real width, Real height);
128
129        /** Resets this Billboard to use the parent BillboardSet's dimensions instead of it's own. */
130        void resetDimensions(void) { mOwnDimensions = false; }
131        /** Sets the colour of this billboard.
132            @remarks
133                Billboards can be tinted based on a base colour. This allows variations in colour irresective of the
134                base colour of the material allowing more varied billboards. The default colour is white.
135                The tinting is effected using vertex colours.
136        */
137        void setColour(const ColourValue& colour);
138
139        /** Gets the colour of this billboard.
140        */
141        const ColourValue& getColour(void) const;
142
143        /** Returns true if this billboard deviates from the BillboardSet's default dimensions (i.e. if the
144            Billboard::setDimensions method has been called for this instance).
145            @see
146                Billboard::setDimensions
147        */
148        bool hasOwnDimensions(void) const;
149
150        /** Retrieves the billboard's personal width, if hasOwnDimensions is true. */
151        Real getOwnWidth(void) const;
152
153        /** Retrieves the billboard's personal width, if hasOwnDimensions is true. */
154        Real getOwnHeight(void) const;
155
156        /** Internal method for notifying the billboard of it's owner.
157        */
158        void _notifyOwner(BillboardSet* owner);
159
160    };
161
162}
163
164#endif
Note: See TracBrowser for help on using the repository browser.