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
00051 #ifndef _SO_MODEL_MATRIX_ELEMENT
00052 #define _SO_MODEL_MATRIX_ELEMENT
00053
00054 #include <Inventor/SbLinear.h>
00055 #include <Inventor/elements/SoAccumulatedElement.h>
00056
00080 SoEXTENDER_Documented class SoModelMatrixElement : public SoAccumulatedElement {
00081
00082 SO_ELEMENT_HEADER(SoModelMatrixElement);
00083
00084 public:
00085
00089 virtual void push(SoState *state);
00090
00094 static void makeIdentity(SoState *state, SoNode *node);
00095
00101 static void set(SoState *state, SoNode *node,
00102 const SbMatrix &matrix, SbBool sendToGL = TRUE);
00103
00107 static void mult(SoState *state, SoNode *node,
00108 const SbMatrix &matrix);
00109
00114 static void translateBy(SoState *state, SoNode *node,
00115 const SbVec3f &translation);
00120 static void rotateBy(SoState *state, SoNode *node,
00121 const SbRotation &rotation);
00126 static void scaleBy(SoState *state, SoNode *node,
00127 const SbVec3f &scaleFactor);
00128
00137 static SbMatrix pushMatrix(SoState *state);
00146 static void popMatrix(SoState *state, const SbMatrix &m);
00147
00152 static void setCullMatrix(SoState *state, SoNode *node,
00153 const SbMatrix &matrix);
00154
00159 static const SbMatrix & getCombinedCullMatrix(SoState *state);
00160
00164 static const SbMatrix & get(SoState *state);
00165
00170 static const SbMatrix & get(SoState *state, SbBool &isIdent);
00171
00175 virtual void print(FILE *fp) const;
00176
00177 private:
00178
00180 virtual void init(SoState *state);
00181
00185 virtual SbBool matches(const SoElement* elt) const;
00186
00188 virtual SoElement* copyMatchInfo() const;
00189
00190 private:
00191
00192 static void initClass();
00193 static void exitClass();
00194 const SbMatrix& getModelMatrix() const { return modelMatrix; }
00195 SbBool isIdent() const { return flags.isModelIdentity; }
00196
00202 static void pushForwardMatrix(SoState *state, SbMatrix& model, SbMatrix& ftmodel);
00203
00209 static void popForwardMatrix(SoState *state, const SbMatrix &m, const SbMatrix& f);
00210
00217 static const SbMatrix& getForwardTraversalMatrix(SoState *state);
00218
00223 static const SbMatrix& getPreForwardTraversalMatrix(SoState *state);
00224
00228 static void resetForwardTraversalMatrix(SoState *state);
00229
00230 private:
00231
00232 virtual void makeEltIdentity();
00233
00234
00235 virtual void setElt(const SbMatrix &matrix, SbBool sendToGL = TRUE);
00236
00237
00238 virtual void multElt(const SbMatrix &matrix);
00239
00240
00241
00242 virtual void translateEltBy(const SbVec3f &translation);
00243 virtual void rotateEltBy(const SbRotation &translation);
00244 virtual void scaleEltBy(const SbVec3f &scaleFactor);
00245
00246
00247 virtual SbMatrix pushMatrixElt();
00248 virtual void popMatrixElt(const SbMatrix &m);
00249
00250
00251
00252 virtual void pushForwardMatrixElt(SbMatrix& m, SbMatrix& f);
00253
00254 virtual void popForwardMatrixElt(const SbMatrix &m, const SbMatrix& f);
00255
00256 virtual ~SoModelMatrixElement();
00257
00258 SbMatrix modelMatrix;
00259 private:
00260 SbMatrix cullMatrix;
00261 SbMatrix modelCullMatrix;
00262 SbMatrix forwardTraversalMatrix;
00263 SbMatrix preForwardTraversalMatrix;
00264 struct Flags {
00265 unsigned int isModelIdentity : 1;
00266 unsigned int haveCullMatrix : 1;
00267 unsigned int haveModelCull : 1;
00268 };
00269 Flags flags;
00270
00271 friend class SoLocalBBoxMatrixElement;
00272 };
00273
00274 #endif
00275
00276
00277