espresso3d.engine.world.sector.actor
Class E3DActor

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.renderer.base.E3DRenderable
          extended byespresso3d.engine.world.sector.actor.E3DActor
All Implemented Interfaces:
E3DCollisionResponseCallback
Direct Known Subclasses:
E3DCameraActor, E3DLogoActor

public abstract class E3DActor
extends E3DRenderable
implements E3DCollisionResponseCallback

Author:
espresso3d An actor is any character or moving or renderable object in the world.

Constructor Summary
E3DActor(E3DActor toCopyActor)
          This copies all the actor geometry into another actor.
E3DActor(E3DEngine engine, E3DWorld world, E3DBoundingObject boundingObject, java.lang.String actorID)
           
E3DActor(E3DEngine engine, E3DWorld world, java.lang.String actorID)
           
 
Method Summary
 void addTriangle(E3DTriangle triangle)
          When adding triangles, we could put the unique vertices into the reduced vertex list, however, since we probably won't add triangles much, its a lot less labor intensive to just calculate it the first time we try to grab the list.
 java.lang.String getActorID()
           
 E3DBoundingObject getBoundingObject()
           
 E3DVector3F getForwardVec()
          getForwardVec()
 E3DVector3F getLeftVec()
           
 E3DVector3F getPositionVec()
           
 E3DSector getSector()
           
 java.util.HashMap getTextureSortedTriangleList()
           
 java.util.ArrayList getTriangleList()
           
 java.util.ArrayList getUniqueVertexList()
          Returns a list of only the unique triangle vertices in the actor (no duplicates).
 E3DVector3F getUpVec()
           
 E3DWorld getWorld()
           
 boolean isActorLit()
          actorLit indicates whether or not the actor should be lit
 boolean isDisplayMesh()
          When true, the actor triangles are rendered.
 boolean isNeedingLightRecalc()
          Returns true if this actor has changed/moved/etc and needs to have its lighting recalculated
 void loadActor(java.lang.String actorFilename)
          Load an actor file's geometry into this actor
 void moveForward(double speed)
          moves the actor along the vector it is facing (forward/backward)
abstract  void onCollision(E3DCollision collision)
          This gets called when this actor collides with something (collider or collidee.
abstract  E3DActor onGetClone()
          This method must be overriden to return a clone of the actor.
 void renderAtPosition(E3DVector3F atPosition)
          Actors are renderable, so this renders the actor directly but usually shouldn't be used.
 void rotate(double angle)
          Rotates around the up vector
 void rotate(double angle, E3DVector3F aroundVec)
          Rotates the actor around the aroundVec.
 void rotateTriangles(double angle, E3DVector3F aroundVec)
          Rotates just the actors triangles (the model) around aroundVec.
 void scale(double scaleAmt)
          Scale the actors triangles by the scaleAmt
 void setActorID(java.lang.String actorID)
           
 void setActorLit(boolean actorLit)
          Sets whether or not the actor sould be lit by the world.
 void setBoundingObject(E3DBoundingObject boundingObject)
           
 void setDisplayMesh(boolean displayMesh)
          /** When true, the actor triangles are rendered.
 void setNeedingLightRecalc(boolean needingLightRecalc)
          Set to true if this actor has changed/moved/etc and needs to have its lighting recalculated, otherwise false This is normally handled by the engine
 void setPositionVec(E3DVector3F positionVec)
          This procedure will move the actor to the new position.
 void setSector(E3DSector sector)
           
 void setTextureSortedTriangleList(java.util.HashMap textureSortedTriangleList)
           
 void setWorld(E3DWorld world)
           
 void translate(E3DVector3F translationAmt)
          Move all the triangles of the actor and the position vec by translationAmt.
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
render
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

E3DActor

public E3DActor(E3DEngine engine,
                E3DWorld world,
                java.lang.String actorID)

E3DActor

public E3DActor(E3DEngine engine,
                E3DWorld world,
                E3DBoundingObject boundingObject,
                java.lang.String actorID)

E3DActor

public E3DActor(E3DActor toCopyActor)
This copies all the actor geometry into another actor. BoundingObject is NOT copied!!! You must do that !

Parameters:
toCopyActor -
Method Detail

loadActor

public void loadActor(java.lang.String actorFilename)
               throws E3DMissingEngineException,
                      java.lang.Exception
Load an actor file's geometry into this actor

Parameters:
actorFilename -
Throws:
E3DMissingEngineException
java.lang.Exception

getTriangleList

public java.util.ArrayList getTriangleList()
Returns:
Returns the triangleList.

addTriangle

public void addTriangle(E3DTriangle triangle)
When adding triangles, we could put the unique vertices into the reduced vertex list, however, since we probably won't add triangles much, its a lot less labor intensive to just calculate it the first time we try to grab the list.

Parameters:
triangle -

translate

public void translate(E3DVector3F translationAmt)
Move all the triangles of the actor and the position vec by translationAmt.


scale

public void scale(double scaleAmt)
Scale the actors triangles by the scaleAmt

Parameters:
scaleAmt -

rotate

public void rotate(double angle,
                   E3DVector3F aroundVec)
Rotates the actor around the aroundVec. This rotates the forward vector, upVector as well as all the model vertices.

Parameters:
angle - Rotation angle in radians
aroundVec - Central axis vector to rotate around

rotateTriangles

public void rotateTriangles(double angle,
                            E3DVector3F aroundVec)
Rotates just the actors triangles (the model) around aroundVec. IT does not modify forward or up vec

Parameters:
angle - Rotation angle in radians
aroundVec - Central axis vector to rotate around

rotate

public void rotate(double angle)
Rotates around the up vector

Parameters:
angle - Angle to rotate in radians

setPositionVec

public void setPositionVec(E3DVector3F positionVec)
This procedure will move the actor to the new position. It takes into account moving all the actor vertices as well as the actors position vec.


moveForward

public void moveForward(double speed)
moves the actor along the vector it is facing (forward/backward)


renderAtPosition

public void renderAtPosition(E3DVector3F atPosition)
Actors are renderable, so this renders the actor directly but usually shouldn't be used. This will render the actor outside of the main rendering loop, so it won't be as efficient as the main rendering loop

Specified by:
renderAtPosition in class E3DRenderable

getBoundingObject

public E3DBoundingObject getBoundingObject()
Returns:
Returns the boundingObject for the actor

setBoundingObject

public void setBoundingObject(E3DBoundingObject boundingObject)
Parameters:
boundingObject - Set the bounding object the actor uses. Eventually, lists of boundingobjects will be supported, so you'll use add

isNeedingLightRecalc

public boolean isNeedingLightRecalc()
Returns true if this actor has changed/moved/etc and needs to have its lighting recalculated

Returns:
Returns the needingLightRecalc.

setNeedingLightRecalc

public void setNeedingLightRecalc(boolean needingLightRecalc)
Set to true if this actor has changed/moved/etc and needs to have its lighting recalculated, otherwise false This is normally handled by the engine

Parameters:
needingLightRecalc - The needingLightRecalc to set.

getSector

public E3DSector getSector()
Returns:
Returns the sector the actor is in

setSector

public void setSector(E3DSector sector)
Parameters:
sector - Set the sector te actor is in

isActorLit

public boolean isActorLit()
actorLit indicates whether or not the actor should be lit

Returns:
Returns the actorLit.

setActorLit

public void setActorLit(boolean actorLit)
Sets whether or not the actor sould be lit by the world. If its false, the actor will be rendered fullbright.

Parameters:
actorLit - The actorLit to set.

getWorld

public E3DWorld getWorld()
Returns:
Returns the world the actor is in

setWorld

public void setWorld(E3DWorld world)
Parameters:
world - Set the world the actor is in

getActorID

public java.lang.String getActorID()
Returns:
Returns the actorID for this actor.

setActorID

public void setActorID(java.lang.String actorID)
Parameters:
actorID - The actorID to set. This can't be changed outside of the constructor

getUniqueVertexList

public java.util.ArrayList getUniqueVertexList()
Returns a list of only the unique triangle vertices in the actor (no duplicates). Useful in collision detection Probably only used by the engine.

Returns:

getPositionVec

public E3DVector3F getPositionVec()
Returns:
Returns the position of the actor

getForwardVec

public E3DVector3F getForwardVec()
getForwardVec()

Returns:
Returns the normalised vector pointing in the direction that is forward

getUpVec

public E3DVector3F getUpVec()
Returns:
Returns a normalised vector pointing in the up direction of the actor

getLeftVec

public E3DVector3F getLeftVec()
Returns:
returns a normalised vector pointing left from the actor if you are looking down the forward vector.

getTextureSortedTriangleList

public java.util.HashMap getTextureSortedTriangleList()

setTextureSortedTriangleList

public void setTextureSortedTriangleList(java.util.HashMap textureSortedTriangleList)

onCollision

public abstract void onCollision(E3DCollision collision)
This gets called when this actor collides with something (collider or collidee. We don't know what to do with a collision here, but anything extending this should

Specified by:
onCollision in interface E3DCollisionResponseCallback

onGetClone

public abstract E3DActor onGetClone()
                             throws java.lang.Exception
This method must be overriden to return a clone of the actor. This normally gets called when a specific actor in the preloadedActorMap of the world is specified in a world's map that is getting loaded What it wants is a clone of the preloaded actor returned (CLONE, not ref to the same object!). This is exposed to you so you can modify the actor if necessary when cloning it.

Throws:
java.lang.Exception

isDisplayMesh

public boolean isDisplayMesh()
When true, the actor triangles are rendered. If false, they aren't

Returns:

setDisplayMesh

public void setDisplayMesh(boolean displayMesh)
/** When true, the actor triangles are rendered. If false, they aren't

Returns: