1 #ifndef COIN_SOLAZYELEMENT_H 2 #define COIN_SOLAZYELEMENT_H 27 #include <Inventor/elements/SoElement.h> 28 #include <Inventor/elements/SoSubElement.h> 29 #include <Inventor/SbColor.h> 37 #define SO_LAZY_SHINY_THRESHOLD 0.005f 69 LIGHT_MODEL_MASK = 1 << LIGHT_MODEL_CASE,
70 COLOR_MATERIAL_MASK = 1 << COLOR_MATERIAL_CASE,
71 DIFFUSE_MASK = 1 << DIFFUSE_CASE,
72 AMBIENT_MASK = 1 << AMBIENT_CASE,
73 EMISSIVE_MASK = 1<<EMISSIVE_CASE,
74 SPECULAR_MASK = 1 << SPECULAR_CASE,
75 SHININESS_MASK = 1 << SHININESS_CASE,
76 TRANSPARENCY_MASK = 1 << TRANSPARENCY_CASE,
77 BLENDING_MASK = 1 << BLENDING_CASE,
78 VERTEXORDERING_MASK = 1 << VERTEXORDERING_CASE,
79 TWOSIDE_MASK = 1 << TWOSIDE_CASE,
80 CULLING_MASK = 1 << CULLING_CASE,
81 SHADE_MODEL_MASK = 1 << SHADE_MODEL_CASE,
82 GLIMAGE_MASK = 1 << GLIMAGE_CASE,
83 ALPHATEST_MASK = 1 << ALPHATEST_CASE,
84 ALL_MASK = (1 << LAZYCASES_LAST)-1
88 OTHER_COLOR_MASK = AMBIENT_MASK|EMISSIVE_MASK|SPECULAR_MASK|SHININESS_MASK,
89 ALL_COLOR_MASK = OTHER_COLOR_MASK|DIFFUSE_MASK,
90 NO_COLOR_MASK = ALL_MASK & (~ALL_COLOR_MASK),
91 ALL_BUT_DIFFUSE_MASK = ALL_MASK &(~ DIFFUSE_MASK),
92 DIFFUSE_ONLY_MASK = ALL_MASK &(~ OTHER_COLOR_MASK)
100 enum VertexOrdering {
110 static void setToDefault(
SoState * state);
111 static void setDiffuse(
SoState * state,
SoNode * node, int32_t numcolors,
112 const SbColor * colors, SoColorPacker * packer);
113 static void setTransparency(
SoState *state,
SoNode *node, int32_t numvalues,
114 const float * transparency, SoColorPacker * packer);
116 int32_t numcolors,
const uint32_t * colors,
117 const SbBool packedtransparency = FALSE);
119 int32_t numindices,
const int32_t *indices);
123 static void setShininess(
SoState *state,
float value);
124 static void setColorMaterial(
SoState *state, SbBool value);
125 static void enableBlending(
SoState *state,
128 static void enableSeparateBlending(
SoState *state,
134 static void disableBlending(
SoState * state);
135 static void setLightModel(
SoState *state,
const int32_t model);
136 static void setVertexOrdering(
SoState * state, VertexOrdering ordering);
137 static void setBackfaceCulling(
SoState * state, SbBool onoff);
138 static void setTwosideLighting(
SoState * state, SbBool onoff);
139 static void setShadeModel(
SoState * state, SbBool flatshading);
140 static void setGLImageId(
SoState * state, uint32_t glimageid, SbBool alphatest);
141 static void setAlphaTest(
SoState * state, SbBool onoff);
144 static float getTransparency(
SoState*,
int index);
145 static const uint32_t * getPackedColors(
SoState*);
146 static const int32_t * getColorIndices(
SoState*);
147 static int32_t getColorIndex(
SoState*,
int num);
151 static float getShininess(
SoState*);
152 static SbBool getColorMaterial(
SoState*);
153 static SbBool getBlending(
SoState *,
154 int & sfactor,
int & dfactor);
155 static SbBool getAlphaBlending(
SoState *,
156 int & sfactor,
int & dfactor);
158 static int32_t getLightModel(
SoState*);
159 static SbBool getAlphaTest(
SoState * state);
161 int32_t getNumDiffuse(
void)
const;
162 int32_t getNumTransparencies(
void)
const;
163 int32_t getNumColorIndices(
void)
const;
164 SbBool isPacked(
void)
const;
165 SbBool isTransparent(
void)
const;
167 static float getDefaultAmbientIntensity(
void);
169 static SbColor getDefaultDiffuse(
void);
170 static SbColor getDefaultAmbient(
void);
171 static SbColor getDefaultSpecular(
void);
172 static SbColor getDefaultEmissive(
void);
173 static float getDefaultShininess(
void);
174 static uint32_t getDefaultPacked(
void);
175 static float getDefaultTransparency(
void);
176 static int32_t getDefaultLightModel(
void);
177 static int32_t getDefaultColorIndex(
void);
179 static void setMaterials(
SoState * state,
SoNode *node, uint32_t bitmask,
180 SoColorPacker * cPacker,
182 const int numdiffuse,
183 const float * transp,
188 const float shininess,
189 const SbBool istransparent);
193 const uint32_t * getPackedPointer(
void)
const;
194 const SbColor * getDiffusePointer(
void)
const;
195 const int32_t * getColorIndexPointer(
void)
const;
197 const float * getTransparencyPointer(
void)
const;
198 static void setTransparencyType(
SoState * state, int32_t type);
202 struct COIN_DLL_API CoinState {
210 int alpha_blend_sfactor;
211 int alpha_blend_dfactor;
213 SbBool packeddiffuse;
217 const uint32_t * packedarray;
218 const float * transparray;
219 const int32_t * colorindexarray;
221 SbBool istransparent;
222 uint32_t diffusenodeid;
223 uint32_t transpnodeid;
225 VertexOrdering vertexordering;
232 SbBool glimageusealphatest;
233 uint32_t reserved[4];
237 virtual void lazyDidSet(uint32_t mask);
238 virtual void lazyDidntSet(uint32_t mask);
240 virtual void setDiffuseElt(
SoNode*, int32_t numcolors,
241 const SbColor * colors, SoColorPacker * packer);
242 virtual void setPackedElt(
SoNode * node, int32_t numcolors,
243 const uint32_t * colors,
const SbBool packedtransparency);
244 virtual void setColorIndexElt(
SoNode * node, int32_t numindices,
245 const int32_t * indices);
246 virtual void setTranspElt(
SoNode * node, int32_t numtransp,
247 const float * transp, SoColorPacker * packer);
249 virtual void setTranspTypeElt(int32_t type);
250 virtual void setAmbientElt(
const SbColor* color);
251 virtual void setEmissiveElt(
const SbColor* color);
252 virtual void setSpecularElt(
const SbColor* color);
253 virtual void setShininessElt(
float value);
254 virtual void setColorMaterialElt(SbBool value);
255 virtual void enableBlendingElt(
int sfactor,
int dfactor,
int alpha_sfactor,
int alpha_dfactor);
256 virtual void disableBlendingElt(
void);
257 virtual void setLightModelElt(
SoState *state, int32_t model);
258 virtual void setMaterialElt(
SoNode * node, uint32_t bitmask,
259 SoColorPacker * packer,
260 const SbColor * diffuse,
const int numdiffuse,
261 const float * transp,
const int numtransp,
265 const float shininess,
266 const SbBool istransparent);
267 virtual void setVertexOrderingElt(VertexOrdering ordering);
268 virtual void setBackfaceCullingElt(SbBool onoff);
269 virtual void setTwosideLightingElt(SbBool onoff);
270 virtual void setShadeModelElt(SbBool flatshading);
271 virtual void setGLImageIdElt(uint32_t glimageid, SbBool alphatest);
272 virtual void setAlphaTestElt(SbBool onoff);
275 SoLazyElementP * pimpl;
279 class COIN_DLL_API SoColorPacker {
284 uint32_t * getPackedColors(
void)
const {
287 SbBool diffuseMatch(
const uint32_t nodeid)
const {
288 return nodeid == this->diffuseid;
290 SbBool transpMatch(
const uint32_t nodeid)
const {
291 return nodeid == this->transpid;
293 void setNodeIds(
const uint32_t diffuse,
const uint32_t transp) {
294 this->diffuseid = diffuse;
295 this->transpid = transp;
297 int32_t getSize(
void)
const {
298 return this->arraysize;
300 void reallocate(
const int32_t size);
302 uint32_t getDiffuseId(
void)
const {
303 return this->diffuseid;
305 uint32_t getTranspId(
void)
const {
306 return this->transpid;
315 #endif // !COIN_SOLAZYELEMENT_H The SoMFFloat class is a container for floating point values.This field is used where nodes...
Definition: SoMFFloat.h:30
The SbColor class contains the red, green and blue components which make up a color value...
Definition: SbColor.h:30
The SoMFColor class is a container for SbColor values.This field is used where nodes, engines or other field containers needs to store multiple color values (i.e. "Red Green Blue" triplets).
Definition: SoMFColor.h:31
static void initClass(void)
Definition: SoElement.cpp:507
virtual SbBool matches(const SoElement *element) const =0
Definition: SoElement.cpp:609
virtual void push(SoState *state)
Definition: SoElement.cpp:570
The SoNode class is the base class for nodes used in scene graphs.Coin is a retained mode 3D visualiz...
Definition: SoNode.h:47
SoElement is the abstract base class for all elements.
Definition: SoElement.h:34
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:35
virtual void init(SoState *state)
Definition: SoElement.cpp:553
virtual SoElement * copyMatchInfo(void) const =0
The SoGLImage class is used to handle OpenGL 2D/3D textures.
Definition: SoGLImage.h:44
The SoLazyElement class is used to handle material and shape properties.So[GL]LazyElement is...
Definition: SoLazyElement.h:40