org.vrspace.server
Class Scene

java.lang.Object
  extended byorg.vrspace.server.Scene

public class Scene
extends java.lang.Object

This keeps track of objects visible to the Client.
This scene uses coordinates to determine which objects are in range.
Scene is updated when client moves more than resolution meters, or when timeout occurs.
It also has some basic filtering capabilities - not tested.


Constructor Summary
Scene(Client client)
          Creates new Scene for Client client
 
Method Summary
 void addFilter(ObjectFilter filter)
          Add TransformFilter or VRObjectFilter
 void addTransform(Transform t)
          Add Transform and it's members to the scene.
 void clear()
          Clears the scene
 boolean contains(java.lang.Object o)
          Does the scene contain o?
 boolean contains(Transform t)
          True if the transform is permanent or is non-permanent and in the members list.
 VRObject[] get(java.lang.Class cl)
          Returns all class instances within the scene
 Transform[] get(double x, double y, double z, double range)
          Returns transforms within the range
Does not return permanent objects
TODO: check bounding boxes
 VRObject get(java.lang.String className, long id)
          Retreives a VRObject from the scene or null if it's not in the scene.
TODO: implement!
 Transform[] getAll()
          Retreive all the Transforms in the scene
 VRObject getClosest(double x, double y, double z, java.lang.Class cl, boolean exact)
          Returns the closest object of some class to the specified point
 Transform getClosestTransform(double x, double y, double z)
          Returns the closest Transform to the specified point
 double getRange()
          returns scene range (meters)
 int getSize()
          return the scene size
 void init()
          Initialize the scene.
 void remove(Transform t)
          Removes an object from the scene.
 void remove(Transform t, boolean removeReference)
           
 void remove(VRObject obj)
          Removes an object from the scene.
 void removeAll()
          Remove all objects from the scene.
 void removeFilter(ObjectFilter filter)
          Remove a TransformFilter/VRObjectFilter
 void setDirty()
          Ensure the scene will be updated on next update() call.
 void setRange(double range)
          set scene size, in meters
 void setResolution(double resolution)
          set scene update resolution, in meters
 void setSize(int size)
          set scene size, in number of transforms
 void setTimeout(long timeout)
          set scene timeout, in milliseconds
protected  VRObject testObject(VRObject o)
          Test an object against set of filters.
protected  boolean testTransform(Transform t)
          Test Transform against set of filters.
 void update()
          Update the scene with old coordinates.
 void update(boolean forceUpdate)
          Update the scene with old coordinates.
 void update(double x, double y, double z)
          Update the scene with coordinates xyz
 void update(double x, double y, double z, boolean forceUpdate)
          Update the scene with coordinates xyz
 void update(Transform t)
          Update the scene with coordinates of t
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scene

public Scene(Client client)
Creates new Scene for Client client

Method Detail

init

public void init()
Initialize the scene.

See Also:
clear()

addTransform

public void addTransform(Transform t)
                  throws java.lang.Exception
Add Transform and it's members to the scene. Filters are checked, called from constructor

Throws:
java.lang.Exception

get

public VRObject get(java.lang.String className,
                    long id)
             throws java.lang.Exception
Retreives a VRObject from the scene or null if it's not in the scene.
TODO: implement!

Throws:
java.lang.Exception

getClosest

public VRObject getClosest(double x,
                           double y,
                           double z,
                           java.lang.Class cl,
                           boolean exact)
Returns the closest object of some class to the specified point

Parameters:
exact - true - return specified class only, false - return subclasses to

getClosestTransform

public Transform getClosestTransform(double x,
                                     double y,
                                     double z)
Returns the closest Transform to the specified point


get

public VRObject[] get(java.lang.Class cl)
Returns all class instances within the scene


get

public Transform[] get(double x,
                       double y,
                       double z,
                       double range)
Returns transforms within the range
Does not return permanent objects
TODO: check bounding boxes


update

public void update()
            throws java.lang.Exception
Update the scene with old coordinates. Use this after setDirty() and scene parameter changes i.e. setSize(), in addFilter() etc.

Throws:
java.lang.Exception

update

public void update(boolean forceUpdate)
            throws java.lang.Exception
Update the scene with old coordinates. Use this after setDirty() and scene parameter changes i.e. setSize(), in addFilter() etc.

Throws:
java.lang.Exception

update

public void update(Transform t)
            throws java.lang.Exception
Update the scene with coordinates of t

Throws:
java.lang.Exception

update

public void update(double x,
                   double y,
                   double z)
            throws java.lang.Exception
Update the scene with coordinates xyz

Throws:
java.lang.Exception

update

public void update(double x,
                   double y,
                   double z,
                   boolean forceUpdate)
            throws java.lang.Exception
Update the scene with coordinates xyz

Throws:
java.lang.Exception

setDirty

public void setDirty()
Ensure the scene will be updated on next update() call.


getAll

public Transform[] getAll()
Retreive all the Transforms in the scene

See Also:
Transform

remove

public void remove(VRObject obj)
            throws java.lang.Exception
Removes an object from the scene.

Throws:
java.lang.Exception

remove

public void remove(Transform t)
            throws java.lang.Exception
Removes an object from the scene. Next update() may add it again.

Throws:
java.lang.Exception

remove

public void remove(Transform t,
                   boolean removeReference)
            throws java.lang.Exception
Throws:
java.lang.Exception

contains

public boolean contains(Transform t)
True if the transform is permanent or is non-permanent and in the members list.


removeAll

public void removeAll()
Remove all objects from the scene. Calls Client.removeObject() for each object in the scene, except for user's Client object, but removes client's parent Transform. Usage: entering new world. After client's transform has been removed, it should stop sending movement


clear

public void clear()
Clears the scene


contains

public boolean contains(java.lang.Object o)
Does the scene contain o?


setRange

public void setRange(double range)
set scene size, in meters


getRange

public double getRange()
returns scene range (meters)


setSize

public void setSize(int size)
set scene size, in number of transforms


getSize

public int getSize()
return the scene size


setResolution

public void setResolution(double resolution)
set scene update resolution, in meters


setTimeout

public void setTimeout(long timeout)
set scene timeout, in milliseconds


addFilter

public void addFilter(ObjectFilter filter)
Add TransformFilter or VRObjectFilter

See Also:
TransformFilter, VRObjectFilter

removeFilter

public void removeFilter(ObjectFilter filter)
Remove a TransformFilter/VRObjectFilter

See Also:
TransformFilter, VRObjectFilter

testTransform

protected boolean testTransform(Transform t)
Test Transform against set of filters. Client's transform don't pass the test.

See Also:
TransformFilter

testObject

protected VRObject testObject(VRObject o)
Test an object against set of filters. Owner of this scene and his Transform never pass the test. Returns null if object did not pass, or the same object, maybe modified by filter(s).

See Also:
VRObjectFilter