Triton
Visual simulation library for ocean rendering.
Environment.h
Go to the documentation of this file.
1// Copyright (c) 2011-2018 Sundog Software LLC. All rights reserved worldwide.
2
3#ifndef TRITON_ENVIRONMENT_H
4#define TRITON_ENVIRONMENT_H
5
10// Data for SWIG follows, used for automatically creating our C# wrapper. Move along...
11#ifdef SWIG
12#define TRITONAPI
13#define SL_VECTOR(a) std::vector<a>
14%module TritonEnvironment
15%include "carrays.i"
16%include "typemaps.i"
17%include "ResourceLoader.h"
18%include "WindFetch.h"
19%include "Matrix3.h"
20%include "Matrix4.h"
21%include "CoordinateSystem.h"
22%array_functions( double, double_array )
23%typemap(ctype) void * "void *"
24%typemap(imtype) void * "System.IntPtr"
25%typemap(cstype) void * "System.IntPtr"
26%typemap(csin) void * "$csinput"
27%typemap(in) void * %{ $1 = $input; %}
28%typemap(out) void * %{ $result = $1; %}
29%typemap(csout) void * {
30 return $imcall;
31 }
32%typemap(ctype) TextureHandle "void *"
33%typemap(imtype) TextureHandle"System.IntPtr"
34%typemap(cstype) TextureHandle "System.IntPtr"
35%typemap(csin) TextureHandle "$csinput"
36%typemap(in) TextureHandle %{ $1 = $input; %}
37%typemap(out) TextureHandle %{ $result = $1; %}
38%typemap(csout) TextureHandle {
39 return $imcall;
40 }
41SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
42SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
43%{
44#include "Environment.h"
45using namespace Triton;
46%}
47#endif
48
49// And now, our actual C++ header:
50#include "TritonCommon.h"
51#include "ResourceLoader.h"
53#include "WindFetch.h"
54#include "Matrix3.h"
55#include "Matrix4.h"
56#include "OrientedBoundingBox.h"
57#include "CoordinateSystem.h"
58
59#include "TritonMap.h"
60#include "TritonVector.h"
61#include "TritonSet.h"
62
63#pragma pack(push)
64#pragma pack(8)
65
66namespace Triton
67{
68class Frustum;
69class Ocean;
70class Camera;
71class Mutex;
72class Stream;
73class BindlessCapsGL;
74class OpenGLDevice;
75
79 OPENGL_2_0,
88};
89
92 SUCCEEDED = 0,
97};
98
99class HeightMapContainer
100{
101public:
102 HeightMapContainer();
103 ~HeightMapContainer();
104 TextureHandle heightMap;
105 Matrix4 heightMapMatrix;
106};
107
111public:
114
118 void SetSteepness(float pSteepness) {
119 steepness = pSteepness; ComputeDerivedValues();
120 }
121
123 void SetWavelength(float pWavelength) {
124 wavelength = pWavelength; ComputeDerivedValues();
125 }
126
128 void SetWavelengthVariance(float pWavelengthVariance) {
129 wavelengthVariance = pWavelengthVariance;
130 }
131
135 void SetWaveDirection(const Vector3& pDirection) {
136 waveDirection = pDirection;
137 waveDirection.Normalize();
138 }
139
144 void SetAutoWaveDirection(bool on) {
145 autoWaveDirection = on;
146 }
147
149 void SetAmplitude(float pAmplitude) {
150 amplitude = pAmplitude; ComputeDerivedValues();
151 }
152
154 void SetSurgeDepth(float pSurgeDepth) {
155 surgeDepth = pSurgeDepth;
156 }
157
159 void SetSteepnessVariance(float pSteepnessVariance) {
160 steepnessVariance = pSteepnessVariance;
161 }
162
167 void SetDepthFalloff(float pFalloff) {
168 depthFalloff = pFalloff;
169 }
170
171 float GetSteepness() const {return steepness;}
172 float GetWavelength() const {return wavelength;}
173 float GetWavelengthVariance() const {return wavelengthVariance;}
174 const Vector3& GetWaveDirection() const {return waveDirection;}
175 float GetAmplitude() const {return amplitude;}
176 float GetSurgeDepth() const {return surgeDepth;}
177 float GetSteepnessVariance() const {return steepnessVariance;}
178 float GetPhaseConstant() const {return phaseConstant;}
179 float GetExpK() const {return kexp;}
180 float GetSpeed() const {return speed;}
181 bool GetAutoWaveDirection() const {return autoWaveDirection;}
182 float GetDepthFalloff() const {return depthFalloff;}
183
184private:
185 float steepness;
186 float wavelength;
187 float wavelengthVariance;
188 Vector3 waveDirection;
189 float amplitude;
190 float surgeDepth;
191 float steepnessVariance;
192 void ComputeDerivedValues();
193 float phaseConstant, kexp, speed;
194 bool autoWaveDirection;
195 float depthFalloff;
196};
197
200{
201public:
202 float wavelength;
203 float height;
204 float direction;
205 float phase;
206};
207
208// Putting this in here for lack of a better place.
209typedef float (*GETUSERHEIGHTPROC)( const Vector3& position );
210
213class Environment : public MemObject
214{
215public:
218
241 EnvironmentError TRITONAPI Initialize(CoordinateSystem cs, Renderer ren, ResourceLoader *rl, void *device = NULL, bool hdr = false);
242
244 virtual ~Environment();
245
254 void TRITONAPI SetLicenseCode(const char *userName, const char *registrationCode);
255
256#ifndef SWIG
267
273 return randomNumberGenerator;
274 }
275#endif // SWIG
276
278 ResourceLoader * TRITONAPI GetResourceLoader() const {
279 return resourceLoader;
280 }
281
284 void * TRITONAPI GetDevice() const {
285 return device;
286 }
287
295 void TRITONAPI SetDirectionalLight(const Vector3& direction, const Vector3& color);
296
301 void TRITONAPI SetAmbientLight(const Vector3& color) {
302 ambientColor = color;
303 }
304
306 const Vector3& TRITONAPI GetLightDirection() const {
307 return lightDirection;
308 }
309
311 const Vector3& TRITONAPI GetDirectionalLightColor() const {
312 return lightColor;
313 }
314
316 const Vector3& TRITONAPI GetAmbientLightColor() const {
317 return ambientColor;
318 }
319
340 void TRITONAPI SetEnvironmentMap(TextureHandle cubeMap, const Matrix3& textureMatrix = Matrix3::Identity) {
341 envMap = cubeMap;
342 envMapMatrix = textureMatrix;
343 }
344
348 return envMap;
349 }
350
354 return envMapMatrix;
355 }
356
396 void TRITONAPI SetHeightMap(TextureHandle pHeightMap, const Matrix4& worldToTextureCoords, void* context=0, const Camera* camera=0);
397
404 TextureHandle TRITONAPI GetHeightMap(const Camera* camera = 0) const;
405
412 Matrix4 TRITONAPI GetHeightMapMatrix(const Camera* camera = 0) const;
413
414#ifndef SWIG
416 void TRITONAPI SetUserHeightCB( GETUSERHEIGHTPROC _userHeightCB ) {
417 userHeightCB = _userHeightCB;
418 }
419
421 GETUSERHEIGHTPROC TRITONAPI GetUserHeightCB() const {
422 return userHeightCB;
423 }
424#endif
425
431 void TRITONAPI SetHeightMapRange( float _range ) {
432 heightMapRange = _range;
433 }
434
440 void TRITONAPI SetHeightMapOffset( float _offset ) {
441 heightMapOffset = _offset;
442 }
443
445 float TRITONAPI GetHeightMapRange() const {
446 return heightMapRange;
447 }
448
450 float TRITONAPI GetHeightMapOffset() const {
451 return heightMapOffset;
452 }
453
496 void TRITONAPI SetDepthMap(TextureHandle pDepthMap);
497
500 TextureHandle TRITONAPI GetDepthMap() const {
501 return depthMap;
502 }
503
511 breakingWavesParameters = params;
512 }
513
516 return breakingWavesParameters;
517 }
518
566 void TRITONAPI SetPlanarReflectionMap(TextureHandle textureMap,
567 const Matrix3& textureMatrix,
568 float normalDisplacementScale = 0.125f) {
569 planarReflectionMap = textureMap;
570 planarReflectionMapMatrix = textureMatrix;
571 planarReflectionDisplacementScale = normalDisplacementScale;
572 }
573
577 return planarReflectionMap;
578 }
579
583 return planarReflectionMapMatrix;
584 }
585
587 float TRITONAPI GetPlanarReflectionDisplacementScale( ) const {
588 return planarReflectionDisplacementScale;
589 }
590
620 void TRITONAPI SimulateSeaState(double beaufortScale, double windDirection, bool leftHanded = false);
621
633 void TRITONAPI AddWindFetch(const WindFetch& fetch, bool leftHanded = false);
634
637 void TRITONAPI ClearWindFetches();
638
650 void TRITONAPI AddSwell(float waveLength, float waveHeight, float direction, float phase = 0, bool leftHanded = false);
651
653 void TRITONAPI ClearSwells();
654
655#ifndef SWIG
657 const TRITON_VECTOR(SwellDescription)& TRITONAPI GetSwells() const;
658#endif
659
670 void TRITONAPI SetDouglasSeaScale(int seaState, float windWaveDirection, int swellState, float swellDirection, bool leftHanded = false);
671
685 void TRITONAPI GetWind(const Vector3& pos, double& windSpeed, double& windDirection, double& fetchLength) const;
686
693 void TRITONAPI SetSeaLevel(double altitudeMSL) {
694 seaLevel = altitudeMSL;
695 }
696
700 double TRITONAPI GetSeaLevel() const {
701 return seaLevel;
702 }
703
714 void TRITONAPI SetAboveWaterVisibility(double visibility, const Vector3& fogColor) {
715 aboveWaterVisibility = visibility;
716 aboveWaterFogColor = fogColor;
717 }
718
723 void TRITONAPI GetAboveWaterVisibility(double& visibility, Vector3& fogColor) const {
724 visibility = aboveWaterVisibility;
725 fogColor = aboveWaterFogColor;
726 }
727
740 void TRITONAPI SetBelowWaterVisibility(double visibility, const Vector3& fogColor) {
741 belowWaterVisibility = visibility;
742 belowWaterFogColor = fogColor;
743 }
744
749 void TRITONAPI GetBelowWaterVisibility(double& visibility, Vector3& fogColor) const {
750 visibility = belowWaterVisibility;
751 fogColor = belowWaterFogColor;
752 }
753
761 void TRITONAPI SetWaveBlendDepth(double depth) {
762 blendDepth = depth;
763 hasBlendDepth = true;
764 }
765
771 double TRITONAPI GetWaveBlendDepth() const {
772 if (hasBlendDepth) {
773 return blendDepth;
774 } else {
775 return belowWaterVisibility;
776 }
777 }
778
782 void TRITONAPI SetSunIntensity(float intensity) {
783 sunIntensity = intensity;
784 }
785
788 float TRITONAPI GetSunIntensity() const {
789 return sunIntensity;
790 }
791
795 void TRITONAPI SetWorldUnits(double worldUnits) {
796 units = worldUnits;
797 }
798
800 double TRITONAPI GetWorldUnits() const {
801 return units;
802 }
803
806 CoordinateSystem TRITONAPI GetCoordinateSystem() const {
807 return coordinateSystem;
808 }
809
813 bool TRITONAPI IsGeocentric() const {
814 return coordinateSystem < FLAT_ZUP;
815 }
816
819 Renderer TRITONAPI GetRenderer() const {
820 return renderer;
821 }
822
824 bool TRITONAPI IsOpenGL() const {
825 return renderer < DIRECTX_9;
826 }
827
829 bool TRITONAPI IsDirectX() const {
830 return renderer >= DIRECTX_9 && renderer != NO_RENDERER;
831 }
832
847 void TRITONAPI SetCameraMatrix(const double *m, const double *explicitCameraPosition = 0);
848
856 void TRITONAPI SetProjectionMatrix(const double *p);
857
869 void TRITONAPI SetViewport(int x, int y, int width, int height);
870
879 void TRITONAPI SetZoomLevel(float zoom) { zoomLevel = zoom; }
880
885 float TRITONAPI GetZoomLevel() const { return zoomLevel; }
886
889 void TRITONAPI SetUserDefinedVertString( const char *userDefinedString );
890
893 void TRITONAPI SetUserDefinedFragString( const char *userDefinedString );
894
897 const char * TRITONAPI GetUserDefinedVertString() const { return userDefinedVertString; }
898
901 const char * TRITONAPI GetUserDefinedFragString() const { return userDefinedFragString; }
902
915 bool TRITONAPI GetViewport(int& x, int& y, int& width, int& height) const;
916
919 const Camera* TRITONAPI GetCamera() const { return camera; };
920
923 Camera* TRITONAPI GetCamera() { return camera; };
924
927 Camera* TRITONAPI CreateCamera(void);
928
931 void TRITONAPI DestroyCamera(Camera* camera);
932
933#ifndef SWIG
936 const TRITON_SET(Camera*)& GetCameras(void) const;
937#endif
938
943 const double * TRITONAPI GetCameraMatrix() const;
944
949 const double * TRITONAPI GetProjectionMatrix() const;
950
956 const double * TRITONAPI GetCameraPosition() const;
957
964 Vector3 TRITONAPI GetUpVector() const;
965
972 Vector3 TRITONAPI GetRightVector() const;
973
979 void TRITONAPI SetConfigOption(const char *key, const char *value);
980
986 const char * TRITONAPI GetConfigOption(const char *key);
987
994 bool TRITONAPI CullSphere(const Vector3& position, double radius) const;
995
996 bool TRITONAPI CullOrientedBoundingBox(const OrientedBoundingBox& obb) const;
997
999 const bool TRITONAPI GetHDREnabled() const {
1000 return hdr;
1001 }
1002
1008 void TRITONAPI EnableOpenMP(bool enabled) {
1009 useOpenMP = enabled;
1010 }
1011
1015 bool TRITONAPI GetOpenMPEnabled() const {
1016 return useOpenMP;
1017 }
1018
1021 float TRITONAPI GetMaximumWaveHeight() const;
1022
1032 void TRITONAPI SetCurrent(const Vector3& direction, double speed) { currentDirection = direction; currentSpeed = speed; }
1033
1035 void TRITONAPI GetCurrent(Vector3& direction, double& speed) const { direction = currentDirection, speed = currentSpeed; }
1036
1039 void TRITONAPI SetWaterTransparency(float t) {
1040 transparency = t;
1041 }
1042
1044 float TRITONAPI GetWaterTransparency() const {
1045 return transparency;
1046 }
1047
1049 Stream* TRITONAPI CreateOpenGLStream(void);
1050
1052 void TRITONAPI DestroyOpenGLStream(Stream* stream);
1053
1055 void TRITONAPI ExecuteOpenGLStream(Stream* stream);
1056
1058 void TRITONAPI ResetOpenGLStream(Stream* stream);
1059
1060#ifndef SWIG
1061
1062 // Internal use only:
1063 void RegisterOcean(Ocean *ocean);
1064 void UnregisterOcean(Ocean *ocean);
1065 bool GetConfusedSeas() const {return confusedSeas;}
1066 void TRITONAPI SetBreakingWaveMap(TextureHandle pBreakingWaveMap, const Matrix4& worldToTextureCoords);
1067 TextureHandle TRITONAPI GetBreakingWaveMap() const {
1068 return breakingWaveMap;
1069 }
1070 Matrix4 TRITONAPI GetBreakingWaveMapMatrix() const {
1071 return breakingWaveMapMatrix;
1072 }
1073
1074 void GetUpRightInVectors(const Vector3& position, Vector3& up, Vector3& right, Vector3& in) const;
1075
1076 TextureHandle GetHeightMapAndMatrix(Matrix4& heightMapMatrix, const Camera* camera) const;
1077
1079 const BindlessCapsGL* GetBindlessCaps(void) const;
1080
1082 const OpenGLDevice* GetOpenGLDevice(void) const;
1083protected:
1084
1085 void TRITONAPI DestroyAllCameras(void);
1086
1087 float adjustDirectionForLeftHanded(float radians);
1088
1089 CoordinateSystem coordinateSystem;
1090
1091 void *device;
1092
1093 Renderer renderer;
1094
1095 ResourceLoader *resourceLoader;
1096
1097 RandomNumberGenerator *randomNumberGenerator, *defaultRandomNumberGenerator;
1098
1099 TRITON_VECTOR(WindFetch) windFetches;
1100
1101 TRITON_VECTOR(Ocean *) oceans;
1102
1104
1105 bool confusedSeas;
1106
1107 Camera* camera;
1108
1109 TRITON_SET(Camera*) cameras;
1110
1111 double units;
1112
1113 Vector3 lightDirection, lightColor, ambientColor;
1114
1115 double seaLevel;
1116
1117 bool hdr, useOpenMP;
1118
1119 double aboveWaterVisibility, belowWaterVisibility;
1120
1121 float sunIntensity;
1122
1123 Vector3 aboveWaterFogColor, belowWaterFogColor;
1124
1125 TextureHandle envMap, breakingWaveMap, depthMap;
1126
1127 GETUSERHEIGHTPROC userHeightCB;
1128
1129 float heightMapRange, heightMapOffset;
1130
1131 Matrix3 envMapMatrix;
1132
1133 Matrix4 breakingWaveMapMatrix;
1134
1135 typedef TRITON_MAP(const Camera*, HeightMapContainer) MapCameraToHeightMapConfig;
1136 MapCameraToHeightMapConfig mapCameraToHeightMapConfig;
1137 Mutex* heightMapMutex;
1138
1139 TextureHandle planarReflectionMap;
1140
1141 Matrix3 planarReflectionMapMatrix;
1142
1143 float planarReflectionDisplacementScale;
1144
1145 Frustum *frustum;
1146
1147 BreakingWavesParameters breakingWavesParameters;
1148
1149 bool doHeightMapCopy;
1150
1151 float douglasShortWL, douglasAvgWL, douglasLongWL;
1152 float douglasLowHeight, douglasModerateHeight, douglasHighHeight;
1153
1154 float zoomLevel;
1155
1156 char *userDefinedVertString;
1157 char *userDefinedFragString;
1158
1159 double blendDepth;
1160 bool hasBlendDepth;
1161
1162 Vector3 currentDirection;
1163 double currentSpeed;
1164
1165 float transparency;
1166
1167 TRITON_SET(Stream*) streams;
1168 void DestroyAllOpenGLStreams();
1169 void DestroyOpenGLDevice();
1170#endif // SWIG
1171
1172};
1173}
1174
1175#pragma pack(pop)
1176
1177#endif
The public interface for setting Triton's environmental parameters.
EnvironmentError
Error codes returned from Environment::Initialize().
Definition: Environment.h:91
@ NO_CONFIG_FOUND
Indicates the initialization succeeded.
Definition: Environment.h:93
@ NULL_RESOURCE_LOADER
The Triton.config file could not be loaded, which likely means you created your ResourceLoader with a...
Definition: Environment.h:94
@ NO_CONTEXT
A null device was passed in, and you're using a DirectX renderer that requires one.
Definition: Environment.h:96
@ NO_DEVICE
A null pointer was passed in for the ResourceLoader object.
Definition: Environment.h:95
Renderer
Support renderers for the Environment constructor.
Definition: Environment.h:78
@ DIRECTX_11
Direct3D9Ex device.
Definition: Environment.h:86
@ OPENGL_3_2
Targets devices capable of OpenGL 2.0 functionality.
Definition: Environment.h:80
@ OPENGL_4_5
OpenGL 4.1, compatible with backward or non-backward-compatible contexts.
Definition: Environment.h:83
@ DIRECT3D9_EX
DirectX9 device.
Definition: Environment.h:85
@ NO_RENDERER
DirectX11 device.
Definition: Environment.h:87
@ OPENGL_4_0
OpenGL 3.2, compatible with backward or non-backward-compatible contexts.
Definition: Environment.h:81
@ OPENGL_4_1
OpenGL 4.0, compatible with backward or non-backward-compatible contexts.
Definition: Environment.h:82
@ DIRECTX_9
OpenGL 4.5, compatible with backward or non-backward-compatible contexts.
Definition: Environment.h:84
Implements a 3x3 matrix and its operations.
An implementation of a 4x4 matrix and some simple operations on it.
A class describing an oriented bounding box.
An interface for overriding Triton's generation of random numbers.
A class for loading Triton's resources from mass storage, which you may extend.
Common typedefs and defines used within Triton.
int TextureHandle
A renderer-agnostic handle for a texture.
Definition: TritonCommon.h:56
A localized or global area of wind of given speed and direction.
Parameters to control behavior of breaking waves at shorelines, used by Environment::SetBreakingWaves...
Definition: Environment.h:110
void SetWaveDirection(const Vector3 &pDirection)
The normalized direction vector pointing toward the shoreline.
Definition: Environment.h:135
void SetWavelengthVariance(float pWavelengthVariance)
How much the wavelength varies as the wave approaches the shore.
Definition: Environment.h:128
void SetAutoWaveDirection(bool on)
Sets whether the direction of the waves should be automatically determined by examining the overall s...
Definition: Environment.h:144
void SetSteepness(float pSteepness)
The "k" value controlling the steepness of the waves; 0 is rounded sine wave, 1.0 is pointy.
Definition: Environment.h:118
void SetAmplitude(float pAmplitude)
The amplitude of the breaking waves.
Definition: Environment.h:149
void SetSteepnessVariance(float pSteepnessVariance)
The variance in steepness as the wave approaches the shore.
Definition: Environment.h:159
void SetSurgeDepth(float pSurgeDepth)
The depth at which the wavelength will rapidly expand to simulate surging surf.
Definition: Environment.h:154
void SetWavelength(float pWavelength)
The starting wavelength of the breaking waves.
Definition: Environment.h:123
void SetDepthFalloff(float pFalloff)
How quickly breaking waves fade off as a function of water depth.
Definition: Environment.h:167
BreakingWavesParameters()
The constructor sets reasonable default values, except for the waveDirection member which we can't re...
Triton's public interface for specifying the camera properties.
Definition: Camera.h:37
Triton's public interface for specifying the environmental conditions and camera properties.
Definition: Environment.h:214
Vector3 TRITONAPI GetUpVector() const
Retrieves a normalized vector pointing "up", based on the coordinate system specified in Environment:...
TextureHandle TRITONAPI GetEnvironmentMap() const
Retrieves the environment cube map passed in via SetEnvironmentMap(), which may be a GLuint,...
Definition: Environment.h:347
const Vector3 &TRITONAPI GetAmbientLightColor() const
Retrieves the RGB color of the ambient light passed in via SetAmbientLight().
Definition: Environment.h:316
void TRITONAPI ClearSwells()
Clears any swells previously added via AddSwell().
Vector3 TRITONAPI GetRightVector() const
Retrieves a normalized vector pointing "right", based on the coordinate system specified in Environme...
void TRITONAPI SetHeightMapRange(float _range)
Sets a height map multiplier.
Definition: Environment.h:431
void TRITONAPI SetHeightMapOffset(float _offset)
Sets a height map offset.
Definition: Environment.h:440
TextureHandle TRITONAPI GetPlanarReflectionMap() const
Retrieves the environment cube map passed in via SetPlanarReflectionMap(), which may be a GLuint,...
Definition: Environment.h:576
float TRITONAPI GetSunIntensity() const
Retrieves the intensity of the transmitted direct sunlight on the water surface, as set with SetSunIn...
Definition: Environment.h:788
void TRITONAPI EnableOpenMP(bool enabled)
Sets Triton's usage of OpenMP to enable parallel proccessing of CPU-intensive tasks across multiple C...
Definition: Environment.h:1008
void TRITONAPI SetConfigOption(const char *key, const char *value)
Sets a configuration setting (defaults in resources/triton.config.) Many settings are read at initial...
void TRITONAPI SetViewport(int x, int y, int width, int height)
Informs Triton of the current viewport position and size.
void TRITONAPI SetBreakingWavesParameters(const BreakingWavesParameters &params)
Configures the parameters used to simulate breaking waves at shorelines.
Definition: Environment.h:510
void TRITONAPI AddSwell(float waveLength, float waveHeight, float direction, float phase=0, bool leftHanded=false)
Adds a swell wave to the ocean conditions in addition to the local wind waves.
Camera *TRITONAPI GetCamera()
Deprecated method to get Triton Camera.
Definition: Environment.h:923
bool TRITONAPI IsOpenGL() const
Returns whether the Renderer specified in the Envrionment() constructor is an OpenGL renderer.
Definition: Environment.h:824
void TRITONAPI SetPlanarReflectionMap(TextureHandle textureMap, const Matrix3 &textureMatrix, float normalDisplacementScale=0.125f)
Passes in an optional planar reflection map used for rendering local reflections in the water.
Definition: Environment.h:566
void TRITONAPI SetBelowWaterVisibility(double visibility, const Vector3 &fogColor)
Sets the simulated atmospheric visibility below the water, used to fog out the surface of the water w...
Definition: Environment.h:740
void TRITONAPI SetLicenseCode(const char *userName, const char *registrationCode)
Licensed users must call SetLicenseCode with your user name and registration code prior to using the ...
void TRITONAPI SetRandomNumberGenerator(RandomNumberGenerator *rng)
Set a custom RandomNumberGenerator - derived random number generator, to override Triton's default us...
RandomNumberGenerator *TRITONAPI GetRandomNumberGenerator() const
Returns either the default RandomNumberGenerator used for all random numbers in Triton,...
Definition: Environment.h:272
void TRITONAPI GetBelowWaterVisibility(double &visibility, Vector3 &fogColor) const
Retrieves the below-water visibility settings previously set with SetBelowWaterVisibility().
Definition: Environment.h:749
const TRITON_SET(Camera *) &GetCameras(void) const
Get all cameras.
float TRITONAPI GetZoomLevel() const
Retrieves any zoom level previously set with SetZoomLevel(), or 1.0 if default.
Definition: Environment.h:885
const char *TRITONAPI GetUserDefinedFragString() const
Retrieves the user defined fragment string previously set with SetUserDefinedFragString.
Definition: Environment.h:901
void TRITONAPI SetEnvironmentMap(TextureHandle cubeMap, const Matrix3 &textureMatrix=Matrix3::Identity)
Passes in an optional environment cube map used for rendering reflections in the water.
Definition: Environment.h:340
void TRITONAPI GetAboveWaterVisibility(double &visibility, Vector3 &fogColor) const
Retrieves the above-water visibility settings previously set with SetAboveWaterVisibility().
Definition: Environment.h:723
void *TRITONAPI GetDevice() const
Retrieves the DirectX device pointer passed in to the Environment() constructor, or an internal OpenG...
Definition: Environment.h:284
void TRITONAPI SetCameraMatrix(const double *m, const double *explicitCameraPosition=0)
Sets the modelview matrix used for rendering the ocean; this must be called every frame prior to call...
EnvironmentError TRITONAPI Initialize(CoordinateSystem cs, Renderer ren, ResourceLoader *rl, void *device=NULL, bool hdr=false)
Initializes the environment prior to use.
void TRITONAPI SetCurrent(const Vector3 &direction, double speed)
Sets a simulated current in the given direction at the given speed.
Definition: Environment.h:1032
TextureHandle TRITONAPI GetHeightMap(const Camera *camera=0) const
Retrieves the height map passed in via SetHeightMap(), which may be a GLuint, LPDIRECT3DTEXTURE9,...
void TRITONAPI ClearWindFetches()
Removes all wind fetches or sea state simulations from the simulated environment, resulting in a perf...
void TRITONAPI GetCurrent(Vector3 &direction, double &speed) const
Retrieves the current direction and speed previously set with SetCurrent().
Definition: Environment.h:1035
ResourceLoader *TRITONAPI GetResourceLoader() const
Retrieves the ResourceLoader object passed in to the Environment() constructor.
Definition: Environment.h:278
void TRITONAPI SimulateSeaState(double beaufortScale, double windDirection, bool leftHanded=false)
Simulates a specific sea state on the Beaufort scale, by clearing out any existing wind fetches passe...
const Vector3 &TRITONAPI GetLightDirection() const
Retrieves the vector toward the infinitely distant directional light source passed in via SetDirectio...
Definition: Environment.h:306
const Vector3 &TRITONAPI GetDirectionalLightColor() const
Retrieves the RGB color of the directional light source passed in via SetDirectionalLight().
Definition: Environment.h:311
Matrix3 TRITONAPI GetPlanarReflectionMapMatrix() const
Retrieves the texture matrix used to transform the planar reflection map lookups at runtime,...
Definition: Environment.h:582
void TRITONAPI SetAmbientLight(const Vector3 &color)
Sets the color of ambient light used to light the water, as from skylight.
Definition: Environment.h:301
Stream *TRITONAPI CreateOpenGLStream(void)
Create an OpenGL stream.
float TRITONAPI GetHeightMapOffset() const
Retrieves the heightmap offset.
Definition: Environment.h:450
Renderer TRITONAPI GetRenderer() const
Returns the Renderer specified in the Environment() constructor, telling you what flavor of OpenGL or...
Definition: Environment.h:819
void TRITONAPI SetDouglasSeaScale(int seaState, float windWaveDirection, int swellState, float swellDirection, bool leftHanded=false)
Simulate conditions as described by the Douglas sea scale (http://en.wikipedia.org/wiki/Douglas_Sea_S...
TextureHandle TRITONAPI GetDepthMap() const
Retrieves the depth map passed in via SetDepthMap(), which may be a GLuint, LPDIRECT3DTEXTURE9,...
Definition: Environment.h:500
bool TRITONAPI GetOpenMPEnabled() const
Retrieves whether OpenMP has been enabled to take advantage of multi-core CPU's.
Definition: Environment.h:1015
double TRITONAPI GetWorldUnits() const
Retrieves the size of one world unit, in meters.
Definition: Environment.h:800
void TRITONAPI SetWaveBlendDepth(double depth)
Sets the ocean depth at which wave heights will start to become dampened, and the water will start be...
Definition: Environment.h:761
void TRITONAPI GetWind(const Vector3 &pos, double &windSpeed, double &windDirection, double &fetchLength) const
Computes the wind conditions at a given location, by evaluating all WindFetch objects that include th...
void TRITONAPI ExecuteOpenGLStream(Stream *stream)
Execute an OpenGL stream.
void TRITONAPI SetUserHeightCB(GETUSERHEIGHTPROC _userHeightCB)
Sets an optional user-provided callback to obtain height data.
Definition: Environment.h:416
void TRITONAPI SetSunIntensity(float intensity)
Sets the intensity of the sunlight visible at the ocean surface; used to modulate the specular highli...
Definition: Environment.h:782
Camera *TRITONAPI CreateCamera(void)
Create a camera.
void TRITONAPI SetAboveWaterVisibility(double visibility, const Vector3 &fogColor)
Sets the simulated atmospheric visibility above the water, used to fog out the surface of the water w...
Definition: Environment.h:714
Matrix4 TRITONAPI GetHeightMapMatrix(const Camera *camera=0) const
Retrieves the texture matrix used to transform the height map lookups at runtime, which was passed in...
void TRITONAPI ResetOpenGLStream(Stream *stream)
Reset an OpenGL stream.
float TRITONAPI GetPlanarReflectionDisplacementScale() const
Retrieves normal displacement scale set for planar reflections via SetPlanarReflectionMap().
Definition: Environment.h:587
const TRITON_VECTOR(SwellDescription) &TRITONAPI GetSwells() const
Retrieves the list of swells added via AddSwell() following startup or the last call to ClearSwells()...
const char *TRITONAPI GetConfigOption(const char *key)
Retrieves the configuration setting for the given configuration key, as set in resources/triton....
const double *TRITONAPI GetCameraPosition() const
Retrieves an array of 3 doubles representing the X, Y, and Z position of the camera,...
const bool TRITONAPI GetHDREnabled() const
Retrieves whether HDR mode is enabled, indicating whether color values are clamped to [0,...
Definition: Environment.h:999
const BindlessCapsGL * GetBindlessCaps(void) const
In OpenGL, get the capabilities of the device; used only internally.
const OpenGLDevice * GetOpenGLDevice(void) const
In OpenGL, get the OpenGL device; used only internally.
void TRITONAPI SetWaterTransparency(float t)
Sets an explicit transparency on the water surface.
Definition: Environment.h:1039
bool TRITONAPI IsGeocentric() const
Returns whether the CoordinateSystem passed into the Environment() constructor is geocentric,...
Definition: Environment.h:813
void TRITONAPI SetWorldUnits(double worldUnits)
Sets the size of one world unit in meters.
Definition: Environment.h:795
bool TRITONAPI CullSphere(const Vector3 &position, double radius) const
Returns true if the given sphere lies within the view frustum, as defined by the modelview - projecti...
bool TRITONAPI IsDirectX() const
Returns whether the Renderer specified in the Environment() constructor is a DirectX renderer.
Definition: Environment.h:829
float TRITONAPI GetWaterTransparency() const
Gets the explicit transparency of the water set via SetWaterTransparency().
Definition: Environment.h:1044
void TRITONAPI SetHeightMap(TextureHandle pHeightMap, const Matrix4 &worldToTextureCoords, void *context=0, const Camera *camera=0)
Optionally sets a height map used by Triton for improved water / shoreline interactions.
const Camera *TRITONAPI GetCamera() const
Deprecated method to get Triton Camera.
Definition: Environment.h:919
const char *TRITONAPI GetUserDefinedVertString() const
Retrieves the user defined vertex string previously set with SetUserDefinedVertString.
Definition: Environment.h:897
const double *TRITONAPI GetCameraMatrix() const
Retrieves an array of 16 doubles representing the modelview matrix passed in via SetCameraMatrix().
GETUSERHEIGHTPROC TRITONAPI GetUserHeightCB() const
Retrieves the function pointer for the user-provided height callback.
Definition: Environment.h:421
float TRITONAPI GetMaximumWaveHeight() const
Gets the estimated maximum wave height in meters at the camera position, given the current wind and s...
bool TRITONAPI GetViewport(int &x, int &y, int &width, int &height) const
Retrieves any viewport information previously set via SetViewport().
void TRITONAPI SetUserDefinedVertString(const char *userDefinedString)
Sets a user defined string to be prepended to all vertex shaders.
void TRITONAPI SetUserDefinedFragString(const char *userDefinedString)
Sets a user defined string to be prepended to all fragment shaders.
const double *TRITONAPI GetProjectionMatrix() const
Retrieves an array of 16 doubles representing the projection matrix passed in via SetProjectionMatrix...
void TRITONAPI SetDirectionalLight(const Vector3 &direction, const Vector3 &color)
Sets the color and direction of directional light used to light the water, as from the sun or moon.
const BreakingWavesParameters &TRITONAPI GetBreakingWavesParameters() const
Retrieves the current parameters for breaking waves.
Definition: Environment.h:515
void TRITONAPI SetProjectionMatrix(const double *p)
Sets the projection matrix used for rendering the ocean; this must be called every frame prior to cal...
virtual ~Environment()
Virtual destructor.
void TRITONAPI DestroyCamera(Camera *camera)
Destroy a camera.
Environment()
Constructor.
void TRITONAPI SetDepthMap(TextureHandle pDepthMap)
Optionally sets a depth texture map used for terrain / water blending at coastlines.
float TRITONAPI GetHeightMapRange() const
Retrieves the height map range.
Definition: Environment.h:445
void TRITONAPI SetSeaLevel(double altitudeMSL)
If you want to change the mean sea level from a height of 0 in flat-earth coordinates,...
Definition: Environment.h:693
CoordinateSystem TRITONAPI GetCoordinateSystem() const
Returns the CoordinateSystem passed into the Environment() constructor, indicating the up vector and ...
Definition: Environment.h:806
void TRITONAPI SetZoomLevel(float zoom)
If your camera is being zoomed from its typical field of view, use this method to let Triton know abo...
Definition: Environment.h:879
double TRITONAPI GetSeaLevel() const
Returns the offset for the mean sea level previously set by SetSeaLevel().
Definition: Environment.h:700
Matrix3 TRITONAPI GetEnvironmentMapMatrix() const
Retrieves the texture matrix used to transform the environment map lookups at runtime,...
Definition: Environment.h:353
void TRITONAPI AddWindFetch(const WindFetch &fetch, bool leftHanded=false)
Adds a Triton::WindFetch to the environment, which specifies an area of wind of a given speed and dir...
double TRITONAPI GetWaveBlendDepth() const
Retrieves the ocean depth at which wave heights will start to become dampened, and the water will sta...
Definition: Environment.h:771
void TRITONAPI DestroyOpenGLStream(Stream *stream)
Destroy an OpenGL stream.
A simple 3x3 matrix class and its operations.
Definition: Matrix3.h:30
An implementation of a 4x4 matrix and some simple operations on it.
Definition: Matrix4.h:30
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
An oriented bounding box defined by a center point and three axes.
Definition: OrientedBoundingBox.h:18
An interface for generating random numbers in Triton.
Definition: RandomNumberGenerator.h:21
This class is used whenever Triton needs to load textures, data files, or shaders from mass storage; ...
Definition: ResourceLoader.h:40
A structure containing a description of a swell in addition to local wind waves (from a distant storm...
Definition: Environment.h:200
float direction
Wave height, from peak to trough.
Definition: Environment.h:204
float phase
Direction in radians.
Definition: Environment.h:205
float height
Wavelength in world units, from peak to peak.
Definition: Environment.h:203
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36
void TRITONAPI Normalize()
Scales the vector to be of length 1.0.
Definition: Vector3.h:67
A localized or global area of wind of given speed and direction.
Definition: WindFetch.h:27