hmi.physics
Class RigidBody

java.lang.Object
  extended by hmi.physics.RigidBody
All Implemented Interfaces:
VObject
Direct Known Subclasses:
OdeRigidBody

public abstract class RigidBody
extends Object
implements VObject

Rigid body

Author:
welberge

Nested Class Summary
 
Nested classes/interfaces inherited from interface hmi.animation.VObject
VObject.Predicate
 
Field Summary
protected  ArrayList<CollisionShape> collisionShapes
           
protected  String id
           
protected  String name
           
protected  ArrayList<float[]> rotationBuffer
           
protected  String sid
           
protected  ArrayList<float[]> translationBuffer
           
 
Constructor Summary
RigidBody()
           
 
Method Summary
abstract  CollisionBox addBox(float[] halfExtends)
          Add a collision box to the local origin
abstract  CollisionBox addBox(float[] q, float[] tr, float[] halfExtends)
          Adds a collision box
abstract  CollisionCapsule addCapsule(float[] q, float[] tr, float radius, float height)
          Adds a collision capsule, aligned with y-axis
abstract  CollisionCapsule addCapsule(float radius, float height)
          Adds a collision capsule, aligned with y-axis
 void addForce(float[] force)
           
abstract  void addForce(float x, float y, float z)
           
 void addForceAtPos(float[] force, float[] pos)
           
abstract  void addForceAtPos(float fx, float fy, float fz, float px, float py, float pz)
           
 void addForceAtRelPos(float[] force, float[] pos)
           
abstract  void addForceAtRelPos(float fx, float fy, float fz, float px, float py, float pz)
           
 void addRelForce(float[] force)
           
abstract  void addRelForce(float x, float y, float z)
           
 void addRelForceAtRelPos(float[] force, float[] pos)
           
abstract  void addRelForceAtRelPos(float fx, float fy, float fz, float px, float py, float pz)
           
 void addRelTorque(float[] t)
           
abstract  void addRelTorque(float x, float y, float z)
           
 void addRotationBuffer(float[] rotBuf)
           
abstract  CollisionSphere addSphere(float radius)
          Adds a collision sphere at the local origin
abstract  CollisionSphere addSphere(float[] tr, float radius)
          Adds a collision capsule, aligned with y-axis
 void addTorque(float[] t)
           
abstract  void addTorque(float x, float y, float z)
           
 void addTranslationBuffer(float[] transBuf)
           
abstract  void adjustMass(float mass)
          Sets the new mass
 void clear()
          prepares the body for removal
 void copy()
           
abstract  Mass createMass()
           
abstract  void getAngularVelocity(float[] result)
          Returns the angular velocity vector in the form of a float array of length three.
abstract  void getAngularVelocity(float[] vc, int vcIndex)
          Like getAngularVelocity(wa), but starting at the specified offset.
 ArrayList<CollisionShape> getCollisionShapes()
           
abstract  void getCOM(float[] com)
           
abstract  void getForce(float[] force)
           
 String getId()
          Returns an interned String that specifies the id.
abstract  void getInertiaTensor(float[] I)
           
abstract  float getMass()
           
 String getName()
          Returns an interned String that specifies the name.
abstract  void getPointRelPosition(float[] dst, float[] point)
          Gets the world position of a point on the body, returns the result in dst
abstract  void getPointVelocity(float[] dst, float[] point)
          Get the velocity of a point on the rigid body, returns the result in dst
abstract  void getRelativePointVelocity(float[] dst, float[] point)
          Get the velocity of a point on the rigid body, in coordinates relative to the body.
abstract  void getRotation(float[] result)
          Returns the rotation quaternion in a float array of length four.
abstract  void getRotation(float[] r, int index)
          Like getRotation(ra), but starting at the specified offset.
 float[] getRotationBuffer()
           
 void getScale(float[] r)
          Returns the scale vector in a float array of length three.
 void getScale(float[] r, int index)
          Like getScale(sa), but starting at the specified offset.
 float[] getScaleBuffer()
           
 String getSid()
          Returns an interned String that specifies the sid.
abstract  void getTorque(float[] torque)
           
abstract  void getTranslation(float[] pos)
          Returns the translation vector in the form of a float array of length three
 float[] getTranslationBuffer()
           
abstract  void getVelocity(float[] result)
          Returns the velocity vector in the form of a float array of length three.
abstract  void removeCollisionShape(CollisionShape s)
          Removes a collision shape
abstract  void rotateInertiaTensor(float[] q)
           
 void setAngularVelocity(float[] aVel)
          Sets the angular velocity vector from a float array of length three.
 void setAngularVelocity(float[] vc, int vcIndex)
          Like setAngularVelocity(wa), but starting at the specified offset.
abstract  void setAngularVelocity(float x, float y, float z)
          Sets the angular velocity vector from three floats.
 void setAxisAngle(float ax, float ay, float az, float angle)
          Sets the rotation quaternion derived from a rotation axis (ax, ay, az) and a rotation angle angle, specified in radians.
abstract  void setCOM(float[] com)
           
abstract  void setEnabled(boolean enabled)
          Disables or enables the body.
abstract  void setForce(float x, float y, float z)
           
 void setId(String id)
          Sets the id for this VObject.
abstract  void setInertiaTensor(float[] I)
           
 void setMass(Mass m)
           
 void setName(String n)
          Sets the name for this VObject.
 void setRotation(float[] rot)
          Sets the rotation quaternion from a float array of length four.
 void setRotation(float[] ra, int raIndex)
          Like setRotation(ra), but starting at the specified offset.
abstract  void setRotation(float w, float x, float y, float z)
          Sets the rotation quaternion from four floats.
 void setScale(float[] sa)
          Sets the scale vector from a float array of lebgth three.
 void setScale(float[] sa, int saIndex)
          Like setScale(sa), but starting at the specified offset
 void setSid(String sid)
          Sets the sid for this VObject.
abstract  void setTorque(float x, float y, float z)
           
 void setTranslation(float[] pos)
          Sets the translation vector from a float array of length three.
 void setTranslation(float[] ta, int taIndex)
          Like setTranslation(ta), but starting at the specified offset.
abstract  void setTranslation(float x, float y, float z)
          Sets the current translation vector from three floats.
 void setVelocity(float[] velocity)
          Sets the velocity vector from a float array of length three.
 void setVelocity(float[] vc, int vcIndex)
          Like setVelocity(va), but starting at the specified offset.
abstract  void setVelocity(float x, float y, float z)
          Sets the velocity vector from three floats.
abstract  void translateInertiaTensor(float[] v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hmi.animation.VObject
getTranslation, getVelocity
 

Field Detail

rotationBuffer

protected ArrayList<float[]> rotationBuffer

translationBuffer

protected ArrayList<float[]> translationBuffer

collisionShapes

protected ArrayList<CollisionShape> collisionShapes

id

protected String id

sid

protected String sid

name

protected String name
Constructor Detail

RigidBody

public RigidBody()
Method Detail

getName

public String getName()
Description copied from interface: VObject
Returns an interned String that specifies the name.

Specified by:
getName in interface VObject

setName

public void setName(String n)
Description copied from interface: VObject
Sets the name for this VObject.

Specified by:
setName in interface VObject

setMass

public void setMass(Mass m)

copy

public void copy()

clear

public void clear()
prepares the body for removal


addBox

public abstract CollisionBox addBox(float[] halfExtends)
Add a collision box to the local origin

Parameters:
halfExtends - half-sizes along x,y,z
Returns:
the box

addBox

public abstract CollisionBox addBox(float[] q,
                                    float[] tr,
                                    float[] halfExtends)
Adds a collision box

Parameters:
q - local rotation
tr - local translation
halfExtends - half-sizes along x,y,z

addSphere

public abstract CollisionSphere addSphere(float radius)
Adds a collision sphere at the local origin

Parameters:
radius - radius of the sphere

addSphere

public abstract CollisionSphere addSphere(float[] tr,
                                          float radius)
Adds a collision capsule, aligned with y-axis

Parameters:
tr - local translation
radius - radius of the balls and cylinder

addCapsule

public abstract CollisionCapsule addCapsule(float[] q,
                                            float[] tr,
                                            float radius,
                                            float height)
Adds a collision capsule, aligned with y-axis

Parameters:
q - local rotation
tr - local translation
radius - radius of the balls and cylinder
height - (on y-axis)

addCapsule

public abstract CollisionCapsule addCapsule(float radius,
                                            float height)
Adds a collision capsule, aligned with y-axis

Parameters:
radius - radius of the balls and cylinder
height - (on y-axis) of the cylinder

removeCollisionShape

public abstract void removeCollisionShape(CollisionShape s)
Removes a collision shape


addRotationBuffer

public void addRotationBuffer(float[] rotBuf)
Parameters:
rotBuf - the rotationBuffer to set

addTranslationBuffer

public void addTranslationBuffer(float[] transBuf)
Parameters:
transBuf - the translationBuffer to set

setEnabled

public abstract void setEnabled(boolean enabled)
Disables or enables the body. Disabled bodies are not updated with the physical simulation step and do not collide with other bodies.


getCOM

public abstract void getCOM(float[] com)

getInertiaTensor

public abstract void getInertiaTensor(float[] I)

setCOM

public abstract void setCOM(float[] com)

setInertiaTensor

public abstract void setInertiaTensor(float[] I)

rotateInertiaTensor

public abstract void rotateInertiaTensor(float[] q)

translateInertiaTensor

public abstract void translateInertiaTensor(float[] v)

getMass

public abstract float getMass()

getTorque

public abstract void getTorque(float[] torque)

getForce

public abstract void getForce(float[] force)

setTranslation

public abstract void setTranslation(float x,
                                    float y,
                                    float z)
Description copied from interface: VObject
Sets the current translation vector from three floats.

Specified by:
setTranslation in interface VObject

setTranslation

public void setTranslation(float[] pos)
Description copied from interface: VObject
Sets the translation vector from a float array of length three.

Specified by:
setTranslation in interface VObject

setTranslation

public void setTranslation(float[] ta,
                           int taIndex)
Description copied from interface: VObject
Like setTranslation(ta), but starting at the specified offset.

Specified by:
setTranslation in interface VObject

getTranslation

public abstract void getTranslation(float[] pos)
Description copied from interface: VObject
Returns the translation vector in the form of a float array of length three

Specified by:
getTranslation in interface VObject

setRotation

public abstract void setRotation(float w,
                                 float x,
                                 float y,
                                 float z)
Description copied from interface: VObject
Sets the rotation quaternion from four floats. qs is the real part, qx, qy, qz the imaginary parts.

Specified by:
setRotation in interface VObject

setRotation

public void setRotation(float[] rot)
Description copied from interface: VObject
Sets the rotation quaternion from a float array of length four. The order is (s, x, y, z), where s is the real part, x, y, z are the imaginary parts.

Specified by:
setRotation in interface VObject

setRotation

public void setRotation(float[] ra,
                        int raIndex)
Description copied from interface: VObject
Like setRotation(ra), but starting at the specified offset.

Specified by:
setRotation in interface VObject

setAxisAngle

public void setAxisAngle(float ax,
                         float ay,
                         float az,
                         float angle)
Description copied from interface: VObject
Sets the rotation quaternion derived from a rotation axis (ax, ay, az) and a rotation angle angle, specified in radians. The axis need not have length one. If all parameters are zero, the rotation is set to the identity quaternion (1,0,0,0).

Specified by:
setAxisAngle in interface VObject

getRotation

public abstract void getRotation(float[] result)
Description copied from interface: VObject
Returns the rotation quaternion in a float array of length four. The order is (s, x, y, z), where s is the scalar part, x, y, z are the imaginary parts.

Specified by:
getRotation in interface VObject

getRotation

public abstract void getRotation(float[] r,
                                 int index)
Description copied from interface: VObject
Like getRotation(ra), but starting at the specified offset.

Specified by:
getRotation in interface VObject

setAngularVelocity

public abstract void setAngularVelocity(float x,
                                        float y,
                                        float z)
Description copied from interface: VObject
Sets the angular velocity vector from three floats.

Specified by:
setAngularVelocity in interface VObject

setAngularVelocity

public void setAngularVelocity(float[] aVel)
Description copied from interface: VObject
Sets the angular velocity vector from a float array of length three.

Specified by:
setAngularVelocity in interface VObject

setAngularVelocity

public void setAngularVelocity(float[] vc,
                               int vcIndex)
Description copied from interface: VObject
Like setAngularVelocity(wa), but starting at the specified offset.

Specified by:
setAngularVelocity in interface VObject

getAngularVelocity

public abstract void getAngularVelocity(float[] result)
Description copied from interface: VObject
Returns the angular velocity vector in the form of a float array of length three.

Specified by:
getAngularVelocity in interface VObject

getAngularVelocity

public abstract void getAngularVelocity(float[] vc,
                                        int vcIndex)
Description copied from interface: VObject
Like getAngularVelocity(wa), but starting at the specified offset.

Specified by:
getAngularVelocity in interface VObject

setVelocity

public abstract void setVelocity(float x,
                                 float y,
                                 float z)
Description copied from interface: VObject
Sets the velocity vector from three floats.

Specified by:
setVelocity in interface VObject

setVelocity

public void setVelocity(float[] velocity)
Description copied from interface: VObject
Sets the velocity vector from a float array of length three.

Specified by:
setVelocity in interface VObject

setVelocity

public void setVelocity(float[] vc,
                        int vcIndex)
Description copied from interface: VObject
Like setVelocity(va), but starting at the specified offset.

Specified by:
setVelocity in interface VObject

getVelocity

public abstract void getVelocity(float[] result)
Description copied from interface: VObject
Returns the velocity vector in the form of a float array of length three.

Specified by:
getVelocity in interface VObject

setForce

public abstract void setForce(float x,
                              float y,
                              float z)

addForce

public abstract void addForce(float x,
                              float y,
                              float z)

addForce

public void addForce(float[] force)

addRelForce

public abstract void addRelForce(float x,
                                 float y,
                                 float z)

addRelForce

public void addRelForce(float[] force)

addForceAtPos

public abstract void addForceAtPos(float fx,
                                   float fy,
                                   float fz,
                                   float px,
                                   float py,
                                   float pz)

addForceAtPos

public void addForceAtPos(float[] force,
                          float[] pos)

addForceAtRelPos

public abstract void addForceAtRelPos(float fx,
                                      float fy,
                                      float fz,
                                      float px,
                                      float py,
                                      float pz)

addForceAtRelPos

public void addForceAtRelPos(float[] force,
                             float[] pos)

addRelForceAtRelPos

public abstract void addRelForceAtRelPos(float fx,
                                         float fy,
                                         float fz,
                                         float px,
                                         float py,
                                         float pz)

addRelForceAtRelPos

public void addRelForceAtRelPos(float[] force,
                                float[] pos)

setTorque

public abstract void setTorque(float x,
                               float y,
                               float z)

addTorque

public abstract void addTorque(float x,
                               float y,
                               float z)

addTorque

public void addTorque(float[] t)

addRelTorque

public abstract void addRelTorque(float x,
                                  float y,
                                  float z)

addRelTorque

public void addRelTorque(float[] t)

adjustMass

public abstract void adjustMass(float mass)
Sets the new mass


getRelativePointVelocity

public abstract void getRelativePointVelocity(float[] dst,
                                              float[] point)
Get the velocity of a point on the rigid body, in coordinates relative to the body. returns the result in dst


getPointVelocity

public abstract void getPointVelocity(float[] dst,
                                      float[] point)
Get the velocity of a point on the rigid body, returns the result in dst


getPointRelPosition

public abstract void getPointRelPosition(float[] dst,
                                         float[] point)
Gets the world position of a point on the body, returns the result in dst


getCollisionShapes

public ArrayList<CollisionShape> getCollisionShapes()

getId

public String getId()
Description copied from interface: VObject
Returns an interned String that specifies the id.

Specified by:
getId in interface VObject

getSid

public String getSid()
Description copied from interface: VObject
Returns an interned String that specifies the sid.

Specified by:
getSid in interface VObject

setId

public void setId(String id)
Description copied from interface: VObject
Sets the id for this VObject.

Specified by:
setId in interface VObject

setSid

public void setSid(String sid)
Description copied from interface: VObject
Sets the sid for this VObject.

Specified by:
setSid in interface VObject

setScale

public void setScale(float[] sa)
Description copied from interface: VObject
Sets the scale vector from a float array of lebgth three.

Specified by:
setScale in interface VObject

setScale

public void setScale(float[] sa,
                     int saIndex)
Description copied from interface: VObject
Like setScale(sa), but starting at the specified offset

Specified by:
setScale in interface VObject

getTranslationBuffer

public float[] getTranslationBuffer()

getScale

public void getScale(float[] r)
Description copied from interface: VObject
Returns the scale vector in a float array of length three.

Specified by:
getScale in interface VObject

getScale

public void getScale(float[] r,
                     int index)
Description copied from interface: VObject
Like getScale(sa), but starting at the specified offset.

Specified by:
getScale in interface VObject

getScaleBuffer

public float[] getScaleBuffer()

getRotationBuffer

public float[] getRotationBuffer()

createMass

public abstract Mass createMass()