Class OGLAppearance
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.shape.BaseAppearance
org.web3d.vrml.renderer.ogl.nodes.shape.OGLAppearance
- All Implemented Interfaces:
org.j3d.aviatrix3d.NodeUpdateListener
,VRMLNode
,FrameStateListener
,VRMLAppearanceNodeType
,VRMLNodeType
,VRMLTextureListener
,OGLAppearanceNodeType
,OGLTextureTransformListener
,OGLVRMLNode
public class OGLAppearance
extends BaseAppearance
implements OGLAppearanceNodeType, OGLTextureTransformListener, org.j3d.aviatrix3d.NodeUpdateListener, FrameStateListener
OpenGL implementation of an Appearance node.
MultiTexture Notes: function and source not mapped 3D Texture Notes: Getting a rescale problem, not working. Cubic Environment Notes: Not implemented.
- Version:
- $Revision: 1.70 $
- Author:
- Alan Hudson
-
Field Summary
Fields inherited from class org.web3d.vrml.renderer.common.nodes.shape.BaseAppearance
ANISOTROPIC_DEGREE_PROP, anisotropicDegree, DEFAULT_ANISOTROPIC_DEGREE, DEFAULT_USE_MIPMAPS, DEFAULT_USETEXTURECACHE, FIELD_ACOUSTIC_PROPERTIES, FIELD_ALPHACUTOFF, FIELD_ALPHAMODE, FIELD_BACKMATERIAL, FIELD_FILL_PROPERTIES, FIELD_LINE_PROPERTIES, FIELD_MATERIAL, FIELD_POINT_PROPERTIES, FIELD_SHADERS, FIELD_TEXTURE, FIELD_TEXTURE_PROPERTIES, FIELD_TEXTURE_TRANSFORM, FILL_PROP_NODE_MSG, FILL_PROP_PROTO_MSG, LINE_PROP_NODE_MSG, LINE_PROP_PROTO_MSG, MATERIAL_NODE_MSG, MATERIAL_PROTO_MSG, numStages, pAcousticProperties, pBackMaterial, pFillProperties, pLineProperties, pMaterial, POINT_PROP_NODE_MSG, POINT_PROP_PROTO_MSG, pPointProperties, pShaders, pTexture, pTextureProperties, pTextureTransform, stages, TEXTURE_NODE_MSG, TEXTURE_PROP_NODE_MSG, TEXTURE_PROP_PROTO_MSG, TEXTURE_PROTO_MSG, totalTextureSize, TRANSFORM_NODE_MSG, TRANSFORM_PROTO_MSG, urls, USE_MIPMAPS_PROP, useMipMaps, useTextureCache, USETEXTURECACHE_PROP, vfAcousticProperties, vfAlphaCutoff, vfAlphaMode, vfBackMaterial, vfFillProperties, vfLineProperties, vfMaterial, vfPointProperties, vfShaders, vfTexture, vfTextureProperties, vfTextureTransform
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
ConstructorsConstructorDescriptionEmpty constructorOGLAppearance
(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.Appearance
Get the appearance instance used to represent this object.protected int
getFormat
(NIOBufferImage image) From the image information, generate the appropriate TextureComponent type.org.j3d.aviatrix3d.SceneGraphObject
Get the scene graph object representation of this node.protected int
getTextureFormat
(org.j3d.aviatrix3d.TextureComponent comp) From the image component format, generate the appropriate texture format.void
notifyExternProtoLoaded
(int index, VRMLNodeType node) Notify a node that an ExternProto has resolved.void
setCCW
(boolean ccw) Specify whether the geometry's triangles are in counter clockwise order (the default) or clockwise.void
Set the fillProperties that should be used for this appearance.void
setLightingEnabled
(boolean enable) Set whether lighting will be used for this appearance.void
Set the line properties that should be used for this appearance.void
setLocalColor
(boolean enable, boolean hasAlpha) Set whether the geometry has local colors to override the diffuse color.void
setMaterial
(VRMLNodeType newMaterial) Set the material that should be used for this appearance.void
Set the point properties that should be used for this appearance.void
setSolid
(boolean solid) Specify whether an object is solid.void
setTexCoordGenMode
(int setNum, String mode) Set the texture coordinate generation mode for a texture set.void
setTexture
(VRMLNodeType newTexture) Set the texture that should be used for this appearance.void
setTextureTransform
(VRMLNodeType newTransform) Set the texture transform that should be used for this appearance.void
Notification that the construction phase of this node has finished.void
textureImageChanged
(int len, VRMLNodeType[] node, NIOBufferImage[] image, String[] url) Invoked when all of the underlying images have changed.void
textureImageChanged
(int idx, VRMLNodeType node, NIOBufferImage image, String url) Invoked when an underlying image has changed.void
textureParamsChanged
(int len, int[] mode, int[] source, int[] function, float alpha, float[] color) Invoked when the texture parameters have changed.void
textureParamsChanged
(int idx, int mode, int source, int function, float alpha, float[] color) Invoked when the texture parameters have changed.void
textureTransformChanged
(OGLVRMLNode src, javax.vecmath.Matrix4f[] tmatrix, boolean[] updated) Invoked when a textureTransform has changed.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.BaseAppearance
addMaterialColorListener, getAcousticProperties, getAlphaCutoff, getAlphaMode, getBackMaterial, getFieldDeclaration, getFieldIndex, getFieldValue, getFillProperties, getLineProperties, getMaterial, getNodeFieldIndices, getNumFields, getPointProperties, getPrimaryType, getShaders, getTexture, getTextureProperties, getTextureTransform, getTotalTextureSize, insureStageSize, processImage, processImages, removeMaterialColorListener, sendRoute, setAcousticProperties, setAlphaCutoff, setAlphaMode, setBackMaterial, setShaders, setTextureProperties, setValue, 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, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, 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.VRMLAppearanceNodeType
addMaterialColorListener, getFillProperties, getLineProperties, getMaterial, getTexture, getTextureTransform, 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, removeNodeListener, sendRoute, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Constructor Details
-
OGLAppearance
public OGLAppearance()Empty constructor -
OGLAppearance
Construct a new instance of this node based on the details from the given node. If the node is not a Appearance node, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a Group node
-
-
Method Details
-
allEventsComplete
public void allEventsComplete()Notification that the rendering of the event model is complete and that rendering is about to begin.- Specified by:
allEventsComplete
in interfaceFrameStateListener
- Overrides:
allEventsComplete
in classAbstractNode
-
setMaterial
Set the material that should be used for this appearance. Setting a value of null will clear the current material.- Specified by:
setMaterial
in interfaceVRMLAppearanceNodeType
- Overrides:
setMaterial
in classBaseAppearance
- Parameters:
newMaterial
- The new material instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setTexture
Set the texture that should be used for this appearance. Setting a value of null will clear the current texture.- Specified by:
setTexture
in interfaceVRMLAppearanceNodeType
- Overrides:
setTexture
in classBaseAppearance
- Parameters:
newTexture
- The new texture instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setTextureTransform
Set the texture transform that should be used for this appearance. Setting a value of null will clear the current texture transform.- Specified by:
setTextureTransform
in interfaceVRMLAppearanceNodeType
- Overrides:
setTextureTransform
in classBaseAppearance
- Parameters:
newTransform
- The new texture transform instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setLineProperties
Set the line properties that should be used for this appearance. Setting a value of null will clear the current property.- Specified by:
setLineProperties
in interfaceVRMLAppearanceNodeType
- Overrides:
setLineProperties
in classBaseAppearance
- Parameters:
prop
- The new property instance instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setPointProperties
Set the point properties that should be used for this appearance. Setting a value of null will clear the current property.- Overrides:
setPointProperties
in classBaseAppearance
- Parameters:
prop
- The new property instance instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setFillProperties
Set the fillProperties that should be used for this appearance. Setting a value of null will clear the current property.- Specified by:
setFillProperties
in interfaceVRMLAppearanceNodeType
- Overrides:
setFillProperties
in classBaseAppearance
- Parameters:
prop
- The new fillProperties instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getAppearance
public org.j3d.aviatrix3d.Appearance getAppearance()Get the appearance instance used to represent this object.- Specified by:
getAppearance
in interfaceOGLAppearanceNodeType
- Returns:
- The appearance instance
-
setTexCoordGenMode
Set the texture coordinate generation mode for a texture set. If its not set then texture coordinates will be used. A value of null will clear the setting.- Specified by:
setTexCoordGenMode
in interfaceOGLAppearanceNodeType
- Parameters:
setNum
- The set which this tex gen mode refersmode
- The mode to use. Straight VRML field value
-
setSolid
public void setSolid(boolean solid) Specify whether an object is solid. The default is true. This will determine if we do backface culling and flip backface normals. Can only be set during setup- Specified by:
setSolid
in interfaceVRMLAppearanceNodeType
- Overrides:
setSolid
in classBaseAppearance
- Parameters:
solid
- Whether the object is solid
-
setLightingEnabled
public void setLightingEnabled(boolean enable) Set whether lighting will be used for this appearance. In general you should let the material node decide this. Needed to handle IndexedLineSets or other geometry that specifically declares lighting be turned off. This method will notify the related Material node for this Appearance.- Specified by:
setLightingEnabled
in interfaceVRMLAppearanceNodeType
- Overrides:
setLightingEnabled
in classBaseAppearance
- 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 interfaceVRMLAppearanceNodeType
- Overrides:
setLocalColor
in classBaseAppearance
- Parameters:
enable
- Whether local color is enabledhasAlpha
- true with the local color also contains alpha values
-
setCCW
public void setCCW(boolean ccw) Specify whether the geometry's triangles are in counter clockwise order (the default) or clockwise. The default is true. This will determine if we do backface culling and flip backface normals. Can only be set during setup- Specified by:
setCCW
in interfaceVRMLAppearanceNodeType
- Overrides:
setCCW
in classBaseAppearance
- Parameters:
ccw
- True for counter-clockwise ordering
-
textureTransformChanged
public void textureTransformChanged(OGLVRMLNode src, javax.vecmath.Matrix4f[] tmatrix, boolean[] updated) Invoked when a textureTransform has changed.- Specified by:
textureTransformChanged
in interfaceOGLTextureTransformListener
- Parameters:
src
- The node instance that was the source of this changetmatrix
- The new TransformMatrix arrayupdated
- Flag for each index illustrating whether it has been updated or not.
-
textureImageChanged
Invoked when an underlying image has changed. Synchronized due to competition for the image arrays.- Specified by:
textureImageChanged
in interfaceVRMLTextureListener
- Overrides:
textureImageChanged
in classBaseAppearance
- Parameters:
idx
- The image idx which changed.node
- The texture which changed.image
- The image for this texture.url
- The url used to load this image.
-
textureImageChanged
Invoked when all of the underlying images have changed.- Specified by:
textureImageChanged
in interfaceVRMLTextureListener
- Overrides:
textureImageChanged
in classBaseAppearance
- Parameters:
len
- The number of valid entries in the image array.node
- The textures which changed.image
- The images for this texture.url
- The urls used to load these images.
-
textureParamsChanged
public void textureParamsChanged(int idx, int mode, int source, int function, float alpha, float[] color) Invoked when the texture parameters have changed. The most efficient route is to set the parameters before the image.- Specified by:
textureParamsChanged
in interfaceVRMLTextureListener
- Overrides:
textureParamsChanged
in classBaseAppearance
- Parameters:
idx
- The texture index which changed.mode
- The mode for the stage.source
- The source for the stage.function
- The function to apply to the stage values.alpha
- The alpha value to use for modes requiring it.color
- The color to use for modes requiring it. 3 Component color.
-
textureParamsChanged
public void textureParamsChanged(int len, int[] mode, int[] source, int[] function, float alpha, float[] color) Invoked when the texture parameters have changed. The most efficient route is to set the parameters before the image.- Specified by:
textureParamsChanged
in interfaceVRMLTextureListener
- Overrides:
textureParamsChanged
in classBaseAppearance
- Parameters:
len
- The number of valid entries in the arrays.mode
- The mode for the stage.source
- The source for the stage.function
- The function to apply to the stage values.alpha
- The alpha value to use for modes requiring it.color
- The color to use for modes requiring it. An array of 3 component colors.
-
getSceneGraphObject
public org.j3d.aviatrix3d.SceneGraphObject getSceneGraphObject()Get the scene graph object representation of this node. This will need to be cast to the appropriate parent type when being used.- Specified by:
getSceneGraphObject
in interfaceOGLVRMLNode
- Returns:
- The OGL representation.
-
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 classBaseAppearance
-
notifyExternProtoLoaded
Description copied from interface:VRMLNodeType
Notify a node that an ExternProto has resolved. This will verify the objects type and add it to the render sceneGraph.- Specified by:
notifyExternProtoLoaded
in interfaceVRMLNodeType
- Overrides:
notifyExternProtoLoaded
in classBaseAppearance
- Parameters:
index
- The field indexnode
- The node resolved- Throws:
InvalidFieldValueException
- If the proto contains he wrong type
-
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.
-
getTextureFormat
protected int getTextureFormat(org.j3d.aviatrix3d.TextureComponent comp) From the image component format, generate the appropriate texture format.- Parameters:
comp
- The image component to get the value from- Returns:
- The appropriate corresponding texture format value
-
getFormat
From the image information, generate the appropriate TextureComponent type.- Parameters:
image
- The image component to get the value from- Returns:
- The appropriate corresponding texture format value
-