Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoMultiTextureCoordinateElement.h
1#ifndef COIN_SOMULTITEXTURECOORDINATEELEMENT_H
2#define COIN_SOMULTITEXTURECOORDINATEELEMENT_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/elements/SoElement.h>
37#include <Inventor/elements/SoSubElement.h>
38#include <Inventor/SbVec2f.h>
39#include <Inventor/SbVec3f.h>
40#include <Inventor/SbVec4f.h>
41
42typedef const SbVec4f & SoTextureCoordinateFunctionCB(void * userdata,
43 const SbVec3f & point,
44 const SbVec3f & normal);
45
46class SoMultiTextureCoordinateElementP;
47
48class COIN_DLL_API SoMultiTextureCoordinateElement : public SoElement {
49 typedef SoElement inherited;
50
51 SO_ELEMENT_HEADER(SoMultiTextureCoordinateElement);
52public:
53 static void initClass(void);
54protected:
56
57public:
58
59 enum CoordType {
60 NONE = 0,
61 TEXGEN = 0,
62 EXPLICIT = 1,
63 FUNCTION = 2,
64 DEFAULT = 3
65 };
66
67 virtual void init(SoState * state);
68
69 static void setDefault(SoState * const state, SoNode * const node, const int unit = 0);
70 static void setFunction(SoState * const state, SoNode * const node,
71 const int unit,
72 SoTextureCoordinateFunctionCB * const func,
73 void * const userdata);
74
75 static void set2(SoState * const state, SoNode * const node,
76 const int unit,
77 const int32_t numCoords, const SbVec2f * const coords);
78 static void set3(SoState * const state, SoNode * const node,
79 const int unit,
80 const int32_t numCoords, const SbVec3f * const coords);
81 static void set4(SoState * const state, SoNode * const node,
82 const int unit,
83 const int32_t numCoords, const SbVec4f * const coords);
84
85 static CoordType getType(SoState * const state, const int unit = 0);
86 virtual CoordType getType(const int unit = 0) const;
87
88 static const SoMultiTextureCoordinateElement * getInstance(SoState * const state);
89
90 const SbVec4f & get(const int unit,
91 const SbVec3f & point,
92 const SbVec3f & normal) const;
93
94 int32_t getNum(const int unit = 0) const;
95 SbBool is2D(const int unit = 0) const;
96 int32_t getDimension(const int unit = 0) const;
97
98 const SbVec2f & get2(const int unit, const int index) const;
99 const SbVec3f & get3(const int unit, const int index) const;
100 const SbVec4f & get4(const int unit, const int index) const;
101
102 const SbVec2f * getArrayPtr2(const int unit = 0) const;
103 const SbVec3f * getArrayPtr3(const int unit = 0) const;
104 const SbVec4f * getArrayPtr4(const int unit = 0) const;
105
106 class UnitData {
107 public:
108 UnitData();
109 UnitData(const UnitData & org);
110
111 SbUniqueId nodeid;
112 CoordType whatKind;
113 SoTextureCoordinateFunctionCB * funcCB;
114 void * funcCBData;
115 int32_t numCoords;
116 const SbVec2f * coords2;
117 const SbVec3f * coords3;
118 const SbVec4f * coords4;
119 int coordsDimension;
120 };
121
122 virtual void push(SoState * state);
123 virtual SbBool matches(const SoElement * elem) const;
124 SoElement * copyMatchInfo(void) const;
125
126 // Coin-3 support
127 const SbVec4f & get(const SbVec3f & point,
128 const SbVec3f & normal) const {
129 return this->get(0, point, normal);
130 }
131
132 static void setFunction(SoState * const state,
133 SoNode * const node,
134 SoTextureCoordinateFunctionCB * const func,
135 void * const userdata) {
136 setFunction(state, node, 0, func, userdata);
137 }
138
139 static void set2(SoState * const state, SoNode * const node,
140 const int32_t numCoords, const SbVec2f * const coords) {
141 set2(state, node, 0, numCoords, coords);
142 }
143 static void set3(SoState * const state, SoNode * const node,
144 const int32_t numCoords, const SbVec3f * const coords) {
145 set3(state, node, 0, numCoords, coords);
146 }
147 static void set4(SoState * const state, SoNode * const node,
148 const int32_t numCoords, const SbVec4f * const coords) {
149 set4(state, node, 0, numCoords, coords);
150 }
151 const SbVec2f & get2(const int index) const {
152 return this->get2(0, index);
153 }
154 const SbVec3f & get3(const int index) const {
155 return this->get3(0, index);
156 }
157 const SbVec4f & get4(const int index) const {
158 return this->get4(0, index);
159 }
160
161
162protected:
163 int getMaxUnits() const;
164 UnitData & getUnitData(const int unit);
165 const UnitData & getUnitData(const int unit) const;
166 SbVec2f convert2;
167 SbVec3f convert3;
168 SbVec4f convert4;
169
170private:
171 SoMultiTextureCoordinateElementP * pimpl;
172};
173
174#endif // !COIN_SOMULTITEXTURECOORDINATEELEMENT_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:49
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
The SbVec4f class is a 4 dimensional vector with floating point coordinates.
Definition SbVec4f.h:49
SoElement is the abstract base class for all elements.
Definition SoElement.h:43
virtual SoElement * copyMatchInfo(void) const =0
virtual SbBool matches(const SoElement *element) const =0
Definition SoElement.cpp:609
static void initClass(void)
Definition SoElement.cpp:507
virtual void init(SoState *state)
Definition SoElement.cpp:553
virtual void push(SoState *state)
Definition SoElement.cpp:570
Definition SoMultiTextureCoordinateElement.h:106
The SoMultiTextureCoordinateElement class is yet to be documented.
Definition SoMultiTextureCoordinateElement.h:48
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
The SoState class manages the Coin scene graph traversal state data.
Definition SoState.h:44