crystalspace.jbind.impl.engine.movable
Class csMovable

java.lang.Object
  extended bycrystalspace.jbind.impl.csNativeObject
      extended bycrystalspace.jbind.impl.csutil.scf.csBase
          extended bycrystalspace.jbind.impl.engine.movable.csMovable
All Implemented Interfaces:
iBase, iMovable, iPointer

public class csMovable
extends csBase
implements iMovable

Author:
Quentin Anciaux

Field Summary
 
Fields inherited from class crystalspace.jbind.impl.csNativeObject
ImplFactory, nPointer
 
Constructor Summary
csMovable(iPointer nPointer)
           
 
Method Summary
 void addListener(iMovableListener listener)
          Add a listener to this movable.
 void clearSectors()
          Clear the list of sectors.
 csVector3 getFullPosition()
          Get the current position but keep track of hierarchical transformations.
 csReversibleTransform getFullTransform()
          Construct the full world to object transformation given this transformation and possible parents transformations.
 java.lang.String getName()
          Return the name of the interface
 iMovable getParent()
          Get the parent movable.
 csVector3 getPosition()
          Get the current position.
 iSectorList getSectors()
          Get the list of sectors for this entity.
 csReversibleTransform getTransform()
          Get the world to object tranformation.
 long getUpdateNumber()
          A number which indicates if the movable has been updated.
 int getVersion()
          Return the version of the interface
 boolean inSector()
          Return true if we are placed in a sector (i.e. visible).
 boolean isFullTransformIdentity()
          Return true if the movable transformation is an identity transformation and the (optional) parent of this movable also is has identity transformation.
protected  boolean isNativePointerValidSafe(long pointer)
           
 boolean isTransformIdentity()
          This function returns true if the movable transformation is an identity transformation.
 void movePosition(csVector3 v)
          Relative move.
 void removeListener(iMovableListener listener)
          Remove a listener from this movable.
 void setParent(iMovable parent)
          Set the parent movable.
 void setPosition(csVector3 v)
          Set the transformation vector for this object.
 void setPosition(iSector home, csVector3 v)
          Set the transformation vector and sector to move to some position.
 void setSector(iSector sector)
          Initialize the list of sectors to one sector where this thing is.
 void setTransform(csMatrix3 matrix)
          Set the transformation matrix for this entity.
 void setTransform(csReversibleTransform t)
          Set the world to object tranformation.
 void transform(csMatrix3 matrix)
          Relative transform.
 void transformIdentity()
          Set the transform of this movable to the identity transform (i.e.not moving at all).
 void updateMove()
          After all movement has been done you need to call UpdateMove() to make the final changes to the entity that is controlled by this movable.
 
Methods inherited from class crystalspace.jbind.impl.csutil.scf.csBase
decRef, equals, finalize, getRefCount, incRef, nDelete, queryInterface, queryInterfaceSafe
 
Methods inherited from class crystalspace.jbind.impl.csNativeObject
changePointer, getPointer, getPointer, getPointerArray, hashCode, isMemoryOwner, isNativePointerValid, newNativeObject, setMemoryOwner, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface crystalspace.jbind.interfaces.iutil.scf.iBase
decRef, getRefCount, incRef, queryInterface, queryInterfaceSafe
 
Methods inherited from interface crystalspace.jbind.interfaces.iPointer
changePointer, getPointer, isMemoryOwner, setMemoryOwner
 

Constructor Detail

csMovable

public csMovable(iPointer nPointer)
Parameters:
nPointer -
Method Detail

getVersion

public int getVersion()
Description copied from interface: iBase
Return the version of the interface

Specified by:
getVersion in interface iBase
Specified by:
getVersion in class csBase
See Also:
iBase.getVersion()

getName

public java.lang.String getName()
Description copied from interface: iBase
Return the name of the interface

Specified by:
getName in interface iBase
Specified by:
getName in class csBase
See Also:
iBase.getName()

isNativePointerValidSafe

protected boolean isNativePointerValidSafe(long pointer)
Specified by:
isNativePointerValidSafe in class csNativeObject
See Also:
csNativeObject.isNativePointerValidSafe(long)

addListener

public void addListener(iMovableListener listener)
Description copied from interface: iMovable
Add a listener to this movable. This listener will be called whenever the movable changes (when UpdateMove() is called) or right before the movable is destroyed.

Specified by:
addListener in interface iMovable
Parameters:
listener -
See Also:
iMovable.addListener(crystalspace.jbind.interfaces.iengine.movable.iMovableListener)

clearSectors

public void clearSectors()
Description copied from interface: iMovable
Clear the list of sectors. This basically makes the object invisible as it will not be present in any sector. The mesh will still be present in the engine list of meshes though. This function does not do anything if the parent is not 0. You have to call UpdateMove() after changing the sector information.

Specified by:
clearSectors in interface iMovable
See Also:
iMovable.clearSectors()

getFullPosition

public csVector3 getFullPosition()
Description copied from interface: iMovable
Get the current position but keep track of hierarchical transformations. So the returned vector will be the world space coordinate where this object really is.

Specified by:
getFullPosition in interface iMovable
Returns:
See Also:
iMovable.getFullPosition()

getFullTransform

public csReversibleTransform getFullTransform()
Description copied from interface: iMovable
Construct the full world to object transformation given this transformation and possible parents transformations.

Specified by:
getFullTransform in interface iMovable
Returns:
See Also:
iMovable.getFullTransform()

getParent

public iMovable getParent()
Description copied from interface: iMovable
Get the parent movable. This is relevant in case the mesh belonging to this movable is part of a hierarchical transformation.

Specified by:
getParent in interface iMovable
Returns:
See Also:
iMovable.getParent()

getPosition

public csVector3 getPosition()
Description copied from interface: iMovable
Get the current position. Remember that positions are relative to some sector. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function returns the position relative to the parent.

Specified by:
getPosition in interface iMovable
Returns:
See Also:
iMovable.getPosition()

getSectors

public iSectorList getSectors()
Description copied from interface: iMovable
Get the list of sectors for this entity. Using this list you can get and set all sectors that this object is in. Note that if an object crosses a portal then you should in theory add every touched sector to this list of sectors. If objects are small then you can get away by not doing this. But it is possible that you will get render/clipping errors. There is a convenience function (iMeshWrapper->PlaceMesh()) which will attempt to find all sectors a mesh is in and update the movable. This will return the sectors of the parent if there is a parent.

Specified by:
getSectors in interface iMovable
Returns:
See Also:
iMovable.getSectors()

getTransform

public csReversibleTransform getTransform()
Description copied from interface: iMovable
Get the world to object tranformation. This==object and Other==world so This2Other() transforms from object to world space. If you modify this transform you have to call UpdateMove() later. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will get the transformation relative to the parent.

Specified by:
getTransform in interface iMovable
Returns:
See Also:
iMovable.getTransform()

getUpdateNumber

public long getUpdateNumber()
Description copied from interface: iMovable
A number which indicates if the movable has been updated. One can use this number to see if the position of the object has changed since the last time it was checked.

Specified by:
getUpdateNumber in interface iMovable
Returns:
See Also:
iMovable.getUpdateNumber()

inSector

public boolean inSector()
Description copied from interface: iMovable
Return true if we are placed in a sector (i.e. visible).

Specified by:
inSector in interface iMovable
Returns:
See Also:
iMovable.inSector()

isFullTransformIdentity

public boolean isFullTransformIdentity()
Description copied from interface: iMovable
Return true if the movable transformation is an identity transformation and the (optional) parent of this movable also is has identity transformation. Only in this case can you know that the object has the same object space coordinates as world space coordinates. Basically this function will return true if GetFullTransform() would return the identity transform.

Specified by:
isFullTransformIdentity in interface iMovable
Returns:
See Also:
iMovable.isFullTransformIdentity()

isTransformIdentity

public boolean isTransformIdentity()
Description copied from interface: iMovable
This function returns true if the movable transformation is an identity transformation. As soon as the object is moved this function will return false. You can use 'TransformIdentity()' to go back to the identity transform which will again let this flag return true. Note that this flag is only relevant for the transform of this movable and doesn't look at the transforms of the parents. Use IsFullTransformIdentity() for that. The engine and visibility cullers can use this information to optimize stuff a bit. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will only test the local transform for identity.

Specified by:
isTransformIdentity in interface iMovable
Returns:
See Also:
iMovable.isTransformIdentity()

movePosition

public void movePosition(csVector3 v)
Description copied from interface: iMovable
Relative move. Note that this function will not check for collision detection or portals. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will move relative to the parent.

Specified by:
movePosition in interface iMovable
Parameters:
v -
See Also:
iMovable.movePosition(crystalspace.jbind.impl.csgeom.vector3.csVector3)

removeListener

public void removeListener(iMovableListener listener)
Description copied from interface: iMovable
Remove a listener from this movable.

Specified by:
removeListener in interface iMovable
Parameters:
listener -
See Also:
iMovable.removeListener(crystalspace.jbind.interfaces.iengine.movable.iMovableListener)

setParent

public void setParent(iMovable parent)
Description copied from interface: iMovable
Set the parent movable. Usually you don't need to call this function yourselves as it is called automatically whenever you add some mesh to another mesh parent (using iMeshWrapper->GetChildren ()->Add()).

Specified by:
setParent in interface iMovable
Parameters:
parent -
See Also:
iMovable.setParent(crystalspace.jbind.interfaces.iengine.movable.iMovable)

setPosition

public void setPosition(csVector3 v)
Description copied from interface: iMovable
Set the transformation vector for this object. Note that the sectors and orientation are unchanged. You have to call UpdateMove() after changing the position of an object. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will set the position relative to the parent.

Specified by:
setPosition in interface iMovable
Parameters:
v -
See Also:
iMovable.setPosition(crystalspace.jbind.impl.csgeom.vector3.csVector3)

setPosition

public void setPosition(iSector home,
                        csVector3 v)
Description copied from interface: iMovable
Set the transformation vector and sector to move to some position. This call doesn't change the orientation of the model. You have to call UpdateMove() after changing the position of an object. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will set the position relative to the parent.

Specified by:
setPosition in interface iMovable
Parameters:
home -
v -
See Also:
iMovable.setPosition(crystalspace.jbind.interfaces.iengine.sector.iSector, crystalspace.jbind.impl.csgeom.vector3.csVector3)

setSector

public void setSector(iSector sector)
Description copied from interface: iMovable
Initialize the list of sectors to one sector where this thing is. This is a convenience funcion. Calling this function makes the object visible in this sector. Use GetSectors() if you want to have more control over where the object really is. This function does not do anything if the parent is not 0. You have to call UpdateMove() after changing the sector information.

Specified by:
setSector in interface iMovable
Parameters:
sector -
See Also:
iMovable.setSector(crystalspace.jbind.interfaces.iengine.sector.iSector)

setTransform

public void setTransform(csReversibleTransform t)
Description copied from interface: iMovable
Set the world to object tranformation. This==object and Other==world for the transform. WARNING: Do not scale objects using the transform in the movable! Several subsystems in Crystal Space (like collision detection and visibility culling) don't work properly if you do that. Instead use iMeshWrapper or iMeshFactoryWrapper->HardTransform() to scale. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will set the transformation relative to the parent.

Specified by:
setTransform in interface iMovable
Parameters:
t -
See Also:
iMovable.setTransform(crystalspace.jbind.impl.csgeom.transfrm.csReversibleTransform)

setTransform

public void setTransform(csMatrix3 matrix)
Description copied from interface: iMovable
Set the transformation matrix for this entity. You have to call UpdateMove() after changing the transform of an object. WARNING: Do not scale objects using the transform in the movable! Several subsystems in Crystal Space (like collision detection and visibility culling) don't work properly if you do that. Instead use iMeshWrapper or iMeshFactoryWrapper->HardTransform() to scale. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will set the transformation relative to the parent.

Specified by:
setTransform in interface iMovable
Parameters:
matrix -
See Also:
iMovable.setTransform(crystalspace.jbind.impl.csgeom.matrix3.csMatrix3)

transform

public void transform(csMatrix3 matrix)
Description copied from interface: iMovable
Relative transform. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will move relative to the parent.

Specified by:
transform in interface iMovable
Parameters:
matrix -
See Also:
iMovable.transform(crystalspace.jbind.impl.csgeom.matrix3.csMatrix3)

transformIdentity

public void transformIdentity()
Description copied from interface: iMovable
Set the transform of this movable to the identity transform (i.e.not moving at all). You have to call UpdateMove() after calling this. This function ignores the hierarchical transformation this movable may be part off. If part of a hierarchical transformation this function will only set the local transform to identity.

Specified by:
transformIdentity in interface iMovable
See Also:
iMovable.transformIdentity()

updateMove

public void updateMove()
Description copied from interface: iMovable
After all movement has been done you need to call UpdateMove() to make the final changes to the entity that is controlled by this movable. This is very important! This function is responsible for calling all movement listeners. If you do not call this function then the visibility cullers will not work right (among other things). UpdateMove() will also check for the transform being the identity transform and in that case it will set the identity flag to true.

Specified by:
updateMove in interface iMovable
See Also:
iMovable.updateMove()