Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Wave.h
Go to the documentation of this file.
1/*
2--------------------------------------------------------------------------------
3This source file is part of Hydrax.
4Visit http://www.ogre3d.org/tikiwiki/Hydrax
5
6Copyright (C) 2011 Jose Luis Cercós Pita <jlcercos@gmail.com>
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://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
53namespace Hydrax{ namespace Noise
54{
55
59class Wave
60{
61public:
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
112protected:
113
114
115private:
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
A wave defined by the direction, amplitude, period, and optionally phase.
Definition Wave.h:60
~Wave()
Destructor.
Definition Wave.cpp:52
float mC
Speed (calculated)
Definition Wave.h:128
Ogre::Vector2 mDir
Direction (must be normalised)
Definition Wave.h:120
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition Wave.cpp:56
float getPhase() const
Returns phase of the wave.
Definition Wave.h:102
float mF
Angular frec.
Definition Wave.h:132
float getSpeed() const
Returns phase speed of the wave.
Definition Wave.h:106
float getLongitude() const
Returns longitude of the wave.
Definition Wave.h:110
float mA
Amplitude.
Definition Wave.h:122
Ogre::Vector2 getDirection() const
Returns direction of the wave.
Definition Wave.h:90
float getAmplitude() const
Returns amplitude of the wave.
Definition Wave.h:94
float mK
Dispersion factor.
Definition Wave.h:134
float mL
Longitude (calculated)
Definition Wave.h:130
double mTime
Elapsed time.
Definition Wave.h:117
float mT
Period.
Definition Wave.h:124
float getPeriod() const
Returns period of the wave.
Definition Wave.h:98
float mP
Phase.
Definition Wave.h:126
float getValue(const float &x, const float &y)
Get the especified x/y noise value.
Definition Wave.cpp:61