51#ifndef _SO_LAZY_ELEMENT
52#define _SO_LAZY_ELEMENT
54#include <Inventor/SbBasic.h>
55#include <Inventor/SbColor.h>
56#include <Inventor/elements/SoElement.h>
57#include <Inventor/elements/SoSubElement.h>
58#include <Inventor/elements/SoLightModelElement.h>
60#include <Inventor/misc/SoColorPacker.h>
70#define SO_LAZY_SHINY_THRESHOLD 0.005
77#define SO_LAZY_NUM_COMPONENTS 12
123 LIGHT_MODEL_CASE = 0,
125 COLOR_MATERIAL_CASE = 1,
139 TRANSPARENCY_CASE = 8,
151 LIGHT_MODEL_MASK = 1 << LIGHT_MODEL_CASE,
153 COLOR_MATERIAL_MASK = 1 << COLOR_MATERIAL_CASE,
155 DIFFUSE_MASK = 1 << DIFFUSE_CASE,
157 AMBIENT_MASK = 1 << AMBIENT_CASE,
159 EMISSIVE_MASK = 1 << EMISSIVE_CASE,
161 SPECULAR_MASK = 1 << SPECULAR_CASE,
163 SHININESS_MASK = 1 << SHININESS_CASE,
165 TRANSPARENCY_MASK = 1 << TRANSPARENCY_CASE,
167 BLENDING_MASK = 1 << BLENDING_CASE,
169 SMOOTHING_MASK = 1 << SMOOTHING_CASE,
171 ALL_MASK = (1 << SO_LAZY_NUM_COMPONENTS)-1,
173 PATTERN_MASK = 1 << PATTERN_CASE,
175 LINE_WIDTH_MASK = 1 << LINE_WIDTH_CASE
210 const uint32_t *colors);
220 const int32_t *indices);
229 { setAmbient(state, node, *color); }SoDEPRECATED
235 { setEmissive(state, node, *color); }SoDEPRECATED
241 { setSpecular(state, node, *color); }
291 return ivState.numDiffuseColors;
297 return ivState.numTransparencies;
303 return (ivState.colorIndices ? ivState.numDiffuseColors : 0);
309 return ivState.packed;
340 return SbColor(0.8F, 0.8F, 0.8F);
346 return SbColor(0.2F, 0.2F, 0.2F);
352 return SbColor(0.0F, 0.0F, 0.0F);
358 return SbColor(0.0F, 0.0F, 0.0F);
409 virtual void commonInit();
412 virtual void init(
SoState *state);
427 virtual SoElement* copyMatchInfo()
const;
432 static void setMaterials(
SoState *state,
444 static void setMaterials(
SoState *state,
461 static void initClass();
462 static void exitClass();
468 const uint32_t *getPackedPointer()
const {
469 return ivState.packedColors.empty() ? NULL : &ivState.packedColors[0];
471 const SbColor *getDiffusePointer()
const {
472 return ivState.diffuseColors;
474 const int32_t *getColorIndexPointer()
const {
475 return ivState.colorIndices;
477 const float *getTransparencyPointer()
const {
478 return ivState.transparencies;
481 static void setHasTransparency(
SoState* state,
int hasTransparency );
485 static void setTransparencyType(
SoState *state, int32_t type);
490 static bool shouldSendMaterial(
SoState *state);
498 static void setLineWidth(
SoState *state,
float width);
501 OTHER_COLOR_MASK = AMBIENT_MASK|EMISSIVE_MASK|SPECULAR_MASK|SHININESS_MASK,
502 ALL_COLOR_MASK = OTHER_COLOR_MASK|DIFFUSE_MASK,
503 NO_COLOR_MASK = ALL_MASK & (~ALL_COLOR_MASK),
504 ALL_BUT_DIFFUSE_MASK = ALL_MASK &(~ DIFFUSE_MASK),
505 DIFFUSE_ONLY_MASK = ALL_MASK &(~ OTHER_COLOR_MASK)
510 virtual void registerGetDependence(
SoState *, uint32_t);
519 virtual void registerRedundantSet(
SoState *, uint32_t);
527 , ambientColor(0,0,0)
528 , emissiveColor(0,0,0)
529 , specularColor(0,0,0)
537 , packedTransparent(false)
538 , numDiffuseColors(0)
539 , numTransparencies(0)
544 , cacheLevelSetBits(0)
545 , cacheLevelSendBits(0)
546 , patternStippleNum(0)
552 uint64_t diffuseNodeId;
556 uint64_t transpNodeId;
564 int32_t colorMaterial;
574 int32_t numDiffuseColors;
575 int32_t numTransparencies;
577 const float *transparencies;
578 std::vector<uint32_t> packedColors;
579 std::vector<uint32_t> packedColors2;
580 const int32_t *colorIndices;
582 uint32_t cacheLevelSetBits;
583 uint32_t cacheLevelSendBits;
584 int32_t patternStippleNum;
593 uint32_t invalidBits;
597 static SbColor *defaultDiffuseColor;
598 static float *defaultTransparency;
599 static int32_t *defaultColorIndices;
600 static uint32_t *defaultPackedColor;
604 static int getNumPatterns() {
608 int m_hasTransparency;
612 virtual void setDiffuseElt(
SoNode *,
616 virtual void setPackedElt(
SoNode *,
618 const uint32_t *colors,
620 virtual void setColorIndexElt(
SoNode *,
622 const int32_t *indices);
623 virtual void setTranspElt(
SoNode *,
627 virtual void setPatternFlagElt(
SbBool flag);
628 virtual void setTranspTypeElt(int32_t type);
629 virtual void setAmbientElt(
const SbColor *color);
630 virtual void setEmissiveElt(
const SbColor *color);
631 virtual void setSpecularElt(
const SbColor *color);
632 virtual void setShininessElt(
float value);
633 virtual void setColorMaterialElt(
SbBool value);
634 virtual void setBlendingElt(
SbBool value);
635 virtual void setSmoothingElt(
SbBool value);
636 virtual void setLightModelElt(
SoState *state, int32_t model);
637 virtual void setLineWidthElt(
float lineWidth);
638 virtual void setMaterialElt(
SoNode *,
647 virtual void setMaterialElt(
SoNode *,
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
Abstract base class for all state elements.
Manages several properties that need to be lazily tracked for OpenGL.
static float getDefaultLineWidth()
Specify Open Inventor defaults for colors, etc.
static const int32_t * getColorIndices(SoState *state)
static void setPacked(SoState *state, SoNode *node, SoColorPacker *cPacker, int32_t numColors, const uint32_t *colors)
Static set method.
static int32_t getColorIndex(SoState *, int num)
static void setColorMaterial(SoState *state, SoNode *node, SbBool value)
static void setShininess(SoState *state, SoNode *node, float value)
static float getTransparency(SoState *, int index)
get() methods get value from Inventor state.
cases
Following masks and cases define the components of the lazy element.
static const uint32_t * getPackedColors(SoState *state)
int32_t getNumDiffuse() const
Method to inquire about current colors.
static SbColor getDefaultEmissive()
Specify Open Inventor defaults for colors, etc.
static SoDEPRECATED void setEmissive(SoState *state, SoNode *node, const SbColor *color)
static SbColor getDefaultSpecular()
Specify Open Inventor defaults for colors, etc.
static SbColor getDefaultAmbient()
Specify Open Inventor defaults for colors, etc.
static void setEmissive(SoState *state, SoNode *node, const SbColor &color)
static SoLazyElement * getInstance(SoState *state)
Returns the top (current) instance of the element in the state Note that the cache dependencies assoc...
static uint32_t getDefaultPacked()
Specify Open Inventor defaults for colors, etc.
static SoType getClassTypeId()
Returns the type identifier for this class.
static void setSpecular(SoState *state, SoNode *node, const SbColor &color)
static void setLightModel(SoState *state, const int32_t model)
static void setSmoothing(SoState *state, SbBool value)
static SbBool getColorMaterial(SoState *)
static void setColorIndices(SoState *state, SoNode *node, int32_t numIndices, const int32_t *indices)
Static set method.
SbBool isTransparent() const
Method to inquire about current colors.
static void setBlending(SoState *state, SbBool value)
static uint32_t getDefaultPackedInternal()
Specify Open Inventor defaults for colors, etc.
static void setTransparency(SoState *state, SoNode *node, int32_t numTransp, const float *transp, SoColorPacker *cPacker)
Static set method.
static float getDefaultShininess()
Specify Open Inventor defaults for colors, etc.
static SbColor getDiffuse(SoState *state, int index)
get() methods get value from Inventor state.
static SbColor getSpecular(SoState *)
static void setAmbient(SoState *state, SoNode *node, const SbColor &color)
virtual void print(FILE *fp) const
Prints element (for debugging).
static int32_t getDefaultLightModel()
Specify Open Inventor defaults for colors, etc.
SbBool isPacked() const
Method to inquire about current colors.
int32_t getNumColorIndices() const
Method to inquire about current colors.
static float getDefaultAmbientIntensity()
Specify Open Inventor defaults for colors, etc.
virtual void push(SoState *state)
push (for non-GL elements)
static SbBool getSmoothing(SoState *)
static SbColor getAmbient(SoState *)
static void setDiffuse(SoState *state, SoNode *node, int32_t numColors, const SbColor *colors, SoColorPacker *cPacker)
Static set method.
static SbBool getBlending(SoState *)
static int32_t getDefaultColorIndex()
Specify Open Inventor defaults for colors, etc.
static SbColor getEmissive(SoState *)
static float getDefaultTransparency()
Specify Open Inventor defaults for colors, etc.
static SoDEPRECATED void setAmbient(SoState *state, SoNode *node, const SbColor *color)
int32_t getNumTransparencies() const
Method to inquire about current colors.
static int32_t getLightModel(SoState *)
static SoDEPRECATED void setSpecular(SoState *state, SoNode *node, const SbColor *color)
static SbColor getDefaultDiffuse()
Specify Open Inventor defaults for colors, etc.
static float getShininess(SoState *)
@ PER_VERTEX_PHONG
Per-vertex Phong lighting.
Multiple-value field containing any number of RGB colors stored as three floats.
Multiple-value field containing any number of floating point values.
Abstract base class for all database nodes.
T * getElement()
Returns a writable instance of the element on the top of the stack with the given type.