Class BaseAppearance
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.shape.BaseAppearance
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLAppearanceNodeType
,VRMLNodeType
,VRMLTextureListener
- Direct Known Subclasses:
NRAppearance
,OGLAppearance
public abstract class BaseAppearance
extends AbstractNode
implements VRMLAppearanceNodeType, VRMLTextureListener
Common base implementation of an Appearance node.
Properties
The properties for this file are loaded once on startup so they cannot be initialized per run of loader. The following properties are used by this class:
org.web3d.vrml.renderer.common.nodes.shape.useTextureCache
Whether to cache textures for later reuse. This caches by URL which might be incorrect for some dynamic systems. It improves performance for files which don't use DEF/USE for textures.org.web3d.vrml.renderer.common.nodes.shape.useMipMaps
Force the use of mipmaps on nodes without TextureProperties.
- Version:
- $Revision: 1.43 $
- Author:
- Justin Couch, Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Property describing the anisotropicDegree valueprotected static final int
The anisotropicDegree valueprotected static final int
The default anisotropicDegree valueprotected static final boolean
The default useMipMaps valueprotected static final boolean
The default useTextureCache valueprotected static final int
Index of the acousticProperties field valueprotected static final int
Index of the alphaCutoff field valueprotected static final int
Index of the alphaMode field valueprotected static final int
Index of the backMaterial field valueprotected static final int
Index of the fillProperties field valueprotected static final int
Index of the lineProperties field valueprotected static final int
Index of the Material field valueprotected static final int
Index of the pointProperties field valueprotected static final int
Index of the backMaterial field valueprotected static final int
Index of the Texture field valueprotected static final int
Index of the textureProperties field valueprotected static final int
Index of the TextureTransform field valueprotected static final String
Message for when the node in setValue() is not a FillPropertiesprotected static final String
Message for when the proto is not a FillPropertiesprotected static final String
Message for when the node in setValue() is not a LinePropertiesprotected static final String
Message for when the proto is not a LinePropertiesprotected static final String
Message for when the node in setValue() is not a Materialprotected static final String
Message for when the proto is not a Materialprotected int
protected VRMLProtoInstance
Proto version of the acousticPropertiesprotected VRMLProtoInstance
Proto version of the backMaterialprotected VRMLProtoInstance
Proto version of the fillPropertiesprotected VRMLProtoInstance
Proto version of the linePropertiesprotected VRMLProtoInstance
Proto version of the materialprotected static final String
Message for when the node in setValue() is not a PointPropertiesprotected static final String
Message for when the proto is not a PointPropertiesprotected VRMLProtoInstance
Proto version of the pointPropertiesprotected VRMLProtoInstance
Proto version of the shadersprotected VRMLProtoInstance
Proto version of the textureprotected VRMLProtoInstance
Proto version of the texturePropertiesprotected VRMLProtoInstance
Proto version of the texture transformprotected TextureStage[]
protected static final String
Message for when the node in setValue() is not a Textureprotected static final String
Message for when the node in setValue() is not a TexturePropertiesprotected static final String
Message for when the proto is not a TexturePropertiesprotected static final String
Message for when the proto is not a Textureprotected static float
Total size of textures (K bytes)protected static final String
Message for when the node in setValue() is not a TextureTransformprotected static final String
Message for when the proto is not a TextureTransformprotected String[]
protected static final String
Property describing the mipmap usageprotected static boolean
The value read from the system property for MIPMAPSprotected static final boolean
The value read from the system property for TEXTURECACHEprotected static final String
Property describing the rescaling method to useprotected VRMLNodeType
SFNode acousticProperties.protected float
SFFloat alphaCutoff.protected String
SFString alphaMode.protected VRMLNodeType
SFNode backMaterial.protected VRMLAppearanceChildNodeType
SFNode fillPropertiesprotected VRMLAppearanceChildNodeType
SFNode lineProperties.protected VRMLMaterialNodeType
SFNode materialprotected VRMLPointPropertiesNodeType
SFNode pointProperties.protected VRMLNodeType
SFNode shaders.protected VRMLTextureNodeType
SFNode texture.protected VRMLTextureProperties2DNodeType
SFNode textureProperties.protected VRMLTextureTransformNodeType
SFNode textureTransformFields 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
Default constructor that initialises all fields to the spec defaults.protected
BaseAppearance
(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.Get the current acousticProperties used by the appearance.float
Get the current alphaCutoff used by the appearance.Get the current alphaMode used by the appearance.Get the current backMaterial used by the appearance.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.Get the current texture used by the appearance.Get the current line properties used by the appearance.Get the current material used by the appearance.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.Get the current point properties used by the appearance.int
Get the primary type of this node.Get the current shaders used by the appearance.Get the current texture used by the appearance.Get the current texture properties used by the appearance.Get the current texture transform used by the appearance.static float
Get the total texture size of all textured loaded to date.protected void
insureStageSize
(int newLen, boolean inc) Insures that the Texture Stage array and associated arrays are at least this big.void
notifyExternProtoLoaded
(int index, VRMLNodeType node) Notify a node that an ExternProto has resolved.protected NIOBufferImage[]
processImage
(int stage, NIOBufferImage niobi, String url) Setup TextureStage parametersprotected void
processImages
(int stage, VRMLTextureNodeType tex) Process the images in this texture.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
Set the acousticProperties that should be used for this appearance.protected void
setAlphaCutoff
(float alphaCutoff) Set the alphaCutoffprotected void
setAlphaMode
(String alphaMode) Set the alphaModevoid
setBackMaterial
(VRMLNodeType prop) Set the backMaterial that should be used for this appearance.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 mat) Set the material that should be used for this appearance.void
Set the point properties that should be used for this appearance.void
setShaders
(VRMLNodeType prop) Set the shaders that should be used for this appearance.void
setSolid
(boolean solid) Specify whether an object is solid.void
setTexture
(VRMLNodeType tex) Set the texture that should be used for this appearance.void
Set the textureProperties that should be used for this appearance.void
setTextureTransform
(VRMLNodeType trans) Set the texture transform that should be used for this appearance.void
Notification that the construction phase of this node has finished.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
Set the value of the field at the given index as a String.void
setValue
(int index, VRMLNodeType child) Set the value of the field at the given index as a node.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.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, 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.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, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_MATERIAL
protected static final int FIELD_MATERIALIndex of the Material field value- See Also:
-
FIELD_TEXTURE
protected static final int FIELD_TEXTUREIndex of the Texture field value- See Also:
-
FIELD_TEXTURE_TRANSFORM
protected static final int FIELD_TEXTURE_TRANSFORMIndex of the TextureTransform field value- See Also:
-
FIELD_LINE_PROPERTIES
protected static final int FIELD_LINE_PROPERTIESIndex of the lineProperties field value- See Also:
-
FIELD_POINT_PROPERTIES
protected static final int FIELD_POINT_PROPERTIESIndex of the pointProperties field value- See Also:
-
FIELD_FILL_PROPERTIES
protected static final int FIELD_FILL_PROPERTIESIndex of the fillProperties field value- See Also:
-
FIELD_TEXTURE_PROPERTIES
protected static final int FIELD_TEXTURE_PROPERTIESIndex of the textureProperties field value- See Also:
-
FIELD_ACOUSTIC_PROPERTIES
protected static final int FIELD_ACOUSTIC_PROPERTIESIndex of the acousticProperties field value- See Also:
-
FIELD_ALPHACUTOFF
protected static final int FIELD_ALPHACUTOFFIndex of the alphaCutoff field value- See Also:
-
FIELD_ALPHAMODE
protected static final int FIELD_ALPHAMODEIndex of the alphaMode field value- See Also:
-
FIELD_BACKMATERIAL
protected static final int FIELD_BACKMATERIALIndex of the backMaterial field value- See Also:
-
FIELD_SHADERS
protected static final int FIELD_SHADERSIndex of the backMaterial field value- See Also:
-
DEFAULT_USETEXTURECACHE
protected static final boolean DEFAULT_USETEXTURECACHEThe default useTextureCache value- See Also:
-
USETEXTURECACHE_PROP
Property describing the rescaling method to use- See Also:
-
useTextureCache
protected static final boolean useTextureCacheThe value read from the system property for TEXTURECACHE -
DEFAULT_USE_MIPMAPS
protected static final boolean DEFAULT_USE_MIPMAPSThe default useMipMaps value- See Also:
-
USE_MIPMAPS_PROP
-
useMipMaps
protected static boolean useMipMapsThe value read from the system property for MIPMAPS -
DEFAULT_ANISOTROPIC_DEGREE
protected static final int DEFAULT_ANISOTROPIC_DEGREEThe default anisotropicDegree value- See Also:
-
ANISOTROPIC_DEGREE_PROP
Property describing the anisotropicDegree value- See Also:
-
anisotropicDegree
protected static final int anisotropicDegreeThe anisotropicDegree value -
MATERIAL_PROTO_MSG
Message for when the proto is not a Material- See Also:
-
MATERIAL_NODE_MSG
Message for when the node in setValue() is not a Material- See Also:
-
TEXTURE_PROTO_MSG
Message for when the proto is not a Texture- See Also:
-
TEXTURE_NODE_MSG
Message for when the node in setValue() is not a Texture- See Also:
-
TRANSFORM_PROTO_MSG
Message for when the proto is not a TextureTransform- See Also:
-
TRANSFORM_NODE_MSG
Message for when the node in setValue() is not a TextureTransform- See Also:
-
FILL_PROP_PROTO_MSG
Message for when the proto is not a FillProperties- See Also:
-
FILL_PROP_NODE_MSG
Message for when the node in setValue() is not a FillProperties- See Also:
-
LINE_PROP_PROTO_MSG
Message for when the proto is not a LineProperties- See Also:
-
LINE_PROP_NODE_MSG
Message for when the node in setValue() is not a LineProperties- See Also:
-
POINT_PROP_PROTO_MSG
Message for when the proto is not a PointProperties- See Also:
-
POINT_PROP_NODE_MSG
Message for when the node in setValue() is not a PointProperties- See Also:
-
TEXTURE_PROP_NODE_MSG
Message for when the node in setValue() is not a TextureProperties- See Also:
-
TEXTURE_PROP_PROTO_MSG
Message for when the proto is not a TextureProperties- See Also:
-
pMaterial
Proto version of the material -
vfMaterial
SFNode material -
pTexture
Proto version of the texture -
vfTexture
SFNode texture. -
pTextureTransform
Proto version of the texture transform -
vfTextureTransform
SFNode textureTransform -
pFillProperties
Proto version of the fillProperties -
vfFillProperties
SFNode fillProperties -
pLineProperties
Proto version of the lineProperties -
vfLineProperties
SFNode lineProperties. -
pPointProperties
Proto version of the pointProperties -
vfPointProperties
SFNode pointProperties. -
pTextureProperties
Proto version of the textureProperties -
vfTextureProperties
SFNode textureProperties. -
pAcousticProperties
Proto version of the acousticProperties -
vfAcousticProperties
SFNode acousticProperties. -
vfAlphaCutoff
protected float vfAlphaCutoffSFFloat alphaCutoff. -
vfAlphaMode
SFString alphaMode. -
pBackMaterial
Proto version of the backMaterial -
vfBackMaterial
SFNode backMaterial. -
pShaders
Proto version of the shaders -
vfShaders
SFNode shaders. -
numStages
protected int numStages -
stages
-
urls
-
totalTextureSize
protected static float totalTextureSizeTotal size of textures (K bytes)
-
-
Constructor Details
-
BaseAppearance
protected BaseAppearance()Default constructor that initialises all fields to the spec defaults. -
BaseAppearance
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
-
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 classAbstractNode
- Parameters:
index
- The field indexnode
- The node resolved- Throws:
InvalidFieldValueException
- If the proto contains he wrong type
-
textureImageChanged
Invoked when an underlying image has changed.- Specified by:
textureImageChanged
in interfaceVRMLTextureListener
- Parameters:
idx
- The stage 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
- 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
- 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
- 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.
-
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
- Parameters:
mat
- The new material instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getMaterial
Get the current material used by the appearance. If none has been set this will return null.- Specified by:
getMaterial
in interfaceVRMLAppearanceNodeType
- Returns:
- The currently set Material
-
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
- Parameters:
tex
- The new texture instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getTexture
Get the current texture used by the appearance. If none has been set this will return null.- Specified by:
getTexture
in interfaceVRMLAppearanceNodeType
- Returns:
- The currently set Texture
-
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
- Parameters:
trans
- The new texture transform instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type
-
getTextureTransform
Get the current texture transform used by the appearance. If none has been set this will return null.- Specified by:
getTextureTransform
in interfaceVRMLAppearanceNodeType
- Returns:
- The currently set TextureTransform
-
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
- Parameters:
prop
- The new property instance instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getLineProperties
Get the current line properties used by the appearance. If none has been set this will return null.- Specified by:
getLineProperties
in interfaceVRMLAppearanceNodeType
- Returns:
- The currently set LineProperties
-
setPointProperties
Set the point properties that should be used for this appearance. Setting a value of null will clear the current property.- Parameters:
prop
- The new property instance instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getPointProperties
Get the current point properties used by the appearance. If none has been set this will return null.- Returns:
- The currently set PointProperties
-
setAcousticProperties
Set the acousticProperties that should be used for this appearance. Setting a value of null will clear the current texture Properties.- Parameters:
prop
- The new acousticProperties instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setAlphaCutoff
Set the alphaCutoff- Parameters:
alphaCutoff
- The new alphaCutoff to use- Throws:
InvalidFieldValueException
- Radius value was negative
-
setAlphaMode
Set the alphaMode- Parameters:
alphaMode
- The new alphaMode to use- Throws:
InvalidFieldValueException
- Radius value was negative
-
setBackMaterial
Set the backMaterial that should be used for this appearance. Setting a value of null will clear the current texture Properties.- Parameters:
prop
- The new backMaterial instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setShaders
Set the shaders that should be used for this appearance. Setting a value of null will clear the current texture Properties.- Parameters:
prop
- The new shaders instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
setTextureProperties
Set the textureProperties that should be used for this appearance. Setting a value of null will clear the current texture Properties.- Parameters:
prop
- The new textureProperties instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getTextureProperties
Get the current texture properties used by the appearance. If none has been set this will return null.- Returns:
- The currently set TextureProperties
-
getAcousticProperties
Get the current acousticProperties used by the appearance. If none has been set this will return null.- Returns:
- The currently set AcousticProperties
-
getAlphaCutoff
public float getAlphaCutoff()Get the current alphaCutoff used by the appearance. If none has been set this will return null.- Returns:
- The currently set AlphaCutoff
-
getAlphaMode
Get the current alphaMode used by the appearance. If none has been set this will return null.- Returns:
- The currently set alphaMode
-
getBackMaterial
Get the current backMaterial used by the appearance. If none has been set this will return null.- Returns:
- The currently set BackMaterial
-
getShaders
Get the current shaders used by the appearance. If none has been set this will return null.- Returns:
- The currently set Shaders
-
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
- Parameters:
prop
- The new fillProperties instance to be used.- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getFillProperties
Get the current texture used by the appearance. If none has been set this will return null.- Specified by:
getFillProperties
in interfaceVRMLAppearanceNodeType
- Returns:
- The currently set FillProperties
-
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
- 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
- Parameters:
enable
- Whether lighting is enabled
-
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
- Parameters:
ccw
- True for counter-clockwise ordering
-
setLocalColor
public void setLocalColor(boolean enable, boolean hasAlpha) Set whether the geometry has local colors to override the diffuse color. If the local color contains alpha values we want to ignore the material's transparency values.- Specified by:
setLocalColor
in interfaceVRMLAppearanceNodeType
- Parameters:
enable
- Whether local color is enabledhasAlpha
- true with the local color also contains alpha values
-
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 interfaceVRMLAppearanceNodeType
- 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 interfaceVRMLAppearanceNodeType
- Parameters:
l
- The new instance to remove
-
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
-
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, String value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a String. This would be used to set SFString 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, VRMLNodeType child) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a node. This would be used to set SFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchild
- The new value to use for the node- Throws:
InvalidFieldException
- The index does not match a known fieldInvalidFieldValueException
- The node does not match the required type.
-
getTotalTextureSize
public static float getTotalTextureSize()Get the total texture size of all textured loaded to date.- Returns:
- The total(K bytes) of textures loaded.
-
processImage
Setup TextureStage parameters- Parameters:
stage
- The TextureStage indexniobi
- The image objecturl
- The source of the image- Returns:
- The array of images
-
insureStageSize
protected void insureStageSize(int newLen, boolean inc) Insures that the Texture Stage array and associated arrays are at least this big. Sets the numStages variable to the largest length.- Parameters:
newLen
- The new lengthinc
- Should this increase the number of valid stages
-
processImages
Process the images in this texture. Recursively follow any multitexture references.- Parameters:
stage
- The TextureStage indextex
- The texture to process.
-