Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/include/OgreBillboard.h @ 11

Last change on this file since 11 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 9.7 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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30#ifndef __Billboard_H__
31#define __Billboard_H__
32
33#include "OgrePrerequisites.h"
34
35#include "OgreVector3.h"
36#include "OgreColourValue.h"
37#include "OgreCommon.h"
38
39namespace Ogre {
40
41    /** A billboard is a primitive which always faces the camera in every frame.
42        @remarks
43            Billboards can be used for special effects or some other trickery which requires the
44            triangles to always facing the camera no matter where it is. Ogre groups billboards into
45            sets for efficiency, so you should never create a billboard on it's own (it's ok to have a
46            set of one if you need it).
47        @par
48            Billboards have their geometry generated every frame depending on where the camera is. It is most
49            beneficial for all billboards in a set to be identically sized since Ogre can take advantage of this and
50            save some calculations - useful when you have sets of hundreds of billboards as is possible with special
51            effects. You can deviate from this if you wish (example: a smoke effect would probably have smoke puffs
52            expanding as they rise, so each billboard will legitimately have it's own size) but be aware the extra
53            overhead this brings and try to avoid it if you can.
54        @par
55            Billboards are just the mechanism for rendering a range of effects such as particles. It is other classes
56            which use billboards to create their individual effects, so the methods here are quite generic.
57        @see
58            BillboardSet
59    */
60
61    class _OgreExport Billboard
62    {
63        friend class BillboardSet;
64        friend class BillboardParticleRenderer;
65    protected:
66        bool mOwnDimensions;
67        bool mUseTexcoordRect;
68        uint16 mTexcoordIndex;      // index into the BillboardSet array of texture coordinates
69        FloatRect mTexcoordRect;    // individual texture coordinates
70        Real mWidth;
71        Real mHeight;
72    public:
73        // Note the intentional public access to main internal variables used at runtime
74        // Forcing access via get/set would be too costly for 000's of billboards
75        Vector3 mPosition;
76        // Normalised direction vector
77        Vector3 mDirection;
78        BillboardSet* mParentSet;
79        ColourValue mColour;
80        Radian mRotation;
81
82        /** Default constructor.
83        */
84        Billboard();
85
86        /** Default destructor.
87        */
88        ~Billboard();
89
90        /** Normal constructor as called by BillboardSet.
91        */
92        Billboard(const Vector3& position, BillboardSet* owner, const ColourValue& colour = ColourValue::White);
93
94        /** Get the rotation of the billboard.
95            @remarks
96                This rotation is relative to the center of the billboard.
97        */
98        const Radian& getRotation(void) const { return mRotation; }
99
100        /** Set the rotation of the billboard.
101            @remarks
102                This rotation is relative to the center of the billboard.
103        */
104        void setRotation(const Radian& rotation);
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(const Vector3& position);
112
113        /** Set 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        void setPosition(Real x, Real y, Real z);
119
120        /** Get the position of the billboard.
121            @remarks
122                This position is relative to a point on the quad which is the billboard. Depending on the BillboardSet,
123                this may be the center of the quad, the top-left etc. See BillboardSet::setBillboardOrigin for more info.
124        */
125        const Vector3& getPosition(void) const;
126
127        /** Sets the width and height for this billboard.
128            @remarks
129                Note that it is most efficient for every billboard in a BillboardSet to have the same dimensions. If you
130                choose to alter the dimensions of an individual billboard the set will be less efficient. Do not call
131                this method unless you really need to have different billboard dimensions within the same set. Otherwise
132                just call the BillboardSet::setDefaultDimensions method instead.
133        */
134        void setDimensions(Real width, Real height);
135
136        /** Resets this Billboard to use the parent BillboardSet's dimensions instead of it's own. */
137        void resetDimensions(void) { mOwnDimensions = false; }
138        /** Sets the colour of this billboard.
139            @remarks
140                Billboards can be tinted based on a base colour. This allows variations in colour irresective of the
141                base colour of the material allowing more varied billboards. The default colour is white.
142                The tinting is effected using vertex colours.
143        */
144        void setColour(const ColourValue& colour);
145
146        /** Gets the colour of this billboard.
147        */
148        const ColourValue& getColour(void) const;
149
150        /** Returns true if this billboard deviates from the BillboardSet's default dimensions (i.e. if the
151            Billboard::setDimensions method has been called for this instance).
152            @see
153                Billboard::setDimensions
154        */
155        bool hasOwnDimensions(void) const;
156
157        /** Retrieves the billboard's personal width, if hasOwnDimensions is true. */
158        Real getOwnWidth(void) const;
159
160        /** Retrieves the billboard's personal width, if hasOwnDimensions is true. */
161        Real getOwnHeight(void) const;
162
163        /** Internal method for notifying the billboard of it's owner.
164        */
165        void _notifyOwner(BillboardSet* owner);
166
167        /** Returns true if this billboard use individual texture coordinate rect (i.e. if the
168            Billboard::setTexcoordRect method has been called for this instance), or returns
169            false if use texture coordinates defined in the parent BillboardSet's texture
170            coordinates array (i.e. if the Billboard::setTexcoordIndex method has been called
171            for this instance).
172            @see
173                Billboard::setTexcoordIndex()
174                Billboard::setTexcoordRect()
175        */
176        bool isUseTexcoordRect(void) const { return mUseTexcoordRect; }
177
178        /** setTexcoordIndex() sets which texture coordinate rect this billboard will use
179            when rendering. The parent billboard set may contain more than one, in which
180            case a billboard can be textured with different pieces of a larger texture
181            sheet very efficiently.
182          @see
183            BillboardSet::setTextureCoords()
184          */
185        void setTexcoordIndex(uint16 texcoordIndex);
186
187        /** getTexcoordIndex() returns the previous value set by setTexcoordIndex().
188            The default value is 0, which is always a valid texture coordinate set.
189            @remarks
190                This value is useful only when isUseTexcoordRect return false.
191          */
192        uint16 getTexcoordIndex(void) const { return mTexcoordIndex; }
193
194        /** setTexcoordRect() sets the individual texture coordinate rect of this billboard
195            will use when rendering. The parent billboard set may contain more than one, in
196            which case a billboard can be textured with different pieces of a larger texture
197            sheet very efficiently.
198        */
199        void setTexcoordRect(const FloatRect& texcoordRect);
200
201        /** setTexcoordRect() sets the individual texture coordinate rect of this billboard
202            will use when rendering. The parent billboard set may contain more than one, in
203            which case a billboard can be textured with different pieces of a larger texture
204            sheet very efficiently.
205        */
206        void setTexcoordRect(Real u0, Real v0, Real u1, Real v1);
207
208        /** getTexcoordRect() returns the previous value set by setTexcoordRect().
209            @remarks
210                This value is useful only when isUseTexcoordRect return true.
211        */
212        const FloatRect& getTexcoordRect(void) const { return mTexcoordRect; }
213    };
214
215}
216
217#endif
Note: See TracBrowser for help on using the repository browser.