Class BaseTwoSidedMaterial
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.shape.BaseTwoSidedMaterial
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLAppearanceChildNodeType
,VRMLMaterialNodeType
,VRMLNodeType
,VRMLSurfaceMaterialNodeType
,VRMLVisualMaterialNodeType
- Direct Known Subclasses:
OGLTwoSidedMaterial
Common base implementation of a two-sided material extension node.
- Version:
- $Revision: 1.4 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Field index for ambientIntensityprotected static final int
Field index for backAmbientIntensityprotected static final int
Field index for backDiffuseColorprotected static final int
Field index for backEmissiveColorprotected static final int
Field index for backShininessprotected static final int
Field index for backSpecularColorprotected static final int
Field index for backTransparencyprotected static final int
Field index for diffuseColorprotected static final int
Field index for emissiveColorprotected static final int
Field index for separateBackColorprotected static final int
Field index for shininessprotected static final int
Field index for specularColorprotected static final int
Field index for transparencyprotected boolean
Should we ignore the specified diffuseColorprotected static final int
Number of fields constantprotected float
exposedField SFFloat ambientIntensity 0.2protected float
exposedField SFFloat backAmbientIntensity 0.2protected float[]
exposedField SFColor backDiffuseColor 0.8 0.8 0.8protected float[]
exposedField SFColor backEmissiveColor 0 0 0protected float
exposedField SFFloat backShininess 0.2protected float[]
exposedField SFColor backSpecularColor 0 0 0protected float
exposedField SFFloat backTransparency 0protected float[]
exposedField SFColor diffuseColor 0.8 0.8 0.8protected float[]
exposedField SFColor emissiveColor 0 0 0protected boolean
exposedField SFBool separateBackColor FALSEprotected float
exposedField SFFloat shininess 0.2protected float[]
exposedField SFColor specularColor 0 0 0protected float
exposedField SFFloat transparency 0Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a default instance of the materialprotected
Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener instance for the material color change notifications.float
Accessor method to get current value of field ambientIntensity, default value is0.2
float[]
Accessor method to get current value of field diffuseColor, default value is0.8 0.8 0.8
.float[]
Accessor method to get current value of field emissiveColor, default value is0 0 0
.getFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.int
Get the primary type of this node.float
Accessor method to get current value of field shininess, default value is0.2
.float[]
Accessor method to get current value of field specularColor, default value is0 0 0
.float
Accessor method to get current value of field transparency, default value is0
void
Remove a listener instance from this node.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setAmbientIntensity
(float intensity) Set a new value for ambientIntensity.protected void
setBackAmbientIntensity
(float intensity) Set a new value for ambientIntensity.protected void
setBackDiffuseColor
(float[] color) Set a new value for diffuseColor.protected void
setBackEmissiveColor
(float[] color) Set a new value for emissiveColor.protected void
setBackShininess
(float shininess) Set a new value for shininess.protected void
setBackSpecularColor
(float[] color) Set a new value for the specularColor.protected void
setBackTransparency
(float trans) Set a new value for the transparency.void
setDiffuseColor
(float[] color) Set a new value for diffuseColor.void
setEmissiveColor
(float[] color) Set a new value for emissiveColor.void
setIgnoreDiffuse
(boolean ignore) Ignore the diffuseColor color term and use 1,1,1 for the diffuse color.protected void
setSeparateBackColor
(boolean state) Set a new value for the separated back face colour state.void
setShininess
(float shininess) Set a new value for shininess.void
setSpecularColor
(float[] color) Set a new value for the specularColor.void
setTransparency
(float trans) Set a new value for the transparency.void
setValue
(int index, boolean value) Set the value of the field at the given index as a float.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_AMBIENT_INTENSITY
protected static final int FIELD_AMBIENT_INTENSITYField index for ambientIntensity- See Also:
-
FIELD_BACK_AMBIENT_INTENSITY
protected static final int FIELD_BACK_AMBIENT_INTENSITYField index for backAmbientIntensity- See Also:
-
FIELD_DIFFUSE_COLOR
protected static final int FIELD_DIFFUSE_COLORField index for diffuseColor- See Also:
-
FIELD_BACK_DIFFUSE_COLOR
protected static final int FIELD_BACK_DIFFUSE_COLORField index for backDiffuseColor- See Also:
-
FIELD_EMISSIVE_COLOR
protected static final int FIELD_EMISSIVE_COLORField index for emissiveColor- See Also:
-
FIELD_BACK_EMISSIVE_COLOR
protected static final int FIELD_BACK_EMISSIVE_COLORField index for backEmissiveColor- See Also:
-
FIELD_SHININESS
protected static final int FIELD_SHININESSField index for shininess- See Also:
-
FIELD_BACK_SHININESS
protected static final int FIELD_BACK_SHININESSField index for backShininess- See Also:
-
FIELD_SPECULAR_COLOR
protected static final int FIELD_SPECULAR_COLORField index for specularColor- See Also:
-
FIELD_BACK_SPECULAR_COLOR
protected static final int FIELD_BACK_SPECULAR_COLORField index for backSpecularColor- See Also:
-
FIELD_TRANSPARENCY
protected static final int FIELD_TRANSPARENCYField index for transparency- See Also:
-
FIELD_BACK_TRANSPARENCY
protected static final int FIELD_BACK_TRANSPARENCYField index for backTransparency- See Also:
-
FIELD_SEPARATE_BACK_COLOR
protected static final int FIELD_SEPARATE_BACK_COLORField index for separateBackColor- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfAmbientIntensity
protected float vfAmbientIntensityexposedField SFFloat ambientIntensity 0.2 -
vfBackAmbientIntensity
protected float vfBackAmbientIntensityexposedField SFFloat backAmbientIntensity 0.2 -
vfDiffuseColor
protected float[] vfDiffuseColorexposedField SFColor diffuseColor 0.8 0.8 0.8 -
vfBackDiffuseColor
protected float[] vfBackDiffuseColorexposedField SFColor backDiffuseColor 0.8 0.8 0.8 -
vfEmissiveColor
protected float[] vfEmissiveColorexposedField SFColor emissiveColor 0 0 0 -
vfBackEmissiveColor
protected float[] vfBackEmissiveColorexposedField SFColor backEmissiveColor 0 0 0 -
vfShininess
protected float vfShininessexposedField SFFloat shininess 0.2 -
vfBackShininess
protected float vfBackShininessexposedField SFFloat backShininess 0.2 -
vfSpecularColor
protected float[] vfSpecularColorexposedField SFColor specularColor 0 0 0 -
vfBackSpecularColor
protected float[] vfBackSpecularColorexposedField SFColor backSpecularColor 0 0 0 -
vfTransparency
protected float vfTransparencyexposedField SFFloat transparency 0 -
vfBackTransparency
protected float vfBackTransparencyexposedField SFFloat backTransparency 0 -
vfSeparateBackColor
protected boolean vfSeparateBackColorexposedField SFBool separateBackColor FALSE -
ignoreDiffuse
protected boolean ignoreDiffuseShould we ignore the specified diffuseColor
-
-
Constructor Details
-
BaseTwoSidedMaterial
protected BaseTwoSidedMaterial()Construct a default instance of the material -
BaseTwoSidedMaterial
Construct a new instance of this node based on the details from the given node. If the node is not the right type, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a Group node
-
-
Method Details
-
setAmbientIntensity
Set a new value for ambientIntensity. How much ambient omnidirectional light is reflected from all light sources.- Specified by:
setAmbientIntensity
in interfaceVRMLMaterialNodeType
- Parameters:
intensity
- The new intensity value- Throws:
InvalidFieldValueException
-
getAmbientIntensity
public float getAmbientIntensity()Accessor method to get current value of field ambientIntensity, default value is0.2
- Specified by:
getAmbientIntensity
in interfaceVRMLMaterialNodeType
- Returns:
- The current ambientIntensity
-
setDiffuseColor
Set a new value for diffuseColor. How much direct, angle-dependent light is reflected from all light sources.- Specified by:
setDiffuseColor
in interfaceVRMLMaterialNodeType
- Parameters:
color
- The new value of diffuseColor- Throws:
InvalidFieldValueException
-
getDiffuseColor
public float[] getDiffuseColor()Accessor method to get current value of field diffuseColor, default value is0.8 0.8 0.8
.- Specified by:
getDiffuseColor
in interfaceVRMLMaterialNodeType
- Returns:
- The current value of diffuseColor
-
setEmissiveColor
Set a new value for emissiveColor. How much glowing light is emitted from this object.- Specified by:
setEmissiveColor
in interfaceVRMLMaterialNodeType
- Parameters:
color
- The new value of EmissiveColor- Throws:
InvalidFieldValueException
-
getEmissiveColor
public float[] getEmissiveColor()Accessor method to get current value of field emissiveColor, default value is0 0 0
.- Specified by:
getEmissiveColor
in interfaceVRMLMaterialNodeType
- Returns:
- The current value of EmissiveColor
-
setShininess
Set a new value for shininess. Low values provide soft specular glows, high values provide sharper, smaller highlights.- Specified by:
setShininess
in interfaceVRMLMaterialNodeType
- Parameters:
shininess
- The new value of Shininess- Throws:
InvalidFieldValueException
-
getShininess
public float getShininess()Accessor method to get current value of field shininess, default value is0.2
.- Specified by:
getShininess
in interfaceVRMLMaterialNodeType
- Returns:
- The current value of Shininess
-
setSpecularColor
Set a new value for the specularColor. Specular highlights are brightness reflections (example: shiny spots on an apple).- Specified by:
setSpecularColor
in interfaceVRMLMaterialNodeType
- Parameters:
color
- The new value of SpecularColor- Throws:
InvalidFieldValueException
-
getSpecularColor
public float[] getSpecularColor()Accessor method to get current value of field specularColor, default value is0 0 0
.- Specified by:
getSpecularColor
in interfaceVRMLMaterialNodeType
- Returns:
- The current value of SpecularColor
-
setTransparency
Set a new value for the transparency. How "clear" an object is: 1.0 is completely transparent, 0.0 is completely opaque .- Specified by:
setTransparency
in interfaceVRMLMaterialNodeType
- Parameters:
trans
- The new value of Transparency- Throws:
InvalidFieldValueException
-
setIgnoreDiffuse
public void setIgnoreDiffuse(boolean ignore) Ignore the diffuseColor color term and use 1,1,1 for the diffuse color.- Specified by:
setIgnoreDiffuse
in interfaceVRMLMaterialNodeType
- Parameters:
ignore
- True to ignore the diffuse term
-
getTransparency
public float getTransparency()Accessor method to get current value of field transparency, default value is0
- Specified by:
getTransparency
in interfaceVRMLMaterialNodeType
- Returns:
- The current value of Transparency
-
addMaterialColorListener
Add a listener instance for the material color change notifications. Adding the same instance more than once is ignored. Adding null values are ignored.- Specified by:
addMaterialColorListener
in interfaceVRMLMaterialNodeType
- Parameters:
l
- The new instance to add
-
removeMaterialColorListener
Remove a listener instance from this node. If the listener is not currently registered, the request is silently ignored.- Specified by:
removeMaterialColorListener
in interfaceVRMLMaterialNodeType
- Parameters:
l
- The new instance to remove
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of floats. This would be used to set SFColor field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setBackAmbientIntensity
Set a new value for ambientIntensity. How much ambient omnidirectional light is reflected from all light sources.- Parameters:
intensity
- The new intensity value- Throws:
InvalidFieldValueException
-
setBackDiffuseColor
Set a new value for diffuseColor. How much direct, angle-dependent light is reflected from all light sources.- Parameters:
color
- The new value of diffuseColor- Throws:
InvalidFieldValueException
-
setBackEmissiveColor
Set a new value for emissiveColor. How much glowing light is emitted from this object.- Parameters:
color
- The new value of EmissiveColor- Throws:
InvalidFieldValueException
-
setBackShininess
Set a new value for shininess. Low values provide soft specular glows, high values provide sharper, smaller highlights.- Parameters:
shininess
- The new value of Shininess- Throws:
InvalidFieldValueException
-
setBackSpecularColor
Set a new value for the specularColor. Specular highlights are brightness reflections (example: shiny spots on an apple).- Parameters:
color
- The new value of SpecularColor- Throws:
InvalidFieldValueException
-
setBackTransparency
Set a new value for the transparency. How "clear" an object is: 1.0 is completely transparent, 0.0 is completely opaque .- Parameters:
trans
- The new value of Transparency- Throws:
InvalidFieldValueException
-
setSeparateBackColor
protected void setSeparateBackColor(boolean state) Set a new value for the separated back face colour state.- Parameters:
state
- true to use different front from back colours
-