org.jdesktop.wonderland.client.jme
Class ViewManager

java.lang.Object
  extended by org.jdesktop.wonderland.client.jme.ViewManager
All Implemented Interfaces:
ViewProperties.ViewPropertiesListener

public class ViewManager
extends java.lang.Object
implements ViewProperties.ViewPropertiesListener

Manages the view into the 3D world. The JME Camera is internal to this class, it is associated with a Cell and a CameraProcessor is defined which specified how the camera tracks the cell. For example ThirdPersonCameraProcessor makes the camera follow the origin of the cell from behind and above the origin giving a third person view. TODO currently the camera processor is hardcoded to ThirdPerson The system provides the concept of a primary ViewCell, when using Wonderland with a set of federated servers the primary ViewCell is the one that is providing most of the user interaction. For example the rendering of the avatar and audio in formation will come from the primary ViewCell. The non primary ViewCells track the primary. The JME Camera and input controls will normally be attached to the View Cells (primary and others), however the system does support attaching the camera and controls to any cell. This is useful in some tool interfaces for positioning cells and visually checking things. It should be noted that when the camera and controls are not attached to a ViewCell the client will have some limitations, for example as the ViewCell is not moving on the server no cache updates will be sent to the client so tools should be careful not to allow the users to move outside of the current cell set.

Author:
paulby

Nested Class Summary
static interface ViewManager.CameraListener
          An interface for listening for camera changes
static interface ViewManager.ViewManagerListener
          Listener interface for ViewManager changes
 
Field Summary
 boolean useAvatars
           
 
Method Summary
 void addCameraListener(ViewManager.CameraListener cameraListener)
          Add a camera listener.
 void addViewManagerListener(ViewManager.ViewManagerListener listener)
          Add a ViewManagerListener which will be notified of changes in the view system
 void attach(Cell cell)
          Attach the 3D view to the specified cell.
protected  void createCameraEntity(org.jdesktop.mtgame.WorldManager wm)
           
 void deregister(ViewCell cell)
          Deregister a ViewCell (usually called when a session is closed) TODO implement
 void detach()
          Detach the 3D view from the cell it's currently attached to.
 CameraController getCameraController()
          Return the current camera controller
 com.jme.math.Vector3f getCameraLookDirection(com.jme.math.Vector3f v)
          Returns the camera "look direction" as a vector.
 com.jme.math.Vector3f getCameraPosition(com.jme.math.Vector3f v3f)
          Convienence method to return the camera position as a vector.
 CameraProcessor getCameraProcessor()
          Return the current camera processor
 CellTransform getCameraTransform()
          Return the transform of the camera
static CameraController getDefaultCamera()
          Get the default camera controller based on the value of the wonderland.client.camera environment variable.
 ViewCell getPrimaryViewCell()
          Returns the primary view cell.
static ViewManager getViewManager()
           
 ViewProperties getViewProperties()
          Returns the collection of properties for the view.
static void initialize(int width, int height)
           
 void register(ViewCell cell, WonderlandSession session)
          Register a ViewCell for a session with the ViewManager
 void removeCameraListener(ViewManager.CameraListener cameraListener)
          Remove the specified camera listener
 void removeViewManagerListener(ViewManager.ViewManagerListener listener)
          Remove the specified ViewManagerListner.
 void setCameraController(CameraController cameraController)
          Set the controller for the camera processor
 void setPrimaryViewCell(ViewCell cell)
          Set the Primary ViewCell for this client.
 void viewPropertiesChange(ViewProperties.ViewProperty property)
          Indicates that the given property has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useAvatars

public boolean useAvatars
Method Detail

initialize

public static void initialize(int width,
                              int height)

getViewManager

public static ViewManager getViewManager()

getDefaultCamera

public static CameraController getDefaultCamera()
Get the default camera controller based on the value of the wonderland.client.camera environment variable. If wonderland.client.camera is not set, the ThirdPersonCamera will be used as the default. If it is set, and its value is one of FIRST_PERSON, FRONT, or THIRD_PERSON, the corresponding camera will be used.

Returns:
the default camera

getViewProperties

public ViewProperties getViewProperties()
Returns the collection of properties for the view.

Parameters:
The - configurable view properties

register

public void register(ViewCell cell,
                     WonderlandSession session)
Register a ViewCell for a session with the ViewManager

Parameters:
cell - ViewCell to register

deregister

public void deregister(ViewCell cell)
Deregister a ViewCell (usually called when a session is closed) TODO implement

Parameters:
cell - ViewCell to deregister

setPrimaryViewCell

public void setPrimaryViewCell(ViewCell cell)
Set the Primary ViewCell for this client. The primary ViewCell is the one that is currently rendering the client avatar etc.

Parameters:
cell -

getPrimaryViewCell

public ViewCell getPrimaryViewCell()
Returns the primary view cell. The session can be obtained from the cell, cell.getCellCache().getSession(). The primaryViewCell may be null, especially during startup. Use the ViewManagerListener to track changes to the primaryViewCell.


attach

public void attach(Cell cell)
Attach the 3D view to the specified cell. Note the 3D view (camera and controls) are usually attached to a ViewCell, however they can be attached to any cell in the system. This can be useful for position cells etc, but note that the Primary ViewCell is not changed in that case so there may be some interesting side effects. For example the ViewCell on the server is not being moved so the client will not receive any cache updates.

Parameters:
cell -

detach

public void detach()
Detach the 3D view from the cell it's currently attached to.


setCameraController

public void setCameraController(CameraController cameraController)
Set the controller for the camera processor


getCameraProcessor

public CameraProcessor getCameraProcessor()
Return the current camera processor

Returns:

getCameraController

public CameraController getCameraController()
Return the current camera controller

Returns:

addViewManagerListener

public void addViewManagerListener(ViewManager.ViewManagerListener listener)
Add a ViewManagerListener which will be notified of changes in the view system

Parameters:
listener - to be added

removeViewManagerListener

public void removeViewManagerListener(ViewManager.ViewManagerListener listener)
Remove the specified ViewManagerListner.

Parameters:
listener -

createCameraEntity

protected void createCameraEntity(org.jdesktop.mtgame.WorldManager wm)

addCameraListener

public void addCameraListener(ViewManager.CameraListener cameraListener)
Add a camera listener. The listener will be called immediately with the current camera position and then every time the camera moves.

Parameters:
cameraListener -

removeCameraListener

public void removeCameraListener(ViewManager.CameraListener cameraListener)
Remove the specified camera listener

Parameters:
cameraListener -

getCameraTransform

public CellTransform getCameraTransform()
Return the transform of the camera

Returns:
the transform of the camera (in world coordinates) for this view

getCameraPosition

public com.jme.math.Vector3f getCameraPosition(com.jme.math.Vector3f v3f)
Convienence method to return the camera position as a vector.

Returns:
The camera position

getCameraLookDirection

public com.jme.math.Vector3f getCameraLookDirection(com.jme.math.Vector3f v)
Returns the camera "look direction" as a vector.

Returns:
The camera look direction

viewPropertiesChange

public void viewPropertiesChange(ViewProperties.ViewProperty property)
Indicates that the given property has changed.

Specified by:
viewPropertiesChange in interface ViewProperties.ViewPropertiesListener
Parameters:
property - The property that has changed


Open Wonderland - http://openwonderland.org