Ocean
X3DInterpolatorNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_SCENEDESCRIPTION_SDX_X3D_X3D_INTERPOLATOR_NODE_H
9 #define META_OCEAN_SCENEDESCRIPTION_SDX_X3D_X3D_INTERPOLATOR_NODE_H
10 
13 
14 #include <map>
15 
16 namespace Ocean
17 {
18 
19 namespace SceneDescription
20 {
21 
22 namespace SDX
23 {
24 
25 namespace X3D
26 {
27 
28 /**
29  * This class implements an abstract x3d interpolator node object.
30  * @ingroup scenedescriptionsdxx3d
31  */
32 class OCEAN_SCENEDESCRIPTION_SDX_X3D_EXPORT X3DInterpolatorNode : virtual public X3DChildNode
33 {
34  protected:
35 
36  /**
37  * Definition of a pair holding two key value indices.
38  */
39  typedef std::pair<size_t, size_t> IndexPair32;
40 
41  /**
42  * Definition of a map mapping keys to key value index pairs.
43  */
44  typedef std::map<Scalar, IndexPair32> KeyMap;
45 
46  protected:
47 
48  /**
49  * Creates a new abstract x3d interpolator node.
50  * @param environment Node environment
51  */
52  explicit X3DInterpolatorNode(const SDXEnvironment* environment);
53 
54  protected:
55 
56  /**
57  * Registers the fields of this node.
58  * @param specification Node specification receiving the field informations
59  */
60  void registerFields(NodeSpecification& specification);
61 
62  /**
63  * Event function to inform the node that it has been initialized and can apply all internal values to corresponding rendering objects.
64  * @see SDXNode::onInitialize().
65  */
66  void onInitialize(const Rendering::SceneRef& scene, const Timestamp timestamp) override;
67 
68  /**
69  * Explicit changing event function for node fields.
70  * @see X3DNode::onFieldChanging().
71  */
72  bool onFieldChanging(const std::string& fieldName, const Field& field) override;
73 
74  /**
75  * Event function for single value 'interpolates'.
76  * @param index Index of the element to 'interpolate'
77  * @param eventTimestamp Timestamp of the faction event
78  */
79  virtual void onSingleValue(const size_t index, const Timestamp eventTimestamp) = 0;
80 
81  /**
82  * Event function to interpolate between two values.
83  * @param leftIndex Index of the left (first) interpolation value
84  * @param rightIndex Index of the right (second) interpolation value
85  * @param interpolationFactor Interpolation factor between the left and the right value with range [0, 1]
86  * @param eventTimestamp Timestamp of the faction event
87  */
88  virtual void onInterpolate(const size_t leftIndex, const size_t rightIndex, const Scalar interpolationFactor, const Timestamp eventTimestamp) = 0;
89 
90  protected:
91 
92  /// Set_fraction field.
94 
95  /// Key field.
97 
98  /// Map mapping interpolation keys to interpolation value indices.
100 };
101 
102 }
103 
104 }
105 
106 }
107 
108 }
109 
110 #endif // META_OCEAN_SCENEDESCRIPTION_SDX_X3D_X3D_INTERPOLATOR_NODE_H
This class is the base class for all scene description fields.
Definition: Field.h:36
This class implements a node specification object.
Definition: scenedescription/Node.h:77
This class implements an abstract x3d child node.
Definition: X3DChildNode.h:31
This class implements an abstract x3d interpolator node object.
Definition: X3DInterpolatorNode.h:33
MultiFloat key_
Key field.
Definition: X3DInterpolatorNode.h:96
void registerFields(NodeSpecification &specification)
Registers the fields of this node.
virtual void onInterpolate(const size_t leftIndex, const size_t rightIndex, const Scalar interpolationFactor, const Timestamp eventTimestamp)=0
Event function to interpolate between two values.
KeyMap keyMap_
Map mapping interpolation keys to interpolation value indices.
Definition: X3DInterpolatorNode.h:99
bool onFieldChanging(const std::string &fieldName, const Field &field) override
Explicit changing event function for node fields.
std::map< Scalar, IndexPair32 > KeyMap
Definition of a map mapping keys to key value index pairs.
Definition: X3DInterpolatorNode.h:44
std::pair< size_t, size_t > IndexPair32
Definition of a pair holding two key value indices.
Definition: X3DInterpolatorNode.h:39
virtual void onSingleValue(const size_t index, const Timestamp eventTimestamp)=0
Event function for single value 'interpolates'.
void onInitialize(const Rendering::SceneRef &scene, const Timestamp timestamp) override
Event function to inform the node that it has been initialized and can apply all internal values to c...
X3DInterpolatorNode(const SDXEnvironment *environment)
Creates a new abstract x3d interpolator node.
SingleFloat setFraction_
Set_fraction field.
Definition: X3DInterpolatorNode.h:93
This class implements a node environment container.
Definition: SDXNode.h:62
This class implements a timestamp.
Definition: Timestamp.h:36
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15