Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoTextureCoordinate3Element.h
Go to the documentation of this file.
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-2014 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>
29#include <Inventor/STL/vector>
30
37typedef const SbVec4f &
38SoTextureCoordinate3FunctionCB(void *userdata, const SbVec3f &point,
39 const SbVec3f &normal);
40
42
56
58
59public:
64 enum CoordType {
65 EXPLICIT = 1, // Coordinates stored in state
66 FUNCTION = 2 // Coordinates generated by software function
67 };
68
73 static void setDefault(SoState *state, SoNode *node);
74
75 // FUNCTION:
76 static void setFunction(SoState *state, SoNode *node,
78 void *userData,
79 SbBool frcSend = FALSE);
80
81 // EXPLICIT:
85 static void set3(SoState *state, SoNode *node,
86 int32_t numCoords, const SbVec3f *coords,
87 SbBool frcSend = FALSE);
88
92 static void set4(SoState *state, SoNode *node,
93 int32_t numCoords, const SbVec4f *coords,
94 SbBool frcSend = FALSE);
95
100 static CoordType getType(SoState *state, int unit=0);
101
102 virtual CoordType getType(int unit=0) const;
103
111
112 // Get routine for FUNCTION case:
113
119 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal,
120 int unit=0) const;
121
122 // Get routines for EXPLICIT case:
123
127 int32_t getNum(int unit=0) const ;
128
129 SbBool is3D(int unit=0) const ;
130
131 SbBool isForceSending(int unit=0) const ;
132
137 const SbVec3f & get3(int index, int unit=0) const;
138 const SbVec4f & get4(int index, int unit=0) const;
139
143 virtual void print(FILE *fp) const;
144
148 virtual void push(SoState *) ;
149
150private:
151
153 virtual void commonInit();
154
156 virtual void init(SoState *state);
157
158 private:
159 // Initializes the SoTextureCoordinate3Element class
160 static void initClass();
161 static void exitClass();
162
163 struct SoTexCoord3Data {
164 SoTexCoord3Data()
165 :whatKind(EXPLICIT),
166 numCoords(0),coords3(NULL),coords4(NULL),coordsAre3D(FALSE),forceSend(FALSE)
167 {}
168
169
170 SoTexCoord3Data& operator=(const SoTexCoord3Data& data)
171 {
172 whatKind = data.whatKind ;
173 numCoords = data.numCoords ;
174 coords3 = data.coords3 ;
175 coords4 = data.coords4 ;
176 coordsAre3D = data.coordsAre3D ;
177 forceSend = data.forceSend;
178 return *this ;
179 }
180
181 // members
182 // What kind of coordinates will be done:
183 CoordType whatKind;
184
185 // Storage for EXPLICIT:
186 int32_t numCoords;
187 const SbVec3f *coords3;
188 const SbVec4f *coords4;
189 SbBool coordsAre3D;
191 } ;
192 SoTexCoord3Data& getData(const size_t unit) const;
193
194private:
195
197
198private:
199 void checkSize(const size_t size) const;
200 //Needed for get method which doesn't have state we need
201 SoState* m_state;
202 mutable std::vector<SoTexCoord3Data> m_texCoord3Data ;
203
204
205 SbVec3f convert3; // To convert from 4-D to 3-D
206 SbVec4f convert4; // To convert from 3-D to 4-D
207};
208
209#endif /* _SO_TEXTURE_COORDINATE3_ELEMENT */
210
211
#define SoEXTENDER_Documented
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SoDEPRECATED void forceSend(int)
static void init()
#define SO_ELEMENT_HEADER(className)
valueRef operator=(valueRef newValue)
Sets this field to newValue.
Definition SoSubField.h:242
const SbVec4f & SoTextureCoordinate3FunctionCB(void *userdata, const SbVec3f &point, const SbVec3f &normal)
Function that TextureCoordinateFunction nodes register to compute texture coordinates.
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
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
size_t size() const