RigsofRods
Soft-body Physics Simulation
Wave.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of Hydrax.
4 Visit http://www.ogre3d.org/tikiwiki/Hydrax
5 
6 Copyright (C) 2011 Jose Luis Cercós Pita <jlcercos@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 WAVE_H_INCLUDED
25 #define WAVE_H_INCLUDED
26 
27 // ----------------------------------------------------------------------------
28 // Include standar libraries
29 // ----------------------------------------------------------------------------
30 #include <math.h>
31 
32 // ----------------------------------------------------------------------------
33 // Include the hydrax prerequisites
34 // ----------------------------------------------------------------------------
35 #include "Prerequisites.h"
36 
37 // ----------------------------------------------------------------------------
38 // Include the noise module
39 // ----------------------------------------------------------------------------
40 #include "Noise.h"
41 
42 // ----------------------------------------------------------------------------
43 // Include the perlin noise
44 // ----------------------------------------------------------------------------
45 #include "Perlin.h"
46 
49 
52 
53 namespace Hydrax{ namespace Noise
54 {
55 
59 class Wave
60 {
61 public:
68  Wave(Ogre::Vector2 dir, float A, float T, float p=0.f);
69 
72  ~Wave();
73 
77  void update(const Ogre::Real &timeSinceLastFrame);
78 
85  float getValue(const float &x, const float &y);
86 
90  inline Ogre::Vector2 getDirection() const{return mDir;}
94  inline float getAmplitude() const{return mA;}
98  inline float getPeriod() const{return mT;}
102  inline float getPhase() const{return mP;}
106  inline float getSpeed() const{return mC;}
110  inline float getLongitude() const{return mL;}
111 
112 protected:
113 
114 
115 private:
117  double mTime;
118 
120  Ogre::Vector2 mDir;
122  float mA;
124  float mT;
126  float mP;
128  float mC;
130  float mL;
132  float mF;
134  float mK;
135 };
136 
137 }} // Namespace
138 
141 
142 #endif // WAVE_H_INCLUDED
y
float y
Definition: (ValueTypes) quaternion.h:6
Hydrax::Noise::Wave::mP
float mP
Phase.
Definition: Wave.h:126
Hydrax::Noise::Wave::mA
float mA
Amplitude.
Definition: Wave.h:122
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::Noise::Wave::mK
float mK
Dispersion factor.
Definition: Wave.h:134
Hydrax::Noise::Wave::getDirection
Ogre::Vector2 getDirection() const
Returns direction of the wave.
Definition: Wave.h:90
Hydrax::Noise::Wave::getValue
float getValue(const float &x, const float &y)
Get the especified x/y noise value.
Definition: Wave.cpp:61
Noise.h
Hydrax::Noise::Wave::mF
float mF
Angular frec.
Definition: Wave.h:132
Perlin.h
Hydrax::Noise::Wave::getSpeed
float getSpeed() const
Returns phase speed of the wave.
Definition: Wave.h:106
Hydrax::Noise::Wave::mL
float mL
Longitude (calculated)
Definition: Wave.h:130
Hydrax::Noise::Wave::mDir
Ogre::Vector2 mDir
Direction (must be normalised)
Definition: Wave.h:120
Hydrax::Noise::Wave::update
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition: Wave.cpp:56
Hydrax::Noise::Wave::getPhase
float getPhase() const
Returns phase of the wave.
Definition: Wave.h:102
Hydrax::Noise::Wave::Wave
Wave(Ogre::Vector2 dir, float A, float T, float p=0.f)
Default constructor.
Definition: Wave.cpp:38
Hydrax::Noise::Wave::mC
float mC
Speed (calculated)
Definition: Wave.h:128
Prerequisites.h
Hydrax::Noise::Wave::mT
float mT
Period.
Definition: Wave.h:124
Hydrax::Noise::Wave
A wave defined by the direction, amplitude, period, and optionally phase.
Definition: Wave.h:59
Hydrax::Noise::Wave::~Wave
~Wave()
Destructor.
Definition: Wave.cpp:52
Hydrax::Noise::Wave::getAmplitude
float getAmplitude() const
Returns amplitude of the wave.
Definition: Wave.h:94
Hydrax::Noise::Wave::getPeriod
float getPeriod() const
Returns period of the wave.
Definition: Wave.h:98
x
float x
Definition: (ValueTypes) quaternion.h:5
Hydrax::Noise::Wave::getLongitude
float getLongitude() const
Returns longitude of the wave.
Definition: Wave.h:110
Hydrax::Noise::Wave::mTime
double mTime
Elapsed time.
Definition: Wave.h:117