OxMFunc Class
This is the base class for all "time-slice function" classes. These classes have one main method (CalcValue) that returns a value based on a finite or cyclical curve for a specific moment in time. This may not seem too exciting at first glance but these turn out to be useful in a myriad of situations; object and texture animation, color/alpha modulation, or even audio attenuation.
OxMBounds itself can be considered a null function - it always returns a value of zero. The various subclasses return values based on their type, but all have the exact the same interface and are designed to be completely interchangeable. The Function Plotter.rbp example project included in the download archive interactively plots function curves and serves as a visual and conceptual aid to help understand how the properties affect each function type.
Tip: You can invert a function curve by setting Maximum to a smaller value than Minimum. For waveform functions the same effect can be achieved by using a negative Speed. This is really only useful for non-symmetrical functions such as OxMFuncWaveSaw - symmetrical waveforms will look the same inverted or not.
Tip: Functions are useful on their own but combining the results of multiple functions can produce very complex or even seemingly random procedural animations with very little work. Experiment!
Constructors
Properties
-
Maximum As Double
Read or set the maximum height of the function curve. -
Minimum As Double
Read or set the minimum height of the function curve. -
Offset As Double
Read or set the function curve offset. For waveform functions this is a normalize value that offsets the start position. In the context of finite functions this property can be used to clip the curve, but is generally best left at zero. -
Speed As Double
Read or set the speed (or frequency) of the function. For waveform functions, speed is defined as waves-per-second. For finite functions, this sets the total function time, where time-slices greater than Speed will simply return the Maximum value. -
UserData As Integer
Can be used to store custom per-function data. This property is a vestige of the OxMath class' origins as part of a larger 3D framework where it serves as a bit-field to tag functions with "usage" flags. For example, surface shaders test this property to determine which RGB component(s) or texture UV coordinate(s) a function modulates.
Methods
-
CalcValue ( time As Double ) As Double
Returns the value of the curve at the given time slice. -
Clone As OxMFunc
Returns a copy of the function. This will properly return the same subclass type when called from a subclass. -
SetValues ( min As Double, max As Double, spd As Double, ofs As Double = 0.0 )