org.vizzini.ui.graphics
Class ShapeCanvasJava3D

java.lang.Object
  extended by org.vizzini.ui.graphics.AbstractShapeCanvas
      extended by org.vizzini.ui.graphics.ShapeCanvasJava3D
All Implemented Interfaces:
IStateful, IShapeCanvas

 class ShapeCanvasJava3D
extends AbstractShapeCanvas

Provides a Java 3D canvas for drawing 3D shapes.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
protected static javax.media.j3d.Transform3D WORLD_TRANSFORM
          Transform from Vizzini coordinates to Java 3D coordinates.
 
Fields inherited from class org.vizzini.ui.graphics.AbstractShapeCanvas
_canvas, _canvasCenter, _isDrawn
 
Constructor Summary
ShapeCanvasJava3D()
           
 
Method Summary
 void add(IShape shape)
          Add the given shape.
 void addStarfieldBackground(int starCount)
          Add a starfield background.
protected  javax.media.j3d.Appearance createAppearance(IShape shape)
          Create a new appearance for the given shape.
protected  javax.media.j3d.BranchGroup createBranchGroup(IShape shape)
          Return a Java 3D Node for the given shape.
protected  Component createCanvas()
          Create the appropriate canvas.
protected  javax.media.j3d.BranchGroup createSceneGraph(com.sun.j3d.utils.universe.SimpleUniverse su)
          Create the scene graph.
protected  javax.media.j3d.TransformGroup createTranformGroup(IShape shape, javax.media.j3d.Transform3D transform, com.sun.j3d.utils.geometry.Primitive primitive)
          Create a new TransformGroup using the given parameters.
protected  javax.media.j3d.Transform3D createTransform(IShape shape)
          Create a new Transform3D for the given shape.
protected  double getOffsetZ()
          Return the offset Z value.
 Vector getPositionOffset()
           
protected  int getPrimFlags(IShape shape)
          Return the primitive flags for the given shape.
protected  void orientationChanged()
          The shapes have moved.
 void setBackground(Color color)
          Set the background color.
 void setPositionOffset(Vector positionOffset)
           
protected  void setQuaternion(Quaternion q)
          Set the current rotation quaternion.
 void setViewPointLightUsed(boolean isViewPointLightUsed)
           
protected  void sizeChanged()
          The canvas size changed.
 void update()
          Update the shapes on this canvas.
protected  javax.media.j3d.Transform3D updateTransform(javax.media.j3d.Transform3D transform, IShape shape)
          Update the given transform for the given shape.
 
Methods inherited from class org.vizzini.ui.graphics.AbstractShapeCanvas
clear, computeQuaternion, getAbsoluteState, getAnchor, getAnchorShapeGroupIterator, getComponent, getMagnify, getPerspectiveConstant, getState, getStatefulParent, getXRotation, getYRotation, getZRotation, isViewPointLightUsed, myPaint, remove, setBounds, setBounds, setMagnify, setPerspectiveConstant, setStatefulParent, setXRotation, setYRotation, setZRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORLD_TRANSFORM

protected static final javax.media.j3d.Transform3D WORLD_TRANSFORM
Transform from Vizzini coordinates to Java 3D coordinates.

Constructor Detail

ShapeCanvasJava3D

ShapeCanvasJava3D()
Method Detail

add

public void add(IShape shape)
Add the given shape.

Specified by:
add in interface IShapeCanvas
Overrides:
add in class AbstractShapeCanvas
Parameters:
shape - The shape to add.
Since:
v0.3

addStarfieldBackground

public void addStarfieldBackground(int starCount)
Add a starfield background.

Parameters:
starCount - Number of stars to use.
Since:
v0.3

getPositionOffset

public Vector getPositionOffset()
Returns:
Return positionOffset.
Since:
v0.3

setBackground

public void setBackground(Color color)
Set the background color.

Specified by:
setBackground in interface IShapeCanvas
Overrides:
setBackground in class AbstractShapeCanvas
Parameters:
color - The new color.
Since:
v0.3

setPositionOffset

public void setPositionOffset(Vector positionOffset)
Parameters:
positionOffset - the positionOffset to set
Since:
v0.3

setViewPointLightUsed

public void setViewPointLightUsed(boolean isViewPointLightUsed)
Specified by:
setViewPointLightUsed in interface IShapeCanvas
Overrides:
setViewPointLightUsed in class AbstractShapeCanvas
Parameters:
isViewPointLightUsed - the isViewPointLightUsed to set
Since:
v0.3

update

public void update()
Update the shapes on this canvas.

Specified by:
update in interface IShapeCanvas
Overrides:
update in class AbstractShapeCanvas
Since:
v0.3

createAppearance

protected javax.media.j3d.Appearance createAppearance(IShape shape)
Create a new appearance for the given shape.

The properties that can be set for a Material object are:

Parameters:
shape - Shape.
Since:
v0.3

createBranchGroup

protected javax.media.j3d.BranchGroup createBranchGroup(IShape shape)
Return a Java 3D Node for the given shape.

Parameters:
shape - Shape.
Since:
v0.3

createCanvas

protected Component createCanvas()
Create the appropriate canvas.

Specified by:
createCanvas in class AbstractShapeCanvas
Since:
v0.3

createSceneGraph

protected javax.media.j3d.BranchGroup createSceneGraph(com.sun.j3d.utils.universe.SimpleUniverse su)
Create the scene graph.

Parameters:
su - Simple universe.
Since:
v0.3

createTranformGroup

protected javax.media.j3d.TransformGroup createTranformGroup(IShape shape,
                                                             javax.media.j3d.Transform3D transform,
                                                             com.sun.j3d.utils.geometry.Primitive primitive)
Create a new TransformGroup using the given parameters.

Parameters:
shape - Shape.
transform - Transform.
primitive - Primitive.
Since:
v0.3

createTransform

protected javax.media.j3d.Transform3D createTransform(IShape shape)
Create a new Transform3D for the given shape.

Parameters:
shape - Shape.
Since:
v0.3

getOffsetZ

protected double getOffsetZ()
Return the offset Z value.

Since:
v0.3

getPrimFlags

protected int getPrimFlags(IShape shape)
Return the primitive flags for the given shape.

Parameters:
shape - Shape.
Since:
v0.3

orientationChanged

protected void orientationChanged()
The shapes have moved.

Overrides:
orientationChanged in class AbstractShapeCanvas
Since:
v0.3

setQuaternion

protected void setQuaternion(Quaternion q)
Set the current rotation quaternion.

Overrides:
setQuaternion in class AbstractShapeCanvas
Parameters:
q - Quaternion.
Since:
v0.3

sizeChanged

protected void sizeChanged()
The canvas size changed.

Overrides:
sizeChanged in class AbstractShapeCanvas
Since:
v0.3

updateTransform

protected javax.media.j3d.Transform3D updateTransform(javax.media.j3d.Transform3D transform,
                                                      IShape shape)
Update the given transform for the given shape.

Parameters:
transform - Transform to update.
shape - Shape.
Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02