00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef COIN_SOINTERPOLATE_H
00025 #define COIN_SOINTERPOLATE_H
00026
00027
00028 #include <Inventor/engines/SoSubEngine.h>
00029 #include <Inventor/engines/SoEngineOutput.h>
00030 #include <Inventor/fields/SoSFFloat.h>
00031
00032 class COIN_DLL_API SoInterpolate : public SoEngine {
00033 typedef SoEngine inherited;
00034 SO_ENGINE_ABSTRACT_HEADER(SoInterpolate);
00035
00036 public:
00037 static void initClass(void);
00038 static void initClasses(void);
00039
00040 SoSFFloat alpha;
00041 SoEngineOutput output;
00042
00043 protected:
00044 SoInterpolate();
00045 virtual ~SoInterpolate();
00046 };
00047
00048
00049
00051
00052
00053 #define SO_INTERPOLATE_HEADER(_class_) \
00054 SO_ENGINE_HEADER(_class_); \
00055 public: \
00056 _class_(); \
00057 static void initClass(); \
00058 protected: \
00059 virtual ~_class_(); \
00060 private: \
00061 virtual void evaluate()
00062
00063
00064 #define PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_) \
00065 SO_ENGINE_CONSTRUCTOR(_class_); \
00066 SO_ENGINE_ADD_INPUT(alpha, (0.0f)); \
00067 SO_ENGINE_ADD_INPUT(input0, _default0_); \
00068 SO_ENGINE_ADD_INPUT(input1, _default1_); \
00069 SO_ENGINE_ADD_OUTPUT(output, _type_)
00070
00071 #define PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
00072 _class_::~_class_() \
00073 { \
00074 }
00075
00076 #define PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_) \
00077 void \
00078 _class_::evaluate(void) \
00079 { \
00080 int n0 = this->input0.getNum(); \
00081 int n1 = this->input1.getNum(); \
00082 float a = this->alpha.getValue(); \
00083 for (int i = SbMax(n0, n1) - 1; i >= 0; i--) { \
00084 _valtype_ v0 = this->input0[SbMin(i, n0-1)]; \
00085 _valtype_ v1 = this->input1[SbMin(i, n1-1)]; \
00086 SO_ENGINE_OUTPUT(output, _type_, set1Value(i, _interpexp_)); \
00087 } \
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 #define SO_INTERPOLATE_SOURCE(_class_, _type_, _valtype_, _default0_, _default1_, _interpexp_) \
00106 \
00107 SO_ENGINE_SOURCE(_class_); \
00108 \
00109 _class_::_class_(void) \
00110 { \
00111 PRIVATE_SO_INTERPOLATE_CONSTRUCTOR(_class_, _type_, _valtype_, _default0_, _default1_); \
00112 this->isBuiltIn = FALSE; \
00113 } \
00114 \
00115 PRIVATE_SO_INTERPOLATE_DESTRUCTOR(_class_) \
00116 PRIVATE_SO_INTERPOLATE_EVALUATE(_class_, _type_, _valtype_, _interpexp_)
00117
00118
00119 #define SO_INTERPOLATE_INITCLASS(_class_, _classname_) \
00120 \
00121 void \
00122 _class_::initClass(void) \
00123 { \
00124 SO_ENGINE_INIT_CLASS(_class_, SoInterpolate, "SoInterpolate"); \
00125 }
00126
00127
00129
00130
00131 #ifndef COIN_INTERNAL
00132
00133 #include <Inventor/engines/SoInterpolateFloat.h>
00134 #include <Inventor/engines/SoInterpolateVec2f.h>
00135 #include <Inventor/engines/SoInterpolateVec3f.h>
00136 #include <Inventor/engines/SoInterpolateVec4f.h>
00137 #include <Inventor/engines/SoInterpolateRotation.h>
00138 #endif // !COIN_INTERNAL
00139
00140
00141 #endif // !COIN_SOINTERPOLATE_H