interpolation.H

Go to the documentation of this file.
00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_X3D_INTERPOLATION_H
00021 #define ARCHON_X3D_INTERPOLATION_H
00022 
00029 #include <archon/x3d/server/core.H>
00030 #include <archon/x3d/server/scene.H>
00031 
00032 namespace Archon
00033 {
00034   namespace X3D
00035   {
00036     using namespace Math;
00037 
00038 
00042     struct InterpolatorNode: virtual ChildNode
00043     {
00044       static const NodeType *type;
00045 
00046     protected:
00047       InterpolatorNode() {}
00048 
00049       virtual bool fractionAssign(const double &, const Time &) = 0;
00050       vector<double> key;
00051 
00052       Time fractionStamp;
00053 
00054     private:
00055       friend void initializeInterpolationComponent();
00056 
00057       EventSource keyChanged;
00058 
00059       Time keyStamp;
00060     };
00061 
00062 
00066     struct ColorInterpolator: InterpolatorNode
00067     {
00068       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00069       {
00070         return new ColorInterpolator(c);
00071       }
00072 
00073       static const NodeType *type;
00074       const NodeType *getType() const { return type; }
00075 
00076       ColorInterpolator(BackRef<ExecutionContext> c):
00077         NodeBase(c), value(Vector3::zero()) {}
00078 
00079     private:
00080       friend void initializeInterpolationComponent();
00081 
00082       vector<Vector3> keyValue; // MFVec3f [in,out]
00083       Vector3         value;    // SFVec3f [out]
00084 
00085       EventSource keyValueChanged;
00086       EventSource valueChanged;
00087 
00088       Time keyValueStamp;
00089 
00090       bool fractionAssign(const double &, const Time &);
00091     };
00092 
00093 
00097     struct CoordinateInterpolator: InterpolatorNode
00098     {
00099       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00100       {
00101         return new CoordinateInterpolator(c);
00102       }
00103 
00104       static const NodeType *type;
00105       const NodeType *getType() const { return type; }
00106 
00107       CoordinateInterpolator(BackRef<ExecutionContext> c):
00108         NodeBase(c) {}
00109 
00110     private:
00111       friend void initializeInterpolationComponent();
00112 
00113       vector<Vector3> keyValue; // MFVec3f [in,out]
00114       vector<Vector3> value;    // MFVec3f [out]
00115 
00116       EventSource keyValueChanged;
00117       EventSource valueChanged;
00118 
00119       Time keyValueStamp;
00120 
00121       bool fractionAssign(const double &, const Time &);
00122     };
00123 
00124 
00128     struct CoordinateInterpolator2D: InterpolatorNode
00129     {
00130       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00131       {
00132         return new CoordinateInterpolator2D(c);
00133       }
00134 
00135       static const NodeType *type;
00136       const NodeType *getType() const { return type; }
00137 
00138       CoordinateInterpolator2D(BackRef<ExecutionContext> c):
00139         NodeBase(c) {}
00140 
00141     private:
00142       friend void initializeInterpolationComponent();
00143 
00144       vector<Vector2> keyValue; // MFVec2f [in,out]
00145       vector<Vector2> value;    // MFVec2f [out]
00146 
00147       EventSource keyValueChanged;
00148       EventSource valueChanged;
00149 
00150       Time keyValueStamp;
00151 
00152       bool fractionAssign(const double &, const Time &);
00153     };
00154 
00155 
00159     struct NormalInterpolator: InterpolatorNode
00160     {
00161       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00162       {
00163         return new NormalInterpolator(c);
00164       }
00165 
00166       static const NodeType *type;
00167       const NodeType *getType() const { return type; }
00168 
00169       NormalInterpolator(BackRef<ExecutionContext> c): NodeBase(c) {}
00170 
00171     private:
00172       friend void initializeInterpolationComponent();
00173 
00174       vector<Vector3> keyValue; // MFVec3f [in,out]
00175       vector<Vector3> value;    // MFVec3f [out]
00176 
00177       EventSource keyValueChanged;
00178       EventSource valueChanged;
00179 
00180       Time keyValueStamp;
00181 
00182       bool fractionAssign(const double &, const Time &);
00183     };
00184 
00185 
00189     struct OrientationInterpolator: InterpolatorNode
00190     {
00191       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00192       {
00193         return new OrientationInterpolator(c);
00194       }
00195 
00196       static const NodeType *type;
00197       const NodeType *getType() const { return type; }
00198 
00199       OrientationInterpolator(BackRef<ExecutionContext> c):
00200         NodeBase(c), value(Vector3(0, 0, 1), 0) {}
00201 
00202     private:
00203       friend void initializeInterpolationComponent();
00204 
00205       vector<Rotation3> keyValue; // MFRotation [in,out]
00206       Rotation3         value;    // SFRotation [out]
00207 
00208       EventSource keyValueChanged;
00209       EventSource valueChanged;
00210 
00211       Time keyValueStamp;
00212 
00213       bool fractionAssign(const double &, const Time &);
00214     };
00215 
00216 
00220     struct PositionInterpolator: InterpolatorNode
00221     {
00222       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00223       {
00224         return new PositionInterpolator(c);
00225       }
00226 
00227       static const NodeType *type;
00228       const NodeType *getType() const { return type; }
00229 
00230       PositionInterpolator(BackRef<ExecutionContext> c):
00231         NodeBase(c), value(Vector3::zero()) {}
00232 
00233     private:
00234       friend void initializeInterpolationComponent();
00235 
00236       vector<Vector3> keyValue; // MFVec3f [in,out]
00237       Vector3         value;    // SFVec3f [out]
00238 
00239       EventSource keyValueChanged;
00240       EventSource valueChanged;
00241 
00242       Time keyValueStamp;
00243 
00244       bool fractionAssign(const double &, const Time &);
00245     };
00246 
00247 
00251     struct PositionInterpolator2D: InterpolatorNode
00252     {
00253       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00254       {
00255         return new PositionInterpolator2D(c);
00256       }
00257 
00258       static const NodeType *type;
00259       const NodeType *getType() const { return type; }
00260 
00261       PositionInterpolator2D(BackRef<ExecutionContext> c):
00262         NodeBase(c), value(Vector3::zero()) {}
00263 
00264     private:
00265       friend void initializeInterpolationComponent();
00266 
00267       vector<Vector2> keyValue; // MFVec2f [in,out]
00268       Vector2         value;    // SFVec2f [out]
00269 
00270       EventSource keyValueChanged;
00271       EventSource valueChanged;
00272 
00273       Time keyValueStamp;
00274 
00275       bool fractionAssign(const double &, const Time &);
00276     };
00277 
00278 
00282     struct ScalarInterpolator: InterpolatorNode
00283     {
00284       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00285       {
00286         return new ScalarInterpolator(c);
00287       }
00288 
00289       static const NodeType *type;
00290       const NodeType *getType() const { return type; }
00291 
00292       ScalarInterpolator(BackRef<ExecutionContext> c):
00293         NodeBase(c), value(0) {}
00294 
00295     private:
00296       friend void initializeInterpolationComponent();
00297 
00298       vector<double> keyValue; // MFDouble [in,out]
00299       double         value;    // SFDouble [out]
00300 
00301       EventSource keyValueChanged;
00302       EventSource valueChanged;
00303 
00304       Time keyValueStamp;
00305 
00306       bool fractionAssign(const double &, const Time &);
00307     };
00308   }
00309 }
00310 
00311 #endif // ARCHON_X3D_INTERPOLATION_H

Generated on Sun Jul 30 22:55:49 2006 for Archon by  doxygen 1.4.4