00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_INTERPOLATE_
00051 #define _SO_INTERPOLATE_
00052
00053 #include <Inventor/SoDB.h>
00054 #include <Inventor/engines/SoSubEngine.h>
00055 #include <Inventor/fields/SoSFFloat.h>
00056 #include <Inventor/fields/SoMFFloat.h>
00057 #include <Inventor/fields/SoMFRotation.h>
00058 #include <Inventor/fields/SoMFVec2f.h>
00059 #include <Inventor/fields/SoMFVec2i32.h>
00060 #include <Inventor/fields/SoMFVec2s.h>
00061 #include <Inventor/fields/SoMFVec3f.h>
00062 #include <Inventor/fields/SoMFVec4f.h>
00063
00065
00066
00067
00068
00069
00070
00071
00073
00101 class SoInterpolate : public SoEngine {
00102
00103 SO_ENGINE_ABSTRACT_HEADER(SoInterpolate);
00104
00105 public:
00109 SoSFFloat alpha;
00114 SoEngineOutput output;
00115
00116 private:
00117 static void initClass();
00118 static void exitClass();
00119 static void initClasses();
00120 static void exitClasses();
00121
00122 private:
00123 SoInterpolate();
00124
00125 static int findMax(int a, int b) { return (a > b) ? a : b; }
00126 static int clamp(int i, int n) { return (i < n) ? i : n-1; }
00127
00128 ~SoInterpolate();
00129 };
00130
00132
00133
00134
00135
00137
00138
00139
00140
00141
00142
00143 #define SO_INTERPOLATE_HEADER(className) \
00144 \
00145 SO_ENGINE_HEADER(className); \
00146 \
00147 private: \
00148 ~className(); \
00149 \
00150 virtual void evaluate(); \
00151 \
00152 private:\
00153 static void initClass(); \
00154 static void exitClass(); \
00155 \
00156 public: \
00157 \
00158 className()
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 #define SO_INTERPOLATE_SOURCE(className, type, \
00169 valType, defaultVal0, defaultVal1, interpVal) \
00170 \
00171 SO_ENGINE_SOURCE(className) \
00172 \
00173 className::className() \
00174 { \
00175 SO_ENGINE_CONSTRUCTOR(className); \
00176 SO_ENGINE_ADD_INPUT(alpha, (0.0)); \
00177 SO_ENGINE_ADD_INPUT(input0, defaultVal0); \
00178 SO_ENGINE_ADD_INPUT(input1, defaultVal1); \
00179 SO_ENGINE_ADD_OUTPUT(output, type); \
00180 isBuiltIn = TRUE; \
00181 } \
00182 \
00183 className::~className() \
00184 { \
00185 } \
00186 \
00187 void \
00188 className::evaluate() \
00189 { \
00190 int n0 = input0.getNum(); \
00191 int n1 = input1.getNum(); \
00192 float a = alpha.getValue(); \
00193 for (int i=findMax(n0,n1)-1; i>=0; i--) { \
00194 valType v0 = input0[clamp(i,n0)]; \
00195 valType v1 = input1[clamp(i,n1)]; \
00196 SO_ENGINE_OUTPUT(output, type, set1Value(i, interpVal)); \
00197 } \
00198 }
00199
00201
00202
00203
00204
00205
00206
00207
00208
00209 #define SO_INTERPOLATE_INITCLASS(className, classPrintName) \
00210 \
00211 void \
00212 className::initClass() \
00213 { \
00214 SO__ENGINE_INIT_CLASS(className, classPrintName, SoInterpolate); \
00215 }
00216
00217 #define SO_INTERPOLATE_EXITCLASS(className) \
00218 \
00219 void \
00220 className::exitClass() \
00221 { \
00222 SO_ENGINE_EXIT_CLASS(className); \
00223 }
00224
00226
00227
00228
00230
00265 class SoInterpolateFloat : public SoInterpolate {
00266 SO_INTERPOLATE_HEADER(SoInterpolateFloat);
00267 public:
00271 SoMFFloat input0;
00272
00276 SoMFFloat input1;
00277
00278
00280
00281
00282
00284 };
00285
00320 class SoInterpolateRotation : public SoInterpolate {
00321 SO_INTERPOLATE_HEADER(SoInterpolateRotation);
00322 public:
00326 SoMFRotation input0;
00327
00331 SoMFRotation input1;
00332
00333
00335
00336
00337
00339 };
00340
00375 class SoInterpolateVec2f : public SoInterpolate {
00376 SO_INTERPOLATE_HEADER(SoInterpolateVec2f);
00377 public:
00381 SoMFVec2f input0;
00382
00386 SoMFVec2f input1;
00387
00388
00390
00391
00392
00394 };
00395
00430 class SoInterpolateVec3f : public SoInterpolate {
00431 SO_INTERPOLATE_HEADER(SoInterpolateVec3f);
00432 public:
00436 SoMFVec3f input0;
00437
00441 SoMFVec3f input1;
00442
00443
00445
00446
00447
00449 };
00450
00485 class SoInterpolateVec4f : public SoInterpolate {
00486 SO_INTERPOLATE_HEADER(SoInterpolateVec4f);
00487 public:
00491 SoMFVec4f input0;
00492
00496 SoMFVec4f input1;
00497
00498
00500
00501
00502
00504 };
00505
00506 #endif
00507
00508
00509
00510
00511
00512
00513