112 lines
3.9 KiB
C++
112 lines
3.9 KiB
C++
// Copyright (c) 2014 Sundog Software LLC. All rights reserved worldwide.
|
|
|
|
#ifndef TRITON_TIDAL_STREAM_WAKE_H
|
|
#define TRITON_TIDAL_STREAM_WAKE_H
|
|
|
|
#ifdef SWIG
|
|
%module TritonTidalStreamWake
|
|
%import "Ocean.h"
|
|
#define TRITONAPI
|
|
%{
|
|
#include "TidalStreamWake.h"
|
|
using namespace Triton;
|
|
%}
|
|
#endif
|
|
|
|
#define NUM_TS_DECALS 1
|
|
|
|
/** \file TidalStreamWake.h
|
|
\brief An object that generates a static wake wave in a given direction, such as that generated by a buoy in a tidal stream.
|
|
*/
|
|
|
|
#include "TritonCommon.h"
|
|
#include "Vector3.h"
|
|
|
|
#pragma pack(push)
|
|
#pragma pack(8)
|
|
|
|
namespace Triton
|
|
{
|
|
class Ocean;
|
|
class Decal;
|
|
|
|
/** An static wake pointing in a given direction at a fixed location, for example from a buoy or bridge pile in a current. */
|
|
class TidalStreamWake : public MemObject
|
|
{
|
|
public:
|
|
/** Construct a TidalStreamWake with the same Triton::Ocean it will be associated with.
|
|
\param pOcean The Triton::Ocean object you will associate this TidalStreamWake with. A common error is
|
|
to create a TidalStreamWake before the Ocean is created, so make sure this is a valid,
|
|
non-null pointer.
|
|
\param pSize The length of the wake generated.
|
|
\param pDraft The distance underwater this object extends.
|
|
\param pWaveMax The maximum wake wave amplitude generated by this object.
|
|
\param pOffset An offset from the object's position to the front of the wake wave.
|
|
\param pUseDecals Whether a decal texture should be applied over the wake for higher resolution appearance
|
|
from above.
|
|
\param pUseDisplacement Whether the wake will displace the ocean surface in 3D or not. For very small tidal stream
|
|
wakes, anomalies may result due to the limited resolution of the underlying water mesh.
|
|
*/
|
|
TidalStreamWake(Ocean *pOcean, double pSize, double pDraft, double pWaveMax = 1.0, double pOffset = 0,
|
|
bool pUseDecals = true, bool pUseDisplacement = true);
|
|
|
|
virtual ~TidalStreamWake();
|
|
|
|
/** For any active TidalStreamWake, this should be called every frame to update its
|
|
position and velocity. No wake will be generated until this is called.
|
|
\param pPosition The position of the object producing the wake, in world coordinates.
|
|
\param pDirection A normalized direction vector indicating the direction of the current or tidal stream.
|
|
\param pVelocity The velocity of the current generating the wake, in meters per second. This will
|
|
influence the height of the wake, up to the maximum amplitude specified in the constructor.
|
|
\param pTime The current simulated time sample, in seconds. This may be relative to any
|
|
reference point in time, as long as that reference point is consistent among
|
|
the multiple calls to Update().
|
|
*/
|
|
void TRITONAPI Update(const Vector3& pPosition, const Vector3& pDirection, double pVelocity, double pTime);
|
|
|
|
// Used internally to clear out the ocean reference when it is deleted.
|
|
void OceanDestroyed() {
|
|
ocean = 0;
|
|
registered = false;
|
|
}
|
|
|
|
// Used internally to clear out the wake manager reference when it is deleted.
|
|
void WakeManagerDestroyed() {
|
|
wakeManagerRegistered = false;
|
|
}
|
|
|
|
// Used internally when ocean quality changes
|
|
void OceanQualityChanged();
|
|
|
|
protected:
|
|
|
|
void UpdateDecals(double time, const Vector3& position, double distanceDampening, const Vector3& direction, double velocity);
|
|
|
|
float CoherentNoise(float t);
|
|
|
|
Ocean *ocean;
|
|
double draft, waveMax, size;
|
|
bool registered, wakeManagerRegistered;
|
|
double amplitudeVariance, directionVariance;
|
|
double amplitudeSpeed, directionSpeed;
|
|
double offset;
|
|
bool useDecal, useDisplacement;
|
|
|
|
float noiseVerts[256];
|
|
|
|
double decalIntensity;
|
|
Decal *decals[NUM_TS_DECALS];
|
|
float decalPeriod;
|
|
double decalStartTimes[NUM_TS_DECALS];
|
|
int currentDecal;
|
|
float decalMinScale, decalMaxScale;
|
|
Vector3 lastPosition;
|
|
double lastTime;
|
|
float animationScale;
|
|
};
|
|
}
|
|
|
|
#pragma pack(pop)
|
|
|
|
#endif
|