Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreBillboard.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 9.9 KB
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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __Billboard_H__
30#define __Billboard_H__
31
32#include "OgrePrerequisites.h"
33
34#include "OgreVector3.h"
35#include "OgreColourValue.h"
36#include "OgreCommon.h"
37#include "OgreHeaderPrefix.h"
38
39namespace Ogre {
40        /** \addtogroup Core
41        *  @{
42        */
43        /** \addtogroup Effects
44        *  @{
45        */
46
47    /** A billboard is a primitive which always faces the camera in every frame.
48        @remarks
49            Billboards can be used for special effects or some other trickery which requires the
50            triangles to always facing the camera no matter where it is. Ogre groups billboards into
51            sets for efficiency, so you should never create a billboard on it's own (it's ok to have a
52            set of one if you need it).
53        @par
54            Billboards have their geometry generated every frame depending on where the camera is. It is most
55            beneficial for all billboards in a set to be identically sized since Ogre can take advantage of this and
56            save some calculations - useful when you have sets of hundreds of billboards as is possible with special
57            effects. You can deviate from this if you wish (example: a smoke effect would probably have smoke puffs
58            expanding as they rise, so each billboard will legitimately have it's own size) but be aware the extra
59            overhead this brings and try to avoid it if you can.
60        @par
61            Billboards are just the mechanism for rendering a range of effects such as particles. It is other classes
62            which use billboards to create their individual effects, so the methods here are quite generic.
63        @see
64            BillboardSet
65    */
66
67        class _OgreExport Billboard : public FXAlloc
68    {
69        friend class BillboardSet;
70        friend class BillboardParticleRenderer;
71    protected:
72        bool mOwnDimensions;
73        bool mUseTexcoordRect;
74        uint16 mTexcoordIndex;      /// Index into the BillboardSet array of texture coordinates
75        FloatRect mTexcoordRect;    /// Individual texture coordinates
76        Real mWidth;
77        Real mHeight;
78    public:
79        // Note the intentional public access to main internal variables used at runtime
80        // Forcing access via get/set would be too costly for 000's of billboards
81        Vector3 mPosition;
82        /// Normalised direction vector
83        Vector3 mDirection;
84        BillboardSet* mParentSet;
85        ColourValue mColour;
86        Radian mRotation;
87
88        /** Default constructor.
89        */
90        Billboard();
91
92        /** Default destructor.
93        */
94        ~Billboard();
95
96        /** Normal constructor as called by BillboardSet.
97        */
98        Billboard(const Vector3& position, BillboardSet* owner, const ColourValue& colour = ColourValue::White);
99
100        /** Get the rotation of the billboard.
101            @remarks
102                This rotation is relative to the center of the billboard.
103        */
104        const Radian& getRotation(void) const { return mRotation; }
105
106        /** Set the rotation of the billboard.
107            @remarks
108                This rotation is relative to the center of the billboard.
109        */
110        void setRotation(const Radian& rotation);
111
112        /** Set the position of the billboard.
113            @remarks
114                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
115                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
116        */
117        void setPosition(const Vector3& position);
118
119        /** Set the position of the billboard.
120            @remarks
121                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
122                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
123        */
124        void setPosition(Real x, Real y, Real z);
125
126        /** Get the position of the billboard.
127            @remarks
128                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
129                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
130        */
131        const Vector3& getPosition(void) const;
132
133        /** Sets the width and height for this billboard.
134            @remarks
135                Note that it is most efficient for every billboard in a BillboardSet to have the same dimensions. If you
136                choose to alter the dimensions of an individual billboard the set will be less efficient. Do not call
137                this method unless you really need to have different billboard dimensions within the same set. Otherwise
138                just call the BillboardSet::setDefaultDimensions method instead.
139        */
140        void setDimensions(Real width, Real height);
141
142        /** Resets this Billboard to use the parent BillboardSet's dimensions instead of it's own. */
143        void resetDimensions(void) { mOwnDimensions = false; }
144        /** Sets the colour of this billboard.
145            @remarks
146                Billboards can be tinted based on a base colour. This allows variations in colour irrespective of the
147                base colour of the material allowing more varied billboards. The default colour is white.
148                The tinting is effected using vertex colours.
149        */
150        void setColour(const ColourValue& colour);
151
152        /** Gets the colour of this billboard.
153        */
154        const ColourValue& getColour(void) const;
155
156        /** Returns true if this billboard deviates from the BillboardSet's default dimensions (i.e. if the
157            Billboard::setDimensions method has been called for this instance).
158            @see
159                Billboard::setDimensions
160        */
161        bool hasOwnDimensions(void) const;
162
163        /** Retrieves the billboard's personal width, if hasOwnDimensions is true. */
164        Real getOwnWidth(void) const;
165
166        /** Retrieves the billboard's personal height, if hasOwnDimensions is true. */
167        Real getOwnHeight(void) const;
168
169        /** Internal method for notifying the billboard of it's owner.
170        */
171        void _notifyOwner(BillboardSet* owner);
172
173        /** Returns true if this billboard use individual texture coordinate rect (i.e. if the
174            Billboard::setTexcoordRect method has been called for this instance), or returns
175            false if use texture coordinates defined in the parent BillboardSet's texture
176            coordinates array (i.e. if the Billboard::setTexcoordIndex method has been called
177            for this instance).
178            @see
179                Billboard::setTexcoordIndex()
180                Billboard::setTexcoordRect()
181        */
182        bool isUseTexcoordRect(void) const { return mUseTexcoordRect; }
183
184        /** setTexcoordIndex() sets which texture coordinate rect this billboard will use
185            when rendering. The parent billboard set may contain more than one, in which
186            case a billboard can be textured with different pieces of a larger texture
187            sheet very efficiently.
188          @see
189            BillboardSet::setTextureCoords()
190          */
191        void setTexcoordIndex(uint16 texcoordIndex);
192
193        /** getTexcoordIndex() returns the previous value set by setTexcoordIndex().
194            The default value is 0, which is always a valid texture coordinate set.
195            @remarks
196                This value is useful only when isUseTexcoordRect return false.
197          */
198        uint16 getTexcoordIndex(void) const { return mTexcoordIndex; }
199
200        /** setTexcoordRect() sets the individual texture coordinate rect of this billboard
201            will use when rendering. The parent billboard set may contain more than one, in
202            which case a billboard can be textured with different pieces of a larger texture
203            sheet very efficiently.
204        */
205        void setTexcoordRect(const FloatRect& texcoordRect);
206
207        /** setTexcoordRect() sets the individual texture coordinate rect of this billboard
208            will use when rendering. The parent billboard set may contain more than one, in
209            which case a billboard can be textured with different pieces of a larger texture
210            sheet very efficiently.
211        */
212        void setTexcoordRect(Real u0, Real v0, Real u1, Real v1);
213
214        /** getTexcoordRect() returns the previous value set by setTexcoordRect().
215            @remarks
216                This value is useful only when isUseTexcoordRect returns true.
217        */
218        const FloatRect& getTexcoordRect(void) const { return mTexcoordRect; }
219    };
220
221        /** @} */
222        /** @} */
223
224}
225
226#include "OgreHeaderSuffix.h"
227
228#endif
Note: See TracBrowser for help on using the repository browser.