Class OGLMaterial
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.shape.BaseMaterial
org.web3d.vrml.renderer.ogl.nodes.shape.OGLMaterial
- All Implemented Interfaces:
org.j3d.aviatrix3d.NodeUpdateListener
,VRMLNode
,FrameStateListener
,VRMLAppearanceChildNodeType
,VRMLMaterialNodeType
,VRMLNodeType
,VRMLSurfaceMaterialNodeType
,VRMLVisualMaterialNodeType
,OGLMaterialNodeType
,OGLVRMLNode
public class OGLMaterial
extends BaseMaterial
implements OGLMaterialNodeType, org.j3d.aviatrix3d.NodeUpdateListener
OpenGL implementation of a material node.
- Version:
- $Revision: 1.18 $
- Author:
- Justin Couch
-
Field Summary
Fields inherited from class org.web3d.vrml.renderer.common.nodes.shape.BaseMaterial
FIELD_AMBIENT_INTENSITY, FIELD_AMBIENTTEXTURE, FIELD_AMBIENTTEXTUREMAPPING, FIELD_DIFFUSE_COLOR, FIELD_DIFFUSETEXTURE, FIELD_DIFFUSETEXTUREMAPPING, FIELD_EMISSIVE_COLOR, FIELD_EMISSIVETEXTURE, FIELD_EMISSIVETEXTUREMAPPING, FIELD_NORMALSCALE, FIELD_NORMALTEXTURE, FIELD_NORMALTEXTUREMAPPING, FIELD_OCCLUSIONSTRENGTH, FIELD_OCCLUSIONTEXTURE, FIELD_OCCLUSIONTEXTUREMAPPING, FIELD_SHININESS, FIELD_SHININESSTEXTURE, FIELD_SHININESSTEXTUREMAPPING, FIELD_SPECULAR_COLOR, FIELD_SPECULARTEXTURE, FIELD_SPECULARTEXTUREMAPPING, FIELD_TRANSPARENCY, ignoreDiffuse, NUM_FIELDS, vfAmbientIntensity, vfAmbientTexture, vfDiffuseColor, vfDiffuseTexture, vfEmissiveColor, vfEmissiveTexture, vfNormalScale, vfNormalTexture, vfOcclusionStrength, vfOcclusionTexture, vfShininess, vfShininessTexture, vfSpecularColor, vfSpecularTexture, vfTransparency
Fields 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
ConstructorsConstructorDescriptionConstruct a default instance of the materialOGLMaterial
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Notification that the rendering of the event model is complete and that rendering is about to begin.org.j3d.aviatrix3d.Material
Request the OpenGL material node structure.org.j3d.aviatrix3d.SceneGraphObject
Get the OpenGL scene graph object representation of this 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
setLightingEnable
(boolean enable) Set whether lighting will be used for this material.void
setLocalColor
(boolean enable, boolean hasAlpha) Set whether the geometry has local colors to override the diffuse color.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
Notification that the construction phase of this node has finished.void
Notification that its safe to update the node now with any operations that could potentially effect the node's bounds.void
Notification that its safe to update the node now with any operations that only change the node's properties, but do not change the bounds.Methods inherited from class org.web3d.vrml.renderer.common.nodes.shape.BaseMaterial
addMaterialColorListener, getAmbientIntensity, getAmbientTexture, getDiffuseColor, getDiffuseTexture, getEmissiveColor, getEmissiveTexture, getFieldDeclaration, getFieldIndex, getFieldValue, getNodeFieldIndices, getNormalScale, getNormalTexture, getNumFields, getOcclusionStrength, getOcclusionTexture, getPrimaryType, getShininess, getShininessTexture, getSpecularColor, getSpecularTexture, getTransparency, removeMaterialColorListener, sendRoute, setNormalScale, setOcclusionStrength, setValue, setValue
Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, 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.VRMLMaterialNodeType
addMaterialColorListener, getAmbientIntensity, getDiffuseColor, getEmissiveColor, getShininess, getSpecularColor, getTransparency, removeMaterialColorListener
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getPrimaryType, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getFieldValue, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Constructor Details
-
OGLMaterial
public OGLMaterial()Construct a default instance of the material -
OGLMaterial
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
-
getMaterial
public org.j3d.aviatrix3d.Material getMaterial()Request the OpenGL material node structure.- Specified by:
getMaterial
in interfaceOGLMaterialNodeType
- Returns:
- The material node
-
setLightingEnable
public void setLightingEnable(boolean enable) Set whether lighting will be used for this material. In general you should let the material node decide this. Needed to handle IndexedLineSets or other geometry that specifically declares lighting be turned off.- Specified by:
setLightingEnable
in interfaceOGLMaterialNodeType
- Parameters:
enable
- Whether lighting is enabled
-
setLocalColor
public void setLocalColor(boolean enable, boolean hasAlpha) Set whether the geometry has local colors to override the diffuse color.- Specified by:
setLocalColor
in interfaceOGLMaterialNodeType
- Parameters:
enable
- Whether local color is enabledhasAlpha
- true with the local color also contains alpha values
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
allEventsComplete
public void allEventsComplete()Notification that the rendering of the event model is complete and that rendering is about to begin. If the node needs to update itself for this frame, it should do so now before the render pass takes place.- Specified by:
allEventsComplete
in interfaceFrameStateListener
- Overrides:
allEventsComplete
in classAbstractNode
-
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
- Overrides:
setAmbientIntensity
in classBaseMaterial
- Parameters:
newAmbientIntensity
- The new intensity value- Throws:
InvalidFieldValueException
-
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
- Overrides:
setDiffuseColor
in classBaseMaterial
- Parameters:
newDiffuseColor
- The new value of diffuseColor- 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
- Overrides:
setIgnoreDiffuse
in classBaseMaterial
- Parameters:
ignore
- True to ignore the diffuse term
-
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
- Overrides:
setEmissiveColor
in classBaseMaterial
- Parameters:
newEmissiveColor
- The new value of EmissiveColor- Throws:
InvalidFieldValueException
-
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
- Overrides:
setShininess
in classBaseMaterial
- Parameters:
newShininess
- The new value of Shininess- Throws:
InvalidFieldValueException
-
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
- Overrides:
setSpecularColor
in classBaseMaterial
- Parameters:
newSpecularColor
- The new value of SpecularColor- Throws:
InvalidFieldValueException
-
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
- Overrides:
setTransparency
in classBaseMaterial
- Parameters:
newTransparency
- The new value of Transparency- Throws:
InvalidFieldValueException
-
getSceneGraphObject
public org.j3d.aviatrix3d.SceneGraphObject getSceneGraphObject()Get the OpenGL scene graph object representation of this node. This will need to be cast to the appropriate parent type when being used. Default implementation returns null.- Specified by:
getSceneGraphObject
in interfaceOGLVRMLNode
- Returns:
- The OpenGL representation.
-
updateNodeBoundsChanges
Notification that its safe to update the node now with any operations that could potentially effect the node's bounds.- Specified by:
updateNodeBoundsChanges
in interfaceorg.j3d.aviatrix3d.NodeUpdateListener
- Parameters:
src
- The node or Node Component that is to be updated.
-
updateNodeDataChanges
Notification that its safe to update the node now with any operations that only change the node's properties, but do not change the bounds.- Specified by:
updateNodeDataChanges
in interfaceorg.j3d.aviatrix3d.NodeUpdateListener
- Parameters:
src
- The node or Node Component that is to be updated.
-