Open Inventor Reference
SoTextureCoordinateElement.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the SoTextureCoordinateElement class.
48  | TextureCoordinates can be specified in several different ways,
49  | from several different nodes: they can be explicitly given by
50  | TextureCoordinate2/4 nodes, they can be automatically generated
51  | (the TextureCoordinateFunction nodes), or they can be DEFAULT,
52  | meaning that each shape must generate its own texture
53  | coordinates (can be set by TextureCoordinateFunctionDefault
54  | node).
55  |
56  | Shapes will have to call TextureCoordinateElement::getType() and
57  | then call either generate default texture coordinates if it
58  | returns DEFAULT, call get2/get4 if it returns EXPLICIT, or call
59  | get(point, normal) if it returns FUNCTION.
60  |
61  | Author(s) : Gavin Bell
62  |
63  ______________ S I L I C O N G R A P H I C S I N C . ____________
64  _______________________________________________________________________
65  */
66 
67 #ifndef _SO_TEXTURE_COORDINATE_ELEMENT
68 #define _SO_TEXTURE_COORDINATE_ELEMENT
69 
70 #include <Inventor/SbLinear.h>
72 
81 
85 typedef const SbVec4f &
86  SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point,
87  const SbVec3f &normal);
88 
90 
92 
93  public:
96  enum CoordType {
97  EXPLICIT = 1,
98  FUNCTION = 2
99  };
100 
102  virtual void init(SoState *state);
103 
106  static void setDefault(SoState *state, SoNode *node);
107 
109  static void setFunction(SoState *state, SoNode *node,
111  void *userData);
113  static void set2(SoState *state, SoNode *node,
114  int32_t numCoords, const SbVec2f *coords);
115  static void set4(SoState *state, SoNode *node,
116  int32_t numCoords, const SbVec4f *coords);
117 
119  static CoordType getType(SoState *state);
120  virtual CoordType getType() const;
121 
127 
129 
133  const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal) const;
134 
136 
138  int32_t getNum() const { return numCoords; }
139 
140  bool is2D() const { return coordsAre2D; }
141 
144  const SbVec2f & get2(int index) const;
145  const SbVec4f & get4(int index) const;
146 
147  virtual void print(FILE *fp) const;
148 
149  SoINTERNAL public:
151  static void initClass();
152 
153  protected:
156 
159  void *funcCBData;
160 
163  const SbVec2f *coords2;
164  const SbVec4f *coords4;
166 
168 
169  private:
170  SbVec2f convert2;
171  SbVec4f convert4;
172 };
173 
174 #endif /* _SO_TEXTURE_COORDINATE_ELEMENT */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
signed int int32_t
Definition: SbTypeDefs.h:43
#define SO_ELEMENT_HEADER(className)
This one is for non-abstract element classes.
Definition: SoSubElement.h:112
const SbVec4f & SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point, const SbVec3f &normal)
Function that TextureCoordinateFunction nodes register to compute texture coordinates.
2D vector class.
Definition: SbLinear.h:246
3D vector class.
Definition: SbLinear.h:120
4D vector class.
Definition: SbLinear.h:559
Abstract base class for all database nodes.
Definition: SoNode.h:103
This is the abstract base class for each state element whose value is replaced whenever it is set.
An SoState collects and holds state while traversing a scene graph.
Definition: SoState.h:82
Element storing the current texture coordinates.
virtual void init(SoState *state)
Initializes element.
static void setFunction(SoState *state, SoNode *node, SoTextureCoordinateFunctionCB *func, void *userData)
FUNCTION:
CoordType whatKind
What kind of coordinates will be done:
virtual void print(FILE *fp) const
Prints element (for debugging)
int32_t getNum() const
Get routines for EXPLICIT case:
static void set4(SoState *state, SoNode *node, int32_t numCoords, const SbVec4f *coords)
static void set2(SoState *state, SoNode *node, int32_t numCoords, const SbVec2f *coords)
EXPLICIT:
CoordType
The (seemingly random) choice of values is for compatibility with Inventor 2.0 binary format files:
virtual ~SoTextureCoordinateElement()
virtual CoordType getType() const
static void setDefault(SoState *state, SoNode *node)
Sets the current texture coordinates, in any of several ways: EXPLICIT, no coordinates (shapes will g...
const SbVec4f & get4(int index) const
static const SoTextureCoordinateElement * getInstance(SoState *state)
Returns the top (current) instance of the element in the state.
const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal) const
Get routine for FUNCTION case:
const SbVec2f & get2(int index) const
Returns the indexed coordinate from an element as a 2- or 4-vector, converting if necessary.
static CoordType getType(SoState *state)
Returns code indicating what has been set in state/element.
int32_t numCoords
Storage for EXPLICIT:
static void initClass()
Initializes the SoTextureCoordinateElement class.
SoTextureCoordinateFunctionCB * funcCB
Storage for FUNCTION: