NAP
Public Member Functions | Protected Member Functions | List of all members
ParameterBlender< ParamType, ValueType > Class Template Reference

#include <parameterblender.h>

Public Member Functions

 ParameterBlender (ParamType &parameter)
 
 ParameterBlender (Parameter &parameter)
 
- Public Member Functions inherited from BaseParameterBlender
 BaseParameterBlender (Parameter &parameter)
 
virtual ~BaseParameterBlender ()=default
 
void blend (float value)
 
void setTarget (const Parameter *target)
 
void clearTarget ()
 
void sync ()
 
bool hasTarget () const
 
const ParametergetTarget () const
 
const ParametergetParameter () const
 
template<typename T >
const T & getTarget () const
 
template<typename T >
T & getParameter ()
 

Protected Member Functions

virtual void onBlend (float value) override
 
virtual void onSync () override
 
virtual void onTargetSet () override
 
void onBlend (float value)
 
void onBlend (float value)
 
void onBlend (float value)
 
void onBlend (float value)
 
void onBlend (float value)
 
void onBlend (float value)
 

Description

template<typename ParamType, typename ValueType>
class nap::ParameterBlender< ParamType, ValueType >

Default (float, vec2, double, etc.) parameter blender. Blends a parameter (source) towards a target parameter based on a lerp value from 0 to 1. This blender uses the default math::lerp function to interpolate between the values. The ParameterType class should have an 'mValue' member to bind to. Provide an ParameterBlender::onBlend() specialization if no lerp function is available.

Inheritance diagram for ParameterBlender< ParamType, ValueType >:
[legend]
Collaboration diagram for ParameterBlender< ParamType, ValueType >:
[legend]

Constructor & Destructor Documentation

◆ ParameterBlender() [1/2]

ParameterBlender ( ParamType &  parameter)

Constructs the default parameter blender

Parameters
parameterthe parameter that is updated based on the computed blend value.

◆ ParameterBlender() [2/2]

ParameterBlender ( Parameter parameter)

Constructs the default parameter blender based on base type

Parameters
parameterthe parameter that is updated based on the computed blend value.

Member Function Documentation

◆ onBlend() [1/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [2/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [3/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [4/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [5/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [6/7]

void onBlend ( float  value)
protectedvirtual

Called after calling blend(). Override in derived class to correctly blend parameter from source to target.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onBlend() [7/7]

void onBlend ( float  value)
overrideprotectedvirtual

Blends the numeric parameter based on current target value. The default implementation uses the math::lerp<T> function. Provide a specialization if required for your own parameter type.

Parameters
valuethe blend value (0-1)

Implements BaseParameterBlender.

◆ onSync()

void onSync
overrideprotectedvirtual

Ensures that subsequent calls to blend() are based on the current parameter value.

Implements BaseParameterBlender.

◆ onTargetSet()

void onTargetSet
overrideprotectedvirtual

Occurs when the target is updated, ensures the current blend value is cached.

Implements BaseParameterBlender.