Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoMultiTextureImageElement.h
1#ifndef COIN_SOMULTITEXTUREIMAGEELEMENT_H
2#define COIN_SOMULTITEXTUREIMAGEELEMENT_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/SoReplacedElement.h>
37#include <Inventor/SbVec2s.h>
38#include <Inventor/SbVec3s.h>
39#include <Inventor/SbColor.h>
40
41class SoState;
42class SoMultiTextureImageElementP;
43
44class COIN_DLL_API SoMultiTextureImageElement : public SoElement {
45 typedef SoElement inherited;
46
47 SO_ELEMENT_HEADER(SoMultiTextureImageElement);
48public:
49 static void initClass(void);
50protected:
52
53public:
54
55 enum Model {
56 // These should match GL_BLEND, GL_MODULATE and GL_DECAL for SGI
57 // Inventor compatibility (these are also used by SoTexture2 and
58 // SoTexture3).
59 BLEND = 0x0be2,
60 MODULATE = 0x2100,
61 DECAL = 0x2101,
62 REPLACE = 0x1E01 // must match GL_REPLACE
63 };
64
65 enum Wrap {
66 // These should match GL_CLAMP and GL_REPEAT for SGI Inventor
67 // compatibility (these are also used by SoTexture2 and
68 // SoTexture3).
69 CLAMP = 0x2900,
70 REPEAT = 0x2901,
71 CLAMP_TO_BORDER = 0x812D
72 };
73
74 virtual void init(SoState * state);
75 static void setDefault(SoState * const state, SoNode * const node, const int unit = 0);
76
77 static void set(SoState * const state, SoNode * const node,
78 const int unit,
79 const SbVec2s & size, const int numComponents,
80 const unsigned char * bytes,
81 const Wrap wrapS,
82 const Wrap wrapT,
83 const Model model, const SbColor & blendColor);
84 static void set(SoState * const state, SoNode * const node,
85 const int unit,
86 const SbVec3s & size, const int numComponents,
87 const unsigned char * bytes,
88 const Wrap wrapS,
89 const Wrap wrapT,
90 const Wrap wrapR,
91 const Model model, const SbColor & blendColor);
92
93 static const unsigned char *get(SoState * const state,
94 const int unit,
95 SbVec2s & size,
96 int & numComponents,
97 Wrap & wrapS,
98 Wrap & wrapT,
99 Model & model,
100 SbColor & blendColor);
101 static const unsigned char *get(SoState * const state,
102 const int unit,
103 SbVec3s & size,
104 int & numComponents,
105 Wrap & wrapS,
106 Wrap & wrapT,
107 Wrap & wrapR,
108 Model & model,
109 SbColor & blendColor);
110
111 static const unsigned char *getImage(SoState * const state,
112 const int unit,
113 SbVec2s & size,
114 int & numComponents);
115 static const unsigned char *getImage(SoState * const state,
116 const int unit,
117 SbVec3s &size,
118 int &numComponents);
119
120 static const SbColor & getBlendColor(SoState * const state, const int unit = 0);
121 static Model getModel(SoState * const state, const int unit = 0);
122 static Wrap getWrapS(SoState * const state, const int unit = 0);
123 static Wrap getWrapT(SoState * const state, const int unit = 0);
124 static Wrap getWrapR(SoState * const state, const int unit = 0);
125
126 static SbBool containsTransparency(SoState * const state);
127
128 static const unsigned char * getDefault(SbVec2s & size, int & numComponents);
129 static const unsigned char * getDefault(SbVec3s & size, int & numComponents);
130
131 virtual void push(SoState * state);
132 virtual SbBool matches(const SoElement * elem) const;
133 SoElement * copyMatchInfo(void) const;
134
135 virtual void setElt(const int unit,
136 const SbUniqueId nodeid,
137 const SbVec2s & size, const int numComponents,
138 const unsigned char * bytes,
139 const Wrap wrapS,
140 const Wrap wrapT,
141 const Model model,
142 const SbColor & blendColor);
143 virtual void setElt(const int unit,
144 const SbUniqueId nodeid,
145 const SbVec3s & size, const int numComponents,
146 const unsigned char * bytes,
147 const Wrap wrapS,
148 const Wrap wrapT,
149 const Wrap wrapR,
150 const Model model,
151 const SbColor & blendColor);
152
153 virtual SbBool hasTransparency(const int unit = 0) const;
154
155 class UnitData {
156 public:
157 UnitData();
158 UnitData(const UnitData & org);
159 SbUniqueId nodeid;
160 SbVec3s size;
161 int numComponents;
162 const unsigned char * bytes;
163 Wrap wrapS, wrapT, wrapR;
164 Model model;
165 SbColor blendColor;
166 };
167
168protected:
169 const UnitData & getUnitData(const int unit) const;
170 int getNumUnits() const;
171
172private:
173 SoMultiTextureImageElementP * pimpl;
174
175 public: // Coin-3 support
176 static void set(SoState * const state, SoNode * const node,
177 const SbVec2s & size, const int numComponents,
178 const unsigned char * bytes,
179 const int wrapS, const int wrapT,
180 const int model, const SbColor & blendColor) {
181 set(state, node,0, size, numComponents, bytes,
182 (Wrap) wrapS, (Wrap) wrapT, (Model) model, blendColor);
183 }
184 static void set(SoState * const state, SoNode * const node,
185 const SbVec2s & size, const int numComponents,
186 const unsigned char * bytes,
187 const Wrap wrapS, const Wrap wrapT,
188 const Model model, const SbColor & blendColor) {
189 set(state, node, 0, size, numComponents, bytes,
190 wrapS, wrapT, model, blendColor);
191 }
192
193 static void set(SoState * const state, SoNode * const node,
194 const SbVec3s & size, const int numComponents,
195 const unsigned char * bytes,
196 const int wrapS, const int wrapT, const int wrapR,
197 const int model, const SbColor & blendColor) {
198 set(state, node, 0, size, numComponents, bytes,
199 (Wrap) wrapS, (Wrap) wrapT, (Wrap) wrapR, (Model) model, blendColor);
200 }
201
202 static void set(SoState * const state, SoNode * const node,
203 const SbVec3s & size, const int numComponents,
204 const unsigned char * bytes,
205 const Wrap wrapS, const Wrap wrapT, const Wrap wrapR,
206 const Model model, const SbColor & blendColor) {
207 set(state, node, 0, size, numComponents, bytes,
208 wrapS, wrapT, wrapR, model, blendColor);
209 }
210
211 static const unsigned char *get(SoState * const state,
212 SbVec2s & size,
213 int & numComponents,
214 Wrap & wrapS,
215 Wrap & wrapT,
216 Model & model,
217 SbColor & blendColor) {
218 return get(state, 0, size, numComponents, wrapS, wrapT, model, blendColor);
219 }
220 static const unsigned char *get(SoState * const state,
221 SbVec3s & size,
222 int & numComponents,
223 Wrap & wrapS,
224 Wrap & wrapT,
225 Wrap & wrapR,
226 Model & model,
227 SbColor & blendColor) {
228 return get(state, 0, size, numComponents, wrapS, wrapT, wrapR, model, blendColor);
229 }
230
231 static const unsigned char *get(SoState * const state,
232 SbVec2s & size,
233 int & numComponents,
234 int & wrapS,
235 int & wrapT,
236 int & model,
237 SbColor & blendColor) {
238 Wrap s, t;
239 Model m;
240 const unsigned char * bytes = get(state, 0, size, numComponents, s, t, m, blendColor);
241 wrapS = (int) s;
242 wrapT = (int) t;
243 model = (int) m;
244 return bytes;
245 }
246 static const unsigned char *get(SoState * const state,
247 SbVec3s & size,
248 int & numComponents,
249 int & wrapS,
250 int & wrapT,
251 int & wrapR,
252 int & model,
253 SbColor & blendColor) {
254 Wrap s, t, r;
255 Model m;
256 const unsigned char * bytes = get(state, 0, size, numComponents, s, t, r, m, blendColor);
257 wrapS = (int) s;
258 wrapT = (int) t;
259 wrapR = (int) r;
260 model = (int) m;
261 return bytes;
262 }
263 static const unsigned char *getImage(SoState * const state,
264 SbVec2s &size,
265 int &numComponents) {
266 return getImage(state, 0, size, numComponents);
267 }
268 static const unsigned char *getImage(SoState * const state,
269 SbVec3s &size,
270 int &numComponents) {
271 return getImage(state, 0, size, numComponents);
272 }
273};
274
275#endif // !COIN_SOMULTITEXTUREIMAGEELEMENT_H
The SbColor class contains the red, green and blue components which make up a color value.
Definition SbColor.h:39
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:51
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition SbVec3s.h:51
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 SoMultiTextureImageElement.h:155
The SoMultiTextureImageElement class is yet to be documented.
Definition SoMultiTextureImageElement.h:44
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
SbByteBuffer get(const char *resloc)
Definition CoinResources.cpp:178
SbBool set(const char *resloc, const SbByteBuffer &buffer, ResourceFlags flags=NONE)
Definition CoinResources.cpp:294