Physics Howto?
by Demolishun · in Torque 3D Professional · 02/21/2012 (11:38 pm) · 2 replies
I am reading through the Physics code for T3D and I am having issues understanding how it is used. I see that there is a reference in the Player.h to a PhysicsPlayer object which is derived from PhysicsObject. What does this do exactly for the Player? Does this just allow the Player to participate in the physics implementation? So would it just be a bounding box shaped rigid body at this point?
What I am hoping to understand is how to redefine the Physics for a player or other objects to have joints and the like.
What I am hoping to understand is how to redefine the Physics for a player or other objects to have joints and the like.
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
Thanks so much. That will definitely help me understand the physics system.
03/23/2012 (9:52 am)
@Ross,Thanks so much. That will definitely help me understand the physics system.
Associate Ross Pawley
In the case of the player, the PxPlayer/BtPlayer handles the physics engine's character controller implementation and exposes some functions that the Player class needs to update the information of the PxPlayer/BtPlayer.
So when the Player's velocity/movement information is updated, that info gets passed in to the appropriate PhysicsPlayer function, which updates the physics simulation for the character controller (on the actual implementation class, PxPlayer/BtPlayer). You can choose (at least for PhysX) which type of collision object the controller will use (box or capsule, capsule is the default IIRC).
If you're trying to implement a more complex character controller, I suggest taking a look into the PxPlayer class. What you'll need to do is implement some new functions for passing in the data related to the configuration of the character (i.e., the shapes for each bone, the joints etc.).
Assuming you're implementing a ragdoll system, you'll need to set up some state variables for whether the Player is currently ragdolled or not, as well as functions for setting the state over the network (that said, for a ragdoll implementation, it probably should be set up separately from the PxPlayer class, since you'd still use a regular controller *until* it's ragdolled).
Then you'll need to implement a method into PhysicsPlayer/PxPlayer (or your custom PxRagdoll class, which you'd keep an instance of in PxPlayer, and expose use of into PhysicsPlayer) that grabs all the bone data for the character when its ragdolled, and use that function to get the data into the Player's bones (i.e., if Player is ragdolled, use the PhysX bone information instead of the animation information).
Anyway, hope this was helpful.