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 intField index for ambientIntensityprotected static final intField index for backAmbientIntensityprotected static final intField index for backDiffuseColorprotected static final intField index for backEmissiveColorprotected static final intField index for backShininessprotected static final intField index for backSpecularColorprotected static final intField index for backTransparencyprotected static final intField index for diffuseColorprotected static final intField index for emissiveColorprotected static final intField index for separateBackColorprotected static final intField index for shininessprotected static final intField index for specularColorprotected static final intField index for transparencyprotected booleanShould we ignore the specified diffuseColorprotected static final intNumber of fields constantprotected floatexposedField SFFloat ambientIntensity 0.2protected floatexposedField SFFloat backAmbientIntensity 0.2protected float[]exposedField SFColor backDiffuseColor 0.8 0.8 0.8protected float[]exposedField SFColor backEmissiveColor 0 0 0protected floatexposedField SFFloat backShininess 0.2protected float[]exposedField SFColor backSpecularColor 0 0 0protected floatexposedField SFFloat backTransparency 0protected float[]exposedField SFColor diffuseColor 0.8 0.8 0.8protected float[]exposedField SFColor emissiveColor 0 0 0protected booleanexposedField SFBool separateBackColor FALSEprotected floatexposedField SFFloat shininess 0.2protected float[]exposedField SFColor specularColor 0 0 0protected floatexposedField 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
ConstructorsModifierConstructorDescriptionprotectedConstruct a default instance of the materialprotectedConstruct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener instance for the material color change notifications.floatAccessor method to get current value of field ambientIntensity, default value is0.2float[]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.intgetFieldIndex(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).intGet the number of fields.intGet the primary type of this node.floatAccessor 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.floatAccessor method to get current value of field transparency, default value is0voidRemove a listener instance from this node.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetAmbientIntensity(float intensity) Set a new value for ambientIntensity.protected voidsetBackAmbientIntensity(float intensity) Set a new value for ambientIntensity.protected voidsetBackDiffuseColor(float[] color) Set a new value for diffuseColor.protected voidsetBackEmissiveColor(float[] color) Set a new value for emissiveColor.protected voidsetBackShininess(float shininess) Set a new value for shininess.protected voidsetBackSpecularColor(float[] color) Set a new value for the specularColor.protected voidsetBackTransparency(float trans) Set a new value for the transparency.voidsetDiffuseColor(float[] color) Set a new value for diffuseColor.voidsetEmissiveColor(float[] color) Set a new value for emissiveColor.voidsetIgnoreDiffuse(boolean ignore) Ignore the diffuseColor color term and use 1,1,1 for the diffuse color.protected voidsetSeparateBackColor(boolean state) Set a new value for the separated back face colour state.voidsetShininess(float shininess) Set a new value for shininess.voidsetSpecularColor(float[] color) Set a new value for the specularColor.voidsetTransparency(float trans) Set a new value for the transparency.voidsetValue(int index, boolean value) Set the value of the field at the given index as a float.voidsetValue(int index, float value) Set the value of the field at the given index as a float.voidsetValue(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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsCompleteMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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:
setAmbientIntensityin 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:
getAmbientIntensityin 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:
setDiffuseColorin 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:
getDiffuseColorin 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:
setEmissiveColorin 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:
getEmissiveColorin 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:
setShininessin 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:
getShininessin 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:
setSpecularColorin 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:
getSpecularColorin 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:
setTransparencyin 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:
setIgnoreDiffusein 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:
getTransparencyin 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:
addMaterialColorListenerin 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:
removeMaterialColorListenerin 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:
getNodeFieldIndicesin 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:
getFieldIndexin 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:
getFieldDeclarationin 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:
getNumFieldsin 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:
getPrimaryTypein 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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
-