Changes

Jump to: navigation, search

Team Guardian Physics

4,234 bytes added, 21:50, 12 April 2011
Functions
By 'northWind'
 
[[Team_Guardian|Back to Team Guardian's Page]]
== Downloads ==
Please skip to the section relevant to your interests :)
=== Combined Physics Simulator/Basic Integration Steps === The barebones packages assume that your working copy is based on sample 28 but should integrate well with all samples 16 (possibly 22) and above. For all packages, the basic steps are the same and are the following: # Copy all files unique to the chosen package into your working copy. Add the files to your solution as desired; I recommend that new project filters be created to keep the package code separate from everything else.# Overwrite all of Chris' files that you did not modify during development that are also present in the chosen barebones package.# Merge together files that you've modified from Chris' reference implementation and that are also present in the chosen barebones package. [mailto:hkamal-al-deen@learn.senecac.on.ca Let me know if any problems arise during this step :)] '''Note that some files don't necessarily need to be copied in (such as Camera.cpp). Use your discretion when deciding on what parts of the framework to filter out and hopefully nothing breaks??''' For the combined package and the physics-only package, this is all that you need to do to get going. To actually get stuff simulating, take a look at some of [[Team_Guardian_Physics#How_to_Use |this code]]. For the collision only package, read on... === Collision Detector Only === After copying/merging in the requisite files from the collision detection package and adding all new files to your solution, the project should now be compiling cleanly. To get any use out of the collision detection, you will want to create a collision space, assign it to be the global collision space and implement the iRigidBody interface for your custom object classes. Let's take a look at this one step at a time:<ol><li>Create a global collision space for all of your collision geometry. For the time being, the only collision space available is the simple one so let's do that:<pre>#include "iCollisionSpace.h"#include "iSimpleCollisionSpace.h"
This is iCollisionSpace* collisionSpace = CreateSimpleCollisionSpace();</pre></li><li> Assign this collision space to be the framework in its default stateglobal collision space for all collision geometries that will be created from this point on. Integration is relatively straightforward and This should be performed in three steps:done during initialization and prior to collision geometry creation.<br/><br/>
# Copy all files unique From a design perspective, it should be possible for multiple collision spaces to coexist in the physics framework into your working copy. Add world but at the files moment this is not implemented correctly so you will have to your solution as desired; I recommend that new project filters be created to keep live with a single global collision space, unfortunately.</li><li>Implement the physics <code>iRigidBody</code separate from everything else.# Overwrite all > interface in some of Chris' files that you did not modify during development that are also present in the physics framework barebones packageyour custom classes.# Merge together files that you've modified from Chris' reference implementation and that are also present A collision geometry requires a RigidBody instance to be passed in the physics framework barebones package. [mailto:hkamal-al-deen@learn.senecac.oncreation (it can also be attached to a RigidBody at a later time); let's take a look at why this is so.ca Let me know if any problems arise during this step :)]</li></ol>
'''Note that some files don't necessarily need to be copied in (such as Camera.cpp). Use your discretion when deciding on what parts of the framework to filter out.'''==== CollisionGeometry and RigidBody ====
The barebones package assumes A collision geometry uses a RigidBody for location, rotation and velocity inforomation. When implementing the iRigidBody interface, it is crucial that your working copy is based on sample 28 but <code>getRBDynamics()</code> return an up to date representation of the object's state in the world. At minimum, the following properties should integrate well be consistent with all samples 16 real-time attributes of the object:<pre>Vector position : Current position of COMVector com : Center of Mass offset.PhysicsType physicsType : Type of physics applied to body, defaults to Falling (possibly 22BUGGY, use PHYS_Falling and PHYS_Floating for now) and above.Matrix orientation : Matrix representing rotation in XYZ</pre>
=== Physics Simulator Only ===A couple of notes:; PhysicsType physicsType : Always return PHYS_Falling or PHYS_Floating. The collision space will filter out collisions between PHYS_FixedInSpace objects to avoid unnecessary collision checks.; Matrix orientation : Ensure that the rotation matrix has not been contaminated with any scale information, otherwise the collision tests may not return correct results. Oh, this might also be a good time to note that scaling is '''not supported''' by the physics simulator or the collision detector :) Having said that, this should be enough to get your objects up and colliding. To detect all collisions at a given time in the world, call <code>populateContactList()</code> on the collision space. Retrieve the list of collisions by calling <code>getContactList()</code>; to find the number of contacts in the world, call <code>getNumContacts()</code>. For more/misc information, see [[Team_Guardian_Physics#RigidBody |RigidBody Reference]] and the [[Team_Guardian_Physics#CollisionSpace |CollisionSpace Reference]].
== Framework Reference ==
=== Functions ===
; Vector getWorldCOM() const : '''REMOVED IN NEXT UPDATE''' Returns the world position of the COM with respect to this body.
; Vector getVelocityAtWorldPoint(const Vector& p) const : Given a point in worldspace, returns its speed taking into account velocity and angular velocity.
; Void setInverseInertiaTensor(const Matrix& i) : Sets the inverse inertia tensor of this body. Automatically sets the inertia tensor as well by inversing the incoming matrix. DOES NOT NEED TO BE CALLED AFTER CALLING setInertiaTensor()
; Matrix& getInverseInertiaTensor() : Returns the inertia tensor or inverse inertia tensor contained by this object.
; Void ApplyImpulse(const Vector& impulse, const Vector& pointOfApplication) : Applies a given impulse instantaneously onto this object at a given world point of application. Can be used to shoot or prod objects.
 
==== Functions Coming In Next Update ====
; void attachTo(RBDynamics* p) : Attaches this RBD to a given RBD. It is not required to call this function after calling PhysicsFrame's AttachTo(PhysicsFrame*) if the RBD resides within the RB of the PhysicsFrame.
; RBDynamics* attachedTo() const : Returns the RBD this RBD is attached to or NULL.
; RBDynamics* attachmentRoot() const : Returns the root of the attachment chain of this RBD.
; float getMass() const : Returns the mass of the RBD at the root of the attachment chain.
; Vector getWorldPosition() const : Returns the world-space position of this body's COM taking into account parent position/orientation.
; Matrix getWorldOrientation() const : Returns the world-space orientation of this body taking into account parent orientation.
== Other Topics Reference ==

Navigation menu