dtCore::ShaderParamOscillator Class Reference

This class is a shader parameter that has an oscillating parameter. More...

#include <shaderparamoscillator.h>

Inheritance diagram for dtCore::ShaderParamOscillator:

dtCore::ShaderParameter dtCore::Base

List of all members.

Public Member Functions

 ShaderParamOscillator (const std::string &name)
 Constructs the float parameter.
virtual const
ShaderParameter::ParamType
GetType () const
 Gets the type of this parameter.
virtual void AttachToRenderState (osg::StateSet &stateSet)
 Assigns the necessary uniform variables for this parameter to the render state.
virtual void Update ()
 Method called by the shader owning this parameter if it detects the parameter has changed state.
void SetValue (float newValue)
 Sets the value - temporarily.
float GetValue () const
 Gets the current value in this parameter.
virtual ShaderParameterClone ()
 Makes a deep copy of the Shader Parameter.
void SetOffset (float offset)
 The starting point for the timer oscillation.
float GetOffset () const
 Gets the starting point for the timer oscillation.
float GetCurrentRange () const
 Gets the current range.
void SetRangeMin (float minimum)
 The minimum range value for the timer.
float GetRangeMin () const
 The minimum range value for the timer.
void SetRangeMax (float maximum)
 The max range value for the timer.
float GetRangeMax () const
 The max range value for the timer.
float GetCurrentCycleTime () const
 Gets the current cycle time.
void SetCycleTimeMin (float cycleTimeMin)
 The minimum amount for Cycle time.
float GetCycleTimeMin () const
 The min amount of cycle time (see SetCycleTimeMin().
void SetCycleTimeMax (float cycleTimeMax)
 The maximum amount for Cycle time.
float GetCycleTimeMax () const
 The max amount of cycle time (see SetCycleTimeMax().
void SetCycleCountTotal (int newCount)
 
Parameters:
count The number of cycles that will happen before oscillation stops.

float GetCycleCountTotal () const
 
Returns:
The number of cycles that will happen before oscillation stops.

void SetUseRealTime (bool useRealTime)
 Indicates whether we use real time or simulation time to do our cycle.
bool GetUseRealTime () const
 Gets the texture unit currently assigned to this shader parameter.
void SetOscillationType (const OscillationType &type)
 Sets the way that the timer oscillates values.
const OscillationTypeGetOscillationType () const
 Gets the source texture type of this parameter.
void SetOscillationTrigger (const OscillationTrigger &type)
 Sets when the timer will begin to oscillate its value.
const OscillationTriggerGetOscillationTrigger () const
 Returns the way that the oscillator will begin.
const float GetCycleDirection () const
 Returns the current cycle direction.
virtual void OnMessage (MessageData *data)
 Called by the dtCore::Base class - used to get timer updates.
void TriggerOscillationStart ()
 Triggers the oscillation to begin if the trigger type is 'manual' Otherwise, it resets the current oscillation to their starting defaults.

Static Public Attributes

static const int INFINITE_CYCLE = -1

Protected Member Functions

virtual ~ShaderParamOscillator ()
void DoShaderUpdate (float timeDelta)
 Does the actual work for the shader.

Classes

class  OscillationTrigger
 The type of trigger for this parameter. More...
class  OscillationType
 The type of oscillation for this parameter. More...


Detailed Description

This class is a shader parameter that has an oscillating parameter.

If you assign this to a node, it will oscillate the value as if it were a time constraint.


Constructor & Destructor Documentation

dtCore::ShaderParamOscillator::ShaderParamOscillator ( const std::string &  name  ) 

Constructs the float parameter.

Parameters:
name Name given to this parameter. If it is to be used in a hardware shader, this name must match the corresponding uniform variable in the shader.

dtCore::ShaderParamOscillator::~ShaderParamOscillator (  )  [protected, virtual]


Member Function Documentation

virtual const ShaderParameter::ParamType& dtCore::ShaderParamOscillator::GetType (  )  const [inline, virtual]

Gets the type of this parameter.

Implements dtCore::ShaderParameter.

void dtCore::ShaderParamOscillator::AttachToRenderState ( osg::StateSet &  stateSet  )  [virtual]

Assigns the necessary uniform variables for this parameter to the render state.

This allows the parameter to communicate to the underlying shader.

Implements dtCore::ShaderParameter.

void dtCore::ShaderParamOscillator::Update (  )  [virtual]

Method called by the shader owning this parameter if it detects the parameter has changed state.

This method when called, sends the current float value in this parameter to the hardware shader. Since this value oscillates continuously, it will push the value every tick.

Implements dtCore::ShaderParameter.

void dtCore::ShaderParamOscillator::SetValue ( float  newValue  )  [inline]

Sets the value - temporarily.

This method is only provided for consistency. Because this parameter oscillates, the value you set will be overridden. Typically, you should never call this method.

Parameters:
newValue The new value to set - only changed temporarily until next tick.
Note:
This does NOT change the param on the actual uniform, just internally until next tick.

float dtCore::ShaderParamOscillator::GetValue (  )  const [inline]

Gets the current value in this parameter.

Returns:
The current floating point value.

ShaderParameter * dtCore::ShaderParamOscillator::Clone (  )  [virtual]

Makes a deep copy of the Shader Parameter.

Used when a user assigns a shader to a node because we clone the template shader and its parameters. Note - Like Update(), this is a pure virtual method that must be implemented on each param.

Implements dtCore::ShaderParameter.

void dtCore::ShaderParamOscillator::SetOffset ( float  offset  )  [inline]

The starting point for the timer oscillation.

In [1.0, 5.0], this would be 1.0. For [-8.0, 12.0], this would be -8.0. Default is 0.0.

Parameters:
offset The offset from zero for the bottom value of the timer.
Note:
Marks as dirty so it will cause a recalculation.

float dtCore::ShaderParamOscillator::GetOffset (  )  const [inline]

Gets the starting point for the timer oscillation.

In [1.0, 5.0], this would be 1.0. For [-8.0, 12.0], this would be -8.0.

Returns:
The offset from zero for the bottom value of the timer.

float dtCore::ShaderParamOscillator::GetCurrentRange (  )  const [inline]

Gets the current range.

Remember offset is the 'bottom', and the 'top' is offset + range. Whenever a tick happens where IsDirty() is true, this value is recomputed.

Returns:
The texture unit.
Note:
This is not settable. Set the RangeMin and/or RangeMax to cause a change in this.

void dtCore::ShaderParamOscillator::SetRangeMin ( float  minimum  )  [inline]

The minimum range value for the timer.

On first update (or first update after a dirty), the min and max are used to compute an actual range. Then, the timer will oscillate between the 'bottom' (offset) and the 'top' (offset plus range). Default is 1.0.

Parameters:
minimum The minimum value for the range. Is reset to <= max on next dirty Update.
Note:
Marks as dirty so it will cause a recalculation. Negative ranges are not allowed (will reset to 1 on Update).

float dtCore::ShaderParamOscillator::GetRangeMin (  )  const [inline]

The minimum range value for the timer.

On first update (or first update after a dirty), the min and max are used to compute an actual range. Then, the timer will oscillate between the 'bottom' (offset) and the 'top' (offset plus range).

Returns:
The minimum range

void dtCore::ShaderParamOscillator::SetRangeMax ( float  maximum  )  [inline]

The max range value for the timer.

On first update (or first update after a dirty), the min and max are used to compute an actual range. Then, the timer will oscillate between the 'bottom' (offset) and the 'top' (offset plus range). Default is 1.0.

Parameters:
maximum The max value for the range. Is reset to >= min on next dirty Update.
Note:
Marks as dirty so it will cause a recalculation. Negative ranges are not allowed (will reset to 1 on Update).

float dtCore::ShaderParamOscillator::GetRangeMax (  )  const [inline]

The max range value for the timer.

On first update (or first update after a dirty), the min and max are used to compute an actual range. Then, the timer will oscillate between the 'bottom' (offset) and the 'top' (offset plus range).

Returns:
The maximum range

float dtCore::ShaderParamOscillator::GetCurrentCycleTime (  )  const [inline]

Gets the current cycle time.

This is the actual amount of time (in seconds) that it takes to go from bottom to top (or reverse). 2X this for a full oscillation. This value is NOT settable. Whenever a tick happens where IsDirty() is true, this value is recomputed.

Returns:
The texture unit.
Note:
This is not settable. Set the CycleTimeMin and/or CycleTimeMax to cause a change in this.

void dtCore::ShaderParamOscillator::SetCycleTimeMin ( float  cycleTimeMin  )  [inline]

The minimum amount for Cycle time.

Cycle Time is defined as the amount of time (in seconds) it takes to go from bottom to top, or reverse. Note, if oscillating up and down or down and up, the complete cycle will take 2X cycle time. Default is 1.0.

Parameters:
cycleTime The time in secs to go from bottom to top or top to bottom.
Note:
Marks as dirty so it will cause a recalculation. Negative ranges are not allowed (will reset to 1 on Update).

float dtCore::ShaderParamOscillator::GetCycleTimeMin (  )  const [inline]

The min amount of cycle time (see SetCycleTimeMin().

Returns:
The min cycle time.

void dtCore::ShaderParamOscillator::SetCycleTimeMax ( float  cycleTimeMax  )  [inline]

The maximum amount for Cycle time.

Cycle Time is defined as the amount of time (in seconds) it takes to go from bottom to top, or reverse. Note, if oscillating up and down or down and up, the complete cycle will take 2X cycle time. Default is 1.0.

Parameters:
cycleTimeMax The time in secs to go from bottom to top or top to bottom.
Note:
Marks as dirty so it will cause a recalculation. Negative ranges are not allowed (will reset to 1 on Update).

float dtCore::ShaderParamOscillator::GetCycleTimeMax (  )  const [inline]

The max amount of cycle time (see SetCycleTimeMax().

Returns:
The max cycle time.

void dtCore::ShaderParamOscillator::SetCycleCountTotal ( int  newCount  )  [inline]

Parameters:
count The number of cycles that will happen before oscillation stops.

float dtCore::ShaderParamOscillator::GetCycleCountTotal (  )  const [inline]

Returns:
The number of cycles that will happen before oscillation stops.

void dtCore::ShaderParamOscillator::SetUseRealTime ( bool  useRealTime  )  [inline]

Indicates whether we use real time or simulation time to do our cycle.

Default is true (real time).

Parameters:
useRealTime True means use real time, false uses simulation time.
Note:
Does not cause Dirty to be true, so no recalculation.

bool dtCore::ShaderParamOscillator::GetUseRealTime (  )  const [inline]

Gets the texture unit currently assigned to this shader parameter.

Returns:
The texture unit.

void dtCore::ShaderParamOscillator::SetOscillationType ( const OscillationType type  )  [inline]

Sets the way that the timer oscillates values.

Basically, the offset is considered the 'bottom' and the offset+range is the 'top'. So, up goes from bottom to top, down does the reverse, and the other two go back and forth as you'd expect. Default is UP.

Parameters:
type The source type.
See also:
OscillationType
Note:
Changing this param at any time causes an instant change in direction (no recalculation)

const OscillationType& dtCore::ShaderParamOscillator::GetOscillationType (  )  const [inline]

Gets the source texture type of this parameter.

Returns:
The source type currently in use by this parameter.

void dtCore::ShaderParamOscillator::SetOscillationTrigger ( const OscillationTrigger type  )  [inline]

Sets when the timer will begin to oscillate its value.

If set to AUTO, oscillation will begin immediately by itself. If set to MANUAL, oscillation will not occur until the decides to call Start.

See also:
OscillationTrigger

const OscillationTrigger& dtCore::ShaderParamOscillator::GetOscillationTrigger (  )  const [inline]

Returns the way that the oscillator will begin.

Returns:
The source trigger currently in use by this parameter.

const float dtCore::ShaderParamOscillator::GetCycleDirection (  )  const [inline]

Returns the current cycle direction.

Should be either 1.0 or -1.0. You cannot set this but you can find out which direction it is currently going.

Returns:
1.0 if going up, -1.0 if going down.

void dtCore::ShaderParamOscillator::OnMessage ( MessageData data  )  [virtual]

Called by the dtCore::Base class - used to get timer updates.

Parameters:
The data from the message
See also:
dtCore::Base

Reimplemented from dtCore::Base.

void dtCore::ShaderParamOscillator::TriggerOscillationStart (  ) 

Triggers the oscillation to begin if the trigger type is 'manual' Otherwise, it resets the current oscillation to their starting defaults.

void dtCore::ShaderParamOscillator::DoShaderUpdate ( float  timeDelta  )  [protected]

Does the actual work for the shader.

When called, make sure you pass in the real or simulated as appropriate, based on mUseRealTime.

Parameters:
timeDelta The real or simulated time to use to modify the shader


Member Data Documentation

const int dtCore::ShaderParamOscillator::INFINITE_CYCLE = -1 [static]


http://www.delta3d.org
2.0.0 generated 14 Feb 2008