de.steeringbehaviors.simulation.renderer
Class Geometrie

java.lang.Object
  extended by de.steeringbehaviors.simulation.renderer.Geometrie
All Implemented Interfaces:
ObjectAttributes
Direct Known Subclasses:
Obstacle, Vehicle

public class Geometrie
extends java.lang.Object
implements ObjectAttributes

class Geometrie Implements the base class for geometrie objects


Field Summary
protected  Rect m_boundingbox
          Bounding box rectangle
protected  Vector2d m_localx
          Local x axis
protected  Vector2d m_localy
          Local y axis
protected  Mind m_mind
          The mind of the geometry, in case it needs one :)
protected  java.lang.String m_objectName
          Name of the object
protected  Point2d m_pos
          Current object position in world coordinates
protected  double m_radius
          Radius of the bounding sphere
protected  double m_scaleX
          The scale factor along the x axis for all shapes of this object
protected  double m_scaleY
          The scale factor along the y axis for all shapes of this object
protected  java.util.Vector m_shapes
          Array with all the Shapes of type RenderInfo describing the geometrie
protected  boolean m_visible
          Flag to set the visibility of the whole object
 
Constructor Summary
Geometrie()
          Constructor
Geometrie(Point2d pos)
          Constructor
Geometrie(Point2d pos, double radius, Rect boundingbox)
          Constructor
Geometrie(java.lang.String objectName, double posX, double posY, double radius, double bminX, double bminY, double bmaxX, double bmaxY)
          Constructor
 
Method Summary
 void addShape(RenderInfo info)
          Adds a new shape to the shape description array
 Rect getBoundingBox()
          Returns the boundingbox of the object
 Vector2d getLocalX()
          Returns the local x axis
 Vector2d getLocalY()
          Returns the local y axis
 Mind getMind()
          Returns the mind object used for steering this geometrie
 java.lang.String getObjectName()
          Returns the name of the object
 java.util.Vector getPoints()
          Returns all the points of the polygon used as a shape.
 Point2d getPos()
          Returns the position of the object
 double getRadius()
          Returns the radius of the object
 double getScaleX()
          Returns the scale of the object along the x axis
 double getScaleY()
          Returns the scale of the object along the y axis
 java.util.Iterator getShapeIter()
          Gets an iterator for the shapes describing the geometrie
 boolean getVisible()
          Returns the visiblity status of the geometry object
 Point2d localToWorld(Point2d p)
          Transforms a point from the world coordinate system to local coordinates
 Vector2d localToWorld(Vector2d p)
          Transforms a vector from the world coordinate system to local coordinates
 void moveCenter(Vector2d relMove)
          Transforms the shapes attached to this object by the vector.
 void onCollide(Geometrie otherObj)
          Simple collsion event handler
 void setAttribute(java.lang.String name, java.lang.String value, java.util.Hashtable objectList)
          Sets a attribute specified by the name
 void setLocalx(Vector2d v)
          Sets the local x axis to the specified vector
 void setMind(Mind theMind)
          Sets the mind that controlls this vehicle
 void setObjectName(java.lang.String objectName)
          Sets the name of the object
 void setPos(double x, double y)
          Sets the position of the object in world coordinates
 void setRadius(double radius)
          Sets the radius of the object
 void setScaleX(double scaleX)
          Scales the complete object along the x axis according to the factor.
 void setScaleY(double scaleY)
          Scales the complete object along the y axis according to the factor.
 void setVisible(boolean visible)
          Sets the visiblity status of the geometry object
protected  void updateBoundingRadius()
          Updates the bounding box radius automaitcally
 Point2d worldToLocal(Point2d p)
          Transforms a point from the local coordinate system to world coordinates
 Vector2d worldToLocal(Vector2d p)
          Transforms a vector from the local coordinate system to world coordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_boundingbox

protected Rect m_boundingbox
Bounding box rectangle


m_localx

protected Vector2d m_localx
Local x axis


m_localy

protected Vector2d m_localy
Local y axis


m_objectName

protected java.lang.String m_objectName
Name of the object


m_pos

protected Point2d m_pos
Current object position in world coordinates


m_radius

protected double m_radius
Radius of the bounding sphere


m_shapes

protected java.util.Vector m_shapes
Array with all the Shapes of type RenderInfo describing the geometrie


m_visible

protected boolean m_visible
Flag to set the visibility of the whole object


m_mind

protected Mind m_mind
The mind of the geometry, in case it needs one :)


m_scaleX

protected double m_scaleX
The scale factor along the x axis for all shapes of this object


m_scaleY

protected double m_scaleY
The scale factor along the y axis for all shapes of this object

Constructor Detail

Geometrie

public Geometrie()
Constructor


Geometrie

public Geometrie(Point2d pos)
Constructor

Parameters:
pos - Position of the object

Geometrie

public Geometrie(Point2d pos,
                 double radius,
                 Rect boundingbox)
Constructor

Parameters:
pos - Position of the object
radius - Radius of the object
boundingbox - Boundingbox of the object

Geometrie

public Geometrie(java.lang.String objectName,
                 double posX,
                 double posY,
                 double radius,
                 double bminX,
                 double bminY,
                 double bmaxX,
                 double bmaxY)
Constructor

Parameters:
objectName - Name of the object
posX - X position
posY - Y position
radius - Radius of the object
bminX - Upper left boundingbox x position
bminY - Upper left boundingbox y position
bmaxX - Lower right boundingbox x position
bmaxY - Lower right boundingbox y position
Method Detail

addShape

public void addShape(RenderInfo info)
Adds a new shape to the shape description array

Parameters:
info - New shape to add

moveCenter

public void moveCenter(Vector2d relMove)
Transforms the shapes attached to this object by the vector. The vector has to be in world coordinates (e.g. newPosition - oldPosition)

Parameters:
relMove - Vector used to move the points

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value,
                         java.util.Hashtable objectList)
Sets a attribute specified by the name

Specified by:
setAttribute in interface ObjectAttributes
Parameters:
name - name of the attribute
value - value of the attribute

setLocalx

public void setLocalx(Vector2d v)
Sets the local x axis to the specified vector

Parameters:
v - New local x axis

setMind

public void setMind(Mind theMind)
Sets the mind that controlls this vehicle

Parameters:
theMind - The new mind

setObjectName

public void setObjectName(java.lang.String objectName)
Sets the name of the object

Parameters:
objectName - New object name

setPos

public void setPos(double x,
                   double y)
Sets the position of the object in world coordinates

Parameters:
x - X position
y - Y position

setRadius

public void setRadius(double radius)
Sets the radius of the object

Parameters:
radius - New radius of the object

setScaleX

public void setScaleX(double scaleX)
Scales the complete object along the x axis according to the factor. Works only if the factor is greater zero.

Parameters:
factor - Scale to apply to the object

setScaleY

public void setScaleY(double scaleY)
Scales the complete object along the y axis according to the factor. Works only if the factor is greater zero.

Parameters:
factor - Scale to apply to the object

setVisible

public void setVisible(boolean visible)
Sets the visiblity status of the geometry object


getBoundingBox

public Rect getBoundingBox()
Returns the boundingbox of the object

Returns:
The bounding box

getLocalX

public Vector2d getLocalX()
Returns the local x axis

Returns:
Local x axis

getLocalY

public Vector2d getLocalY()
Returns the local y axis

Returns:
Local y axis

getMind

public Mind getMind()
Returns the mind object used for steering this geometrie

Returns:
The mind of the object

getObjectName

public java.lang.String getObjectName()
Returns the name of the object

Returns:
The object name

getPoints

public java.util.Vector getPoints()
Returns all the points of the polygon used as a shape. The points are all in world space, not in object space.

Returns:
Array with all points in world space.

getPos

public Point2d getPos()
Returns the position of the object

Returns:
Object position

getRadius

public double getRadius()
Returns the radius of the object

Returns:
The radius

getScaleX

public double getScaleX()
Returns the scale of the object along the x axis

Returns:
The x axis scale

getScaleY

public double getScaleY()
Returns the scale of the object along the y axis

Returns:
The y axis scale

getShapeIter

public java.util.Iterator getShapeIter()
Gets an iterator for the shapes describing the geometrie

Returns:
An iterator over all shapes of type RenderInfo

getVisible

public boolean getVisible()
Returns the visiblity status of the geometry object

Returns:
Visiblity of the geometry

onCollide

public void onCollide(Geometrie otherObj)
Simple collsion event handler

Parameters:
otherObj - Geometry object collided with

localToWorld

public Point2d localToWorld(Point2d p)
Transforms a point from the world coordinate system to local coordinates

Parameters:
p - Point in world coordinates
Returns:
Point in local coordinates

localToWorld

public Vector2d localToWorld(Vector2d p)
Transforms a vector from the world coordinate system to local coordinates

Parameters:
p - Vector in world coordinates
Returns:
Vector in local coordinates

updateBoundingRadius

protected void updateBoundingRadius()
Updates the bounding box radius automaitcally


worldToLocal

public Point2d worldToLocal(Point2d p)
Transforms a point from the local coordinate system to world coordinates

Parameters:
p - Point in local coordinates
Returns:
Point in world coordinates

worldToLocal

public Vector2d worldToLocal(Vector2d p)
Transforms a vector from the local coordinate system to world coordinates

Parameters:
p - Vector in local coordinates
Returns:
Vector in world coordinates