syn3d.nodes.java3d
Class SceneNodeJava3D

java.lang.Object
  extended by syn3d.base.ActiveNode
      extended by syn3d.nodes.GroupNode
          extended by syn3d.nodes.SceneNode
              extended by syn3d.nodes.java3d.SceneNodeJava3D
All Implemented Interfaces:
java.io.Serializable, EndNotificationListener, SceneChangeListener

public class SceneNodeJava3D
extends SceneNode
implements SceneChangeListener, java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class syn3d.nodes.SceneNode
SceneNode.SceneTimerTask
 
Field Summary
protected  BranchGroup axisGroup
           
protected  BranchGroup branchgroup
           
protected  Canvas3D canvas3D
           
protected  int detachKey
           
protected  Frame3DJava3D frame
           
protected  int lightRotationMode
           
protected  DirectionalLight[] lights
           
protected  Shape3D lightVector
           
protected  Switch mainSwitch
           
protected  PluginManager pluginManager
          A reference to the pluginManager scene
protected  BranchGroup rootGroup
           
protected  SimpleUniverse universe
           
 
Fields inherited from class syn3d.nodes.SceneNode
anonymousSceneNumber, dirtyNodes, fileName, FLY_BY_MODE, icon, listeners, REFRESH_PERIOD, refreshPeriod, refreshPeriodChanged, ROTATION_MODE, timer, viewingMode
 
Fields inherited from class syn3d.base.ActiveNode
children, name, parent
 
Constructor Summary
SceneNodeJava3D(ActiveNode parent, PluginManager pm)
           
 
Method Summary
static void addChildToParentGroup(Group j3dGroup, Node j3dChild)
          Helper to add a child to a group at run-time.
 void attach()
          Allow the scene to be displayed by attaching the main branchgroup
static void attach(ActiveNode node)
          Allow the scene to be displayed by attaching the main branchgroup
static void attach(ActiveNode node, int key)
          Allow the scene to be displayed by attaching the main branchgroup
 void attach(int key)
          Allow the scene to be displayed by attaching the main branchgroup
 void autoZoom()
          Auto zooms the scene out of all objects
 void changeProjection()
          Turns perspective on an off
 void detach()
          Allow modifications to the scene by detaching the main branchgroup
static void detach(ActiveNode node)
          Allow modifications to the scene by detaching the main branchgroup
static void detach(ActiveNode node, int key)
          Allow modifications to the scene by detaching the main branchgroup
 void detach(int key)
          Allow modifications to the scene by detaching the main branchgroup Attaching will be accepted only with the given key => this allows a code to detach once for all, and call functions that do attach/detach with other or no keys => the higher level detach/attach is the only one taken in account Tip: use Object.hashCode() to get a unique ID.
 void doAction(java.lang.Object action)
          When the user has selected an action in the list return by getActions(), this method is called.
 java.lang.Object get3DObject()
          Returns the 3D object that this node refers to.
 java.util.List getActions()
          Returns a list of possible actions on this node.
 BranchGroup getBranchgroup()
           
 Canvas3D getCanvas3D()
           
 int getLightRotationMode()
           
 DirectionalLight[] getLights()
           
 SimpleUniverse getUniverse()
           
 void init2DPosition(int posX, int posY)
          Initialize 2D rotation algorithm with the current position as origin.
 boolean isVisible()
           
 ActiveNode pick(int posX, int posY)
          Selects a single pick at the given position.
 void remove()
          Removes this node from the parent list.
static void removeChildFromParentGroup(Node j3dChild)
          Helper to remove a child from a group at run-time.
 void removeSceneJ3D()
           
 void reset()
          Reset all values to default
 void restoreScene(PluginManager pm)
          Restore scene : subclasses can restore the scene once all ActiveNOde have been initialised
 void rotate2D(int newX, int newY)
          Does a rotation of the scene according to moves in a 2D coordinate system.
 boolean saveSceneJava3D(java.io.File f)
           
 void sceneChanged(SceneNode scene)
           
 void setVisible(boolean status)
           
 void showLightVector(float x, float y, float z)
           
 java.util.ArrayList toggleAllPicks(int posX, int posY)
          Adds or removes all picks between the given position and the last position, to the selected objects.
 java.util.ArrayList toggleSinglePick(int posX, int posY)
          Adds or removes a single pick at the given position to the selected objects.
 void translate2D(int newX, int newY)
          Does a translation of the scene according to moves in a 2D coordinate system.
 void zoom(int zoomIncrement)
          Zooms in or out of the scene according to the increment.
 void zoom2D(int newX, int newY)
          Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.
 
Methods inherited from class syn3d.nodes.SceneNode
addDirtyNode, addListener, getIcon, getRefreshPeriod, getScene, getViewingMode, notificationEnd, notifyChange, notifyListeners, propagateHighlightEvent, propagateInternalChangeEvent, removeDirtyNode, removeListener, restoreReferences, saveChildren, setRefreshPeriod, setViewingMode
 
Methods inherited from class syn3d.nodes.GroupNode
getScene
 
Methods inherited from class syn3d.base.ActiveNode
addChild, findDescendantOfType, findDescendantOfType, getChildren, getName, getParent, highlight, notifyInternalChange, notifyStructuralChange, propagateAddChildEvent, propagateChangeNameEvent, propagateRemoveChildEvent, propagateStructuralChangeEvent, removeChild, removeNodeTree, removeNodeTreeFrom, setName, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

universe

protected transient SimpleUniverse universe

rootGroup

protected transient BranchGroup rootGroup

branchgroup

protected transient BranchGroup branchgroup

canvas3D

protected transient Canvas3D canvas3D

frame

protected transient Frame3DJava3D frame

lights

protected transient DirectionalLight[] lights

lightRotationMode

protected int lightRotationMode

lightVector

protected transient Shape3D lightVector

detachKey

protected int detachKey

mainSwitch

protected transient Switch mainSwitch

axisGroup

protected transient BranchGroup axisGroup

pluginManager

protected transient PluginManager pluginManager
A reference to the pluginManager scene

Constructor Detail

SceneNodeJava3D

public SceneNodeJava3D(ActiveNode parent,
                       PluginManager pm)
Method Detail

getActions

public java.util.List getActions()
Description copied from class: ActiveNode
Returns a list of possible actions on this node. Actions may be classified by categories using the "|" separator. Ex: a transform node may have the following actions: "Rotate|90° on X", "Rotate|180° on X", etc...

Overrides:
getActions in class SceneNode
Returns:
an array of possible actions, or a null or empty array if this node doesn't handle any action

doAction

public void doAction(java.lang.Object action)
Description copied from class: ActiveNode
When the user has selected an action in the list return by getActions(), this method is called. The node should then do what it claims.

Overrides:
doAction in class SceneNode
Parameters:
action - An action previously declared by the getActions method.

remove

public void remove()
Description copied from class: SceneNode
Removes this node from the parent list. Notifies the parents for structural change.

Overrides:
remove in class SceneNode

get3DObject

public java.lang.Object get3DObject()
Description copied from class: ActiveNode
Returns the 3D object that this node refers to. The object may depend on the 3D model used (Xith3D, Java3D) This object was previously created in the plugin create method, or in the loadTo method during de-serialization.

Overrides:
get3DObject in class ActiveNode
Returns:
the Object used for the scene graph, which probably depends on the underlying 3D architecture. This can be used on a parent node in the plugin canCreate method to check for this architecture.

isVisible

public boolean isVisible()
Overrides:
isVisible in class SceneNode

setVisible

public void setVisible(boolean status)
Overrides:
setVisible in class SceneNode

restoreScene

public void restoreScene(PluginManager pm)
Restore scene : subclasses can restore the scene once all ActiveNOde have been initialised

Overrides:
restoreScene in class SceneNode
Parameters:
pm -

getCanvas3D

public Canvas3D getCanvas3D()
Returns:
Returns the canvas3D associated to this universe

getUniverse

public SimpleUniverse getUniverse()
Returns:
Returns the universe.

getLights

public DirectionalLight[] getLights()
Returns:
Returns the lights.

getLightRotationMode

public int getLightRotationMode()
Returns:
Returns the rotationMode.

getBranchgroup

public BranchGroup getBranchgroup()
Returns:
Returns the branchgroup.

detach

public void detach()
Allow modifications to the scene by detaching the main branchgroup


attach

public void attach()
Allow the scene to be displayed by attaching the main branchgroup


detach

public static void detach(ActiveNode node)
Allow modifications to the scene by detaching the main branchgroup


attach

public static void attach(ActiveNode node)
Allow the scene to be displayed by attaching the main branchgroup


detach

public void detach(int key)
Allow modifications to the scene by detaching the main branchgroup Attaching will be accepted only with the given key => this allows a code to detach once for all, and call functions that do attach/detach with other or no keys => the higher level detach/attach is the only one taken in account Tip: use Object.hashCode() to get a unique ID. Note: key 0 is the default. Thus, a current detachKey != 0 prevents default attach/detach ops.


attach

public void attach(int key)
Allow the scene to be displayed by attaching the main branchgroup


detach

public static void detach(ActiveNode node,
                          int key)
Allow modifications to the scene by detaching the main branchgroup


attach

public static void attach(ActiveNode node,
                          int key)
Allow the scene to be displayed by attaching the main branchgroup


addChildToParentGroup

public static void addChildToParentGroup(Group j3dGroup,
                                         Node j3dChild)
Helper to add a child to a group at run-time. Avoids code dup


removeChildFromParentGroup

public static void removeChildFromParentGroup(Node j3dChild)
Helper to remove a child from a group at run-time. Avoids code dup


sceneChanged

public void sceneChanged(SceneNode scene)
Specified by:
sceneChanged in interface SceneChangeListener

showLightVector

public void showLightVector(float x,
                            float y,
                            float z)

init2DPosition

public void init2DPosition(int posX,
                           int posY)
Description copied from class: SceneNode
Initialize 2D rotation algorithm with the current position as origin. Typically, this is related to mouse positions in X and Y.

Overrides:
init2DPosition in class SceneNode

rotate2D

public void rotate2D(int newX,
                     int newY)
Description copied from class: SceneNode
Does a rotation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many rotate2D as required.

Overrides:
rotate2D in class SceneNode
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

translate2D

public void translate2D(int newX,
                        int newY)
Description copied from class: SceneNode
Does a translation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many translate2D as required.

Overrides:
translate2D in class SceneNode
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

zoom

public void zoom(int zoomIncrement)
Description copied from class: SceneNode
Zooms in or out of the scene according to the increment. This is an arbitrary algorithm to help create correct zoom factors. You could use setZoomFactor and then update the zoom matrix directly, with the same effect.
The added value of this function is to provide a relative and easy to manipulate way to zoom in or out, with increments like +1 or -1 for small zooms, and +10 and -10 for greater zooms, etc...

Overrides:
zoom in class SceneNode
Parameters:
zoomIncrement - A value typically 1 or -1, but which can be greater for fast zooms. Positive values zoom in, negative values zoom out.

zoom2D

public void zoom2D(int newX,
                   int newY)
Description copied from class: SceneNode
Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.

Overrides:
zoom2D in class SceneNode
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

changeProjection

public void changeProjection()
Description copied from class: SceneNode
Turns perspective on an off

Overrides:
changeProjection in class SceneNode

reset

public void reset()
Description copied from class: SceneNode
Reset all values to default

Overrides:
reset in class SceneNode

autoZoom

public void autoZoom()
Description copied from class: SceneNode
Auto zooms the scene out of all objects

Overrides:
autoZoom in class SceneNode

toggleSinglePick

public java.util.ArrayList toggleSinglePick(int posX,
                                            int posY)
Description copied from class: SceneNode
Adds or removes a single pick at the given position to the selected objects.

Overrides:
toggleSinglePick in class SceneNode
Parameters:
posX - the 2D X position where to do the picking
posY - the 2D Y position where to do the picking
Returns:
Returns the current selection, possibly an empy array
See Also:
ActiveNode.higlight(boolean,Object)

toggleAllPicks

public java.util.ArrayList toggleAllPicks(int posX,
                                          int posY)
Description copied from class: SceneNode
Adds or removes all picks between the given position and the last position, to the selected objects.

Overrides:
toggleAllPicks in class SceneNode
Parameters:
posX - the 2D X position defining a region with the last position. All objects in this region should be picked.
Returns:
Returns the current selection, possibly an empy array
See Also:
ActiveNode.higlight(boolean,Object)

pick

public ActiveNode pick(int posX,
                       int posY)
Description copied from class: SceneNode
Selects a single pick at the given position.

Overrides:
pick in class SceneNode
Parameters:
posX - the 2D X position where to do the picking
posY - the 2D Y position where to do the picking
Returns:
Returns the picked node or possibly a null object if there was nothing to pick at this position
See Also:
ActiveNode.higlight(boolean,Object)

saveSceneJava3D

public boolean saveSceneJava3D(java.io.File f)

removeSceneJ3D

public void removeSceneJ3D()