Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoTextureMatrixElement.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 : Gavin Bell (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2017 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_TEXTURE_MATRIX_ELEMENT
51#define _SO_TEXTURE_MATRIX_ELEMENT
52
53#include <Inventor/SbLinear.h>
54#include <Inventor/elements/SoAccumulatedElement.h>
55#include <Inventor/STL/vector>
56
74SoEXTENDER_Documented class SoTextureMatrixElement : public SoAccumulatedElement {
75
76 SO_ELEMENT_HEADER(SoTextureMatrixElement);
77
78 public:
82 virtual void push(SoState *state);
83
87 static void makeIdentity(SoState *state, SoNode *node);
88
89
93 static void set(SoState *state, SoNode *node, const SbMatrix &matrix);
94
98 static void mult(SoState *state, SoNode *node,
99 const SbMatrix &matrix);
100
105 static void translateBy(SoState *state, SoNode *node,
106 const SbVec3f &translation);
107
112 static void rotateBy(SoState *state, SoNode *node,
113 const SbRotation &rotation);
114
119 static void scaleBy(SoState *state, SoNode *node,
120 const SbVec3f &scaleFactor);
121
125 static const SbMatrix & get(SoState *state, int unit=0);
126
130 virtual void print(FILE *fp) const;
131
132private:
133
135 virtual void commonInit();
136
138 virtual void init(SoState *state);
139
140 private:
141 // Initializes the SoTextureMatrixElement class
142 static void initClass();
143 static void exitClass();
144 static void emptyMatrix(SoState *state);
145
146 private:
147 // Sets the matrix in an instance to identity
148 virtual void makeEltIdentity(int unit=0);
149
150 // Multiplies into the matrix in an instance
151 virtual void multElt(const SbMatrix &matrix, int unit=0);
152
153 // Each of these performs the appropriate operation on the matrix
154 // in an instance
155 virtual void translateEltBy(const SbVec3f &translation, int unit=0);
156 virtual void rotateEltBy(const SbRotation &translation, int unit=0);
157 virtual void scaleEltBy(const SbVec3f &scaleFactor, int unit=0);
158
159 // Sets the matrix in an instance to given matrix
160 virtual void setElt(const SbMatrix &matrix, int unit);
161
162 // Gets the matrix from an instance
163 virtual const SbMatrix & getElt(int unit=0) const;
164
165 virtual ~SoTextureMatrixElement();
166
167 // return texture matrix for the given texture unit
168 SbMatrix& getTexMatrix(const int unit) const;
169
170private:
171 // This stores the list of node id's as pointers associated to
172 // each texture unit.
173 typedef std::vector<SbMatrix> SbMatrixList;
174 mutable SbMatrixList m_textureMatrixList;
175};
176
177#endif /* _SO_TEXTURE_MATRIX_ELEMENT */
178
179
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 database nodes.
Definition SoNode.h:145
Traversal state.
Definition SoState.h:74
Stores the current texture matrix.
virtual void push(SoState *state)
Overrides push() method to copy values from next instance in the stack.
static void set(SoState *state, SoNode *node, const SbMatrix &matrix)
Sets the texture transform matrix to the given matrix.
static void scaleBy(SoState *state, SoNode *node, const SbVec3f &scaleFactor)
Multiplies a matrix that performs the specified transformation into the texture matrix.
virtual void print(FILE *fp) const
Prints element (for debugging).
static void translateBy(SoState *state, SoNode *node, const SbVec3f &translation)
Multiplies a matrix that performs the specified transformation into the texture matrix.
static void rotateBy(SoState *state, SoNode *node, const SbRotation &rotation)
Multiplies a matrix that performs the specified transformation into the texture matrix.
static const SbMatrix & get(SoState *state, int unit=0)
Returns current matrix from the state.
static void makeIdentity(SoState *state, SoNode *node)
Sets the texture matrix to the identity matrix.
static void mult(SoState *state, SoNode *node, const SbMatrix &matrix)
Multiplies the given matrix into the texture matrix.