org.jdesktop.wonderland.client.jme.cellrenderer
Class BasicRenderer

java.lang.Object
  extended by org.jdesktop.wonderland.client.jme.cellrenderer.BasicRenderer
All Implemented Interfaces:
CellRenderer, CellRendererJME
Direct Known Subclasses:
AvatarJME, ModelRenderer

public abstract class BasicRenderer
extends java.lang.Object
implements CellRendererJME

Abstract Renderer class that implements CellRendererJME

Author:
paulby

Nested Class Summary
 class BasicRenderer.AssetResourceLocator
          JME Asset locator using WL Asset manager
 class BasicRenderer.MoveProcessor
          An mtgame ProcessorCompoenent to process cell moves.
 
Field Summary
protected  Cell cell
           
protected  org.jdesktop.mtgame.Entity entity
           
protected static java.util.logging.Logger logger
           
protected  BasicRenderer.MoveProcessor moveProcessor
           
protected  com.jme.scene.Node rootNode
           
protected  com.jme.scene.Node sceneRoot
           
 
Constructor Summary
BasicRenderer(Cell cell)
           
 
Method Summary
protected  void addDefaultComponents(org.jdesktop.mtgame.Entity entity, com.jme.scene.Node rootNode)
           
protected  void addRenderState(com.jme.scene.Node node)
          Add the default renderstate to the root node.
static void applyTransform(com.jme.scene.Spatial node, CellTransform transform)
          Apply the transform to the jme node
 void cellTransformUpdate(CellTransform localTransform)
          Callback notifying the renderer that the cell transform has changed.
protected  void cleanupSceneGraph(org.jdesktop.mtgame.Entity entity)
          Cleanup the scene graph, allowing resources to be gc'ed TODO - should be abstract, but don't want to break compatability in 0.5 API
protected  org.jdesktop.mtgame.Entity createEntity()
           
protected abstract  com.jme.scene.Node createSceneGraph(org.jdesktop.mtgame.Entity entity)
          Create the scene graph.
static void entityAddChild(org.jdesktop.mtgame.Entity parentEntity, org.jdesktop.mtgame.Entity child)
          Convenience method which attaches the child entity to the specified parent AND sets the attachpoint of the childs RenderComponent to the scene root of the parents RenderComponent
protected  java.net.URL getAssetURL(java.lang.String uri)
          Given a url, determine and return the full asset URL.
 Cell getCell()
          Return the cell that contains this component
 org.jdesktop.mtgame.Entity getEntity()
          Return the entity for this basic renderer.
 com.jme.scene.Node getSceneRoot()
          Return the scene root, this is the node created by createSceneGraph.
 CellStatus getStatus()
          Return the current status of the CellRenderer
 boolean isCollisionEnabled()
           
 void setBackfaceCullingEnabled(boolean backfaceCullingEnabled)
           
 void setCollisionEnabled(boolean collisionEnabled)
           
 void setLightingEnabled(boolean lightingEnabled)
           
 void setPickingEnabled(boolean pickingEnabled)
           
 void setStatus(CellStatus status, boolean increasing)
          Notify the renderer of a cell status change
protected  org.jdesktop.mtgame.CollisionComponent setupCollision(org.jdesktop.mtgame.CollisionSystem collisionSystem, com.jme.scene.Node rootNode)
           
protected  org.jdesktop.mtgame.PhysicsComponent setupPhysics(org.jdesktop.mtgame.CollisionComponent physicsCC, org.jdesktop.mtgame.PhysicsSystem physicsSystem, com.jme.scene.Node rootNode)
           
protected  org.jdesktop.mtgame.CollisionComponent setupPhysicsCollision(org.jdesktop.mtgame.CollisionSystem collisionSystem, com.jme.scene.Node rootNode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static java.util.logging.Logger logger

cell

protected Cell cell

entity

protected org.jdesktop.mtgame.Entity entity

rootNode

protected com.jme.scene.Node rootNode

sceneRoot

protected com.jme.scene.Node sceneRoot

moveProcessor

protected BasicRenderer.MoveProcessor moveProcessor
Constructor Detail

BasicRenderer

public BasicRenderer(Cell cell)
Method Detail

getCell

public Cell getCell()
Return the cell that contains this component

Returns:

getStatus

public CellStatus getStatus()
Description copied from interface: CellRenderer
Return the current status of the CellRenderer

Specified by:
getStatus in interface CellRenderer
Returns:

setStatus

public void setStatus(CellStatus status,
                      boolean increasing)
Description copied from interface: CellRenderer
Notify the renderer of a cell status change

Specified by:
setStatus in interface CellRenderer

entityAddChild

public static void entityAddChild(org.jdesktop.mtgame.Entity parentEntity,
                                  org.jdesktop.mtgame.Entity child)
Convenience method which attaches the child entity to the specified parent AND sets the attachpoint of the childs RenderComponent to the scene root of the parents RenderComponent

Parameters:
parentEntity -
child -

createEntity

protected org.jdesktop.mtgame.Entity createEntity()

getSceneRoot

public com.jme.scene.Node getSceneRoot()
Return the scene root, this is the node created by createSceneGraph. The BasicRenderer also has a rootNode which contains the cell transform, the rootNode is the parent of the scene root.

Returns:

addRenderState

protected void addRenderState(com.jme.scene.Node node)
Add the default renderstate to the root node. Override this method if you want to apply a different RenderState

Parameters:
node -

addDefaultComponents

protected void addDefaultComponents(org.jdesktop.mtgame.Entity entity,
                                    com.jme.scene.Node rootNode)

setupCollision

protected org.jdesktop.mtgame.CollisionComponent setupCollision(org.jdesktop.mtgame.CollisionSystem collisionSystem,
                                                                com.jme.scene.Node rootNode)

setupPhysics

protected org.jdesktop.mtgame.PhysicsComponent setupPhysics(org.jdesktop.mtgame.CollisionComponent physicsCC,
                                                            org.jdesktop.mtgame.PhysicsSystem physicsSystem,
                                                            com.jme.scene.Node rootNode)

setupPhysicsCollision

protected org.jdesktop.mtgame.CollisionComponent setupPhysicsCollision(org.jdesktop.mtgame.CollisionSystem collisionSystem,
                                                                       com.jme.scene.Node rootNode)

createSceneGraph

protected abstract com.jme.scene.Node createSceneGraph(org.jdesktop.mtgame.Entity entity)
Create the scene graph. The node returned will have default components set to handle collision and rendering. The returned graph will also automatically be positioned correctly with the cells transform. This is achieved by adding the returned Node to a rootNode for this renderer which automatically tracks the cells transform.

Returns:

cleanupSceneGraph

protected void cleanupSceneGraph(org.jdesktop.mtgame.Entity entity)
Cleanup the scene graph, allowing resources to be gc'ed TODO - should be abstract, but don't want to break compatability in 0.5 API

Parameters:
entity -

applyTransform

public static void applyTransform(com.jme.scene.Spatial node,
                                  CellTransform transform)
Apply the transform to the jme node

Parameters:
node -
transform -

getEntity

public org.jdesktop.mtgame.Entity getEntity()
Return the entity for this basic renderer. The first time this method is called the entity will be created using createEntity()

Specified by:
getEntity in interface CellRendererJME
Returns:

cellTransformUpdate

public void cellTransformUpdate(CellTransform localTransform)
Callback notifying the renderer that the cell transform has changed.

Specified by:
cellTransformUpdate in interface CellRenderer
Parameters:
localTransform - the new local transform of the cell

getAssetURL

protected java.net.URL getAssetURL(java.lang.String uri)
                            throws java.net.MalformedURLException
Given a url, determine and return the full asset URL. This is a convenience method that invokes methods on AssetUtils using the session associated with the cell for this cell renderer

Parameters:
uri - The asset URI
Returns:
A URL representing the uri
Throws:
java.net.MalformedURLException - Upon error forming the URL

isCollisionEnabled

public boolean isCollisionEnabled()
Returns:
the collisionEnabled

setCollisionEnabled

public void setCollisionEnabled(boolean collisionEnabled)
Parameters:
collisionEnabled - the collisionEnabled to set

setPickingEnabled

public void setPickingEnabled(boolean pickingEnabled)

setLightingEnabled

public void setLightingEnabled(boolean lightingEnabled)

setBackfaceCullingEnabled

public void setBackfaceCullingEnabled(boolean backfaceCullingEnabled)


Open Wonderland - http://openwonderland.org