com.threerings.tudey.space
Class SimpleSpaceElement

java.lang.Object
  extended by com.threerings.tudey.space.SimpleSpaceElement
All Implemented Interfaces:
SpaceElement, SpaceObject
Direct Known Subclasses:
ShapeElement

public abstract class SimpleSpaceElement
extends Object
implements SpaceElement

A simple implementation of the SpaceElement interface.


Constructor Summary
SimpleSpaceElement()
           
 
Method Summary
 Rect getBounds()
          Returns a reference to the bounds of the object.
 boolean getIntersection(Ray2D ray, Vector2f result)
          Finds the intersection of a ray with this element and places it in the supplied vector (if it exists).
 void getNearestPoint(Vector2f point, Vector2f result)
          Finds the nearest point of this element to the supplied point and places it in the supplied vector.
 Space getSpace()
          Returns a reference to the space to which this element has been added, if any.
 Transform2D getTransform()
          Returns a reference to the transform of the element.
 Object getUserObject()
          Returns this element's user object reference.
 boolean intersects(Capsule capsule)
          Determines whether this element intersects the supplied capsule.
 boolean intersects(Circle circle)
          Determines whether this element intersects the supplied circle.
 boolean intersects(Compound compound)
          Determines whether this element intersects the supplied compound.
 boolean intersects(None compound)
          Determines whether this element intersects the supplied none.
 boolean intersects(Point point)
          Determines whether this element intersects the supplied point.
 boolean intersects(Polygon polygon)
          Determines whether this element intersects the supplied polygon.
 boolean intersects(Segment segment)
          Determines whether this element intersects the supplied segment.
 void setTransform(Transform2D transform)
          Sets the transform to the specified value and promotes it to Transform2D.UNIFORM, then updates the bounds of the element.
 void setUserObject(Object object)
          Sets the element's user object reference.
abstract  void updateBounds()
          Updates the bounds of the element.
 boolean updateLastVisit(int visit)
          Checks and updates the last visit value.
 void wasAdded(Space space)
          Notes that the element was added to the specified space.
 void willBeRemoved()
          Notes that the element will be removed from the space.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSpaceElement

public SimpleSpaceElement()
Method Detail

setUserObject

public void setUserObject(Object object)
Sets the element's user object reference.


setTransform

public void setTransform(Transform2D transform)
Sets the transform to the specified value and promotes it to Transform2D.UNIFORM, then updates the bounds of the element.


getTransform

public Transform2D getTransform()
Returns a reference to the transform of the element.


getSpace

public Space getSpace()
Returns a reference to the space to which this element has been added, if any.


updateBounds

public abstract void updateBounds()
Updates the bounds of the element.


getUserObject

public Object getUserObject()
Description copied from interface: SpaceElement
Returns this element's user object reference.

Specified by:
getUserObject in interface SpaceElement

wasAdded

public void wasAdded(Space space)
Description copied from interface: SpaceElement
Notes that the element was added to the specified space.

Specified by:
wasAdded in interface SpaceElement

willBeRemoved

public void willBeRemoved()
Description copied from interface: SpaceElement
Notes that the element will be removed from the space.

Specified by:
willBeRemoved in interface SpaceElement

getIntersection

public boolean getIntersection(Ray2D ray,
                               Vector2f result)
Description copied from interface: SpaceElement
Finds the intersection of a ray with this element and places it in the supplied vector (if it exists).

Specified by:
getIntersection in interface SpaceElement
Returns:
true if the ray intersected the element (in which case the result will contain the point of intersection), false otherwise.

getNearestPoint

public void getNearestPoint(Vector2f point,
                            Vector2f result)
Description copied from interface: SpaceElement
Finds the nearest point of this element to the supplied point and places it in the supplied vector.

Specified by:
getNearestPoint in interface SpaceElement

intersects

public boolean intersects(Point point)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied point.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(Segment segment)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied segment.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(Circle circle)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied circle.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(Capsule capsule)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied capsule.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(Polygon polygon)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied polygon.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(Compound compound)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied compound.

Specified by:
intersects in interface SpaceElement

intersects

public boolean intersects(None compound)
Description copied from interface: SpaceElement
Determines whether this element intersects the supplied none.

Specified by:
intersects in interface SpaceElement

getBounds

public Rect getBounds()
Description copied from interface: SpaceObject
Returns a reference to the bounds of the object.

Specified by:
getBounds in interface SpaceObject

updateLastVisit

public boolean updateLastVisit(int visit)
Description copied from interface: SpaceObject
Checks and updates the last visit value. This is used to determine when we have visited (e.g., rendered) the object without having to clear a flag for all objects before performing the operation. Instead, we use a unique visitation id for each operation and assume that any object with that id has been visited already.

Specified by:
updateLastVisit in interface SpaceObject
Returns:
true if the last visit value was not equal to the value provided (and has now been set to that value), false if the object had already been visited during the current operation.


Copyright © 2011. All Rights Reserved.