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
00100 class SoInterpolate : public SoEngine {
00101
00102 SO_ENGINE_ABSTRACT_HEADER(SoInterpolate);
00103
00104 public:
00108 SoSFFloat alpha;
00113 SoEngineOutput output;
00114
00115 private:
00116 static void initClass();
00117 static void exitClass();
00118 static void initClasses();
00119 static void exitClasses();
00120
00121 private:
00122 SoInterpolate();
00123
00124 static int findMax(int a, int b) { return (a > b) ? a : b; }
00125 static int clamp(int i, int n) { return (i < n) ? i : n-1; }
00126
00127 ~SoInterpolate();
00128 };
00129
00131
00132
00133
00134
00136
00137
00138
00139
00140
00141
00142 #define SO_INTERPOLATE_HEADER(className) \
00143 \
00144 SO_ENGINE_HEADER(className); \
00145 \
00146 private: \
00147 ~className(); \
00148 \
00149 virtual void evaluate(); \
00150 \
00151 private:\
00152 static void initClass(); \
00153 static void exitClass(); \
00154 \
00155 public: \
00156 \
00157 className()
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 #define SO_INTERPOLATE_SOURCE(className, type, \
00168 valType, defaultVal0, defaultVal1, interpVal) \
00169 \
00170 SO_ENGINE_SOURCE(className) \
00171 \
00172 className::className() \
00173 { \
00174 SO_ENGINE_CONSTRUCTOR(className); \
00175 SO_ENGINE_ADD_INPUT(alpha, (0.0)); \
00176 SO_ENGINE_ADD_INPUT(input0, defaultVal0); \
00177 SO_ENGINE_ADD_INPUT(input1, defaultVal1); \
00178 SO_ENGINE_ADD_OUTPUT(output, type); \
00179 isBuiltIn = TRUE; \
00180 } \
00181 \
00182 className::~className() \
00183 { \
00184 } \
00185 \
00186 void \
00187 className::evaluate() \
00188 { \
00189 int n0 = input0.getNum(); \
00190 int n1 = input1.getNum(); \
00191 float a = alpha.getValue(); \
00192 for (int i=findMax(n0,n1)-1; i>=0; i--) { \
00193 valType v0 = input0[clamp(i,n0)]; \
00194 valType v1 = input1[clamp(i,n1)]; \
00195 SO_ENGINE_OUTPUT(output, type, set1Value(i, interpVal)); \
00196 } \
00197 }
00198
00200
00201
00202
00203
00204
00205
00206
00207
00208 #define SO_INTERPOLATE_INITCLASS(className, classPrintName) \
00209 \
00210 void \
00211 className::initClass() \
00212 { \
00213 SO__ENGINE_INIT_CLASS(className, classPrintName, SoInterpolate); \
00214 }
00215
00216 #define SO_INTERPOLATE_EXITCLASS(className) \
00217 \
00218 void \
00219 className::exitClass() \
00220 { \
00221 SO_ENGINE_EXIT_CLASS(className); \
00222 }
00223
00225
00226
00227
00229
00263 class SoInterpolateFloat : public SoInterpolate {
00264 SO_INTERPOLATE_HEADER(SoInterpolateFloat);
00265 public:
00269 SoMFFloat input0;
00270
00274 SoMFFloat input1;
00275
00276
00278
00279
00280
00282 };
00283
00317 class SoInterpolateRotation : public SoInterpolate {
00318 SO_INTERPOLATE_HEADER(SoInterpolateRotation);
00319 public:
00323 SoMFRotation input0;
00324
00328 SoMFRotation input1;
00329
00330
00332
00333
00334
00336 };
00337
00371 class SoInterpolateVec2f : public SoInterpolate {
00372 SO_INTERPOLATE_HEADER(SoInterpolateVec2f);
00373 public:
00377 SoMFVec2f input0;
00378
00382 SoMFVec2f input1;
00383
00384
00386
00387
00388
00390 };
00391
00425 class SoInterpolateVec3f : public SoInterpolate {
00426 SO_INTERPOLATE_HEADER(SoInterpolateVec3f);
00427 public:
00431 SoMFVec3f input0;
00432
00436 SoMFVec3f input1;
00437
00438
00440
00441
00442
00444 };
00445
00479 class SoInterpolateVec4f : public SoInterpolate {
00480 SO_INTERPOLATE_HEADER(SoInterpolateVec4f);
00481 public:
00485 SoMFVec4f input0;
00486
00490 SoMFVec4f input1;
00491
00492
00494
00495
00496
00498 };
00499
00500 #endif
00501
00502
00503
00504
00505
00506
00507