![]()
gePhysicsObject
Description: Constrained rigid body interface
Source file: ...\genesis3d\OpenSource\Source\Physics\PhysicsObject.h
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 gePhysicsObjectConstants:
viewNotes:
viewChange 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.
![]()
#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).
![]()
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
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"
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
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
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 thegePhysicsObject_Create() function or the SetPhysicsScale() function.
po: The relevent PhysicsObject
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 duringgePhysicsObject_Create).
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_SetOriginalLocation(gePhysicsObject* po, const geVec3d* loc);
Sets OriginalLocation variable of gePhysicsObject structure.gePhysicsObject_Create.
Note that this value is not scaled by PhysicsScale, as would be done during
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
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
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
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
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
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
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
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
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 functionComputeForces, where it is added to the force of the object.
AppliedForce is used during
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
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearTorque(gePhysicsObject* po, int configIndex);
Removes the torque from an object.
po: The relevent PhysicsObject
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearAppliedForce(gePhysicsObject* po, int configIndex);
Removes the applied force from an object.
po: The relevent PhysicsObject
Return to Contents
GENESISAPI void GENESISCC gePhysicsObject_ClearAppliedTorque(gePhysicsObject* po, int configIndex);
Removes the applied torque from an object.
po: The relevent PhysicsObject
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
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
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
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
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
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
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"ComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia
Inertia tensor is used in
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 inComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
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 inComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
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 inComputeForces and ApplyGlobalFrameImpulse, so probably has to do with inertia.
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 duringcreation of the object
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
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 duringcreation of the object
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
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
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
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
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 theGetXFormInEditorSpace() and GetLocationInEditorSpace() to see the affects of the scaling.
pPhysob: The relevent PhysicsObject
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 duringcreation of object
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 ishere. 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: 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.
config
Return to Contents