Game Development Community

Need step-by-step instructions for importing collada player models

by Judy L Tyrer · in Torque 3D Professional · 07/05/2009 (12:13 pm) · 12 replies

This is a documentation request because the documentation is really confusing on how to get a player into the game starting with a collada model. I've dug around in the Collada docs and the T3D docs and the forums and I think I have pieced together enough, but it hasn't been easy and with the way the docs are evolving, I think this is one area where "easy" would be awesome. Something like "So you have a model in <insert random 3D art program here> and you want to get it and all its animations into Torque" and then very simple don't explain all the nuances but give me links if I care instructions.

So, apparently I need to put all my animations in the .max file (oh yeah, I'm in 3DS) from which I am exporting, a departure from previous version. Then I need to export the whole shebang to Collada and I think I need to check create clip, since the documentation says I'll need an animated clip in order for the animation to run. But do I need the animation sample and, if so, should I choose the longest animation as the sample length? I'm going to try both, but it would be nice to know.

The second issue is how to go from player.DAE to the player.dts and animation.dsq files I'm going to need. The TSShapeConstructor documents are so full of typing numbers without an explanation of what they mean that it makes me want to crawl under the bed and hide. AND it still doesn't explain how to get from *.DAE to *.dsq.

So while my model is exporting I'm just writing that I'd really like something quite specific and very noobish. And if something like this exists and I just haven't found it yet (highly possible), if someone could be so kind as to aim me in the right direction I'd be forever grateful.

I promise I'll hire a REAL artist soon.

#1
07/05/2009 (12:47 pm)
I am new to all this, and I don't know a lot about the legacy stuff, but since today is still July4th weekend, and you aren't likely to get any expert opinions till monday or so, I'll do the best I can.

1. forget about <animation-clip>. Just make one long animation. T3D has that new tool, i forget what its called, its on the tool bar, where you can cut it into sequences now. I did it with a drawbridge and, much to my amazement, it was easy. How easy it will be with players, I don't know.

2. You don't have to (I don't think) worry about how to get the thing into DTS. T3D does that for you when you import it as a Collada (DAE) file.

3. TSShapeConstructor is only used after you get the model in. It can do various things like add collision meshes and what not. Lol, I don't know what the "what not" is, but I have successfully added a collision mesh.

4. If you are familiar with the old way of doing it, you can forget about Collada and do it that way. It all still works.

5. Hell no, it hasn't been easy!

6. I'd like those docs too.
#2
07/05/2009 (12:58 pm)
*sigh*

I got a cached .dts file, but no animations. I looked through the collada file and even though I had both a root and run animation sequence in the .max file, I only have one animation listed (the one that puts the mesh into the root pose, but not the animations themselves).

This is highly confusing and I'm not convinced it needs to be. It's like I'm missing some key piece of information and I can't seem to find it anywhere.
#3
07/05/2009 (1:22 pm)
Quote:
I got a cached .dts file, but no animations. I looked through the collada file and even though I had both a root and run animation sequence in the .max file, I only have one animation listed

I haven't used collada for player shapes.... but this might work to make the animations work, give this a try:
  • create your player datablock like normal
  • create a YOURDTSSHAPENAME.cs (it's the name of your DTS) in the "art/shapes/player/yourshapesdirectory" directory. This file will be automagically executed when the shape loads, if they are both located in the same place.

  • In this file add
    function YOURDTSSHAPENAMEDts::onLoad(%this)
    {
       %this.addSequence("./root.dsq", "root");
       %this.addSequence("./forward.dsq", "run");
    }
    
    singleton TSShapeConstructor(YOURDTSSHAPENAMEDts)
    {
       canSaveDynamicFields = "1";
       baseShape = "art/shapes/players/yourshapesdirectory/YOURDTSSHAPENAME.dts";
       upAxis = "DEFAULT";
       unit = "-1";
    };

    But again, I don't use collada, so I don't know how much help that will be.

    Also, in Torque 3D Resolved Bugs sub-forum -> Strange Player loading interdependencies by Jeff Faust, there is a fix to allow the use of the old style shape constructor.
    #4
    07/05/2009 (7:46 pm)
    Thanks for the help. The day was almost a total bust, but at long last.. it's really really BAD, even for engineering art, but it's a mesh with an animation. I had to export the .dsq from the dts exporter AND have the animation embedded in the .DAE file to get it to work.

    Of course, I have no idea why the right arm runs through the body, over the head, and out the other side, but the good thing is the IK works. The spine is doing it's damnedest to comform. And the run animation pulls the knees up to the chest and waddles like a duck.

    If someone can give me instructions for posting a screenshot, I'll be happy to let you all laugh. It's BAD.

    #5
    07/05/2009 (10:02 pm)
    Ah, sorry to hear that. I don't think that such things as skeletons and animations export to differing formats all that well... I'm holding out on using collada myself, good 'ol DTS and DSQ 's all the way for me.

    To post a screenshot, you'll need to have them uploaded somewhere, and you'll need the direct url of it's location -- which you place in the [ image ] url [ /image ] tags (remove the spaces to make it work).
    #6
    07/05/2009 (10:44 pm)
    Hi Judy,

    The addition of Collada to the art pipeline means you have several options when it comes to getting models into Torque. I'd agree with you that the possible workflows need to be better documented though. Depending on where you're getting your models and animation data from, you could:

    1. Export your model and all of your animations within the one .DAE file. You can use the new ShapeEditor tool to split them up into separate sequences if required. This is probably the easiest path, since you only have a single file to worry about

    2. Export individual animations to .DAE or .DSQ files, then use TSShapeConstructor to add them to a .DAE or .DTS model at load-time. This approach is useful if you want to share a set of animations with a number of character models that have the same skeleton.

    Quote:I got a cached .dts file, but no animations. I looked through the collada file and even though I had both a root and run animation sequence in the .max file, I only have one animation listed

    Many Collada exporters do not support the <animation_clip> element, and just put the whole animation timeline into a single sequence. You can split this up in Torque using the ShapeEditor tool (which is also a great way to preview Collada and DTS shapes and check their animations!).

    Quote:The second issue is how to go from player.DAE to the player.dts and animation.dsq files I'm going to need.

    When Torque loads a Collada file (.DAE), it saves the converted model to a .DTS file, so that it will load much faster next time. If there were any animations in the .DAE, they will be in the .DTS as well. The cached.dts is just a faster way for the engine to load the .dae.

    There is no way (or need?) to convert .DAE to .DSQ.

    Quote:I had to export the .dsq from the dts exporter AND have the animation embedded in the .DAE file to get it to work.

    Hmmm. You should only have to have one or the other. If you send me the file I'll be happy to take a look at what might be going wrong.
    #7
    07/18/2009 (11:33 am)
    Thanks for the help. Sorry it's taken so long to get back to you (and it's taken so long to get back to THIS *mutters something rude about day jobs and crunch*).

    So I started over (since the animation was so screwed up anyway) and now I have a good animation and when I put it in the shape editor and broke it up it all looked good BUT... (you knew there was a but, right?)

    How do I save the changes? There was no "save" button on the mission editor, presumably because I hadn't changed the mission file as this is my player character.

    When I left the editor, none of the changes were saved. The DAE file was just the same as it was earlier and, thus, none of the animations were named and, thus, none of them show up in game. *cries*

    By the way, if you need someone to proof-read the documentation on how to get a collada exported character player into the game, I volunteer!!! Also, could you make one of the player characters in the demo or pack collada so there would be an example to follow? That way I could edit the collada file myself (I know XML). I just don't know where in the heck to put the animation names.

    Oh, and while I'm kvetching, the shape editor expects the names to be "bip01 pelvis" but 3D Studio creates them as bip01_pelvis so they don't show up. And there's a red X for mount0-32 which should go away if there is any mount# in the file. And what is AIRepair node and why do I need it?

    MY KINGDOM FOR SOME DOCUMENTATION!!!!

    Did I mention it would be really nice if this were documented?
    #8
    07/19/2009 (8:20 pm)
    Quote:How do I save the changes? There was no "save" button on the mission editor, presumably because I hadn't changed the mission file as this is my player character.

    The ShapeEditor save button is located in the 'Properties' window as shown below:

    teamrobertson.co.nz/tmp/shape_editor_save.png
    Pressing this button will save the changes to a TSShapeConstructor script, in a file with the same name as your model except .cs extension.

    Quote:That way I could edit the collada file myself (I know XML). I just don't know where in the heck to put the animation names.

    There should be no need to manually modify the XML => nor would you want to, since re-exporting the model would overwrite all of your changes! The Shape Editor should do everything you need to split animations, set cyclic/blend flags and add triggers. If there is something missing, please raise it as a feature request.

    Quote:Oh, and while I'm kvetching, the shape editor expects the names to be "bip01 pelvis" but 3D Studio creates them as bip01_pelvis so they don't show up. And there's a red X for mount0-32 which should go away if there is any mount# in the file.

    Both good points => the Hints tab currently just does a simple string compare. I need to make it a bit smarter.

    Quote:And what is AIRepair node and why do I need it?

    Hovering the mouse over one of the Hint tab entries will give a short description of the node or sequence. In the case of AIRepairNode it says 'unused'. I believe that ShapeBase does a lookup for this node, but it is not actually used anywhere. Likely a legacy from Tribes.

    Quote:MY KINGDOM FOR SOME DOCUMENTATION!!!!

    Did I mention it would be really nice if this were documented?

    Updated docs for the Shape Editor tool, the Collada loader and TSShapeConstructor are with MichP, pending publication. At this stage there is still no tutorial for getting a collada player character into T3D, but I believe there are plans for this.
    #9
    08/02/2009 (8:24 pm)
    Hi Judy,

    Updated docs for the Shape Editor, Collada loader and TSShapeConstructor have now been published to the official T3D docs page (http://docs.garagegames.com/torque-3d/official/ in the Artist Section).

    Quote:Oh, and while I'm kvetching, the shape editor expects the names to be "bip01 pelvis" but 3D Studio creates them as bip01_pelvis so they don't show up. And there's a red X for mount0-32 which should go away if there is any mount# in the file.

    Done and done.
    #10
    08/23/2009 (8:17 am)
    hey guys,
    I am trying to export a simple shape from max to COLLADA , but when it's loaded all the bones appear as shapes.I manages to run the animations, but the bones are still visible. How do you fix this?
    #11
    08/23/2009 (2:14 pm)
    This is a guess, but does your hierarchy have the correct mesh and detail? I.e., do you have a detail2 and mesh2 to match and are the ending numbers different than your bone numbers? I haven't tried LOD with collada yet, but I'm guessing it's probably similar such that for every detail you have to specify the mesh that matches explicitely.
    #12
    08/23/2009 (3:07 pm)
    I actually solved the problem but forgot to reply.

    The problem was that I was using meshes for bones.
    In the DTS exporter it doesn't matter if you use a bone or a mesh object for a bone. But COLLADA needs only bone objects to represent what is a bone (and i think Michael Perry should add this into the exporter documentation).

    I've just fixed it and now it works flawlessly.
    LODs seem to need the same hierarchy setup to work. I haven't tested them yet too.
    Anyway thanks for your support.