gePhysicsObject

Description: Constrained rigid body interface

Source file: ...\genesis3d\OpenSource\Source\Physics\PhysicsObject.h

Contents:

Functions: Create, Destroy, ApplyGlobalFrameForce, ApplyGlobalFrameImpulse, ComputeForces, Integrate, GetMass, SetMass, GetOneOverMass, GetXForm, SetXForm, GetXFormInEditorSpace, GetOriginalLocation, SetOriginalLocation, GetLocation, GetLocationInEditorSpace, GetLinearVelocity, SetLinearVelocity, GetAngularVelocity, SetAngularVelocity, GetForce, SetForce, GetTorque, SetTorque, GetAppliedForce, SetAppliedForce, GetAppliedTorque, SetAppliedTorque, ClearForce, ClearTorque, ClearAppliedForce, ClearAppliedTorque, IncForce, IncTorque, IncAppliedForce, IncAppliedTorque, GetOrientation, SetOrientation, GetInertiaTensor, GetInertiaTensorInverse, GetInertiaTensorInPhysicsSpace, GetInertiaTensorInverseInPhysicsSpace, IsAffectedByGravity, SetIsAffectedByGravity, RespondsToForces, SetRespondsToForces, GetLinearDamping, SetLinearDamping, GetAngularDamping, SetAngularDamping, SetActiveConfig, GetActiveConfig, SetPhysicsScale, GetPhysicsScale

Types: gePhysicsObject

Constants: view

Notes: view

Change for Genesis3D v1.6: types float have been changed to geFloat

Types:

typedef struct gePhysicsObject gePhysicsObject;

NOTE: The contents of this structure have been intentionally left out of the interface, by the designers of this module. Think of this as a handle only.

Return to Contents 

Constants:

#define PHYSICSOBJECT_GRAVITY (-3.9f)

(KT Note:) This is the gravity constant that may be applied to objects. Its value makes me think that calculations are done with English units (i.e. the gravity is in feet/second^2).

Return to Contents 

Functions:

GENESISAPI gePhysicsObject * GENESISCC gePhysicsObject_Create (const geVec3d* StartLocation, float mass, geBoolean IsAffectedByGravity, geBoolean RespondsToForces, float linearDamping, float angularDamping, const geVec3d* Mins, const geVec3d* Maxs, float physicsScale);
Creates a PhysicsObject. Use the Xform from this object to move your cameras, actors, particles, ...
StartLocation, the position of the object
mass, the mass of the object
AffectedByGravity, True is you want the object to be affected by gravity, False if you don't
RespondsToForces, True if you want the object to be affected by forces, False if you don't
linearDamping,
this is the amount to reduce linear velocities by during each calculation cycle.
angularDamping, this is the amount to reduce rotational velocities by during each calculation cycle.
Mins, Mimumum coordinates for bounding box.
Maxs, Maxumum coordinates for bounding box
physicsScale, Scales all forces and values that affect this object. use the
GetXFormInEditorSpace() and GetLocationInEditorSpace() to see the affects of the scaling.
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_Destroy(gePhysicsObject** pPhysob);
Destroys the physics object
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_ApplyGlobalFrameForce(gePhysicsObject* pod, geVec3d* force, geVec3d* radiusVector, geBoolean isAppliedForce, int configIndex);
I'm not sure but I think this applies a constant force to the object.
(From the source code): "Apply force in global frame with changes taking effect on next iteration of gePhysicsObject's owner"
pod: The relevent PhysicsObject
force: the linear force vector to apply
radiusVector: The following formula used is: object Torque += radiusVector CrossProduct force. Thus, I believe that one should image the base of the radiusVector to be at the center of the physics object, and the tip of this vector will be (the offset of) the location that force is applied. Thus a linear force, applied off center, can create a torque (rotation) of the object.
isAppliedForce: True if the force is to be an "applied force".
configIndex: must be 0 or 1
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_ApplyGlobalFrameImpulse (gePhysicsObject* pPhysob, geVec3d* pImpulse, geVec3d* pRadVec, int configIndex);
I'm not sure but I think this applies a constant impulse to the object
(From the source code): "Apply impulse in global frame with immediate change in velocities"
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_ComputeForces(gePhysicsObject* pod, int configIndex);
I think this will compute and combine all the forces that are applied to the object.
(From the source code): "// add damping ... // clear force and torque accumulators... // add gravity // add forces"
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_Integrate(gePhysicsObject* pod, float deltaTime, int SourceConfigIndex);
I think this is the update time for the object. I used it and the lower the time is the slower the object moves in relationship to the entire physics system. A number between 0.0f and 1.0f.
(From the source code): "// Integrate a gePhysicsObject's equations of motion by time step deltaTime"
Users shouldn't need to call this function directly. Just call
gePhysicsSystem_Interate, which will then call this function.
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI float GENESISCC gePhysicsObject_GetMass(const gePhysicsObject* po);
Returns the mass of the object
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetMass(gePhysicsObject* po, float mass);
Sets the mass of the object
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI float GENESISCC gePhysicsObject_GetOneOverMass(const gePhysicsObject* po);
Returns 1/mass.
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetXForm(const gePhysicsObject* po, geXForm3d* xform, int configIndex);
Returns the Xform of the object
po: The relevent PhysicsObject
xform: where desired XForm is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetXForm(gePhysicsObject* po, const geXForm3d* xform, int configIndex);
Set the Xform of the object
po: The relevent PhysicsObject
xform: where desired XForm is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetXFormInEditorSpace(const gePhysicsObject* po, geXForm3d* xform, int configIndex);
Returns a scaled Xform of the object, It's scale is determined by the physicsScale value in the gePhysicsObject_Create() function or the SetPhysicsScale() function.
po: The relevent PhysicsObject
xform: where desired XForm is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetOriginalLocation(const gePhysicsObject* po, geVec3d* loc);
Not sure what it returns but if I had to guess, I would think you must first set the location using the function below and it will return those parameter. Useful for collision detection?
OriginalLocation = StartLocation, scaled by PhysicsScale (both as specified during gePhysicsObject_Create).
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetOriginalLocation(gePhysicsObject* po, const geVec3d* loc);
Sets OriginalLocation variable of gePhysicsObject structure.
Note that this value is not scaled by PhysicsScale, as would be done during
gePhysicsObject_Create.
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetLocation(const gePhysicsObject *po, geVec3d *Location, int configIndex);
Returns the location of the object.
(From the source code:) "// get gePhysicsObject's location in Physics space (xlation and olocation are in Physics space units)"
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetLocationInEditorSpace(const gePhysicsObject* po, geVec3d* loc, int configIndex);
Returns the scaled location of the object. It's scale is determined by the physicsScale value in the gePhysicsObject_Create() function or the SetPhysicsScale() function.
(From the source code:) "// get gePhysicsObject's location in editor(world) space"
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetLinearVelocity(const gePhysicsObject* po, geVec3d* vel, int configIndex);
Returns the linear velocity of the object.
po: The relevent PhysicsObject
vel: where desired geVec3d linear velocity of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetLinearVelocity(gePhysicsObject* po, const geVec3d* vel, int configIndex);
Sets the linear velocity of the object.
po: The relevent PhysicsObject
vel: where desired geVec3d linear velocity of the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetAngularVelocity(const gePhysicsObject* po, geVec3d* vel, int configIndex);
Return the angular velocity of the object. Basically the speed at which the object is rotating.
po: The relevent PhysicsObject
vel: where desired geVec3d Angular velocity of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetAngularVelocity(gePhysicsObject* po, const geVec3d* vel, int configIndex);
Set the angular velocity of the object. Basically the speed at which the object is rotating.
po: The relevent PhysicsObject
vel: where desired geVec3d Angular velocity of the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetForce(const gePhysicsObject* po, geVec3d* force, int configIndex);
Returns the force on the object.
po: The relevent PhysicsObject
force: where desired geVec3d force of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetForce(gePhysicsObject* po, const geVec3d* force, int configIndex);
Sets the force applied to the object.
po: The relevent PhysicsObject
force: where desired geVec3d force applied to the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetTorque(const gePhysicsObject* po, geVec3d* torque, int configIndex);
Return the torque applied to the object. Basically the force that causes the object to spin.
po: The relevent PhysicsObject
force: where desired geVec3d torque of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetTorque(gePhysicsObject* po, const geVec3d* torque, int configIndex);
Sets the torque applied to the object. Basically the force that causes the object to spin.
po: The relevent PhysicsObject
force: where desired geVec3d torque applied to the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetAppliedForce(const gePhysicsObject* po, geVec3d* force, int configIndex);
Returns the force that is applied to an object that collides with this object.
Note: No collision detection is effected from this function
This returns AppliedForce variable from the gePhysicsObject structure.
po: The relevent PhysicsObject
force: where desired geVec3d applied linear force of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetAppliedForce(gePhysicsObject* po, const geVec3d* force, int configIndex);
Sets the force that is applied to an object that collides with this object.
Note: No collision detection is effected from this function
AppliedForce is used during
ComputeForces, where it is added to the force of the object.
po: The relevent PhysicsObject
force: where desired geVec3d linear force to be applied to the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetAppliedTorque(const gePhysicsObject* po, geVec3d* torque, int configIndex);
Returns the torque that is applied to an object that collides with this object.
Note: No collision detection is effected from this function
This returns AppliedTorque variable from the gePhysicsObject structure.
po: The relevent PhysicsObject
torque: where desired geVec3d torque force of the object is to be copied to.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetAppliedTorque(gePhysicsObject* po, const geVec3d* torque, int configIndex);
Sets the torque that is applied to an object that collides with this object.
Note: No collision detection is effected from this function
po: The relevent PhysicsObject
torque: where desired geVec3d applied torque to be applied to the object is to be copied from.
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearForce(gePhysicsObject* po, int configIndex);
Removes the force from an object.
po: The relevent PhysicsObject
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearTorque(gePhysicsObject* po, int configIndex);
Removes the torque from an object.
po: The relevent PhysicsObject
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearAppliedForce(gePhysicsObject* po, int configIndex);
Removes the applied force from an object.
po: The relevent PhysicsObject
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearAppliedTorque(gePhysicsObject* po, int configIndex);
Removes the applied torque from an object.
po: The relevent PhysicsObject
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_IncForce(gePhysicsObject* po, const geVec3d* forceInc, int configIndex);
Adds the given forceInc to the current force.
po: The relevent PhysicsObject
forceInc: force to inc by
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_IncTorque(gePhysicsObject* po, const geVec3d* torqueInc, int configIndex);
Adds the given torqueInc to the current torque.
po: The relevent PhysicsObject
torqueInc: torque to inc by
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_IncAppliedForce(gePhysicsObject* po, const geVec3d* forceInc, int configIndex);
Adds the given forceInc to the current appliedForce.
po: The relevent PhysicsObject
forceInc: applied force to inc by
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_IncAppliedTorque(gePhysicsObject* po, const geVec3d* torqueInc, int configIndex);
Adds the given torqueInc to the current AppliedTorque.
po: The relevent PhysicsObject
torqueInc: applied torque to inc by
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetOrientation(const gePhysicsObject* po, geQuaternion* orient, int configIndex);
Returns the orientation of the object in quaternion form.
po: The relevent PhysicsObject
orient: geQuaternion to copy to
configIndex: must be 0 or
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetOrientation(gePhysicsObject* po, const geQuaternion* orient, int configIndex);
Sets the orientation of the object from quaternion form.
po: The relevent PhysicsObject
orient: geQuaternion to copy from
configIndex: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetInertiaTensor(const gePhysicsObject* po, Matrix33* iTensor);
Don't know what a inertia tensor is.
(From source code): "// get inertia tensor and inverse in body (local unrotated) space"
Inertia tensor is used in
ComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia
po: The relevent PhysicsObject
iTensorInv: ?
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetInertiaTensorInverse(const gePhysicsObject* po, Matrix33* iTensorInv);
Don't know what a inertia tensor is.
Inertia tensor inverse is used in ComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
po: The relevent PhysicsObject
iTensorInv: ?
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetInertiaTensorInPhysicsSpace(const gePhysicsObject* pPhysob, Matrix33* pITensor, int configIndex);
Don't know what a inertia tensor is.
Inertia tensor is used in ComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
Probably returns results in Physics space units, rather than in editor(world) space units
pPhysob: The relevent PhysicsObject
pITensor: ?
configIndex
: must be 0 or 1
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_GetInertiaTensorInverseInPhysicsSpace(const gePhysicsObject* pPhysob, Matrix33* pITensorInv, int configIndex);
Don't know what a inertia tensor is.
Inertia tensor inverse is used in ComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
Probably returns results in Physics space units, rather than in editor(world) space units
pPhysob: The relevent PhysicsObject
pITensorInv: ?
configIndex
: must be 0 or 1
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_IsAffectedByGravity(const gePhysicsObject* po);
Returns true if the object is affected by gravity, false if it is not.
This is initially set during creation of the object
po: The relevent PhysicsObject
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetIsAffectedByGravity(gePhysicsObject* po, geBoolean flag);
Set to true if the object is affected by gravity, false if it is not.
po: The relevent PhysicsObject
flag: true or false.
Return to Contents
GENESISAPI geBoolean GENESISCC gePhysicsObject_RespondsToForces(const gePhysicsObject* po);
Returns true if the object is affected by forces, false if it is not.
This is initially set during creation of the object
po: The relevent PhysicsObject
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetRespondsToForces(gePhysicsObject* po, geBoolean flag);
Set to true if the object is affected by forces, false if it is not.
po: The relevent PhysicsObject
flag: true or false.
Return to Contents
GENESISAPI float GENESISCC gePhysicsObject_GetLinearDamping(const gePhysicsObject* po);
Returns the linear damping
po: The relevent PhysicsObject
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetLinearDamping(gePhysicsObject* po, float linearDamping);
Sets the linear damping
po: The relevent PhysicsObject
linearDamping: should be 0.0f to 1.0f
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI float GENESISCC gePhysicsObject_GetAngularDamping(const gePhysicsObject* po);
Returns the angular damping
po: The relevent PhysicsObject
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetAngularDamping(gePhysicsObject* po, float angularDamping);
Sets the angular damping
po: The relevent PhysicsObject
angularDamping: should be 0.0f to 1.0f
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetActiveConfig(gePhysicsObject* pPhysob, int configIndex);
Objects can have more than one config this will set which one it is using.
pPhysob: The relevent PhysicsObject
configIndex: should be 0 or 1
Return to Contents
GENESISAPI int GENESISCC gePhysicsObject_GetActiveConfig(gePhysicsObject* pPhysob);
Objects can have more than one config this will return which one it is using.
pPhysob: The relevent PhysicsObject
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetPhysicsScale(gePhysicsObject* pPhysob, float scale);
Scales all forces and values that affect this object. use the GetXFormInEditorSpace() and GetLocationInEditorSpace() to see the affects of the scaling.
pPhysob: The relevent PhysicsObject
scale: any number.
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
GENESISAPI float GENESISCC gePhysicsObject_GetPhysicsScale(gePhysicsObject* pPhysob);
Returns the scale of the object.
This is initially set during creation of object
pPhysob: The relevent PhysicsObject
Note: In Genesis3D v1.6 all float types have been converted to geFloat
Return to Contents
Notes:
The comments of these functions were made by Jeff on the Genesis3D forum. His original post is here. Kdtop has made additional notes (indicated by color blue)
This module handles the following aspects of object physics: application of forces and torques, inertia, linear and rotational velocities, translation. It does not handle any collisions, or calculate reflections off a wall (for example).
The following terms are used in this module
config
: Objects can have more than one config. This will determine which one it is using. Perhaps an application of this would be to use a different set of physics constants in water versus air.
linear force: The force that keeps an object moving in a straight line
angular force: The force that keeps an object spinning
torque: a rotational force. essentially same as angular force
applied force: An applied force is added to the object's force each time
ComputeForces is called (i.e. a constant force). A regular force is zeroed out after additions, but not so with an applied force. AppliedForce is affected as follows: ApplyGlobalFrameForce will add specifed Force to AppliedForce if boolean IsAppliedForce is true. IncAppliedForce will also increment AppliedForce
applied torque: An applied torque is added to the object's torque each time
ComputeForces is called (i.e. a constant force). A regular torque is zeroed out after additions, but not so with an applied torque. AppliedTorque is affected as follows: ApplyGlobalFrameForce will add specifed Torque to AppliedForce if boolean IsAppliedForce is true. IncAppliedTorque will also increment AppliedTorque.
damping: The amount to decrease object velocities by each cycle (to simulate friction)
Return to Contents