Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoModelMatrixElement.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25** Modified by : Gavin Bell (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50
51#ifndef _SO_MODEL_MATRIX_ELEMENT
52#define _SO_MODEL_MATRIX_ELEMENT
53
54#include <Inventor/SbLinear.h>
55#include <Inventor/elements/SoAccumulatedElement.h>
56
80SoEXTENDER_Documented class SoModelMatrixElement : public SoAccumulatedElement {
81
82 SO_ELEMENT_HEADER(SoModelMatrixElement);
83
84 public:
85
89 virtual void push(SoState *state);
90
94 static void makeIdentity(SoState *state, SoNode *node);
95
101 static void set(SoState *state, SoNode *node,
102 const SbMatrix &matrix, SbBool sendToGL = TRUE);
103
107 static void mult(SoState *state, SoNode *node,
108 const SbMatrix &matrix);
109
114 static void translateBy(SoState *state, SoNode *node,
115 const SbVec3f &translation);
120 static void rotateBy(SoState *state, SoNode *node,
121 const SbRotation &rotation);
126 static void scaleBy(SoState *state, SoNode *node,
127 const SbVec3f &scaleFactor);
128
146 static void popMatrix(SoState *state, const SbMatrix &m);
147
152 static void setCullMatrix(SoState *state, SoNode *node,
153 const SbMatrix &matrix);
154
159 static const SbMatrix & getCombinedCullMatrix(SoState *state);
160
164 static const SbMatrix & get(SoState *state);
165
170 static const SbMatrix & get(SoState *state, SbBool &isIdent);
171
175 virtual void print(FILE *fp) const;
176
177private:
178
180 virtual void init(SoState *state);
181
185 virtual SbBool matches(const SoElement* elt) const;
186
188 virtual SoElement* copyMatchInfo() const;
189
190 private:
191 // Initializes the SoModelMatrixElement class
192 static void initClass();
193 static void exitClass();
194 const SbMatrix& getModelMatrix() const { return modelMatrix; }
195 SbBool isIdent() const { return flags.isModelIdentity; }
196
198 static const SbMatrix& getCullMatrix(SoState* state);
199
201 const SbMatrix& getCullMatrix();
202
208 static void pushForwardMatrix(SoState *state, SbMatrix& model, SbMatrix& ftmodel);
209
215 static void popForwardMatrix(SoState *state, const SbMatrix &m, const SbMatrix& f);
216
223 static const SbMatrix& getForwardTraversalMatrix(SoState *state);
224
229 static const SbMatrix& getPreForwardTraversalMatrix(SoState *state);
230
234 static void resetForwardTraversalMatrix(SoState *state);
235
236 private:
237 // Sets the matrix in an instance to identity
238 virtual void makeEltIdentity();
239
240 // Sets the matrix in an instance to given matrix
241 virtual void setElt(const SbMatrix &matrix, SbBool sendToGL = TRUE);
242
243 // Multiplies into the matrix in an instance
244 virtual void multElt(const SbMatrix &matrix);
245
246 // Each of these performs the appropriate operation on the matrix
247 // in an instance
248 virtual void translateEltBy(const SbVec3f &translation);
249 virtual void rotateEltBy(const SbRotation &translation);
250 virtual void scaleEltBy(const SbVec3f &scaleFactor);
251
252 // virtual methods for push/pop so GL element can Do The Right Thing:
253 virtual SbMatrix pushMatrixElt();
254 virtual void popMatrixElt(const SbMatrix &m);
255
256 // same as previous but taking into account forward traversal transformation
257
258 virtual void pushForwardMatrixElt(SbMatrix& m, SbMatrix& f);
259
260 virtual void popForwardMatrixElt(const SbMatrix &m, const SbMatrix& f);
261
262 virtual ~SoModelMatrixElement();
263
264 SbMatrix modelMatrix;
265 private:
266 SbMatrix cullMatrix;
267 SbMatrix modelCullMatrix;
268 SbMatrix forwardTraversalMatrix; // transformation inside a foward traversal
269 SbMatrix preForwardTraversalMatrix; // transformation until first foward traversal
270 struct Flags {
271 unsigned int isModelIdentity : 1;
272 unsigned int haveCullMatrix : 1; // TRUE if cullMatrix set
273 unsigned int haveModelCull : 1; // TRUE if model*cull computed
274 };
275 Flags flags;
276
278};
279
280#endif /* _SO_MODEL_MATRIX_ELEMENT */
281
282
4x4 matrix class.
Definition SbMatrix.h:309
Class for representing a rotation.
Definition SbRotation.h:126
3D vector class.
Definition SbVec.h:932
Abstract base class for each state element whose value may be accumulated when it is set.
Abstract base class for all state elements.
Definition SoElement.h:102
Stores the transformation matrix from object space to some local coordinate space during application ...
Stores the current model matrix.
static void mult(SoState *state, SoNode *node, const SbMatrix &matrix)
Multiplies the given matrix into the model matrix.
static void scaleBy(SoState *state, SoNode *node, const SbVec3f &scaleFactor)
This multiplies a matrix that performs the specified transformation into the model matrix.
virtual void push(SoState *state)
Overrides push() method to copy values from next instance in the stack.
static void popMatrix(SoState *state, const SbMatrix &m)
This method is used by the TransformSeparator node.
static const SbMatrix & get(SoState *state, SbBool &isIdent)
Returns current model matrix from the state, sets given flag to TRUE if matrix is known to be identit...
virtual void print(FILE *fp) const
Prints element (for debugging).
static void rotateBy(SoState *state, SoNode *node, const SbRotation &rotation)
This multiplies a matrix that performs the specified transformation into the model matrix.
static void makeIdentity(SoState *state, SoNode *node)
Sets the model matrix to the identity matrix.
static void set(SoState *state, SoNode *node, const SbMatrix &matrix, SbBool sendToGL=TRUE)
Sets the model matrix to the given matrix.
static const SbMatrix & get(SoState *state)
Returns current model matrix from the state.
static void translateBy(SoState *state, SoNode *node, const SbVec3f &translation)
This multiplies a matrix that performs the specified transformation into the model matrix.
static void setCullMatrix(SoState *state, SoNode *node, const SbMatrix &matrix)
Sets the transformation that defines the volume that view-volume culling should be tested against.
static const SbMatrix & getCombinedCullMatrix(SoState *state)
This method gets the model*cullMatrix combined matrix (which is cached by this element).
static SbMatrix pushMatrix(SoState *state)
This method is used by the TransformSeparator node.
Abstract base class for all database nodes.
Definition SoNode.h:145
Traversal state.
Definition SoState.h:74
int SbBool
Boolean type.
Definition SbBase.h:87