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.base.E3DPortalEnabledRenderableItem
              extended byespresso3d.engine.world.sector.actor.E3DActor
All Implemented Interfaces:
E3DCollisionDetectableObject, E3DPortalEnabledItem
Direct Known Subclasses:
E3DCameraActor, E3DHighResLogoActor, E3DLowResLogoActor

public abstract class E3DActor
extends E3DPortalEnabledRenderableItem
implements E3DCollisionDetectableObject

Author:
espresso3d An actor is an object made of triangle geometry. Actors are (or can be) textured, lit, and animated (not yet) 3d objects in a world/sector

Field Summary
 
Fields inherited from class espresso3d.engine.renderer.base.E3DRenderable
RENDERMODE_SOLID, RENDERMODE_TEXTURED, RENDERMODE_WIREFRAME
 
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()
          Return the bounding object or null for bounding collision tests
 E3DVector3F getForward()
          getForwardVec()
 E3DVector3F getLeft()
           
 E3DVector3F getPosition()
          Used to get the position of t he object
 E3DSortedRenderableMap getTextureSortedTriangleMap()
           
 java.util.ArrayList getTriangleList()
          Must return an ArrayList of E3DTriangles that make up the geometry of the object.
 java.util.ArrayList getUniqueVertexList()
          Returns a list of only the unique triangle vertices in the actor (no duplicates).
 E3DVector3F getUp()
           
 E3DWorld getWorld()
           
 boolean isActorLit()
          actorLit indicates whether or not the actor should be lit
abstract  boolean isCollideable()
          Override and return true if this actor is something other actors/objects can collide with.
 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, boolean fromJar)
          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 onCollisionActor(E3DCollision collision)
          This gets called when an actor collides with this actor (collider or collidee.
abstract  void onCollisionSprite(E3DCollision collision)
          This gets called when a particle collides with this actor
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 upVec)
          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 setPosition(E3DVector3F positionVec)
          This procedure will move the actor to the new position.
 void setRenderMode(int renderMode)
          When an actor's render mode is set, all of its geometry must also be converted over to that render mode.
 void setTextureSortedTriangleMap(E3DSortedRenderableMap textureSortedTriangleMap)
           
 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.world.sector.base.E3DPortalEnabledRenderableItem
checkSectorChangeDuringMovement, getSector, setSector
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getRenderableOptionsKey, getRenderMode, initCorrectGeometryRenderer, render
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface espresso3d.engine.collision.base.E3DCollisionDetectableObject
getEngine, getSector
 

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,
                      boolean fromJar)
               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()
Description copied from interface: E3DCollisionDetectableObject
Must return an ArrayList of E3DTriangles that make up the geometry of the object. This is used for direct triangle collisions

Specified by:
getTriangleList in interface E3DCollisionDetectableObject
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 upVec)
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
upVec - Normalised 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

setPosition

public void setPosition(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()
Description copied from interface: E3DCollisionDetectableObject
Return the bounding object or null for bounding collision tests

Specified by:
getBoundingObject in interface E3DCollisionDetectableObject
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.

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.

Specified by:
getUniqueVertexList in interface E3DCollisionDetectableObject
Returns:

getPosition

public E3DVector3F getPosition()
Description copied from interface: E3DCollisionDetectableObject
Used to get the position of t he object

Specified by:
getPosition in interface E3DCollisionDetectableObject
Returns:
Returns the position of the actor

getForward

public E3DVector3F getForward()
getForwardVec()

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

getUp

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

getLeft

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

onCollisionActor

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

Specified by:
onCollisionActor in interface E3DCollisionDetectableObject
Parameters:
collision -

onCollisionSprite

public abstract void onCollisionSprite(E3DCollision collision)
This gets called when a particle collides with this actor

Specified by:
onCollisionSprite in interface E3DCollisionDetectableObject
Parameters:
collision -

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:

getTextureSortedTriangleMap

public E3DSortedRenderableMap getTextureSortedTriangleMap()

setTextureSortedTriangleMap

public void setTextureSortedTriangleMap(E3DSortedRenderableMap textureSortedTriangleMap)

setRenderMode

public void setRenderMode(int renderMode)
When an actor's render mode is set, all of its geometry must also be converted over to that render mode. Having a single piece of geometry in an actor different than the rest of the actor is NOT allowed.

Overrides:
setRenderMode in class E3DRenderable
Parameters:
renderMode -

isCollideable

public abstract boolean isCollideable()
Override and return true if this actor is something other actors/objects can collide with. If false, it will be ignore for other actor/object's collision detection

Specified by:
isCollideable in interface E3DCollisionDetectableObject
Returns: