Coin  4.0.10
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 void init(SoState * state) override;
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 void push(SoState * state) override;
132 SbBool matches(const SoElement * elem) const override;
133 SoElement * copyMatchInfo(void) const override;
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 UnitData & operator=(const UnitData & org) = default;
160 SbUniqueId nodeid;
161 SbVec3s size;
162 int numComponents;
163 const unsigned char * bytes;
164 Wrap wrapS, wrapT, wrapR;
165 Model model;
166 SbColor blendColor;
167 };
168
169protected:
170 const UnitData & getUnitData(const int unit) const;
171 int getNumUnits() const;
172
173private:
174 SoMultiTextureImageElementP * pimpl;
175
176 public: // Coin-3 support
177 static void set(SoState * const state, SoNode * const node,
178 const SbVec2s & size, const int numComponents,
179 const unsigned char * bytes,
180 const int wrapS, const int wrapT,
181 const int model, const SbColor & blendColor) {
182 set(state, node,0, size, numComponents, bytes,
183 (Wrap) wrapS, (Wrap) wrapT, (Model) model, blendColor);
184 }
185 static void set(SoState * const state, SoNode * const node,
186 const SbVec2s & size, const int numComponents,
187 const unsigned char * bytes,
188 const Wrap wrapS, const Wrap wrapT,
189 const Model model, const SbColor & blendColor) {
190 set(state, node, 0, size, numComponents, bytes,
191 wrapS, wrapT, model, blendColor);
192 }
193
194 static void set(SoState * const state, SoNode * const node,
195 const SbVec3s & size, const int numComponents,
196 const unsigned char * bytes,
197 const int wrapS, const int wrapT, const int wrapR,
198 const int model, const SbColor & blendColor) {
199 set(state, node, 0, size, numComponents, bytes,
200 (Wrap) wrapS, (Wrap) wrapT, (Wrap) wrapR, (Model) model, blendColor);
201 }
202
203 static void set(SoState * const state, SoNode * const node,
204 const SbVec3s & size, const int numComponents,
205 const unsigned char * bytes,
206 const Wrap wrapS, const Wrap wrapT, const Wrap wrapR,
207 const Model model, const SbColor & blendColor) {
208 set(state, node, 0, size, numComponents, bytes,
209 wrapS, wrapT, wrapR, model, blendColor);
210 }
211
212 static const unsigned char *get(SoState * const state,
213 SbVec2s & size,
214 int & numComponents,
215 Wrap & wrapS,
216 Wrap & wrapT,
217 Model & model,
218 SbColor & blendColor) {
219 return get(state, 0, size, numComponents, wrapS, wrapT, model, blendColor);
220 }
221 static const unsigned char *get(SoState * const state,
222 SbVec3s & size,
223 int & numComponents,
224 Wrap & wrapS,
225 Wrap & wrapT,
226 Wrap & wrapR,
227 Model & model,
228 SbColor & blendColor) {
229 return get(state, 0, size, numComponents, wrapS, wrapT, wrapR, model, blendColor);
230 }
231
232 static const unsigned char *get(SoState * const state,
233 SbVec2s & size,
234 int & numComponents,
235 int & wrapS,
236 int & wrapT,
237 int & model,
238 SbColor & blendColor) {
239 Wrap s, t;
240 Model m;
241 const unsigned char * bytes = get(state, 0, size, numComponents, s, t, m, blendColor);
242 wrapS = (int) s;
243 wrapT = (int) t;
244 model = (int) m;
245 return bytes;
246 }
247 static const unsigned char *get(SoState * const state,
248 SbVec3s & size,
249 int & numComponents,
250 int & wrapS,
251 int & wrapT,
252 int & wrapR,
253 int & model,
254 SbColor & blendColor) {
255 Wrap s, t, r;
256 Model m;
257 const unsigned char * bytes = get(state, 0, size, numComponents, s, t, r, m, blendColor);
258 wrapS = (int) s;
259 wrapT = (int) t;
260 wrapR = (int) r;
261 model = (int) m;
262 return bytes;
263 }
264 static const unsigned char *getImage(SoState * const state,
265 SbVec2s &size,
266 int &numComponents) {
267 return getImage(state, 0, size, numComponents);
268 }
269 static const unsigned char *getImage(SoState * const state,
270 SbVec3s &size,
271 int &numComponents) {
272 return getImage(state, 0, size, numComponents);
273 }
274};
275
276#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:296