Cortex
10.0.0-a4
|
#include <CurveLookup.h>
Public Types | |
typedef T | BaseType |
Public Member Functions | |
CurveLookup (const std::string &name, const std::string &label, const std::string &toolTip="") | |
int | addCurve (const std::string &name, const std::string &defaultCurve="y C 0 1") |
void | knob (DD::Image::Knob_Callback f) |
Call this in the knobs() method for a node, to build the interface for the curves. | |
void | validate (T xMin=0, T xMax=1, unsigned numSamples=100) |
void | append (DD::Image::Hash &hash) const |
Append all the curves to the specified Hash. | |
void | append (unsigned curveIndex, DD::Image::Hash &hash) const |
Append an individual curve to the specified Hash. | |
void | validate (unsigned curveIndex, T xMin=0, T xMax=1, unsigned numSamples=100) |
T | evaluate (unsigned curveIndex, T x) const |
The CurveLookup class provides a useful wrapper around a bunch of DD::Image::Animation pointers, which can be used to provide lookup curves to a node. It contains everything necessary to declare the interface, sample the curve in _evaluate(), and then interpolate those sample values to perform quick evaluations in engine(). It's templated on the type you want to be returned from the evaluate() method. It also deals with the fact that the API for using curve lookups changed completely between Nuke5 and Nuke5.1.
int IECoreNuke::CurveLookup< T >::addCurve | ( | const std::string & | name, |
const std::string & | defaultCurve = "y C 0 1" |
||
) |
Call this in the constructor for a node, to add as many curves as required. Returns the index which should be passed to the validate and evaluate calls below, but this is guaranteed to be 0 for the first curve, 1 for the second etc. You cannot add more curves once knobs() has been called.
|
inline |
Calculate the y value for the specified curve at the specified position. validate() must have been called for that curve before this method is called.
void IECoreNuke::CurveLookup< T >::validate | ( | T | xMin = 0 , |
T | xMax = 1 , |
||
unsigned | numSamples = 100 |
||
) |
Call this in the _validate method for a node, to sample the curves into a lookup which can be evaluated quickly in engine().
void IECoreNuke::CurveLookup< T >::validate | ( | unsigned | curveIndex, |
T | xMin = 0 , |
||
T | xMax = 1 , |
||
unsigned | numSamples = 100 |
||
) |
As above, but samples just one curve - this can be used if you wish to sample different curves over different ranges. curveIndex is 0 for the first curve added, and increments by 1 for each subsequent curve.