org.jdesktop.wonderland.client.cell.utils
Class CellPlacementUtils

java.lang.Object
  extended by org.jdesktop.wonderland.client.cell.utils.CellPlacementUtils

public class CellPlacementUtils
extends java.lang.Object

A set of utility routines to aid the initial placement of Cells in the world based upon the hints given to it.

Author:
Jordan Slott

Constructor Summary
CellPlacementUtils()
           
 
Method Summary
static float getBoundsHeight(com.jme.bounding.BoundingVolume bounds)
          Returns the vertical component of the bounds, assuming the +y axis is up.
static com.jme.math.Vector3f getCellOrigin(ServerSessionManager session, com.jme.bounding.BoundingVolume bounds, CellTransform viewTransform)
          Returns a vector that represents the origin of a Cell placed optimally, given the bounding volume of the Cell and the "view" Cell Tranform.
static com.jme.math.Quaternion getCellRotation(CellTransform viewTransform)
          Returns the rotation of a Cell so that is faces the viewer.
static CellTransform getCellTransform(ServerSessionManager session, com.jme.bounding.BoundingVolume bounds, CellTransform viewTransform)
          Returns a Cell transform so that it is optimally placed given the bounding volume of the Cell and the transform of the viewer.
static float getDistance(com.jme.bounding.BoundingVolume bounds, float fieldOfView, float minDistance, float maxDistance)
          Returns the distance away to play a Cell so that its horizontal bounds are entirely in-view.
static com.jme.math.Vector3f getLookDirection(com.jme.math.Quaternion rotation, com.jme.math.Vector3f v)
          Returns the "look direction" given a rotation.
static float getVectorToCollidable(org.jdesktop.mtgame.JMECollisionSystem collision, com.jme.math.Vector3f position, com.jme.math.Vector3f lookAt)
          Returns the distance from the avatar to the closest collidable object, given a "look at" vector of the avatar and its current position.
static float getVectorToGround(org.jdesktop.mtgame.JMECollisionSystem collision, com.jme.math.Vector3f position)
          Returns the distance to the ground from the given position vector.
static CellTransform transform(CellTransform transform, CellTransform fromReferenceSystem, CellTransform toReferenceSystem)
          A utility routine to convert the given transform from world coordinates to another reference system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellPlacementUtils

public CellPlacementUtils()
Method Detail

getCellTransform

public static CellTransform getCellTransform(ServerSessionManager session,
                                             com.jme.bounding.BoundingVolume bounds,
                                             CellTransform viewTransform)
Returns a Cell transform so that it is optimally placed given the bounding volume of the Cell and the transform of the viewer. Optionally takes the current server session, if null, uses the primary one. The transform returned is in world coordinates.

Parameters:
session - The server session
bounds - The bounding volume of the Cell
viewTransform - The transform of the view Cell

getCellOrigin

public static com.jme.math.Vector3f getCellOrigin(ServerSessionManager session,
                                                  com.jme.bounding.BoundingVolume bounds,
                                                  CellTransform viewTransform)
Returns a vector that represents the origin of a Cell placed optimally, given the bounding volume of the Cell and the "view" Cell Tranform. Also takes the server session, if null, uses the primary session. The origin returned is in world coordinates.

Parameters:
session - The server session
bounds - The bounding volume of the Cell
viewTransform - The transform of the view Cell

getCellRotation

public static com.jme.math.Quaternion getCellRotation(CellTransform viewTransform)
Returns the rotation of a Cell so that is faces the viewer.

Parameters:
viewTransform - The transform of the viewer
Returns:
A rotation in world coordinates

getDistance

public static float getDistance(com.jme.bounding.BoundingVolume bounds,
                                float fieldOfView,
                                float minDistance,
                                float maxDistance)
Returns the distance away to play a Cell so that its horizontal bounds are entirely in-view. Takes the bounding volume of the Cell and a field- of-view of the viewer (in degrees). Assumes the bounding volume is either a sphere or box, if not, assumes it has a radius of 1.0.

This method assumes the Cell is rotated so that, with respect to the viewer, the +x axis is to the right, the +y axis is up, and the +z axis is towards the viewer.

This distance returned is at least 'minDistance' away from the viewer and at most 'maxDistance' away from the viewer. If the value for the minimum distance is -1, there is no minimum distance. If the maximum distance is -1, there is no maximum distance. Note that the maximum distance takes precendence over the minimum distance: that is, the Cell may be placed closer than the minimum distance if it exceeds the maximum distance.

Parameters:
bounds - The bounding volume of the Cell
fieldOfView - The field-of-view of the viewer (in degrees)
minDistance - The minimum distance away from the viewer that the front face of the Cell may be, or -1 for no minimum distance
maxDistance - The maximum distance away from the viewer that the front face of the Cell may be, or -1 for no maximim distance
Returns:
The distance away to place the Cell so that the horizontal bounds are entirely within view.

getBoundsHeight

public static float getBoundsHeight(com.jme.bounding.BoundingVolume bounds)
Returns the vertical component of the bounds, assuming the +y axis is up.

Parameters:
bounds - The bounding volume
Returns:
The vertical component of the bounds

getLookDirection

public static com.jme.math.Vector3f getLookDirection(com.jme.math.Quaternion rotation,
                                                     com.jme.math.Vector3f v)
Returns the "look direction" given a rotation.

Parameters:
rotation - The Quaternion rotation
v - If non-null, place the look-direction in this vector
Returns:
The look direction

getVectorToGround

public static float getVectorToGround(org.jdesktop.mtgame.JMECollisionSystem collision,
                                      com.jme.math.Vector3f position)
Returns the distance to the ground from the given position vector. This method assumes the ground is in the -y direction. Returns -1 if no ground is found.

Parameters:
collision - The collision system to do picking
position - The world translation of the position from which the vector to the ground will be computed.
Returns:
A floating point distance to the ground, as a positive number.

getVectorToCollidable

public static float getVectorToCollidable(org.jdesktop.mtgame.JMECollisionSystem collision,
                                          com.jme.math.Vector3f position,
                                          com.jme.math.Vector3f lookAt)
Returns the distance from the avatar to the closest collidable object, given a "look at" vector of the avatar and its current position. Returns -1 if no collidable is found.

This method is used, for example, to find the closest "wall" to the avatar.

Parameters:
collision - The collision system to do picking
position - The position of the avatar
lookAt - The direction the avatar is looking at
Returns:
A floating point distance to the closest collidable object

transform

public static CellTransform transform(CellTransform transform,
                                      CellTransform fromReferenceSystem,
                                      CellTransform toReferenceSystem)
A utility routine to convert the given transform from world coordinates to another reference system. Typically, the given transform is the initial transform of the Cell in world coordinates and we want to transform with respect to some Cell in the world.



Open Wonderland - http://openwonderland.org