Class WF3DNode

java.lang.Object
  |
  +--WF3DNode
Direct Known Subclasses:
WF3DScene

public class WF3DNode
extends java.lang.Object

This class is used to represent a VRML node of any type. A node contains certain fields depending on the node type. See the Nodes package to get a listing of all node types and their corresponding fields.


Field Summary
 java.lang.String name
          The unique user defined name of this node
 int type
          The type of this node.
 
Method Summary
 void addChild(WF3DNode node)
          Adds a node to the children field of this object.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 WF3DNode[] getChildren()
           
 WF3DField getField(int fieldIndex)
          Retrieves a field of this object.
 WF3DNode getNode(int fieldIndex)
          Retrieves the contained node in the specified field of this object.
 WF3DNode getNode(java.lang.String name)
          Retrieves the node with the specified name by searching for it in this object's fields and sub-nodes.
 WF3DNode getParent()
           
 WF3DNode makeUSEInstance()
          Creates and returns a copy of this object.
 void move(float moveX, float moveY, float moveZ)
          Moves the object and all its sub-objects relative to the parent object.
 void removeChild(WF3DNode node)
          Removes a node from the children field of this object.
 void rotN(float x, float y, float z, float Nx, float Ny, float Nz, float angle)
          Rotates the object relative the parent object.
 void scale(float scaleX, float scaleY, float scaleZ)
          Scales the object and all its sub-objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public java.lang.String name
The unique user defined name of this node


type

public int type
The type of this node. See the Node class for more information.

Method Detail

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.

makeUSEInstance

public WF3DNode makeUSEInstance()
Creates and returns a copy of this object. This method is used when instancing using the USE-mechanism in VRML.

Returns:
a copy of this instance.

getChildren

public WF3DNode[] getChildren()

getParent

public WF3DNode getParent()

addChild

public void addChild(WF3DNode node)
Adds a node to the children field of this object.

Parameters:
node - the node to be added to the children field.

removeChild

public void removeChild(WF3DNode node)
Removes a node from the children field of this object.

Parameters:
node - the node to be removed from the children field.

getNode

public WF3DNode getNode(int fieldIndex)
Retrieves the contained node in the specified field of this object. This method calls getField (fieldIndex).getNode ().

Parameters:
fieldIndex - the index of the field to be accessed.
Returns:
the node in the specified field.

getField

public WF3DField getField(int fieldIndex)
Retrieves a field of this object. The fieldIndex parameter indicate which field to return. The field index used for accessing a particular field is found under the node classes in the Nodes package. Ex. accessing field translation in a Transform node is done with this code:
transformNode.getField (Nodes.Transform.translation);

Parameters:
fieldIndex - the index of the field to be accessed
Returns:
the WF3DField that represent the specified field

getNode

public WF3DNode getNode(java.lang.String name)
Retrieves the node with the specified name by searching for it in this object's fields and sub-nodes. If the node was not found this method returns null.

Parameters:
name - The name of the node to retrieve
Returns:
The WF3DNode representing the named node.

scale

public void scale(float scaleX,
                  float scaleY,
                  float scaleZ)
Scales the object and all its sub-objects.

This method works for nodes of type DirectionalLight, PointLight, Scene, Shape and Transform.

Parameters:
scaleX - the scaling along the x axis
scaleY - the scaling along the y axis
scaleZ - the scaling along the z axis

move

public void move(float moveX,
                 float moveY,
                 float moveZ)
Moves the object and all its sub-objects relative to the parent object.

This method works for nodes of type DirectionalLight, PointLight, Scene, Shape and Transform.

Parameters:
moveX - the movement along the x axis
moveY - the movement along the y axis
moveZ - the movement along the z axis

rotN

public void rotN(float x,
                 float y,
                 float z,
                 float Nx,
                 float Ny,
                 float Nz,
                 float angle)
Rotates the object relative the parent object. The parameters specify a rotation point (around which the rotation will be performed), a normalised rotation vector (specifying a direction to rotate around) and an angle that control the amount of rotation. A normalised vector means that sqrt(Nx*Nx + Ny*Ny + Nz*Nz) = 1, which can be enforced by dividing each Nx, Ny and Nz by the amount sqrt(Nx*Nx + Ny*Ny + Nz*Nz).

This method works for nodes of type DirectionalLight, PointLight, Scene, Shape and Transform.

Parameters:
x - the x coordinate of the point around which the rotation will be performed
y - the y coordinate of the point around which the rotation will be performed
z - the z coordinate of the point around which the rotation will be performed
Nx - the x coordinate of the normalised rotation vector
Ny - the y coordinate of the normalised rotation vector
Nz - the z coordinate of the normalised rotation vector
angle - the rotation angle, in radians (1 radian = PI/180 degrees)