|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.entity.Entity
Entity
defines a game entity that consists of a piece of
geometry, a position and an orientation. An entity can be a collection of
children entities. An entity with multiple children create a tree structure,
as children can have children. Rendering the entity causes the parent
entity to render it's own geometry and then render each child.
If the parent of an entity is null, the parent is considered to be the
Locale
. The entities local coordinate system is relative to the
parent. That is, if a position of a entity is (0, 1, 0), it is one unit
along the Y-Axis of the parent.
An Entity
is not required to maintain geometry. If there is
no geometry, it will simply not be rendered. This will allow for an
Entity
to represent something abstract.
Field Summary | |
protected BoundingVolume |
boundingVolume
|
protected java.util.List |
children
|
protected Geometry |
geometry
|
static int |
VISIBILITY_CUBE
Defines using cube tests for visibility calculations. |
static int |
VISIBILITY_POINT
Defines using simple point tests for visibility calculations. |
static int |
VISIBILITY_SPHERE
Defines using sphere tests for visibility calculations. |
Constructor Summary | |
Entity(int id)
Constructor initializes the entity. |
|
Entity(int id,
Entity child)
Constructor intializes the entity with a second entity as a child. |
Method Summary | |
void |
addChild(Entity child)
addChild adds an Entity to the entity with
this entity the parent. |
void |
checkVisibility(Frustum frustum)
checkVisibility updates the visibility of this entity
based on the frustum levels. |
float |
distance(Entity ent)
distance returns the distance between this entity and
a given entity. |
BoundingVolume |
getBoundingVolume()
getBoundingVolume returns the volume that contains this
entity. |
Geometry |
getGeometry()
getGeometry returns the geometry of this entity. |
int |
getId()
getId returns the id of the entity. |
PhysicsModule |
getPhysics()
getPhysics returns the physics module of the particular
entity. |
Vector |
getPosition()
getPosition returns the position of the entity in
three dimensional space. |
boolean |
hasCollision(Entity ent)
hasCollision determines if this entity is colliding with
a provided entity. |
boolean |
hasMoved()
hasMoved returns true if the entity has moved during the
last update, false otherwise. |
boolean |
isVisible()
isVisible returns true if the entity is currently visible
and false if it is not. |
void |
removeChild(Entity child)
removeChild removes the requested child from the list
of children. |
void |
render()
render translates and rotates the entity based on it's
attributes. |
void |
setBoundingVolume(BoundingVolume volume)
setBoundingVolume sets the volume that contains this
entity. |
void |
setGeometry(Geometry geometry)
setGeometry sets the geometry of this entity. |
void |
setMoved(boolean hasMoved)
setMoved sets the moved flag. |
void |
setPhysicsModule(PhysicsModule physics)
setPhysicsModule sets the module the defines how the
physics of the entity are handled. |
void |
setPitch(float angle)
setPitch sets the pitch angle of the entity. |
void |
setPosition(Vector position)
setPosition sets the position of this entity. |
void |
setRoll(float angle)
setRoll sets the roll angle of the entity. |
void |
setVisibilityType(int type)
setVisibilityType sets what type of visibility check will
be used for this entity. |
void |
setYaw(float angle)
setYaw sets the yaw angle of the entity. |
java.lang.String |
toString()
toString creates a string representation of the
Entity object. |
void |
update(float time)
update updates the state of the entity. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int VISIBILITY_POINT
public static final int VISIBILITY_SPHERE
public static final int VISIBILITY_CUBE
protected java.util.List children
protected Geometry geometry
protected BoundingVolume boundingVolume
Constructor Detail |
public Entity(int id)
Entity
are empty.
id
- the id of the entity
MonkeyRuntimeException
- if the id is less than 1.public Entity(int id, Entity child)
id
- the id of the entitychild
- the entities child node.
MonkeyRuntimeException
- if the id is less than 1.Method Detail |
public void addChild(Entity child)
addChild
adds an Entity
to the entity with
this entity the parent.
child
- the Entity
to add to the children list.public void removeChild(Entity child)
removeChild
removes the requested child from the list
of children.
child
- the child to remove from the list.public void setBoundingVolume(BoundingVolume volume)
setBoundingVolume
sets the volume that contains this
entity.
setBoundingVolume
in interface EntityInterface
volume
- the volume that contains this entity.public BoundingVolume getBoundingVolume()
getBoundingVolume
returns the volume that contains this
entity.
getBoundingVolume
in interface EntityInterface
public boolean hasCollision(Entity ent)
hasCollision
determines if this entity is colliding with
a provided entity.
ent
- the entity to check.
public float distance(Entity ent)
distance
returns the distance between this entity and
a given entity.
ent
- the entity to check.
public void setPosition(Vector position)
setPosition
sets the position of this entity.
position
- the new position of this entity.public void setYaw(float angle)
setYaw
sets the yaw angle of the entity. Where yaw is
defined as rotation about the local Y axis.
angle
- the angle of yaw.public void setRoll(float angle)
setRoll
sets the roll angle of the entity. Where roll
is defined as rotation about the local Z axis.
angle
- the angle of roll.public void setPitch(float angle)
setPitch
sets the pitch angle of the entity. Where
pitch is defined as rotation about the local x axis.
angle
- the angle of pitch.public void setMoved(boolean hasMoved)
setMoved
sets the moved flag.
hasMoved
- true if the entity has moved, false otherwise.public void setPhysicsModule(PhysicsModule physics)
setPhysicsModule
sets the module the defines how the
physics of the entity are handled. This allows the entity to
interact with the world (what ever that may be) in a realistic and
appropriate manner.
physics
- the physics module for this entity.public boolean hasMoved()
hasMoved
returns true if the entity has moved during the
last update, false otherwise.
public void setGeometry(Geometry geometry)
setGeometry
sets the geometry of this entity. If the
geometry object is null, nothing will be rendered for this entity.
geometry
- the geometry to set for this entity.public Vector getPosition()
getPosition
returns the position of the entity in
three dimensional space.
public PhysicsModule getPhysics()
getPhysics
returns the physics module of the particular
entity.
public int getId()
getId
returns the id of the entity.
public void update(float time)
update
updates the state of the entity.
update
in interface EntityInterface
time
- the amount of time between frames.public void render()
render
translates and rotates the entity based on it's
attributes. It then renders the geometry of the entity if there is any.
Each child is then rendered in turn.
render
in interface EntityInterface
public boolean isVisible()
isVisible
returns true if the entity is currently visible
and false if it is not.
isVisible
in interface EntityInterface
public void checkVisibility(Frustum frustum)
checkVisibility
updates the visibility of this entity
based on the frustum levels.
checkVisibility
in interface EntityInterface
frustum
- the camera's view frustum.public void setVisibilityType(int type)
setVisibilityType
sets what type of visibility check will
be used for this entity. Valid parameters are: VISIBILITY_POINT,
VISIBILITY_SPHERE, and VISIBILITY_CUBE.
type
- what type of test to make for visibilty.
MonkeyRuntimeException
- if the visibilty flag is not valid.public java.lang.String toString()
toString
creates a string representation of the
Entity
object. The format is as follows:
public Geometry getGeometry()
getGeometry
returns the geometry of this entity.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |