Class BaseMaterial
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.shape.BaseMaterial
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLAppearanceChildNodeType
,VRMLMaterialNodeType
,VRMLNodeType
,VRMLSurfaceMaterialNodeType
,VRMLVisualMaterialNodeType
- Direct Known Subclasses:
NRMaterial
,OGLMaterial
Common base implementation of a material node.
- Version:
- $Revision: 1.12 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Field index for ambientIntensityprotected static final int
Field index for SFNode ambientTextureprotected static final int
Field index for ambientTextureMappingprotected static final int
Field index for diffuseColorprotected static final int
Field index for SFNode diffuseTextureprotected static final int
Field index for diffuseTextureMappingprotected static final int
Field index for emissiveColorprotected static final int
Field index for SFNode emissiveTextureprotected static final int
Field index for emissiveTextureMappingprotected static final int
Field index for normalScaleprotected static final int
Field index for SFNode normalTextureprotected static final int
Field index for normalTextureMappingprotected static final int
Field index for normalScaleprotected static final int
Field index for SFNode occlusionTextureprotected static final int
Field index for occlusionTextureMappingprotected static final int
Field index for shininessprotected static final int
Field index for SFNode shininessTextureprotected static final int
Field index for shininessTextureMappingprotected static final int
Field index for specularColorprotected static final int
Field index for SFNode specularTextureprotected static final int
Field index for specularTextureMappingprotected 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 VRMLTextureNodeType
SFNode ambientTexture.protected float[]
exposedField SFColor diffuseColor 0.8 0.8 0.8protected VRMLTextureNodeType
SFNode texture diffuseTexture.protected float[]
exposedField SFColor emissiveColor 0 0 0protected VRMLTextureNodeType
SFNode texture emissiveTexture.protected float
exposedField SFFloat normalScale 1protected VRMLTextureNodeType
SFNode texture normalTexture.protected float
exposedField SFFloat occlusionStrength 1protected VRMLTextureNodeType
SFNode texture occlusionTexture.protected float
exposedField SFFloat shininess 0.2protected VRMLTextureNodeType
SFNode texture shininessTexture.protected float[]
exposedField SFColor specularColor 0 0 0protected VRMLTextureNodeType
SFNode texture specularTexture.protected 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
BaseMaterial
(VRMLNodeType node) 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
Get the current ambientTexture.float[]
Accessor method to get current value of field diffuseColor, default value is0.8 0.8 0.8
.Get the current diffuseTexture.float[]
Accessor method to get current value of field emissiveColor, default value is0 0 0
.Get the current emissiveTexture.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).float
Accessor method to get current value of field normalCcale, default value is1
Get the current normalTexture.int
Get the number of fields.float
Accessor method to get current value of field occlusionstrength, default value is1
Get the current occlusionTexture.int
Get the primary type of this node.float
Accessor method to get current value of field shininess, default value is0.2
.Get the current shininessTexture.float[]
Accessor method to get current value of field specularColor, default value is0 0 0
.Get the current specularTexture.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 newAmbientIntensity) Accessor method to set a new value for field attribute ambientIntensity.void
setDiffuseColor
(float[] newDiffuseColor) Accessor method to set a new value for field attribute diffuseColor.void
setEmissiveColor
(float[] newEmissiveColor) Accessor method to set a new value for field attribute emissiveColor.void
setIgnoreDiffuse
(boolean ignore) Ignore the diffuseColor color term and use 1,1,1 for the diffuse color.void
setNormalScale
(float newNormalScale) Accessor method to set a new value for field attribute normalScale.void
setOcclusionStrength
(float newOcclusionStrength) Accessor method to set a new value for field attribute occlusionStrength.void
setShininess
(float newShininess) Accessor method to set a new value for field attribute shininess.void
setSpecularColor
(float[] newSpecularColor) Accessor method to set a new value for field attribute specularColor.void
setTransparency
(float newTransparency) Accessor method to set a new value for field attribute transparency.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, 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, setValue, updateRefCount
-
Field Details
-
FIELD_AMBIENT_INTENSITY
protected static final int FIELD_AMBIENT_INTENSITYField index for ambientIntensity- See Also:
-
FIELD_DIFFUSE_COLOR
protected static final int FIELD_DIFFUSE_COLORField index for diffuseColor- See Also:
-
FIELD_EMISSIVE_COLOR
protected static final int FIELD_EMISSIVE_COLORField index for emissiveColor- See Also:
-
FIELD_SHININESS
protected static final int FIELD_SHININESSField index for shininess- See Also:
-
FIELD_SPECULAR_COLOR
protected static final int FIELD_SPECULAR_COLORField index for specularColor- See Also:
-
FIELD_TRANSPARENCY
protected static final int FIELD_TRANSPARENCYField index for transparency- See Also:
-
FIELD_NORMALSCALE
protected static final int FIELD_NORMALSCALEField index for normalScale- See Also:
-
FIELD_OCCLUSIONSTRENGTH
protected static final int FIELD_OCCLUSIONSTRENGTHField index for normalScale- See Also:
-
FIELD_AMBIENTTEXTUREMAPPING
protected static final int FIELD_AMBIENTTEXTUREMAPPINGField index for ambientTextureMapping- See Also:
-
FIELD_DIFFUSETEXTUREMAPPING
protected static final int FIELD_DIFFUSETEXTUREMAPPINGField index for diffuseTextureMapping- See Also:
-
FIELD_EMISSIVETEXTUREMAPPING
protected static final int FIELD_EMISSIVETEXTUREMAPPINGField index for emissiveTextureMapping- See Also:
-
FIELD_NORMALTEXTUREMAPPING
protected static final int FIELD_NORMALTEXTUREMAPPINGField index for normalTextureMapping- See Also:
-
FIELD_OCCLUSIONTEXTUREMAPPING
protected static final int FIELD_OCCLUSIONTEXTUREMAPPINGField index for occlusionTextureMapping- See Also:
-
FIELD_SHININESSTEXTUREMAPPING
protected static final int FIELD_SHININESSTEXTUREMAPPINGField index for shininessTextureMapping- See Also:
-
FIELD_SPECULARTEXTUREMAPPING
protected static final int FIELD_SPECULARTEXTUREMAPPINGField index for specularTextureMapping- See Also:
-
FIELD_AMBIENTTEXTURE
protected static final int FIELD_AMBIENTTEXTUREField index for SFNode ambientTexture- See Also:
-
FIELD_DIFFUSETEXTURE
protected static final int FIELD_DIFFUSETEXTUREField index for SFNode diffuseTexture- See Also:
-
FIELD_EMISSIVETEXTURE
protected static final int FIELD_EMISSIVETEXTUREField index for SFNode emissiveTexture- See Also:
-
FIELD_NORMALTEXTURE
protected static final int FIELD_NORMALTEXTUREField index for SFNode normalTexture- See Also:
-
FIELD_OCCLUSIONTEXTURE
protected static final int FIELD_OCCLUSIONTEXTUREField index for SFNode occlusionTexture- See Also:
-
FIELD_SHININESSTEXTURE
protected static final int FIELD_SHININESSTEXTUREField index for SFNode shininessTexture- See Also:
-
FIELD_SPECULARTEXTURE
protected static final int FIELD_SPECULARTEXTUREField index for SFNode specularTexture- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfAmbientIntensity
protected float vfAmbientIntensityexposedField SFFloat ambientIntensity 0.2 -
vfDiffuseColor
protected float[] vfDiffuseColorexposedField SFColor diffuseColor 0.8 0.8 0.8 -
vfEmissiveColor
protected float[] vfEmissiveColorexposedField SFColor emissiveColor 0 0 0 -
vfShininess
protected float vfShininessexposedField SFFloat shininess 0.2 -
vfSpecularColor
protected float[] vfSpecularColorexposedField SFColor specularColor 0 0 0 -
vfTransparency
protected float vfTransparencyexposedField SFFloat transparency 0 -
vfNormalScale
protected float vfNormalScaleexposedField SFFloat normalScale 1 -
vfOcclusionStrength
protected float vfOcclusionStrengthexposedField SFFloat occlusionStrength 1 -
vfAmbientTexture
SFNode ambientTexture. -
vfDiffuseTexture
SFNode texture diffuseTexture. -
vfEmissiveTexture
SFNode texture emissiveTexture. -
vfNormalTexture
SFNode texture normalTexture. -
vfOcclusionTexture
SFNode texture occlusionTexture. -
vfShininessTexture
SFNode texture shininessTexture. -
vfSpecularTexture
SFNode texture specularTexture. -
ignoreDiffuse
protected boolean ignoreDiffuseShould we ignore the specified diffuseColor
-
-
Constructor Details
-
BaseMaterial
protected BaseMaterial()Construct a default instance of the material -
BaseMaterial
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
Accessor method to set a new value for field attribute ambientIntensity. How much ambient omnidirectional light is reflected from all light sources.- Specified by:
setAmbientIntensity
in interfaceVRMLMaterialNodeType
- Parameters:
newAmbientIntensity
- 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
Accessor method to set a new value for field attribute diffuseColor. How much direct, angle-dependent light is reflected from all light sources.- Specified by:
setDiffuseColor
in interfaceVRMLMaterialNodeType
- Parameters:
newDiffuseColor
- 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
Accessor method to set a new value for field attribute emissiveColor. How much glowing light is emitted from this object.- Specified by:
setEmissiveColor
in interfaceVRMLMaterialNodeType
- Parameters:
newEmissiveColor
- 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
Accessor method to set a new value for field attribute shininess. Low values provide soft specular glows, high values provide sharper, smaller highlights.- Specified by:
setShininess
in interfaceVRMLMaterialNodeType
- Parameters:
newShininess
- 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
Accessor method to set a new value for field attribute specularColor. Specular highlights are brightness reflections (example: shiny spots on an apple).- Specified by:
setSpecularColor
in interfaceVRMLMaterialNodeType
- Parameters:
newSpecularColor
- 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
-
getAmbientTexture
Get the current ambientTexture.- Returns:
- The currently set ambientTexture
-
getDiffuseTexture
Get the current diffuseTexture.- Returns:
- The currently set diffuseTexture
-
getEmissiveTexture
Get the current emissiveTexture.- Returns:
- The currently set emissiveTexture
-
getNormalTexture
Get the current normalTexture.- Returns:
- The currently set normalTexture
-
getOcclusionTexture
Get the current occlusionTexture.- Returns:
- The currently set occlusionTexture
-
getShininessTexture
Get the current shininessTexture.- Returns:
- The currently set shininessTexture
-
getSpecularTexture
Get the current specularTexture.- Returns:
- The currently set specularTexture
-
setTransparency
Accessor method to set a new value for field attribute transparency. How "clear" an object is: 1.0 is completely transparent, 0.0 is completely opaque .- Specified by:
setTransparency
in interfaceVRMLMaterialNodeType
- Parameters:
newTransparency
- The new value of transparency- Throws:
InvalidFieldValueException
-
setNormalScale
Accessor method to set a new value for field attribute normalScale.- Parameters:
newNormalScale
- The new value of normalScale- Throws:
InvalidFieldValueException
-
setOcclusionStrength
Accessor method to set a new value for field attribute occlusionStrength.- Parameters:
newOcclusionStrength
- The new value of occlusionStrength- 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
-
getNormalScale
public float getNormalScale()Accessor method to get current value of field normalCcale, default value is1
- Returns:
- The current value of NormalScale
-
getOcclusionStrength
public float getOcclusionStrength()Accessor method to get current value of field occlusionstrength, default value is1
- Returns:
- The current value of OcclusionStrength
-
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
-
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
-
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
-
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, 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
-