org.xith3d.base
Class Xith3DEnvironment

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraph
      extended by org.xith3d.base.Xith3DEnvironment
All Implemented Interfaces:
CanvasBag, RenderableSceneGraph

public class Xith3DEnvironment
extends SceneGraph
implements RenderableSceneGraph

This class offers the common objects needed for Xith3D rendering. Link it with an instance of RenderLoop ("renderLoop.addRenderEngine(RenderEngine)") to let the scene be rendered in a separate thread.

See Also:
RenderLoop

Field Summary
 boolean canvasAliveCheckSuppressed
           
 
Fields inherited from class org.xith3d.scenegraph.SceneGraph
CHECK_FOR_ILLEGAL_MODIFICATION, huds, modListener
 
Constructor Summary
Xith3DEnvironment()
          Creates a new Xith3DEnvironment with eyePosition defaulted to (0, 0, 5), viewFocus defaulted to (0, 0, 0), and vecUp defaulted to (0, 1, 0).
Xith3DEnvironment(float eyePositionX, float eyePositionY, float eyePositionZ, float viewFocusX, float viewFocusY, float viewFocusZ, float vecUpX, float vecUpY, float vecUpZ)
          Creates a new Xith3DEnvironment.
Xith3DEnvironment(float eyePositionX, float eyePositionY, float eyePositionZ, float viewFocusX, float viewFocusY, float viewFocusZ, float vecUpX, float vecUpY, float vecUpZ, RenderLoop renderLoop)
          Creates a new Xith3DEnvironment.
Xith3DEnvironment(RenderLoop renderLoop)
          Creates a new Xith3DEnvironment with eyePosition defaulted to (0, 0, 5), viewFocus defaulted to (0, 0, 0), and vecUp defaulted to (0, 1, 0).
Xith3DEnvironment(org.openmali.vecmath2.Tuple3f eyePosition, org.openmali.vecmath2.Tuple3f viewFocus, org.openmali.vecmath2.Tuple3f vecUp)
          Creates a new Xith3DEnvironment.
Xith3DEnvironment(org.openmali.vecmath2.Tuple3f eyePosition, org.openmali.vecmath2.Tuple3f viewFocus, org.openmali.vecmath2.Tuple3f vecUp, RenderLoop renderLoop)
          Creates a new Xith3DEnvironment.
 
Method Summary
 Canvas3D addCanvas(Canvas3D canvas)
          Adds a Canvas3D to the list of canveses.
 Canvas3D addCanvas(Canvas3D canvas, View view)
          Adds a Canvas3D to the list of canveses.
 Canvas3DWrapper addCanvas(Canvas3DWrapper canvasWrapper)
          Adds a Canvas3D to the list of canveses.
 Canvas3DWrapper addCanvas(Canvas3DWrapper canvasWrapper, View view)
          Adds a Canvas3D to the list of canveses.
 void checkRenderPreferences()
          Checks the render preferences.
static Xith3DEnvironment createHeadless()
          Creates a new headless (without a View) Xith3DEnvironment.
static Xith3DEnvironment createHeadless(RenderLoop renderLoop)
          Creates a new headless (without a View) Xith3DEnvironment.
 void destroy()
          Destroy all resources.
 Canvas3D getCanvas()
          
 Canvas3D getCanvas(int index)
          
 OperationScheduler getOperationScheduler()
          Returns the OperationScheduler.
 PhysicsEngine getPhysicsEngine()
          Returns the PhysicsEngine, which is automatically updated by the RenderLoop.
 PickScheduler getPickScheduler()
          Returns this environment's PickScheduler.
 RenderLoop getRenderLoop()
          Returns the RenderLoop.
 EnvScreenshotEngine getScreenshotEngine()
          Returns this environment's ScreenshotEngine.
 SoundDriver getSoundDriver()
          Deprecated. use SoundProcessor.getInstance() instead to get the sound driver.
 boolean isCanvasAlive(Canvas3D canvas)
          Checkes if a Canvas3D is currently to be rendered.
 boolean isCanvasAlive(Canvas3DWrapper canvasWrapper)
          Checkes if a Canvas3DPanel is currently to be rendered.
 void removeAllCanvas3Ds()
          Removes all Canvas3Ds from the View
 void removeCanvas(Canvas3D canvas)
          Removes a Canvas3D from the list of canveses.
 void removeCanvas(Canvas3DWrapper canvasWrapper)
          Removes a Canvas3D from the list of canveses.
 void render()
          Renders all Canvas3Ds.
 void render(long nanoGameTime, long nanoFrameTime)
          Renders all Canvas3Ds.
 void reviveCanvas(Canvas3D canvas)
          (Re-)activates a Canvas3D to be rendered by the RenderLoop
 void reviveCanvas(Canvas3DWrapper canvasWrapper)
          (Re-)activates a Canvas3D to be rendered by the RenderLoop
 void setCanvasRenderPassMap(java.util.HashMap<Canvas3D,java.util.List<RenderPass>> canvasRenderPassMap)
          Sets a map, that defines a list of RenderPasses to be rendered to each mapped canvas.
 void setPhysicsEngine(PhysicsEngine physEngine)
          Sets the PhysicsEngine, which is automatically updated by the RenderLoop.
 void setPickScheduler(PickScheduler picker)
          Sets this environment's PickScheduler.
 void setRenderLoop(RenderLoop renderLoop)
          Sets the RenderLoop.
 void setScreenshotEngine(EnvScreenshotEngine engine)
          Sets this environment's ScreenshotEngine.
 void setSoundDriver(SoundDriver soundDriver)
          Deprecated. use SoundProcessor.getInstance() instead to set the sound driver.
 void suspendCanvas(Canvas3D canvas)
          Suspends a Canvas3D do not be rendered for the moment.
 void suspendCanvas(Canvas3DWrapper canvasWrapper)
          Suspends a Canvas3D do not be rendered for the moment.
 void updateInputSystem(long gameTime, UpdatingThread.TimingMode timingMode)
          Updates the InputSystem.
 void updatePhysicsEngine(long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          Updates the PhysicsEngine.
 
Methods inherited from class org.xith3d.scenegraph.SceneGraph
addBranchGraph, addHUD, addParallelBranch, addParallelBranch, addPerspectiveBranch, addPerspectiveBranch, addRenderPass, addRenderPassFirst, addScenegraphModificationListener, addView, checkForIllegalModification, getBranchGroup, getBranchGroup, getHUD, getNumberOfBranchGroups, getNumberOfViews, getRenderer, getTotalNumChildren, getTotalNumShapes, getView, getView, removeAllBranchGraphs, removeBranchGraph, removeHUD, removeRenderPass, removeScenegraphModificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xith3d.scenegraph.RenderableSceneGraph
addBranchGraph, addHUD, addParallelBranch, addParallelBranch, addPerspectiveBranch, addPerspectiveBranch, addRenderPass, addRenderPassFirst, addScenegraphModificationListener, addView, getBranchGroup, getRenderer, getView, getView, removeAllBranchGraphs, removeBranchGraph, removeHUD, removeRenderPass, removeScenegraphModificationListener
 

Field Detail

canvasAliveCheckSuppressed

public boolean canvasAliveCheckSuppressed
Constructor Detail

Xith3DEnvironment

public Xith3DEnvironment(float eyePositionX,
                         float eyePositionY,
                         float eyePositionZ,
                         float viewFocusX,
                         float viewFocusY,
                         float viewFocusZ,
                         float vecUpX,
                         float vecUpY,
                         float vecUpZ,
                         RenderLoop renderLoop)
Creates a new Xith3DEnvironment.

Parameters:
eyePositionX - the center of the eye
eyePositionY - the center of the eye
eyePositionZ - the center of the eye
viewFocusX - the point the view looks at
viewFocusY - the point the view looks at
viewFocusZ - the point the view looks at
vecUpX - the vector pointing up
vecUpY - the vector pointing up
vecUpZ - the vector pointing up
renderLoop - the RenderLoop instance to link this environment with

Xith3DEnvironment

public Xith3DEnvironment(float eyePositionX,
                         float eyePositionY,
                         float eyePositionZ,
                         float viewFocusX,
                         float viewFocusY,
                         float viewFocusZ,
                         float vecUpX,
                         float vecUpY,
                         float vecUpZ)
Creates a new Xith3DEnvironment.

Parameters:
eyePositionX - the center of the eye
eyePositionY - the center of the eye
eyePositionZ - the center of the eye
viewFocusX - the point the view looks at
viewFocusY - the point the view looks at
viewFocusZ - the point the view looks at
vecUpX - the vector pointing up
vecUpY - the vector pointing up
vecUpZ - the vector pointing up

Xith3DEnvironment

public Xith3DEnvironment(org.openmali.vecmath2.Tuple3f eyePosition,
                         org.openmali.vecmath2.Tuple3f viewFocus,
                         org.openmali.vecmath2.Tuple3f vecUp,
                         RenderLoop renderLoop)
Creates a new Xith3DEnvironment.

Parameters:
eyePosition - the environment's view's location (or null for no View creation)
viewFocus - the environment's view's center (where to look at) (or null for no View creation)
vecUp - the environment's view's normal which is pointing up (or null for no View creation)
renderLoop - the RenderLoop instance to link this environment with

Xith3DEnvironment

public Xith3DEnvironment(org.openmali.vecmath2.Tuple3f eyePosition,
                         org.openmali.vecmath2.Tuple3f viewFocus,
                         org.openmali.vecmath2.Tuple3f vecUp)
Creates a new Xith3DEnvironment.

Parameters:
eyePosition - the environment's view's location (or null for no View creation)
viewFocus - the environment's view's center (where to look at) (or null for no View creation)
vecUp - the environment's view's normal which is pointing up (or null for no View creation)

Xith3DEnvironment

public Xith3DEnvironment(RenderLoop renderLoop)
Creates a new Xith3DEnvironment with eyePosition defaulted to (0, 0, 5), viewFocus defaulted to (0, 0, 0), and vecUp defaulted to (0, 1, 0)

.

Parameters:
renderLoop - the RenderLoop instance to link this environment with

Xith3DEnvironment

public Xith3DEnvironment()
Creates a new Xith3DEnvironment with eyePosition defaulted to (0, 0, 5), viewFocus defaulted to (0, 0, 0), and vecUp defaulted to (0, 1, 0)

.

Method Detail

setRenderLoop

public void setRenderLoop(RenderLoop renderLoop)
Sets the RenderLoop.

Parameters:
renderLoop - the RenderLoop to set

getRenderLoop

public final RenderLoop getRenderLoop()
Returns the RenderLoop.

Returns:
the RenderLoop to return

getOperationScheduler

public final OperationScheduler getOperationScheduler()
Returns the OperationScheduler.

Returns:
the OperationScheduler

setScreenshotEngine

public void setScreenshotEngine(EnvScreenshotEngine engine)
Sets this environment's ScreenshotEngine.

Parameters:
engine - the ScreenshotEngine to set

getScreenshotEngine

public EnvScreenshotEngine getScreenshotEngine()
Returns this environment's ScreenshotEngine.

Returns:
the ScreenshotEngine

setPickScheduler

public void setPickScheduler(PickScheduler picker)
Sets this environment's PickScheduler.

Parameters:
picker - the PickScheduler to set

getPickScheduler

public PickScheduler getPickScheduler()
Returns this environment's PickScheduler.

Returns:
the PickScheduler

setPhysicsEngine

public void setPhysicsEngine(PhysicsEngine physEngine)
Sets the PhysicsEngine, which is automatically updated by the RenderLoop.

Parameters:
physEngine - the PhysicsEngine to set

getPhysicsEngine

public PhysicsEngine getPhysicsEngine()
Returns the PhysicsEngine, which is automatically updated by the RenderLoop.

Returns:
the PhysicsEngine

updatePhysicsEngine

public final void updatePhysicsEngine(long gameTime,
                                      long frameTime,
                                      UpdatingThread.TimingMode timingMode)
Updates the PhysicsEngine.

Parameters:
gameTime -
frameTime -
timingMode -

updateInputSystem

public final void updateInputSystem(long gameTime,
                                    UpdatingThread.TimingMode timingMode)
Updates the InputSystem.

Parameters:
gameTime -
timingMode -

setSoundDriver

@Deprecated
public void setSoundDriver(SoundDriver soundDriver)
Deprecated. use SoundProcessor.getInstance() instead to set the sound driver.

Sets the sound driver.


getSoundDriver

@Deprecated
public SoundDriver getSoundDriver()
Deprecated. use SoundProcessor.getInstance() instead to get the sound driver.

Returns the sound driver.


addCanvas

public Canvas3D addCanvas(Canvas3D canvas,
                          View view)
Adds a Canvas3D to the list of canveses. It will be rendered from now on.

Specified by:
addCanvas in interface CanvasBag
Parameters:
canvas - the Canvas3D to be added
view - the view to add the Canvas3D to
Returns:
the given Canvas3D back again

addCanvas

public Canvas3D addCanvas(Canvas3D canvas)
Adds a Canvas3D to the list of canveses. It will be rendered from now on.

Specified by:
addCanvas in interface CanvasBag
Parameters:
canvas - the Canvas3D to be added
Returns:
the given Canvas3D back again

addCanvas

public Canvas3DWrapper addCanvas(Canvas3DWrapper canvasWrapper,
                                 View view)
Adds a Canvas3D to the list of canveses. It will be rendered from now on.

Specified by:
addCanvas in interface CanvasBag
Parameters:
canvasWrapper - the Canvas3D to be added
view - the view to add the Canvas3D to
Returns:
the given Canvas3DWrapper back again

addCanvas

public Canvas3DWrapper addCanvas(Canvas3DWrapper canvasWrapper)
Adds a Canvas3D to the list of canveses. It will be rendered from now on.

Specified by:
addCanvas in interface CanvasBag
Parameters:
canvasWrapper - the Canvas3D to be added
Returns:
the given Canvas3DWrapper back again

removeCanvas

public void removeCanvas(Canvas3D canvas)
Removes a Canvas3D from the list of canveses. It won't be rendered anymore.

Specified by:
removeCanvas in interface CanvasBag
Parameters:
canvas - the Canvas3D to be removed

removeCanvas

public void removeCanvas(Canvas3DWrapper canvasWrapper)
Removes a Canvas3D from the list of canveses. It won't be rendered anymore.

Specified by:
removeCanvas in interface CanvasBag
Parameters:
canvasWrapper - the Canvas3D to be removed

removeAllCanvas3Ds

public void removeAllCanvas3Ds()
Removes all Canvas3Ds from the View

Specified by:
removeAllCanvas3Ds in interface CanvasBag

getCanvas

public Canvas3D getCanvas()

Specified by:
getCanvas in interface CanvasBag
Returns:
the Canvas3D added first to the Xith3DEnvironment or null

getCanvas

public Canvas3D getCanvas(int index)

Specified by:
getCanvas in interface CanvasBag
Parameters:
index - the desired Canvas3D's index
Returns:
the Canvas3D added first to the Xith3DEnvironment or null

suspendCanvas

public void suspendCanvas(Canvas3D canvas)
Suspends a Canvas3D do not be rendered for the moment.

Specified by:
suspendCanvas in interface CanvasBag
Parameters:
canvas - the arguable Canvas3D

suspendCanvas

public void suspendCanvas(Canvas3DWrapper canvasWrapper)
Suspends a Canvas3D do not be rendered for the moment.

Specified by:
suspendCanvas in interface CanvasBag
Parameters:
canvasWrapper - the arguable Canvas3D containing Canvas3DWrapper

reviveCanvas

public void reviveCanvas(Canvas3D canvas)
(Re-)activates a Canvas3D to be rendered by the RenderLoop

Specified by:
reviveCanvas in interface CanvasBag
Parameters:
canvas - the arguable Canvas3D

reviveCanvas

public void reviveCanvas(Canvas3DWrapper canvasWrapper)
(Re-)activates a Canvas3D to be rendered by the RenderLoop

Specified by:
reviveCanvas in interface CanvasBag
Parameters:
canvasWrapper - the arguable Canvas3D containing Canvas3DWrapper

isCanvasAlive

public boolean isCanvasAlive(Canvas3D canvas)
Checkes if a Canvas3D is currently to be rendered.

Specified by:
isCanvasAlive in interface CanvasBag
Parameters:
canvas - the arguable Canvas3D
Returns:
true, if the Canvas3D is currently rendered.

isCanvasAlive

public boolean isCanvasAlive(Canvas3DWrapper canvasWrapper)
Checkes if a Canvas3DPanel is currently to be rendered.

Specified by:
isCanvasAlive in interface CanvasBag
Parameters:
canvasWrapper - the arguable Canvas3DWrapper
Returns:
true, if the Canvas3D is currently rendered.

setCanvasRenderPassMap

public void setCanvasRenderPassMap(java.util.HashMap<Canvas3D,java.util.List<RenderPass>> canvasRenderPassMap)
Sets a map, that defines a list of RenderPasses to be rendered to each mapped canvas. The default value is null, which means, that all RenderPasses are rendered to each canvas.

Parameters:
canvasRenderPassMap -

checkRenderPreferences

public void checkRenderPreferences()
Checks the render preferences.


render

public void render(long nanoGameTime,
                   long nanoFrameTime)
Renders all Canvas3Ds.

Parameters:
nanoGameTime -
nanoFrameTime -

render

public void render()
Renders all Canvas3Ds. This method is usually called by the RenderLoop thread. It simply invokes render( System.nanoTime(), -1L ).


destroy

public void destroy()
Destroy all resources.


createHeadless

public static final Xith3DEnvironment createHeadless(RenderLoop renderLoop)
Creates a new headless (without a View) Xith3DEnvironment.

Parameters:
renderLoop - the RenderLoop instance to link this environment with

createHeadless

public static final Xith3DEnvironment createHeadless()
Creates a new headless (without a View) Xith3DEnvironment.