29 #ifndef __X3DSEQUENCERNODE_H__
30 #define __X3DSEQUENCERNODE_H__
70 template<
class MType >
class H3DAPI_API
KeyValues :
public MType {};
78 template<
class TheType,
class KeyValuesIn,
class SequencerClass >
85 ValueChanged() { currentPosition = 0; fractionInitialized =
false; }
86 bool fractionInitialized;
93 inline typename TheType::value_type evaluateValueChanged(
94 const typename KeyValuesIn::vector_type &key_value,
95 const vector< H3DFloat > &keys,
98 if( setFraction <= keys.front() )
99 return key_value.front();
100 else if( setFraction >= keys.back() )
101 return key_value.back();
105 i < (
H3DInt32 )key_value.size() - 1 &&
106 !( setFraction >= keys[i] && setFraction < keys[ i + 1 ] );
111 virtual void update() {
112 if( TheType::routes_in[0] == TheType::event.ptr ||
113 TheType::routes_in[1] == TheType::event.ptr ||
114 TheType::routes_in[2] == TheType::event.ptr ) {
116 SequencerClass * sn =
117 static_cast< SequencerClass *
>( TheType::getOwner() );
119 bool notMonotonically =
false;
121 const typename KeyValuesIn::vector_type &key_value =
122 sn->keyValue->getValue();
124 const vector< H3DFloat > &keys = sn->key->getValue();
127 Console(LogLevel::Warning) <<
"Warning: The key array is empty in " <<
128 "X3DSequencerNode ( " << sn->getName() <<
129 " ). Node will not be used. " << endl;
133 if( key_value.empty() ) {
134 Console(LogLevel::Warning) <<
"Warning: The keyValue array is empty in " <<
135 "X3DSequencerNode ( " << sn->getName() <<
136 " ). Node will not be used. " << endl;
140 if( keys.size() != key_value.size() ) {
141 Console(LogLevel::Warning) <<
"Warning: The key and keyValue arrays mismatch in " <<
142 "X3DSequencerNode ( " << sn->getName() <<
143 " ). Node will not be used. " << endl;
149 for(
int i = 0; i < (int)keys.size() - 1; ++i ) {
150 if( keys[i] > keys[ i + 1 ] )
151 notMonotonically =
true;
154 if( notMonotonically ) {
155 Console(LogLevel::Warning) <<
"Warning: The key array is not monotonically " <<
156 "non-decreasing in X3DSequencerNode ( " << sn->getName() <<
157 " ). Node will not be used. " << endl;
162 if( TheType::routes_in[0] == TheType::event.ptr ) {
164 if( currentPosition > (
H3DInt32 )key_value.size() - 1 )
167 TheType::value = key_value[ currentPosition ];
170 else if( TheType::routes_in[1] == TheType::event.ptr ) {
172 if( currentPosition < 0 )
173 currentPosition = (
H3DInt32) key_value.size() - 1;
175 TheType::value = key_value[ currentPosition ];
178 else if( TheType::routes_in[2] == TheType::event.ptr ) {
179 fractionInitialized =
true;
181 static_cast< SFFloat *
>( TheType::routes_in[2] )->
getValue( sn ->
id );
182 TheType::value = evaluateValueChanged(key_value, keys, setFraction);
188 template<
class TheType,
class KeyValuesIn >
friend class ValueChanged;
193 Inst< SFBool > _next = 0,
194 Inst< SFBool > _previous = 0,
195 Inst< SFFloat > _set_fraction = 0,
196 Inst< MFFloat > _key = 0 );
227 H3DUniquePtr< MFFloat >
key;
Contains the MFFloat field class.
Contains the SFBool field class.
Contains the SFFloat field class.
Header file for X3DChildNode, X3D scene-graph node.
The SFFloat field contains one single-precision floating point number.
Definition: SFFloat.h:41
This abstract node type indicates that the concrete nodes which are instantiated based on it may be u...
Definition: X3DChildNode.h:42
Each value in the keyValue field corresponds in order to the parameter value in the key field.
Definition: X3DSequencerNode.h:70
ValueChanged is a specialized class used to evaluate and set the value_changed field depending on the...
Definition: X3DSequencerNode.h:83
This abstract node type is the base node type from which all Sequencers are derived.
Definition: X3DSequencerNode.h:65
H3DUniquePtr< MFFloat > key
Each value in the keyValue field corresponds in order to the parameter value in the key field.
Definition: X3DSequencerNode.h:227
H3DUniquePtr< SFFloat > set_fraction
The set_fraction inputOnly field receives an SFFloat event and causes the sequencing function to eval...
Definition: X3DSequencerNode.h:218
H3DUniquePtr< SFBool > previous
Receipt of previous event triggers previous output value in keyValue array, previous goes to last ele...
Definition: X3DSequencerNode.h:210
H3DUniquePtr< SFBool > next
Receipt of next event triggers next output value in keyValue array, next goes to initial element afte...
Definition: X3DSequencerNode.h:203
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: X3DSequencerNode.h:230
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194