RigsofRods
Soft-body Physics Simulation
Lightning.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of SkyX.
4 Visit http://www.paradise-studios.net/products/skyx/
5 
6 Copyright (C) 2009-2012 Xavier Verguín González <xavyiy@gmail.com>
7 
8 This program is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/copyleft/lesser.txt.
21 --------------------------------------------------------------------------------
22 */
23 
24 #ifndef _SkyX_VClouds_Lightning_H_
25 #define _SkyX_VClouds_Lightning_H_
26 
27 #include "Prerequisites.h"
28 
29 namespace SkyX { namespace VClouds{
30 
31  class Lightning
32  {
33  public:
36  struct Segment
37  {
38  public:
42  : a(Ogre::Vector3())
43  , b(Ogre::Vector3())
44  {
45  }
46 
51  Segment(const Ogre::Vector3& a_, const Ogre::Vector3& b_)
52  : a(a_)
53  , b(b_)
54  {
55  }
56 
58  Ogre::Vector3 a;
60  Ogre::Vector3 b;
61  };
62 
75  Lightning(Ogre::SceneManager* sm, Ogre::SceneNode* sn, const Ogre::Vector3& orig, const Ogre::Vector3& dir, const Ogre::Real& l,
76  const Ogre::uint32& d, const Ogre::uint32& rec, const Ogre::Real& tm, const Ogre::Real& wm, const Ogre::Vector2& b = Ogre::Vector2(0,1));
77 
80  ~Lightning();
81 
84  void create();
85 
88  void remove();
89 
93  void update(Ogre::Real timeSinceLastFrame);
94 
98  inline const Ogre::Vector3& getDirection() const
99  {
100  return mDirection;
101  }
102 
106  inline const Ogre::Real& getLength() const
107  {
108  return mLength;
109  }
110 
114  inline const Ogre::Real& getIntensity() const
115  {
116  return mIntensity;
117  }
118 
122  inline Ogre::BillboardSet* getBillboardSet() const
123  {
124  return mBillboardSet;
125  }
126 
130  inline Ogre::SceneNode* getSceneNode() const
131  {
132  return mSceneNode;
133  }
134 
138  inline const bool& isFinished() const
139  {
140  return mFinished;
141  }
142 
147  void _updateRenderQueueGroup(const Ogre::uint8& rqg);
148 
149  private:
155  void _updateData(const Ogre::Real& alpha, const Ogre::Real& currentPos, const Ogre::Real& parentTime);
156 
158  Ogre::Vector3 mOrigin;
160  Ogre::Vector3 mDirection;
162  Ogre::Real mLength;
163 
165  Ogre::Real mRealLength;
167  Ogre::uint32 mDivisions;
169  Ogre::uint32 mRecursivity;
171  Ogre::Real mWidthMultiplier;
173  Ogre::Vector2 mBounds;
175  Ogre::Vector2 mAngleRange;
176 
178  Ogre::Real mTime;
180  Ogre::Real mTimeMultiplier;
182  Ogre::Vector3 mTimeMultipliers;
183 
185  Ogre::Real mIntensity;
186 
188  std::vector<Segment> mSegments;
190  std::vector<Lightning*> mChildren;
191 
193  Ogre::BillboardSet* mBillboardSet;
195  Ogre::SceneManager* mSceneManager;
197  Ogre::SceneNode* mSceneNode;
198 
200  bool mCreated;
202  bool mFinished;
203  };
204 
205 }}
206 
207 #endif
SkyX::VClouds::Lightning::Segment::a
Ogre::Vector3 a
Segment start.
Definition: Lightning.h:58
SkyX::VClouds::Lightning::getBillboardSet
Ogre::BillboardSet * getBillboardSet() const
Get billboard set.
Definition: Lightning.h:122
SkyX::VClouds::Lightning::update
void update(Ogre::Real timeSinceLastFrame)
Update.
Definition: Lightning.cpp:180
SkyX::VClouds::Lightning::getIntensity
const Ogre::Real & getIntensity() const
Get lightning intensity.
Definition: Lightning.h:114
SkyX::VClouds::Lightning::mSceneManager
Ogre::SceneManager * mSceneManager
Scene manager.
Definition: Lightning.h:195
SkyX::VClouds::Lightning::remove
void remove()
Remove.
Definition: Lightning.cpp:156
SkyX::VClouds::Lightning::mIntensity
Ogre::Real mIntensity
Lightning intensity.
Definition: Lightning.h:185
SkyX
Definition: AtmosphereManager.cpp:30
SkyX::VClouds::Lightning::mTimeMultiplier
Ogre::Real mTimeMultiplier
Global time multiplier.
Definition: Lightning.h:180
SkyX::VClouds::Lightning::getLength
const Ogre::Real & getLength() const
Get ray length.
Definition: Lightning.h:106
SkyX::VClouds::Lightning::isFinished
const bool & isFinished() const
Has the ray finished?
Definition: Lightning.h:138
SkyX::VClouds::Lightning::mRealLength
Ogre::Real mRealLength
Real ray length (total segments length amount)
Definition: Lightning.h:165
SkyX::VClouds::Lightning::mSceneNode
Ogre::SceneNode * mSceneNode
Scene node.
Definition: Lightning.h:197
SkyX::VClouds::Lightning::mTimeMultipliers
Ogre::Vector3 mTimeMultipliers
Per step time multipliers.
Definition: Lightning.h:182
SkyX::VClouds::Lightning::_updateData
void _updateData(const Ogre::Real &alpha, const Ogre::Real &currentPos, const Ogre::Real &parentTime)
Update data.
Definition: Lightning.cpp:252
SkyX::VClouds::Lightning::mWidthMultiplier
Ogre::Real mWidthMultiplier
Width multiplier.
Definition: Lightning.h:171
SkyX::VClouds::Lightning::mCreated
bool mCreated
Has been create() already called?
Definition: Lightning.h:200
SkyX::VClouds::Lightning::mFinished
bool mFinished
Has the ray finished?
Definition: Lightning.h:202
SkyX::VClouds::Lightning::mSegments
std::vector< Segment > mSegments
Segments.
Definition: Lightning.h:188
SkyX::VClouds::Lightning::mChildren
std::vector< Lightning * > mChildren
Children lightnings.
Definition: Lightning.h:190
SkyX::VClouds::Lightning::mRecursivity
Ogre::uint32 mRecursivity
Recursivity level.
Definition: Lightning.h:169
SkyX::VClouds::Lightning::_updateRenderQueueGroup
void _updateRenderQueueGroup(const Ogre::uint8 &rqg)
Update render queue group.
Definition: Lightning.cpp:242
SkyX::VClouds::Lightning::mLength
Ogre::Real mLength
Ray length.
Definition: Lightning.h:162
SkyX::VClouds::Lightning::mDivisions
Ogre::uint32 mDivisions
Number of divisions.
Definition: Lightning.h:167
SkyX::VClouds::Lightning
Definition: Lightning.h:31
SkyX::VClouds::Lightning::~Lightning
~Lightning()
Destructor.
Definition: Lightning.cpp:53
SkyX::VClouds::Lightning::mBounds
Ogre::Vector2 mBounds
Ray bounds (for internal visual calculations)
Definition: Lightning.h:173
SkyX::VClouds::Lightning::mDirection
Ogre::Vector3 mDirection
Ray direction.
Definition: Lightning.h:160
SkyX::VClouds::Lightning::Lightning
Lightning(Ogre::SceneManager *sm, Ogre::SceneNode *sn, const Ogre::Vector3 &orig, const Ogre::Vector3 &dir, const Ogre::Real &l, const Ogre::uint32 &d, const Ogre::uint32 &rec, const Ogre::Real &tm, const Ogre::Real &wm, const Ogre::Vector2 &b=Ogre::Vector2(0, 1))
Constructor.
Definition: Lightning.cpp:28
SkyX::VClouds::Lightning::getSceneNode
Ogre::SceneNode * getSceneNode() const
Get scene node.
Definition: Lightning.h:130
SkyX::VClouds::Lightning::create
void create()
Create.
Definition: Lightning.cpp:58
SkyX::VClouds::Lightning::getDirection
const Ogre::Vector3 & getDirection() const
Get ray direction.
Definition: Lightning.h:98
SkyX::VClouds::Lightning::mAngleRange
Ogre::Vector2 mAngleRange
Angle range (Little values -> Less derivations, bigger values -> More derivations)
Definition: Lightning.h:175
Ogre
Definition: ExtinguishableFireAffector.cpp:35
SkyX::VClouds::Lightning::mOrigin
Ogre::Vector3 mOrigin
Ray origin.
Definition: Lightning.h:158
SkyX::VClouds::Lightning::mTime
Ogre::Real mTime
Current elapsed time.
Definition: Lightning.h:178
SkyX::VClouds::Lightning::mBillboardSet
Ogre::BillboardSet * mBillboardSet
Billboard set.
Definition: Lightning.h:193
SkyX::VClouds::Lightning::Segment
Segment struct.
Definition: Lightning.h:36
SkyX::VClouds::Lightning::Segment::Segment
Segment()
Default constructor.
Definition: Lightning.h:41
SkyX::VClouds::Lightning::Segment::Segment
Segment(const Ogre::Vector3 &a_, const Ogre::Vector3 &b_)
Constructor.
Definition: Lightning.h:51
SkyX::VClouds::Lightning::Segment::b
Ogre::Vector3 b
Segment end.
Definition: Lightning.h:60