Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoTextureCoordinateElement.h
Go to the documentation of this file.
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-2014 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_COORDINATE_ELEMENT
51#define _SO_TEXTURE_COORDINATE_ELEMENT
52
53#include <Inventor/SbLinear.h>
55#include <Inventor/SbEnums.h>
56#include <memory>
57
58#include <Inventor/STL/vector>
59
65typedef const SbVec4f &
66SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point,
67 const SbVec3f &normal);
68
69
82
84
85 public:
90 enum CoordType {
91 EXPLICIT = 1, // Coordinates stored in state
92 FUNCTION = 2 // Coordinates generated by software function
93 };
94
99 static void setDefault(SoState *state, SoNode *node);
100
101 // FUNCTION:
102 static void setFunction(SoState *state, SoNode *node,
104 void *userData,
105 SbBool frcSend = FALSE);
106 // EXPLICIT:
110 static void set2(SoState *state, SoNode *node,
111 int32_t numCoords, const SbVec2f *coords,
112 SbBool frcSend = FALSE);
113
117 static void set4(SoState *state, SoNode *node,
118 int32_t numCoords, const SbVec4f *coords,
119 SbBool frcSend = FALSE);
120
125 static CoordType getType(SoState *state, int unit=0);
126
127 virtual CoordType getType(int unit=0) const;
128
136
137 // Get routine for FUNCTION case:
138
144 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal,
145 int unit=0) const;
146
147 // Get routines for EXPLICIT case:
148
152 int32_t getNum(int unit=0) const ;
153
154 SbBool is2D(int unit=0) const ;
155
156 SbBool isForceSending(int unit=0) const ;
157
162 const SbVec2f & get2(int index, int unit=0) const;
163 const SbVec4f & get4(int index, int unit=0) const;
164
168 virtual void print(FILE *fp) const;
169
173 virtual void push(SoState *) ;
174
175private:
176
178 virtual void commonInit();
179
181 virtual void init(SoState *state);
182
183 private:
188 class TexGenEvaluator
189 {
190 public:
191 virtual const SbVec4f& eval(const SbVec3f &point, const SbVec3f &normal) = 0;
192 };
193
195 static void setTextureCoordType(SoState *state, SoNode *node, CoordType coordType);
196
197 // Initializes the SoTextureCoordinateElement class
198 static void initClass();
199 static void exitClass();
200
201 private:
202
204
205 struct SoTexCoordData
206 {
207 // What kind of coordinates will be done:
208 CoordType whatKind;
209
210 // Storage for FUNCTION:
211 std::shared_ptr<TexGenEvaluator> m_texGenEvaluatorUserDefined;
212
213 // Storage for EXPLICIT:
214 int32_t numCoords;
215 const SbVec2f *coords2;
216 const SbVec4f *coords4;
217 SbBool coordsAre2D;
219
220 SoTexCoordData() :
221 whatKind(EXPLICIT),
222 numCoords(0),
223 coords2(NULL),
224 coords4(NULL),
225 coordsAre2D(FALSE),
227 {
228 }
229
230 void initValues( const CoordType &type )
231 {
232 whatKind = type;
233 numCoords = 0;
234 coords2 = NULL;
235 coords4 = NULL;
236 coordsAre2D = FALSE;
238 m_texGenEvaluatorUserDefined.reset();
239 }
240
241 SoTexCoordData& operator=(const SoTexCoordData& data)
242 {
243 if ( &data != this )
244 {
245 whatKind = data.whatKind ;
246 numCoords = data.numCoords ;
247 coords2 = data.coords2 ;
248 coords4 = data.coords4 ;
249 coordsAre2D = data.coordsAre2D ;
250 forceSend = data.forceSend;
251 }
252 return *this ;
253 }
254 } ;
255
256 SoTexCoordData& getTexCoordData( const int unit ) const;
257
258 private:
259 SbVec2f m_convert2; // To convert from 4-D to 2-D
260 SbVec4f m_convert4; // To convert from 2-D to 4-D
261
262 //Neeed for get method which don't have state we need
263 SoState* m_state;
264
265 typedef std::vector<SoTexCoordData> SoTexCoordDataList;
266
267 mutable SoTexCoordDataList m_texCoordData ;
268};
269
270
271#endif /* _SO_TEXTURE_COORDINATE_ELEMENT */
#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 & SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point, const SbVec3f &normal)
Function that TextureCoordinateFunction nodes register to compute texture coordinates.
2D vector class.
Definition SbVec.h:76
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
Stores the current texture coordinates.
SbBool isForceSending(int unit=0) const
virtual CoordType getType(int unit=0) const
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.
static const SoTextureCoordinateElement * getInstance(SoState *state)
Returns the top (current) instance of the element in the state.
virtual void push(SoState *)
Overrides push() method to copy values from next instance in the stack.
static void setDefault(SoState *state, SoNode *node)
Sets the current texture coordinates, in any of several ways: EXPLICIT, no coordinates (shapes will g...
static void set2(SoState *state, SoNode *node, int32_t numCoords, const SbVec2f *coords, SbBool frcSend=FALSE)
const SbVec4f & get4(int index, int unit=0) const
const SbVec2f & get2(int index, int unit=0) const
Returns the indexed coordinate from an element as a 2- or 4-vector, converting if necessary.
SbBool is2D(int unit=0) const
static void set4(SoState *state, SoNode *node, int32_t numCoords, const SbVec4f *coords, SbBool frcSend=FALSE)
static void setFunction(SoState *state, SoNode *node, SoTextureCoordinateFunctionCB *func, void *userData, SbBool frcSend=FALSE)
const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal, int unit=0) const
Given point and normal, returns texture coordinate.
int32_t getNum(int unit=0) const
Returns the number of coordinate points in an instance.
static CoordType getType(SoState *state, int unit=0)
Returns code indicating what has been set in state/element.
int SbBool
Boolean type.
Definition SbBase.h:87