Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoTextureCoordinate3Element.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Patrick Vigneras (Nov 1999)
22**=======================================================================*/
23
24#ifndef _SO_TEXTURE_COORDINATE3_ELEMENT
25#define _SO_TEXTURE_COORDINATE3_ELEMENT
26
27#include <Inventor/SbLinear.h>
28#include <Inventor/elements/SoReplacedTextureElement.h>
29#include <Inventor/STL/vector>
30
40typedef const SbVec4f &
41SoTextureCoordinate3FunctionCB(void *userdata, const SbVec3f &point,
42 const SbVec3f &normal);
43
45
58SoEXTENDER_Documented class SoTextureCoordinate3Element : public SoReplacedTextureElement {
59
60 SO_ELEMENT_HEADER(SoTextureCoordinate3Element);
61
62public:
67 enum CoordType {
68 EXPLICIT = 1, // Coordinates stored in state
69 FUNCTION = 2 // Coordinates generated by software function
70 };
71
76 static void setDefault(SoState *state, SoNode *node);
77
78 // FUNCTION:
79 static void setFunction(SoState *state, SoNode *node,
81 void *userData,
82 SbBool frcSend = FALSE);
83
84 // EXPLICIT:
88 static void set3(SoState *state, SoNode *node,
89 int32_t numCoords, const SbVec3f *coords,
90 SbBool frcSend = FALSE);
91
95 static void set4(SoState *state, SoNode *node,
96 int32_t numCoords, const SbVec4f *coords,
97 SbBool frcSend = FALSE);
98
103 static CoordType getType(SoState *state, int unit=0);
104
105 virtual CoordType getType(int unit=0) const;
106
114
115 // Get routine for FUNCTION case:
116
122 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal,
123 int unit=0) const;
124
125 // Get routines for EXPLICIT case:
126
130 int32_t getNum(int unit=0) const ;
131
132 SbBool is3D(int unit=0) const ;
133
134 SbBool isForceSending(int unit=0) const ;
135
140 const SbVec3f & get3(int index, int unit=0) const;
141 const SbVec4f & get4(int index, int unit=0) const;
142
146 virtual void print(FILE *fp) const;
147
151 virtual void push(SoState *) ;
152
153private:
154
156 virtual void commonInit();
157
159 virtual void init(SoState *state);
160
161 private:
162 // Initializes the SoTextureCoordinate3Element class
163 static void initClass();
164 static void exitClass();
165
166 struct SoTexCoord3Data {
167 SoTexCoord3Data()
168 :whatKind(EXPLICIT),
169 numCoords(0),coords3(NULL),coords4(NULL),coordsAre3D(FALSE),forceSend(FALSE)
170 {}
171
172
173 SoTexCoord3Data& operator=(const SoTexCoord3Data& data)
174 {
175 whatKind = data.whatKind ;
176 numCoords = data.numCoords ;
177 coords3 = data.coords3 ;
178 coords4 = data.coords4 ;
179 coordsAre3D = data.coordsAre3D ;
180 forceSend = data.forceSend;
181 return *this ;
182 }
183
184 // members
185 // What kind of coordinates will be done:
186 CoordType whatKind;
187
188 // Storage for EXPLICIT:
189 int32_t numCoords;
190 const SbVec3f *coords3;
191 const SbVec4f *coords4;
192 SbBool coordsAre3D;
193 SbBool forceSend;
194 } ;
195 SoTexCoord3Data& getData(const size_t unit) const;
196
197private:
198
200
201private:
202 void checkSize(const size_t size) const;
203 //Needed for get method which doesn't have state we need
204 SoState* m_state;
205 mutable std::vector<SoTexCoord3Data> m_texCoord3Data ;
206
207
208 SbVec3f convert3; // To convert from 4-D to 3-D
209 SbVec4f convert4; // To convert from 3-D to 4-D
210};
211
212#endif /* _SO_TEXTURE_COORDINATE3_ELEMENT */
213
214
3D vector class.
Definition SbVec.h:932
4D vector class.
Definition SbVec.h:2214
Abstract base class for all database nodes.
Definition SoNode.h:145
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Traversal state.
Definition SoState.h:74
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Stores the curre...
const SbVec4f & get4(int index, int unit=0) const
const SbVec4f & SoTextureCoordinate3FunctionCB(void *userdata, const SbVec3f &point, const SbVec3f &normal)
Function that TextureCoordinateFunction nodes register to compute texture coordinates.
SbBool isForceSending(int unit=0) const
static CoordType getType(SoState *state, int unit=0)
Returns code indicating what has been set in state/element.
static void set4(SoState *state, SoNode *node, int32_t numCoords, const SbVec4f *coords, SbBool frcSend=FALSE)
static void setDefault(SoState *state, SoNode *node)
Sets the current texture coordinates, in any of several ways: EXPLICIT, no coordinates (shapes will g...
const SbVec3f & get3(int index, int unit=0) const
Returns the indexed coordinate from an element as a 3- or 4-vector, converting if necessary.
static void set3(SoState *state, SoNode *node, int32_t numCoords, const SbVec3f *coords, SbBool frcSend=FALSE)
const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal, int unit=0) const
Given point and normal, returns texture coordinate.
virtual void print(FILE *fp) const
Prints element (for debugging).
CoordType
The choice of values is for compatibility with Open Inventor 2.0 binary format files.
virtual CoordType getType(int unit=0) const
int32_t getNum(int unit=0) const
Returns the number of coordinate points in an instance.
static const SoTextureCoordinate3Element * getInstance(SoState *state)
Returns the top (current) instance of the element in the state.
static void setFunction(SoState *state, SoNode *node, SoTextureCoordinate3FunctionCB *func, void *userData, SbBool frcSend=FALSE)
SbBool is3D(int unit=0) const
virtual void push(SoState *)
Overrides push() method to copy values from next instance in the stack.
Stores the current texture coordinates.
int SbBool
Boolean type.
Definition SbBase.h:87