Triton
Visual simulation library for ocean rendering.
WakeGenerator.h
Go to the documentation of this file.
1// Copyright (c) 2011-2016 Sundog Software, LLC. All rights reserved worldwide.
2
3#ifndef TRITON_WAKE_GENERATOR_H
4#define TRITON_WAKE_GENERATOR_H
5
6#ifdef SWIG
7%module TritonWakeGenerator
8%import "Ocean.h"
9#define TRITONAPI
10%{
11#include "WakeGenerator.h"
12using namespace Triton;
13%}
14#endif
15
16#include "TritonCommon.h"
17#include "Vector3.h"
18#include "TritonVector.h"
19
24#pragma pack(push)
25#pragma pack(8)
26
27namespace Triton
28{
29class Ocean;
30
31struct SBowSprayEmitter
32{
33 int numSprays;
34 Vector3f offset;
35 double sprayVelocityScale;
37
38 double spraySizeScale;
39
40 SBowSprayEmitter(int _numSprays, double _sprayVelocityScale, double _spraySizeScale)
41 : numSprays(_numSprays), offset(0,0,0), sprayVelocityScale(_sprayVelocityScale), spraySizeScale(_spraySizeScale)
42 {
43
44 }
45};
46
49{
50public:
55
56 // Bow spray settings:
58
63
64 std::vector<SBowSprayEmitter> bowSprayEmitters;
65
66 // Kelvin wake settings:
67 bool bowWave;
68
71
72 double bowWaveScale;
73
74 double bowWaveMax;
75
76 double bowSize;
79
81
83
84 // Ship geometry:
85 double length;
86
87 double beamWidth;
88
89 double draft;
91
92 // Prop wash / tubulent wake settings:
93 bool propWash;
94
97
99
101
102 // Hull spray settings:
105
107
109
111
113
115
117
119
120 // Hull wake settings
125};
126
132{
133public:
143 WakeGenerator(Ocean *pOcean, const WakeGeneratorParameters& parameters);
144
145 virtual ~WakeGenerator();
146
158 void TRITONAPI Update(const Vector3& pPosition, const Vector3& pDirection, double pVelocity, double pTime, bool pDisableWash = false);
159
162
166 Vector3 TRITONAPI GetPosition() const {
167 return position;
168 }
169
171 Vector3 TRITONAPI GetSternPosition() const {
172 return sternPosition;
173 }
174
179 double TRITONAPI GetVelocity() const {
180 return velocity;
181 }
182
184 bool TRITONAPI HasPropWash() const {
185 return params.propWash;
186 }
187
195 void TRITONAPI SetLODDistance(double distance) {
196 lodDistance = distance;
197 }
198
201 double TRITONAPI GetLODDistance() const {
202 return lodDistance;
203 }
204
206 const WakeGeneratorParameters& TRITONAPI GetParameters() const;
207
209 void TRITONAPI SetParameters(const WakeGeneratorParameters& parameters);
210
211 // Used internally to clear out the ocean reference when it is deleted.
212 void OceanDestroyed() {
213 ocean = 0;
214 registered = false;
215 }
216
217 // Used internally to clear out the wake manager reference when it is deleted.
218 void WakeManagerDestroyed() {
219 registeredWakeManager = false;
220 }
221
222 // Used internally to keep track of the current max wake number.
223 int GetMaxWakeNumber() const {
224 return wakeNumber - 1;
225 }
226
227 // Used internally for fading prop wash effects.
228 double GetDistanceTravelled() const {
229 return distanceTravelled;
230 }
231
232 // Return the Ocean object this wake is attached to (if any)
233 // Used internally.
234 const Ocean *GetOcean() const {
235 return ocean;
236 }
237
238protected:
239 Vector3 position, sternPosition, lastPosition, washPosition, lastEmitPosition, lastWaveEmitPosition, lastLastEmitPosition;
240 Vector3 lastEmitSourcePosition, lastWakePosition;
241 double velocity;
242 double distanceTravelled;
243 Ocean *ocean;
244 double lastSprayEmitTime, lastWaveEmitTime;
245 double lodDistance, hullSpeed;
246 double sprayCullDist;
247 bool firstEmit, firstWaveEmit, registered, registeredWakeManager;
248 int wakeNumber, lastWakeNumber;
249 double minPropSegmentLength, decayRate, washDecayRate;
250 double sprayPositionVariation, curveGenerationFactor;
251 double gravity, maxDistanceSquared;
252 int maxWakes;
253 bool wakesAffectHeight;
254
256};
257}
258
259#pragma pack(pop)
260
261#endif
Common typedefs and defines used within Triton.
A 3D Vector class and its operations.
An object that generates a ship Kelvin wake as it moves.
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
The Ocean class allows you to configure and draw Triton's water simulation.
Definition: Ocean.h:81
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36
A 3D single-precision vector class, and its operations.
Definition: Vector3.h:149
A WakeGenerator represents an object on the water that generates a wake as it moves,...
Definition: WakeGenerator.h:132
void TRITONAPI SetParameters(const WakeGeneratorParameters &parameters)
Set this WakeGenerator's parameters using the WakeGeneratorParameters provided.
Vector3 TRITONAPI GetSternPosition() const
Retrieves the world position of the point where stern wakes originate from.
Definition: WakeGenerator.h:171
bool TRITONAPI HasPropWash() const
Retrieves whether propeller backwash was enabled for this wake generator.
Definition: WakeGenerator.h:184
void TRITONAPI Update(const Vector3 &pPosition, const Vector3 &pDirection, double pVelocity, double pTime, bool pDisableWash=false)
For any active WakeGenerator, this should be called every frame to update its position and velocity.
const WakeGeneratorParameters &TRITONAPI GetParameters() const
Returns the current parameters for this WakeGenerator.
Vector3 TRITONAPI GetPosition() const
Retrieves the world position of the WakeGenerator.
Definition: WakeGenerator.h:166
WakeGenerator(Ocean *pOcean, const WakeGeneratorParameters &parameters)
Construct a WakeGenerator with the same Triton::Ocean it will be associated with.
void TRITONAPI SetLODDistance(double distance)
Sets the distance at which the number of visible wake waves will be halved.
Definition: WakeGenerator.h:195
double TRITONAPI GetVelocity() const
Retrieves the velocity of the WakeGenerator.
Definition: WakeGenerator.h:179
void ClearWakes()
Clears all previously emitted wakes from the Ocean.
double TRITONAPI GetLODDistance() const
Retrieves the LOD distance set in Triton::WakeGenerator::SetLODDistance(), or 0 if LOD is disabled.
Definition: WakeGenerator.h:201
WakeGeneratorParameters contains the parameters required to construct a Triton::WakeGenerator object.
Definition: WakeGenerator.h:49
double hullSprayStartOffset
The offset at which hull spray effects begin.
Definition: WakeGenerator.h:106
float shipSpeedMaxFoam
Ship speed corresponding to maximum foam.
Definition: WakeGenerator.h:123
double hullSprayVerticalOffset
A vertical offset to the starting point of new hull spray particles.
Definition: WakeGenerator.h:114
double draft
The "draft" of the ship, or the depth the hull extends to underwater.
Definition: WakeGenerator.h:89
bool sternWaves
Whether stern wakes should be generated from this object.
Definition: WakeGenerator.h:80
float hullWakeLength
Multiplier for length of hull wake.
Definition: WakeGenerator.h:122
double hullSprayScale
The initial velocity of hull spray particles as a percent of the ship velocity (0-1)
Definition: WakeGenerator.h:110
double propWashOffset
Use this to have propeller backwash effects generated from a point different from the ship position.
Definition: WakeGenerator.h:95
bool sprayEffects
Whether you wish this wake to emit spray particles originating from this wake generator.
Definition: WakeGenerator.h:57
double bowSprayOffset
Use this to have spray particles emitted from a point different from the ship position.
Definition: WakeGenerator.h:59
double sternWaveOffset
Offset for the stern wakes.
Definition: WakeGenerator.h:82
double sternWakeMultiplier
A scaling factor applied to the stern Kelvin wake effects.
Definition: WakeGenerator.h:118
double bowWaveOffset
Offset from the ship position, along the direction of travel, at which bow waves will originate.
Definition: WakeGenerator.h:69
double bowSize
The size of the bow in world units; affects the wavelength of the bow wave, and the initial spread of...
Definition: WakeGenerator.h:76
double propWashWidthMultiplier
Multiplies the beam width by this value to arrive at the width of the prop wash effect.
Definition: WakeGenerator.h:98
double length
The length of the object generating the wake.
Definition: WakeGenerator.h:85
float hullWakeWidth
Mulitplier for width of hull wake.
Definition: WakeGenerator.h:121
double bowWaveScale
A scaling factor for the bow wave's amplitude at the bow of the ship.
Definition: WakeGenerator.h:72
bool bowWave
Whether the bow wave effect should exist on this object.
Definition: WakeGenerator.h:67
double bowWaveMax
The maximum amplitude of the bow wave, or -1.0 for unbounded.
Definition: WakeGenerator.h:74
WakeGeneratorParameters()
The constructor populates all data members with reasonable default values, although you will at a min...
double bowWakeMultiplier
A scaling factor applied to the bow Kelvin wake effect.
Definition: WakeGenerator.h:116
bool propWash
Whether you want propeller backwash effects generated from this wake generator.
Definition: WakeGenerator.h:93
int numHullSprays
How many spray particle systems are emitted periodically along the hull of the ship.
Definition: WakeGenerator.h:103
double hullSpraySizeScale
A scaling factor applied to the hull spray particles.
Definition: WakeGenerator.h:112
double propWashFadeTime
The amount of time, in seconds, over which the prop wash will dissipate.
Definition: WakeGenerator.h:100
float shipSpeedMinFoam
Minimum ship speed before foam is created.
Definition: WakeGenerator.h:124
double hullSprayEndOffset
The offset at which hull spray effects end.
Definition: WakeGenerator.h:108
double beamWidth
The width of the object generating the wake.
Definition: WakeGenerator.h:87