Game Development Community

how to load objects with XML?

by deepscratch · in Torque Game Engine Advanced · 02/17/2009 (3:13 am) · 5 replies

hi all,

question is: how can I load an object at startup into tgea using XML?

what I am trying to do is load up a character that uses a physx skeleton into the game, and have it work as a regular character until it gets damaged, then uses ragdoll variables that are in the XML file to take over the animation thread.

I know it has been done (dinosaurs, and some others that I have seen vids of). but nowhere is there any info on how to actually do it.

any help would really be apreciated.

thanks

#1
02/17/2009 (6:52 am)
Your question is far too broad. What do you mean by "object using XML"? A model stored in some sort of XML format? Just IK information to be added to a DTS model? Torque only accepts DTS models as animated characters. The DTS format has no support for IK constraint information, since it doesn't feature any kind of ragdoll animation whatsoever.

However, the TSShapeInstance class allows you to access and modify the rotations of each joint, and even have the existing animation be blended against the overridden values. But if you want physics-driven ragdoll, you need to code it yourself or find a resource that implements it.

I remember a ragdoll pack, but AFAIK it was just a massive amount of death animations.
#2
02/17/2009 (8:57 am)
@Manoel,
what I'm trying to do is call an XML document that contains the physx rig information that I have attached to the bip skeleton of my character models, upon their death.

by doing so, the physx rig becomes a group of jointed physx actors which react to impulses, gravity, explosions, basically it becomes a ragdoll.

my question is how do I get the engine to call the XML when a character recieves death damage or a vast amount of impule damage from, lets say a nearby grenade. if the damage is not till death, the XML releases control back to the engine after a period af time calculated by the damage taken.

possibly this could be done with regular scripting?
#3
02/17/2009 (9:16 am)
Since you're asking if this can be done via scripting, I assume you're using stock Torque. So no, it can't be done via scripting. Torque has no ragdoll, nor physx support out-of-the box.

XML files are just data stored in text format (you cant "call" them and they can't do things on their own). Torque as it is doesn't knows what to do with them.

I'm not sure about ragdolls, but I remember some guys integrating physx in Torque on the forums. Didn't seem to be doing anything too fancy yet, so no physx on animated models for now.
#4
02/17/2009 (10:20 am)
@Manoel,

I have integrated physx a while back already, and I do believe that it can be done via scripting, if you can get a weapon to fire a projectile, and have that projectile do damage, or leave a decal, then this too is possible. the trick is to know how.
#5
02/17/2009 (11:11 am)
Ah, you have physx going on. It probably knows how to use the XML you have.

When you want your character to become a ragdoll, you'll need to tell physx to load the XML and position all physx simulation joints to match the current positions and rotations of the now-dead character's joints, disable Torque animation control on all joints and on every advanceTime read the physix joints rotations and copy them back to the player model joints.

That'll need to be done in C++. The only thing you should do via script is probably add a field to the PlayerData where you can specify the physx ragdoll XML (that way you don't have it hardcoded) and add a console method to the Player class to enable the ragdoll (and call it when the character "dies"), since you can't access all joints transforms via script by default.

(Also anything the character ragdoll will collide with needs to be properly registered with physx.)