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

public abstract class E3DActor
extends E3DPortalEnabledRenderable
implements E3DCollisionDetectableObject, E3DLightableObject

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

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)
          Create an actor with a bounding object
E3DActor(E3DEngine engine, E3DWorld world, java.lang.String actorID)
          Create an actor without a bounding object
 
Method Summary
 void addSound3DToAssociatedList(E3DSound3D sound3D)
           
 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()
           
 java.util.ArrayList getAssociatedSound3DList()
           
 E3DBoundingObject getBoundingObject()
          Return the bounding object or null for bounding collision tests
 E3DMesh getMesh()
           
 E3DOrientation getOrientation()
           
 E3DSkeleton getSkeleton()
           
 E3DSortedRenderableMap getTextureSortedTriangleMap()
           
 java.util.ArrayList getTriangleList()
          Must return an ArrayList of E3DTriangles that make up the geometry of the object.
 java.util.ArrayList getUniqueVertexPositionList()
          Returns a list of only the unique triangle vertices in the actor (no duplicates).
 E3DWorld getWorld()
           
abstract  boolean isCollideable()
          Override and return true if this actor is something other actors/objects can collide with.
 boolean isDebugBoundingObjectDisplayed()
           
 boolean isDebugSkeletonDisplayed()
           
 boolean isLit()
          actorLit indicates whether or not the actor should be lit (if not, it will be fullbright)
 boolean isModelDisplayed()
          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 removeSound3DFromAssociatedList(E3DSound3D sound3D)
           
 void render()
          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 scale(double scaleAmt)
          Scale the actors triangles and bounding object (if it exists)
 void setActorID(java.lang.String actorID)
           
 void setBoundingObject(E3DBoundingObject boundingObject)
           
 void setDebugBoundingObjectDisplayed(boolean debugBoundingObjectDisplayed)
           
 void setDebugSkeletonDisplayed(boolean debugSkeletonDisplayed)
           
 void setLit(boolean actorLit)
          Sets whether or not the actor sould be lit by the world.
 void setModelDisplayed(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 setSkeleton(E3DSkeleton skeleton)
           
 void setWorld(E3DWorld world)
           
 void translate(E3DVector3F translationAmt)
          Move all the triangles of the actor and the position vec by translationAmt.
 void update(double lastFrameTimeSeconds)
          Automatically updates any actor information that needs to be updated/checked every frame.
 
Methods inherited from class espresso3d.engine.world.sector.base.E3DPortalEnabledRenderable
checkSectorChangeDuringMovement, getSector, setSector
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getBlendMode, getKey, getRenderMode, initCorrectGeometryRenderer, isKeyChanged, setBlendMode, setKeyChanged
 
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
 
Methods inherited from interface espresso3d.engine.collision.base.E3DCollisionDetectableObject
getEngine, getSector
 

Constructor Detail

E3DActor

public E3DActor(E3DEngine engine,
                E3DWorld world,
                java.lang.String actorID)
Create an actor without a bounding object

Parameters:
engine - The engine the actor is part of
world - Currently required because an actors textureset is loaded into the world's textureset so it can be shared across all objects (better for memory allocation)
actorID - A unique ID for the actor

E3DActor

public E3DActor(E3DEngine engine,
                E3DWorld world,
                E3DBoundingObject boundingObject,
                java.lang.String actorID)
Create an actor with a bounding object

Parameters:
engine - The engine the actor is part of
world - Currently required because an actors textureset is loaded into the world's textureset so it can be shared across all objects (better for memory allocation)
boundingObject - Bounding object for the actor
actorID - A unique ID for the actor

E3DActor

public E3DActor(E3DActor toCopyActor)
This copies all the actor geometry into another actor.

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

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 -

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:

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 and bounding object (if it exists)

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

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)


render

public void render()
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:
render 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.

isLit

public boolean isLit()
actorLit indicates whether or not the actor should be lit (if not, it will be fullbright)

Specified by:
isLit in interface E3DLightableObject
Returns:
Returns the actorLit.

setLit

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

Specified by:
setLit in interface E3DLightableObject
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

getUniqueVertexPositionList

public java.util.ArrayList getUniqueVertexPositionList()
Returns a list of only the unique triangle vertices in the actor (no duplicates). The vertices returned are in local coordinate space (NOT world).

Specified by:
getUniqueVertexPositionList in interface E3DCollisionDetectableObject
Returns:
List of E3DVector3F's representing unique triangle vertices in the actors mesh in local coordinate space.

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

isModelDisplayed

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

Returns:

setModelDisplayed

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

Returns:

getTextureSortedTriangleMap

public E3DSortedRenderableMap getTextureSortedTriangleMap()

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

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:

getSkeleton

public E3DSkeleton getSkeleton()

setSkeleton

public void setSkeleton(E3DSkeleton skeleton)

update

public void update(double lastFrameTimeSeconds)
Automatically updates any actor information that needs to be updated/checked every frame. (sound data, skeleton, etc). This is called by the engine only.

Parameters:
lastFrameTimeSeconds -

isDebugSkeletonDisplayed

public boolean isDebugSkeletonDisplayed()

setDebugSkeletonDisplayed

public void setDebugSkeletonDisplayed(boolean debugSkeletonDisplayed)

isDebugBoundingObjectDisplayed

public boolean isDebugBoundingObjectDisplayed()

setDebugBoundingObjectDisplayed

public void setDebugBoundingObjectDisplayed(boolean debugBoundingObjectDisplayed)

getMesh

public E3DMesh getMesh()

getOrientation

public E3DOrientation getOrientation()
Specified by:
getOrientation in interface E3DCollisionDetectableObject

getAssociatedSound3DList

public java.util.ArrayList getAssociatedSound3DList()

addSound3DToAssociatedList

public void addSound3DToAssociatedList(E3DSound3D sound3D)

removeSound3DFromAssociatedList

public void removeSound3DFromAssociatedList(E3DSound3D sound3D)