noope.entities
Class Entity

java.lang.Object
  |
  +--noope.entities.Entity

public class Entity
extends java.lang.Object

This class represents a physical object modelled. Physics, the physics engine class, contains an object of the Entities class, which stores internally, a list of Entities. It also stores an internal forceAccumulator that is used by the Law objects to accumulate their contibution to the total force on that Entity.

Version:
19 April 2001: added dispose() [Miklos Reiter]
Author:
Miklos Reiter

Field Summary
protected  java.lang.String name
          The name associated with this Entity
protected  Physics physics
          A reference to the physics world so getActiveForce can learn about its environment.
protected  LawPropertyRecord[] properties
          An array of LawPropertyRecords that store the properties of this entity for each Law currently in use
 
Constructor Summary
Entity(BlockReader br, Physics phys)
          Construcst an Entity from the supplied BlockReader.
 
Method Summary
 void addForce(Vector3D force)
          Apply a force to this Entity.
 void dispose()
          Disposes of system resources.
protected  Vector3D getActiveForce()
          Return this Entity's own contribution to the resultant force.
 double getInertialMass()
          Return this Entity's inertial mass, used in Newton's second law (F = ma) calculations
 java.lang.String getName()
          Return this Entity's name
 Physics getPhysics()
          Returns the Physics object this Entity belongs to.
 Vector3D getPosition()
          Return this Entity's position
 LawPropertyRecord getPropertyRecord(int lawnumber)
          This method gets the LawPropertyRecord corresponding to the law with the given number.
 Vector3D getVelocity()
          Return this Entity's velocity
 void setPosition(Vector3D newPosition)
          While I was at it, I've also added this method, in case it'll be needed later for some other law.
 void setVelocity(Vector3D newVelocity)
          This method has been added, because it is needed by certain laws like SphereCollision.
 void step(double deltaTime)
          Apply Newtonian physics to update velocity and position.
 java.lang.String toString()
          Returns a String representation of the Entity for debug-quality printing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name associated with this Entity

properties

protected LawPropertyRecord[] properties
An array of LawPropertyRecords that store the properties of this entity for each Law currently in use

physics

protected Physics physics
A reference to the physics world so getActiveForce can learn about its environment.
Constructor Detail

Entity

public Entity(BlockReader br,
              Physics phys)
       throws BRLoadingException
Construcst an Entity from the supplied BlockReader. This constructor expects the BlockReader to contain the name as the first Entry; after that, position, velocity, inertialMass (the first two vectors of the form (x, y, z) and the latter just a number), in this order. If one is missing, the constructor will assume that it is not provided and will use the default value. If it then occurrs later, an exception is raised.
Parameters:
br - BlockReader used to initialise name, position, velocity, inertialMass and properties.
phys - Reference to the Physics world
Method Detail

getInertialMass

public double getInertialMass()
Return this Entity's inertial mass, used in Newton's second law (F = ma) calculations

getPosition

public Vector3D getPosition()
Return this Entity's position

getVelocity

public Vector3D getVelocity()
Return this Entity's velocity

getName

public java.lang.String getName()
Return this Entity's name

getPropertyRecord

public LawPropertyRecord getPropertyRecord(int lawnumber)
This method gets the LawPropertyRecord corresponding to the law with the given number. as it's refernce number. Lawnumbers are allocated to each Law by the Laws object when they are created.
See Also:
Laws.Laws(BlockReader, Physics), Law.constructNewPropertyRecord(BlockReader, Entity)

addForce

public void addForce(Vector3D force)
Apply a force to this Entity. The force is represented by the Vector3D force. This method is called by each law. It adds force to forceAccumulator.

step

public void step(double deltaTime)
Apply Newtonian physics to update velocity and position. Also resets accumulator and calls getActiveForce before it runs so it can use the active force too. No need to override.
Parameters:
deltaTime - the time step to use when updating velocity and position

getActiveForce

protected Vector3D getActiveForce()
Return this Entity's own contribution to the resultant force. This should be overridden for active objects (previously known as Intellegent objects).

toString

public java.lang.String toString()
Returns a String representation of the Entity for debug-quality printing.
Overrides:
toString in class java.lang.Object

setVelocity

public void setVelocity(Vector3D newVelocity)
This method has been added, because it is needed by certain laws like SphereCollision.

setPosition

public void setPosition(Vector3D newPosition)
While I was at it, I've also added this method, in case it'll be needed later for some other law.

getPhysics

public Physics getPhysics()
Returns the Physics object this Entity belongs to.

dispose

public void dispose()
Disposes of system resources. Added by Miklos Reiter on 19-Apr-2001.