feud.testgame.view
Class ClientObject

java.lang.Object
  extended bycom.threed.jpct.Object3D
      extended byfeud.testgame.view.ClientObject
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AnimatedObject, BulletView

public class ClientObject
extends com.threed.jpct.Object3D

A client object is the visual presentation of a LocalObject. Because we are using a 3D presentation here, it simply an extended version of jPCT's Object3D class. In addition to a normal Object3D, a ClientObject holds a few "backbuffer" values, that has been set based on new data from the server but that hasn't been used in the view until now.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.threed.jpct.Object3D
BILLBOARDING_DISABLED, BILLBOARDING_ENABLED, BLENDING_DISABLED, BLENDING_ENABLED, BUMPMAPPING_DISABLED, BUMPMAPPING_ENABLED, COLLISION_CHECK_NONE, COLLISION_CHECK_OTHERS, COLLISION_CHECK_SELF, COLLISION_DETECTION_NOT_OPTIMIZED, COLLISION_DETECTION_OPTIMIZED, COLLISION_NONE, CULLING_DISABLED, CULLING_ENABLED, ELLIPSOID_ALIGNED, ELLIPSOID_TRANSFORMED, ENVMAP_CAMERASPACE, ENVMAP_DISABLED, ENVMAP_ENABLED, ENVMAP_WORLDSPACE, ENVMAP_XY, ENVMAP_XZ, ENVMAP_YZ, FILTERING_DISABLED, FILTERING_ENABLED, FINALIZE_DEFAULT, FINALIZE_PRESORTX, FINALIZE_PRESORTY, FINALIZE_PRESORTZ, LIGHTING_ALL_ENABLED, LIGHTING_NO_LIGHTS, MOUSE_SELECTABLE, MOUSE_UNSELECTABLE, NO_OBJECT, OBJ_INVISIBLE, OBJ_VISIBLE, RAY_MISSES_BOX, SECTOR_AUTODETECT, SECTOR_PRECALCULATED, SHADING_FAKED_FLAT, SHADING_GOURAUD, SPECULAR_DISABLED, SPECULAR_ENABLED, TRANSPARENCY_MODE_ADD, TRANSPARENCY_MODE_DEFAULT, UNKNOWN_OBJECTSIZE
 
Constructor Summary
ClientObject()
          Creates a new, empty client object.
ClientObject(com.threed.jpct.Object3D obj)
          Create a new client object based on an existing Object3D.
ClientObject(com.threed.jpct.Object3D obj, com.threed.jpct.Object3D child)
          Creates a new client object plus a child object.
 
Method Summary
 void addToTicks(long val)
          Adds a number of ticks to the current tick count.
 void addToWorld(com.threed.jpct.World world)
          Adds the object as well as a child (if any) to the world.
 void animate(float ix, int seq)
           
 int getBackAnimation()
          Returns the backbuffer animation sequence.
 int getBackAnimationSpeed()
          Gets the speed of the backbuffer animation.
 com.threed.jpct.SimpleVector getBackPosition()
          Returns the back position.
 com.threed.jpct.Matrix getBackRotationMatrix()
          Returns the back rotation matrix.
 com.threed.jpct.SimpleVector getBackSpeed()
          Returns the nback speed vector.
 int getLastSequence()
          Returns the last animation sequence.
 long getTicks()
          Gets the animation ticks passed.
 boolean isModified()
          Returns if this object has been modified.
 boolean isOld()
          Determines if the object is "old".
 boolean isRemote()
          Returns if this object is a remote one or a local one.
 void process(long ticks, Level level)
          In this default implementation, the method does nothing.
 void processLocal(long ticks, Level level, LocalObject lo)
          In this default implementation, the method does nothing.
 void removeFromWorld(com.threed.jpct.World world)
          Removes the object as well as a child (if any) from the world.
 void resetTicks()
          Resets the animation ticks.
 void setAnimSpeed(int speed)
          Sets the animation speed of the currently displayed animation.
 void setBackAnimation(int anim)
          Sets the backbuffer animation sequence.
 void setBackAnimationSpeed(int speed)
          Sets the animtion speed of the backbuffer animation.
 void setBackPosition(com.threed.jpct.SimpleVector pos)
          Sets the back position.
 void setBackRotationMatrix(com.threed.jpct.Matrix mat)
          Sets the back rotation matrix.
 void setBackSpeed(com.threed.jpct.SimpleVector spd)
          Sets the back speed vector.
 void setClampingMode(int mode)
          A short cut to set the clamping mode for this object's animation (and it child object).
 void setLastSequence(int seq)
          Sets the last animation sequence.
 void setModified(boolean mod)
          Marks this object has being modified.
 void setRemoteFlag(boolean flag)
          Marks this object as being transfered from the server (the model of course, not this object directly).
 void setToLocalObject(LocalObject lo)
          Updates the backbuffer of this object with data from a LocalObject.
 void setVisibility(boolean visi)
           
 void touch()
          "Touches" the object, i.e. it marks the object as being used with a timestamp.
 
Methods inherited from class com.threed.jpct.Object3D
addChild, addCollisionListener, addParent, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, align, align, animate, build, calcBoundingBox, calcCenter, calcMinDistance, calcMinDistance, calcNormals, calcTextureWrap, calcTextureWrapSpherical, checkForCollision, checkForCollisionEllipsoid, checkForCollisionSpherical, clearAdditionalColor, clearAnimation, clearObject, cloneObject, createDummyObj, createTriangleStrips, createTriangleStrips, decoupleMesh, disableCollisionListeners, disableLazyTransformations, disableVertexSharing, ellipsoidIntersectsAABB, enableCollisionListeners, enableLazyTransformations, getAdditionalColor, getAnimationSequence, getCenter, getCollisionListeners, getEllipsoidMode, getEnvmapMode, getID, getLighting, getMesh, getName, getNextID, getOcTree, getOrigin, getOriginMatrix, getParents, getPolygonManager, getRotationMatrix, getRotationPivot, getScale, getTransformedCenter, getTranslation, getTranslationMatrix, getUserObject, getVisibility, getWorldTransformation, getXAxis, getYAxis, getZAxis, hasChild, hasParent, invert, isBumpmapped, isEnvmapped, isSelectable, mergeObjects, rayIntersectsAABB, rayIntersectsAABB, rebuild, recreateTextureCoords, removeChild, removeCollisionListener, removeMultiTexturing, removeParent, reorderSectors, resetCollisionStatus, resetNextID, rotateAxis, rotateMesh, rotateX, rotateY, rotateZ, scale, setAdditionalColor, setAllTextures, setAllTextures, setAnimationSequence, setAsMultiSectored, setBaseTexture, setBillboarding, setBlending, setBoundingBox, setBumpmapped, setBumpmapTexture, setCenter, setCollisionMode, setCollisionOptimization, setCulling, setEllipsoidMode, setEnvmapDirection, setEnvmapMode, setEnvmapped, setFiltering, setLighting, setMesh, setName, setNextID, setOcTree, setOrigin, setRotationMatrix, setRotationPivot, setScale, setSector, setSectorDetectionMode, setSelectable, setShadingMode, setSortOffset, setSpecularLighting, setTexture, setTexture, setTranslationMatrix, setTransparency, setTransparencyMode, setUserObject, sphereIntersectsAABB, translate, translate, translateMesh, wasTargetOfLastCollision, wasVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientObject

public ClientObject()
Creates a new, empty client object. This can be used as a "glue" object between other, real, objects. Just like the dummy Object3D in jPCT would.


ClientObject

public ClientObject(com.threed.jpct.Object3D obj)
Create a new client object based on an existing Object3D.

Parameters:
obj - the base object

ClientObject

public ClientObject(com.threed.jpct.Object3D obj,
                    com.threed.jpct.Object3D child)
Creates a new client object plus a child object. This is a convience method for handling weapons in this "game". The fact that the actual object is composed of parent and child is reflected in some methods, not in all. Basically, the behaviour of the composed object is similar to an Object3D in jPCT that has a child object attached to it.

Parameters:
obj - the base object
child - the base object of the child
Method Detail

processLocal

public void processLocal(long ticks,
                         Level level,
                         LocalObject lo)
In this default implementation, the method does nothing. You may fill it for a client object if you want to process something that is based on a local object that has been created by this client and that should be treated different from what process() itself does.

Parameters:
ticks - time passed since the last run
level - the current level
lo - the LocalObject that this client object represents. Client objects and local objects are not bound directly, which is why the client object doesn't know of its local one.

process

public void process(long ticks,
                    Level level)
In this default implementation, the method does nothing. This is for all kinds of processing like playing animation, doing the movement etc...

Parameters:
ticks - time passed since the last run
level - the current level

addToWorld

public void addToWorld(com.threed.jpct.World world)
Adds the object as well as a child (if any) to the world. This is similar to World.addObject() from the jPCT framework but it takes care of the child object.

Parameters:
world - the world

removeFromWorld

public void removeFromWorld(com.threed.jpct.World world)
Removes the object as well as a child (if any) from the world. This is similar to World.removeObject() from the jPCT framework but it takes care of the child object.

Parameters:
world - the world

animate

public void animate(float ix,
                    int seq)

setVisibility

public void setVisibility(boolean visi)

setClampingMode

public void setClampingMode(int mode)
A short cut to set the clamping mode for this object's animation (and it child object).

Parameters:
mode - the new clamping mode like in jPCT's Animation class.

isOld

public boolean isOld()
Determines if the object is "old". In this context, an object is old if it hasn't been touched for more than 5 seconds.

Returns:
boolean is it old?

touch

public void touch()
"Touches" the object, i.e. it marks the object as being used with a timestamp.


setRemoteFlag

public void setRemoteFlag(boolean flag)
Marks this object as being transfered from the server (the model of course, not this object directly). The purpose is to be able to tell if an object has been initially created on another client or on this one.

Parameters:
flag - true, if it's a remote object

isRemote

public boolean isRemote()
Returns if this object is a remote one or a local one.

Returns:
boolean is it remote?

setModified

public void setModified(boolean mod)
Marks this object has being modified. Modified means, that the server has updated the local object which this object represents.

Parameters:
mod - true, if it has been modified

isModified

public boolean isModified()
Returns if this object has been modified. Modified means, that the server has updated the local object which this object represents.

Returns:
boolean is it modified?

setBackRotationMatrix

public void setBackRotationMatrix(com.threed.jpct.Matrix mat)
Sets the back rotation matrix. This matrix has been changed due to a change in the server's data but that change hasn't been reflected in the view yet.

Parameters:
mat - the new rotation matrix

getBackRotationMatrix

public com.threed.jpct.Matrix getBackRotationMatrix()
Returns the back rotation matrix.

Returns:
Matrix the matrix

setBackPosition

public void setBackPosition(com.threed.jpct.SimpleVector pos)
Sets the back position. This position has been changed due to a change in the server's data but that change hasn't been reflected in the view yet.

Parameters:
pos - the new position

getBackPosition

public com.threed.jpct.SimpleVector getBackPosition()
Returns the back position.

Returns:
SimpleVector the position

setBackSpeed

public void setBackSpeed(com.threed.jpct.SimpleVector spd)
Sets the back speed vector. This speed vector has been changed due to a change in the server's data but that change hasn't been reflected in the view yet.

Parameters:
spd - the new speed vector

getBackSpeed

public com.threed.jpct.SimpleVector getBackSpeed()
Returns the nback speed vector.

Returns:
SimpleVector the vector

setToLocalObject

public void setToLocalObject(LocalObject lo)
Updates the backbuffer of this object with data from a LocalObject. Usually, this object has been transfered from the server and contains a new position, speed etc...

Parameters:
lo - the local object that contains the new data

resetTicks

public void resetTicks()
Resets the animation ticks. A client object doesn't necessarily use an animation, but the LocalObject itself contains the information. Therefore, the basic animation methods are within this class, even if it may not use them.


getTicks

public long getTicks()
Gets the animation ticks passed.

Returns:
long the ticks

addToTicks

public void addToTicks(long val)
Adds a number of ticks to the current tick count.

Parameters:
val - the number of ticks to add

setLastSequence

public void setLastSequence(int seq)
Sets the last animation sequence. This is the one that has been used in the last displayed frame.

Parameters:
seq - the sequence

getLastSequence

public int getLastSequence()
Returns the last animation sequence. This is the one that has been used in the last displayed frame.

Returns:
int the sequence

setAnimSpeed

public void setAnimSpeed(int speed)
Sets the animation speed of the currently displayed animation.

Parameters:
speed - the speed

setBackAnimationSpeed

public void setBackAnimationSpeed(int speed)
Sets the animtion speed of the backbuffer animation.

Parameters:
speed - the speed

getBackAnimationSpeed

public int getBackAnimationSpeed()
Gets the speed of the backbuffer animation.

Returns:
int the speed

setBackAnimation

public void setBackAnimation(int anim)
Sets the backbuffer animation sequence.

Parameters:
anim - the sequence number

getBackAnimation

public int getBackAnimation()
Returns the backbuffer animation sequence.

Returns:
int the sequence number