Game Development Community

multiple animations in one dsq file

by Jeff Yaskus · in Torque Game Engine · 02/02/2010 (5:24 pm) · 13 replies

How do you load a DSQ when it has multiple animations within it ?

It seems the normal method wouldn't work --

For example;

A friend created a "beast" creature model and it has (4) animations ; idle, run, attack, die ... but he exported all in the same DSQ file.

Now its up to me to script it --

Using what I've known so far -- I'd expect something like this ... in my beastShape.cs file.
baseShape = "./beast.dts";
   sequence0 = "~/data/shapes/beast.dsq run";
   sequence1 = "~/data/shapes/beast.dsq attack";
   sequence2 = "~/data/shapes/beast.dsq idle";
   sequence3 = "~/data/shapes/beast.dsq die";

or would it be like this ?
sequence0 = "~/data/shapes/beast.dsq run attack idle die";

Any suggestions ?

#1
02/02/2010 (5:28 pm)
I don't think there's any way to do this in stock code. The latter method won't work because TSShapeConstructor just doesn't work like that, and the former method won't give the desired results because it will play the entire beast.dsq file for each animation, which will look a bit messed-up. You'll either have to jump into the code for TSShapeConstructor and figure out a way to designate that an animation is contained in a specific part of a DSQ file (and then modify Player for the same), or just get your friend to export the normal way ;P.
#2
02/02/2010 (5:33 pm)
You need separate DSQs for each sequence. A source file (.3ds, .Mb whatever your art application saves) can usually house multiple sequences, but only for the purpose of outputting separate DSQs.

If all the animations are in one sequence, there MIGHT be a way to script it to start each animation sequence with a frame offset, but it's just complicated for no reason. Tell your friend to re-export the sequences as separate DSQs.

For example:

baseShape = "./beast.dts";  
sequence0 = "~/data/shapes/beast_Run.dsq run";  //beast_Run.dsq
sequence1 = "~/data/shapes/beast_Attack.dsq attack";  //beast_Attack.dsq 
sequence2 = "~/data/shapes/beast_Idle.dsq idle";   //beast_Idle.dsq
sequence3 = "~/data/shapes/beast_Die.dsq die";  //beast_Die.dsq
#3
02/02/2010 (5:56 pm)
Indeed, what you have there is not standard, and as the Daniel(s) said, you should go the way it was made:

You can have your animations within the DTS, or have a DSQ for each animation, and apply those to certain DTS(s) using TSShapeConstructor.

While possible, go in the direction the framework is expecting you to do things, or you'll lose tons of time.
#4
02/02/2010 (7:10 pm)
I imagine, I could split up the sequences fairly easily and quickly...for a 'one time fee' or code swap.

rex@brokeassgames.com

...all I'd need is the DTS and the 'multi'/DSQ, first; to see how convoluted it might be. Might even be done, 'while you wait'....!
#5
02/02/2010 (7:33 pm)
I found my answer through trial and error ... you list them all in one line, in the order they exist. (ie. my 2nd example)

maybe its an un-documented feature or such - but oddly enough, it does work.
#6
02/03/2010 (5:06 pm)
Well... I don't fathom HOW it worked, but if it works, that's all that matters. How are you calling the animations? And how does it know which frames to play?
#7
02/03/2010 (5:42 pm)
Wow... odd. I'm going to have to read that code again ;P.
#8
02/03/2010 (5:56 pm)
I was surprised too ... it works fine as long as I have them listed in the proper order. I call the animations just like normal using setActionThread("run"), etc...
#9
02/03/2010 (6:09 pm)
Hmm, I wouldn't have expected that to work though it makes sense that it would. When parsing the string for the tags the parser would be space delimited and the semicolon would be the delimiter to stop parsing. I think this definitely falls under the undocumented feature category.
#10
02/03/2010 (6:41 pm)
I would be more prone to put it in the "lucky bastard" category.
#11
02/03/2010 (8:49 pm)
I'm not 'too' surprised, as the 'per'sequence data is stored in the DSQ, 'name' being one of them, along with FrameCount, and the other 'matter arrays'/flags that get set.

Our DSQTweaker, reads all these flags and lets you know what is in each 'sequence' of a multiDSQ[as I calls em].

...We're trying to get this functionality working, to allow the 'extraction' of each sequence of a 'multiDSQ' and saving this out to a new DSQ file, FTW!

It is still a good idea to store animation data in single DSQ files, as when you want to fine tune transform data on a per node basis...as in only have lower body nodes holding data in a movement sequence, to help with upper body item holding, etc...glad it all worked out; you really can do some tricks with DTS & DSQ. T3D and TSShapeConstructor, are the BOMB! So much more you can do there, with those two formats and DAE...
#12
02/03/2010 (10:53 pm)
I just don't see how the engine knows which keyframes to play for each sequence :P. But then, Torque has surprised me before...
#13
02/04/2010 (8:36 am)
(snip)TSShapeInstance::getKeyframeCount(snip)
-actual line of Source edited...or here
TSShapeInstance::getSequence

...perhaps here? I 'think' that TGE 'thinks' all 'Frames' of a sequence are 'KeyFrames'...

Working on DSQTweaker taught me a little about the formats, more than I thought!

...all I do know is that I can read/edit all these flags with DSQTweaker, :)!...which is how we wanted it, reading all the data in the file, on a per-sequence basis!

...join us on the Darkside of the Force, Daniel....we doin' 'stuf'!