exporting animated 3ds max files via Collada into T3D
by Steve · in Torque 3D Professional · 06/01/2009 (6:35 am) · 5 replies
I thought I had this figured out once, but I guess I didn't. Also, I moved this from "artist's corner" because I did not get any replies.
I am using T3D. My artist is using 3ds max 2009. She exported an un-animated model (a gate, sort of) using the Collada exporter. I loaded it fine into T3D, no problems.
Now, she added an animation whereby the gate swings open and closed. Whenever I try to open this new .DAE file in T3D I get an "unhandled exception error". I get the option to debug in VS2008, and T3D crashes.
I know that I need to set up a datablock and an OnAdd function to get the animation to play. However, even if I did this incorrectly, should trying to import this .DAE file crash the whole game?
I don't know how to proceed. I have been trying to get this to work for about 2 days now, and the good news is I'm learning alot, lol. The bad news is, I can't get it to work. I know nothing about 3DMax. At this point, I am split 50 - 50 over whether the problem is in my T3D scripts or in something that needs to be set in 3DMax. Torsion detects no error in my scripts, but to my eternal shame, I must admit that I don't (yet!) fully understand what the scripts do.
I have searched the torque forums and I have not been able to find a step by step guide to writing the scripts necessary to get a .DAE animation to run. I can only find bits and pieces, and maybe of them were before the new Collada exporter. The closest I have come is Lara Engebretson's video, which I am told, is not up to date anymore. Can anyone find it in their heart to post an idiot's guide to creating these scripts? I am sure I could do it, if i just had a template to follow!
Also, can anyone please give me the basic minimum settings or a step by step guide to export via Collada the most basic animated object?
Here are the scripts I wrote:
in scripts/server/ I created gate.cs and put there:
datablock StaticShapeData(GateAnimated)
{
category = "AnimatedObjects";
shapeFile = "~/art/shapes/collada/New/GateAnimated.cached.dts";
};
function GateAnimated::onAdd(%this,%obj)
{
//%obj.playThread(0,"ambient");
}
function staticshapedata::create(%block)
{
%obj = new staticshape()
{
datablock = %block;
};
return(%obj);
}
and in server/scripts/game.cs :
exec("./gate.cs")
Thanks in advance for reading my post, and any help or even just pointing me to where I can figure this out for myself.
I am using T3D. My artist is using 3ds max 2009. She exported an un-animated model (a gate, sort of) using the Collada exporter. I loaded it fine into T3D, no problems.
Now, she added an animation whereby the gate swings open and closed. Whenever I try to open this new .DAE file in T3D I get an "unhandled exception error". I get the option to debug in VS2008, and T3D crashes.
I know that I need to set up a datablock and an OnAdd function to get the animation to play. However, even if I did this incorrectly, should trying to import this .DAE file crash the whole game?
I don't know how to proceed. I have been trying to get this to work for about 2 days now, and the good news is I'm learning alot, lol. The bad news is, I can't get it to work. I know nothing about 3DMax. At this point, I am split 50 - 50 over whether the problem is in my T3D scripts or in something that needs to be set in 3DMax. Torsion detects no error in my scripts, but to my eternal shame, I must admit that I don't (yet!) fully understand what the scripts do.
I have searched the torque forums and I have not been able to find a step by step guide to writing the scripts necessary to get a .DAE animation to run. I can only find bits and pieces, and maybe of them were before the new Collada exporter. The closest I have come is Lara Engebretson's video, which I am told, is not up to date anymore. Can anyone find it in their heart to post an idiot's guide to creating these scripts? I am sure I could do it, if i just had a template to follow!
Also, can anyone please give me the basic minimum settings or a step by step guide to export via Collada the most basic animated object?
Here are the scripts I wrote:
in scripts/server/ I created gate.cs and put there:
datablock StaticShapeData(GateAnimated)
{
category = "AnimatedObjects";
shapeFile = "~/art/shapes/collada/New/GateAnimated.cached.dts";
};
function GateAnimated::onAdd(%this,%obj)
{
//%obj.playThread(0,"ambient");
}
function staticshapedata::create(%block)
{
%obj = new staticshape()
{
datablock = %block;
};
return(%obj);
}
and in server/scripts/game.cs :
exec("./gate.cs")
Thanks in advance for reading my post, and any help or even just pointing me to where I can figure this out for myself.
#2
Thanks!
06/01/2009 (4:05 pm)
Please email me the file at mattf@garagegames.com and I will make sure the crash gets looked into.Thanks!
#3
I found two different problems in your model:
The first is that your animation is unnamed in the collada file. This does not violate the collada spec, but does cause the loader problems when it tries to generate a 3space sequence. This is what actually causes the crash.
The second is that several nodes in the model have the same name. Again, this is ok under collada, but not for Torque (actually the model will probably load and display ok, but you'd have problems if you tried to find a particular node by name!).
Both these issues will be handled automagically in the next T3D beta, but for now you could:
a) try to correct the issues in your modeling program prior to export (may not be possible depending on how much control the exporter gives you)
b) manually edit the collada file to set the animation name attribute, and make sure your node names are unique. eg.
06/02/2009 (8:23 pm)
Hi Steve,I found two different problems in your model:
The first is that your animation is unnamed in the collada file. This does not violate the collada spec, but does cause the loader problems when it tries to generate a 3space sequence. This is what actually causes the crash.
The second is that several nodes in the model have the same name. Again, this is ok under collada, but not for Torque (actually the model will probably load and display ok, but you'd have problems if you tried to find a particular node by name!).
Both these issues will be handled automagically in the next T3D beta, but for now you could:
a) try to correct the issues in your modeling program prior to export (may not be possible depending on how much control the exporter gives you)
b) manually edit the collada file to set the animation name attribute, and make sure your node names are unique. eg.
<library_animations>
<animation name="gate_anim">
...
<node id="node-Scene_Root" name="Scene_Root">
<node id="node-Gate_2" name="Gate">
<node id="node-Gate" name="GateA">
</node>
<node id="node-Building_Top" name="Building_Top">
</node>
<node id="node-Gate_1" name="GateB">
</node>
</node>
</node>
#4
I would have done something like
I will tell your artist I want 2 animation threads. The first I want is "ambient", and the second I want is the gate opening "openTheGate";
If you have animations in your collada shape that use bones it would be wise to name them uniquely. I never tried to name them the same thing so I am not sure what that would do.
Side note: Just remember setThreadDir only works while the animation is playing.This example script would make your gate open and close every 10 seconds.
06/03/2009 (3:02 am)
First off I've never done this::datablock StaticShapeData(GateAnimated)
{
category = "AnimatedObjects";
shapeFile = "~/art/shapes/collada/New/GateAnimated.cached.dts";
};
function GateAnimated::onAdd(%this,%obj)
{
//%obj.playThread(0,"ambient");
}I would have done something like
datablock StaticShapeData(GateAnimated)
{
category = "AnimatedObjects";
shapeFile = "~/art/shapes/collada/New/GateAnimated.dae";
};
function GateAnimated::onAdd(%this,%obj)
{
%obj.playThread(0,"ambient");
%obj.openGate();
}
function GateAnimated::openGate(%this)
{
%this.stopThread(0);
%this.playThread(1, "openTheGate");
%this.schedule(5000, "closeGate"); //in 5 sec close the gate
}
function GateAnimated::closeGate(%this)
{
//Example setThreadDir( thread , forward(bool) )
%this.setThreadDir(1, false); //this means backwards
%this.schedule(5000, "openGate");
}I will tell your artist I want 2 animation threads. The first I want is "ambient", and the second I want is the gate opening "openTheGate";
If you have animations in your collada shape that use bones it would be wise to name them uniquely. I never tried to name them the same thing so I am not sure what that would do.
Side note: Just remember setThreadDir only works while the animation is playing.This example script would make your gate open and close every 10 seconds.
#5
@Jesse: I will try your scripts, if mine don't work, but that part is now on hold since I know the collada file needs work first. My biggest problem was that I didnt know whether is was my scripts or the collada file which was causing the game to crash outright. I feel a lot better now.
06/03/2009 (7:57 am)
@everyone: from the bottom of my heart, truly, I would like to thank you all for the help! @Jesse: I will try your scripts, if mine don't work, but that part is now on hold since I know the collada file needs work first. My biggest problem was that I didnt know whether is was my scripts or the collada file which was causing the game to crash outright. I feel a lot better now.
Torque 3D Owner Steve
YP productions