org.xith3d.physics
Class PhysicsGFXManager

java.lang.Object
  extended by org.xith3d.physics.PhysicsGFXManager
All Implemented Interfaces:
Updatable

public class PhysicsGFXManager
extends java.lang.Object
implements Updatable

The PhysicsGFXManager is capable of updating the graphical representations of Collideables each frame or vice versa, if instantiated with the inverse flag.


Constructor Summary
PhysicsGFXManager()
           
PhysicsGFXManager(boolean inverse)
           
 
Method Summary
 TransformGroup add(Body body)
          Adds a Body and its graphical counterpart to the manager.
 TransformGroup add(Body body, TransformGroup node)
          Adds a Body and its graphical counterpart to the manager.
 TransformGroup add(Collideable collider)
          Adds a Collideable and its graphical counterpart to the manager.
 TransformGroup add(Collideable collider, TransformGroup node)
          Adds a Collideable and its graphical counterpart to the manager.
 void clear()
          Removes all items (colliders and GFX objects).
 TransformGroup directAdd(Body body, GroupNode parentGroup)
          Adds a Body and its graphical counterpart to the manager.
 TransformGroup directAdd(Body body, TransformGroup node, GroupNode parentGroup)
          Adds a Body and its graphical counterpart to the manager.
 TransformGroup directAdd(Collideable collider, GroupNode parentGroup)
          Adds a Collideable and its graphical counterpart to the manager.
 TransformGroup directAdd(Collideable collider, TransformGroup node, GroupNode parentGroup)
          Adds a Collideable and its graphical counterpart to the manager.
 void directAdd(Joint joint, GroupNode parentGroup, org.openmali.vecmath2.Colorf lineColor, float lineWidth)
          Adds all Bodies of a Joint and its graphical counterpart and lines for the Joint itself to the manager.
 Body getBody(int index)
           
 TransformGroup getBodyGFX(int index)
           
 Collideable getCollider(int index)
           
 TransformGroup getColliderGFX(int index)
           
 int getNumItems()
          Gets the number of items (collideables + bodies).
 boolean isInverse()
          The "normal" update implementation updates the graphical parts from the physical one.
 void remove(Body body)
          Removes a Body and its graphical counterpart from the manager.
 void remove(Collideable collider)
          Removes a Collider and its graphical counterpart from the manager.
 void remove(Joint joint)
          Removes a Joint's Bodies and their graphical counterparts and the oint-lines from the manager.
 void remove(TransformGroup node)
          Removes a Collider and its graphical counterpart from the manager.
 void removeBody(int index)
          Removes a Body and its graphical counterpart from the manager.
 void removeCollider(int index)
          Removes a Collider and its graphical counterpart from the manager.
 void update(long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          Updates this Updatable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhysicsGFXManager

public PhysicsGFXManager(boolean inverse)
Parameters:
inverse - if true, the physical parts are updated from the graphical ones

PhysicsGFXManager

public PhysicsGFXManager()
Method Detail

isInverse

public final boolean isInverse()
The "normal" update implementation updates the graphical parts from the physical one. If inverse is true, the physical part is updated from the graphical one.

Returns:
update inversely?

getNumItems

public final int getNumItems()
Gets the number of items (collideables + bodies).

Returns:
the number of items (collideables + bodies).

directAdd

public final TransformGroup directAdd(Collideable collider,
                                      TransformGroup node,
                                      GroupNode parentGroup)
Adds a Collideable and its graphical counterpart to the manager.

Parameters:
collider -
node -
parentGroup - if not null, the node will be directly added to this group
Returns:
the TransformGroup back again

directAdd

public final TransformGroup directAdd(Collideable collider,
                                      GroupNode parentGroup)
Adds a Collideable and its graphical counterpart to the manager.
This method uses collider.getBaseGFX() to create the GFX object.

Parameters:
collider -
parentGroup - if not null, the node will be directly added to this group
Returns:
the TransformGroup, that is used to position the GFX object

directAdd

public final TransformGroup directAdd(Body body,
                                      TransformGroup node,
                                      GroupNode parentGroup)
Adds a Body and its graphical counterpart to the manager.

Parameters:
body -
node -
parentGroup - if not null, the node will be directly added to this group
Returns:
the TransformGroup back again

directAdd

public final TransformGroup directAdd(Body body,
                                      GroupNode parentGroup)
Adds a Body and its graphical counterpart to the manager.
This method uses collider.getBaseGFX() to create the GFX objects for all Collideables in the Body.

Parameters:
body -
parentGroup - if not null, the node will be directly added to this group
Returns:
the TransformGroup, that is used to position the GFX object

directAdd

public final void directAdd(Joint joint,
                            GroupNode parentGroup,
                            org.openmali.vecmath2.Colorf lineColor,
                            float lineWidth)
Adds all Bodies of a Joint and its graphical counterpart and lines for the Joint itself to the manager.

Parameters:
joint -
parentGroup -
lineColor -
lineWidth -

add

public final TransformGroup add(Collideable collider,
                                TransformGroup node)
Adds a Collideable and its graphical counterpart to the manager.

Parameters:
collider -
node -
Returns:
the TransformGroup back again

add

public final TransformGroup add(Collideable collider)
Adds a Collideable and its graphical counterpart to the manager.
This method uses collider.getBaseGFX() to create the GFX object.

Parameters:
collider -
Returns:
the TransformGroup, that is used to position the GFX object

removeCollider

public final void removeCollider(int index)
Removes a Collider and its graphical counterpart from the manager. (optional operation)

Parameters:
index -

remove

public final void remove(Collideable collider)
Removes a Collider and its graphical counterpart from the manager. (optional operation)

Parameters:
collider -

add

public final TransformGroup add(Body body,
                                TransformGroup node)
Adds a Body and its graphical counterpart to the manager.

Parameters:
body -
node -
Returns:
the TransformGroup back again

add

public final TransformGroup add(Body body)
Adds a Body and its graphical counterpart to the manager.
This method uses collider.getBaseGFX() to create the GFX object.

Parameters:
body -
Returns:
the TransformGroup, that is used to position the GFX object

removeBody

public final void removeBody(int index)
Removes a Body and its graphical counterpart from the manager. (optional operation)

Parameters:
index -

remove

public final void remove(Body body)
Removes a Body and its graphical counterpart from the manager. (optional operation)

Parameters:
body -

remove

public final void remove(Joint joint)
Removes a Joint's Bodies and their graphical counterparts and the oint-lines from the manager. (optional operation)

Parameters:
body -

remove

public final void remove(TransformGroup node)
Removes a Collider and its graphical counterpart from the manager. (optional operation)

Parameters:
node -

clear

public final void clear()
Removes all items (colliders and GFX objects).


getCollider

public final Collideable getCollider(int index)

getBody

public final Body getBody(int index)

getColliderGFX

public final TransformGroup getColliderGFX(int index)

getBodyGFX

public final TransformGroup getBodyGFX(int index)

update

public void update(long gameTime,
                   long frameTime,
                   UpdatingThread.TimingMode timingMode)
Updates this Updatable object.

Specified by:
update in interface Updatable
Parameters:
gameTime - the gameTime in Milliseconds
frameTime - the frameTime in Milliseconds (needed time for the last frame)
timingMode - the TimingMode to use for frameTime.