Orxonox  0.0.5 Codename: Arcturus
LensFlare.h
Go to the documentation of this file.
1  /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * David 'davidsa' Salvisberg
24  * Co-authors:
25  * ...
26  *
27  */
28 
34 #ifndef _LensFlare_H__
35 #define _LensFlare_H__
36 
37 #include "OrxonoxPrereqs.h"
38 
39 #include "OgreBillboardSet.h"
40 
41 #include "core/GraphicsManager.h"
42 #include "util/Math.h"
45 #include "graphics/Billboard.h"
46 
47 namespace orxonox
48 {
57  //TODO: The Hardware Occlusion only works properly for a single Flare on the screen,
58  // if we have multiple strong lights it'll become way more complicated to determine how much of every object is occluded individually
59  // there's below a 100 render queue groups, so maybe we should take turns for each object to be tested, so we only have one of the objects rendered at a time
60  // obviously we shouldn't use too many of these effects anyways, since they use a lot of processing power, so not sure whether it's worth implementing a solution that works for multiple lens flares on screen
62  {
67  class Lens
68  {
69  public:
71  float alpha_;
72  float scale_;
73  float position_;
74  Lens (const std::string& material, float alpha, float scale, float position)
75  {
76  this->material_ = material;
77  this->alpha_ = alpha;
78  this->scale_ = scale;
79  this->position_ = position;
80  }
81  };
82 
83  public:
84  LensFlare(Context* context);
85  virtual ~LensFlare();
86 
87  inline void setScale(float scale)
88  { this->scale_ = scale; }
89  inline float getScale() const
90  { return this->scale_; }
91 
98  inline void setColour(const ColourValue& colour)
99  { this->colour_ = colour; }
105  inline const ColourValue& getColour() const
106  { return this->colour_; }
107 
119  inline void setFadeResolution(unsigned int fadeResolution)
120  { this->fadeResolution_ = fadeResolution > 0 ? fadeResolution : 1; }
126  inline unsigned int getFadeResolution() const
127  { return this->fadeResolution_; }
128 
135  inline void setFadeExponent(float exponent)
136  { this->fadeExponent_ = exponent; }
142  inline float getFadeExponent() const
143  { return this->fadeExponent_; }
144 
151  inline void setFadeOnViewBorder(bool fadeOnViewBorder)
152  { this->fadeOnViewBorder_ = fadeOnViewBorder; }
159  inline bool isFadeOnViewBorder() const
160  { return this->fadeOnViewBorder_; }
161 
162  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
163 
164  virtual void tick(float dt) override;
165 
166  virtual void changedVisibility() override;
167 
168  private:
169  void registerVariables();
170 
171  void createBillboards();
172 
173  void updateBillboardStates(const Vector3& viewDirection, float dimension, bool isLightVisible);
174 
175  void updateBillboardAlphas(float alpha);
176 
177  unsigned int getPointCount(float dimension) const;
178 
179  std::vector<Lens> lensConfiguration_;
181  std::vector<Billboard*> billboards_;
182 
183  float scale_;
185  unsigned int fadeResolution_;
187  ColourValue colour_;
188  };
189 }
190 
191 #endif /* _LensFlare_H__ */
unsigned int fadeResolution_
how many points should be sampled per axis for the screen border fade. High number => smooth fade...
Definition: LensFlare.h:185
The StaticEntity is the simplest derivative of the orxonox::WorldEntity class.
Definition: StaticEntity.h:50
std::vector< Billboard * > billboards_
The visible billboards.
Definition: LensFlare.h:181
float getFadeExponent() const
This returns the exponent of the fade-out function.
Definition: LensFlare.h:142
float scale_
Which base scale should the Lens Flare have.
Definition: LensFlare.h:72
Declaration of the Tickable interface.
::std::string string
Definition: gtest-port.h:756
Declaration of GraphicsManager Singleton.
const ColourValue & getColour() const
This returns the current base colour of the billboards.
Definition: LensFlare.h:105
float scale_
this factor is used to scale the billboard to the desired size
Definition: LensFlare.h:183
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
void setScale(float scale)
Definition: LensFlare.h:87
bool isFadeOnViewBorder() const
Determine whether the out-of-screen-fade-effect is on or off.
Definition: LensFlare.h:159
xmlelement
Definition: Super.h:519
Billboard * occlusionBillboard_
this is a transparent billboard used solely for the Hardware Occlusion Query
Definition: LensFlare.h:180
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
Definition: Billboard.h:43
This is a nested Class used to easily set properties of the different sublenses of a LensFlare effect...
Definition: LensFlare.h:67
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
std::string material_
Which material should the Lens use, current choices include burst, bursthalo, halo1, halo2, halo3.
Definition: LensFlare.h:70
void setFadeOnViewBorder(bool fadeOnViewBorder)
Turn the out-of-screen-fade-effect on or off.
Definition: LensFlare.h:151
std::vector< Lens > lensConfiguration_
this stores the lensConfiguration
Definition: LensFlare.h:179
unsigned int getFadeResolution() const
This returns the resolution of the out-of-screen-fade-effect.
Definition: LensFlare.h:126
Definition: Context.h:45
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
void setFadeResolution(unsigned int fadeResolution)
This sets the resolution of the out-of-screen-fade-effect.
Definition: LensFlare.h:119
void setFadeExponent(float exponent)
This sets the exponent of the fade-out function.
Definition: LensFlare.h:135
void setColour(const ColourValue &colour)
This sets the base colour of the billboards.
Definition: LensFlare.h:98
float alpha_
Which base alpha value should the Lens use.
Definition: LensFlare.h:71
ColourValue colour_
this stores the base colour of the light
Definition: LensFlare.h:187
float fadeExponent_
this determines how fast the flare fades away as it gets obstructed
Definition: LensFlare.h:186
Lens(const std::string &material, float alpha, float scale, float position)
Definition: LensFlare.h:74
float position_
This defines how far along the view direction the flare should be positioned, e.g. 0.5 would position the flare halfway between the viewer and the base burst, 0 at the camera, 1 at the burst.
Definition: LensFlare.h:73
The Tickable interface provides a tick(dt) function, that gets called every frame.
Definition: Tickable.h:52
float getScale() const
Definition: LensFlare.h:89
bool fadeOnViewBorder_
should the effect fade out on the border of the view?
Definition: LensFlare.h:184
This class adds a configurable LensFlare effect by adding multiple billboards for the several compone...
Definition: LensFlare.h:61