Game Development Community

Animating SimpleBox Tutorial

by rlevine · in Torque Game Engine · 04/04/2007 (10:09 am) · 6 replies

I've been having trouble getting our animations into Torque, so I started going through tutorials in an effort to figure it out. So far, I've gone through the tutorial located here but as it is written for TGE1.3, I'm not sure if it is still current, or there is anything above and beyond what's listed there that I need to do. I have TGE1.5 and TGEA and get similar results on both (though all my log files listed here are from TGEA).

I went through the whole tutorial, exported all the .dst and .dsq files, created a simpleBox.cs file and threw them all into a folder with the texture file. I exec("~/data/shapes/simpleBox/simplebox.cs") from server/scripts/game.cs, and get no warnings in the console upon compiling and running the script file. My simpleBoxDTS shows up under the 'Shapes' category in the editor (after I added a category field to the datablock), but I run into problems when I actually try to place the object.

When using this as my script file:
datablock TSShapeConstructor(simpleBoxDTS)
{
        category = "SimpleBoxAnim";
	baseShape = "./simpleBox.dts";
	sequence0 = "./simpleBox_bendFrontBack.dsq bendFrontBack";
	sequence1 = "./simpleBox_bendSide.dsq bendSide";
	sequence2 = "./simpleBox_look.dsq look";
	sequence3 = "./simpleBox_jumpForward.dsq jumpForward";
	sequence4 = "./simpleBox_jumpUp.dsq jumpUp";
	sequence5 = "./simpleBox_fallBack.dsq fallBack";
};

Immediately after I click to place the simpleBox animation, in the console log I see an error that states:
Quote: (0): Unable to find function TSShapeConstructor::create

So, to counter that, I added this to my simplebox.cs:

function TSShapeConstructor::create(%block)
{
    %obj = new TSShapeConstructor()
            {
                datablock = %block;
            };
       return %obj;
}

Now when I try to place the object, I get the following in cosole:

Quote:starter_water_demo/data/shapes/simpleBox/simplebox.cs (18): preload failed for (null): .
(this error is the one I get in TGEA, but other than the path, i'm pretty sure it's the same as what I was getting in TGE1.5).
You'll get a similar error if you try instantiating a TSShapeConstructor in the console window without giving it a datablock name (only the path changes to ). I suspect that this may be where I went wrong as nothing about adding this was mentioned in the tutorial, but the tutorial only talks about viewing the results in showtool, not in-game.

I went through the simpleBox tutorial one more time, repeating all the steps, and doing my best to make sure I followed all the directions, but seem to keep coming up with this result. The only difference between my simplebox.cs file, and the one given in the example is that I add a 'category' member to the datablock so I can access it in the editor.

The animation plays in showtool with the models I exported, and I think the simplebox.dts is good because I can place it as a static shape with the editor. I'm a bit stumped, and before I start trying to import our own animations, I need to make sure I can load the simple one correctly.

Anybody see anything I may have missed?

-Gavin

#1
04/04/2007 (10:12 am)
Ive always done the simple box tutorial, with Animation embedded inside of the DTS.
#2
04/04/2007 (10:30 am)
@Surge

I was able to get that tutorial working correctly (with the animations embedded into the DTS), but it doesn't seem to like our skin and bone animated models. When I applied the same steps to our in-house models, it animates, but it also displays the first frame of the animation throughout the entire cycle. I can tell that there is another mesh underneath it that is animating as parts of it stick out and overlap. This happens both in showtool and in the game. I can post a few screenshots if my description doesn't make sense =/ My reading seemed to suggest that the dst+dsq method was what I would need in order to get our in-house models animating properly, but if there is another way, I'm willing to give it a try. Perhaps I should try the embedded DTS method and adjust my node hierarchy in Maya?

-Gavin
#3
04/04/2007 (12:59 pm)
I don't know if this just isn't documented very well or I just completely missed it, but it seems you need to have both a StaticShapeData datablock and a TSShapeConstructor datablock in order to get sequence animations to work. I'm not sure if that is the preferred way to do it or not, but for reference here's what I ended up doing to get my animations to work with dst + dsq sequence files.

datablock StaticShapeData(simpleBoxDTS)
{
    category = "Anims";
    shapeFile = "~/data/shapes/simpleBox/simpleBox.dts";
};

datablock TSShapeConstructor(simpleBoxDTSSequence)
{
 	baseShape = "~/data/shapes/simpleBox/simpleBox.dts";
	sequence0 = "~/data/shapes/simpleBox/simpleBox_bendFrontBack.dsq bendFrontBack";
	sequence1 = "~/data/shapes/simpleBox/simpleBox_bendSide.dsq bendSide";
	sequence2 = "~/data/shapes/simpleBox/simpleBox_look.dsq look";
	sequence3 = "~/data/shapes/simpleBox/simpleBox_jumpForward.dsq jumpForward";
	sequence4 = "~/data/shapes/simpleBox/simpleBox_jumpUp.dsq jumpUp";
	sequence5 = "~/data/shapes/simpleBox/simpleBox_fallBack.dsq fallBack";
};

Things to note here:

I altered my models hierarchy to match that of the simpleBox_start.mb distributed with the maya2dts_filepack. The mesh's node needs to be at the root level, and not embedded into the DTS hierarchy tree where the animation joints are (pretty sure this is why I was seeing what seemed to be the first frame of the animation when I tried the embedded DTS method before). With my hierarchy adjusted to match that of the tutorial's example, I just exported everything as per the instructions into seperate dts and dsq files. The only thing I found to be missing from the tutorial was mention of the StaticShapeData datablock in the .cs file.

I no longer get the (0): Unable to find function TSShapeConstructor::create error, even though I don't define my own TSShapeConstructor::create. This leads me to believe it is a bad idea to declare one as I did in my first post.

The StaticShapeData and TSShapeConstructor datablocks need to have different names (one is 'simpleBoxDTS' and the other 'simpleBoxDTSSequence', it won't work if they have the same name). The shape appears in your creator tree under the category and name specified in the StaticShapeData datablock. Also, you do not need to specify a 'category' in the TSShapeConstructor datablock, I didn't test out what happens if you leave it in.

I can now call playthread(0, "sequncename") on any of my seperate animations to play them (which afaik, can't be done when the animation is embedded).

####.playthread(0, "bendFrontBack")

I already tested our in-house animations using this method and things are working beautifully now.

As I mentioned this may not be the 'correct' or the only way to get animations loading, but after several days of trial and error this was the first method I found to actually work. As I didn't see this documented in the tutorials anywhere I wanted to post my solution and hopefully save someone else some time.

-Gavin
#4
04/04/2007 (1:03 pm)
That is interetsing.
Your in new territory for me. Ive only been doing simple embedded animations, and Full
character sequences, but never combined the two.
This makes for some interesting possibilities.
#5
04/04/2007 (4:30 pm)
Hi Gavin,

Your deductions are perfectly correct. You see, the TSShapeConstructor isn't something you can add to a level, rather it's purpose is to tell Torque which DSQ animation files it should load when it loads a particular DTS file. So, in your case, the TSShapeConstructor is telling Torue to load 6 DSQ animations whenever it uses the simpleBox.dts shape. In your StaticShape Datablock, your shape file is simpleBox.dts, so Torque already knows that it has to load 6 DSQ files to go with it.

Providing you declare a TSShapeConstructor for a particular shape, whenever you use that shape (be it a StaticShape, Item, Player, Vehicle etc), Torque will load the DSQ files you declare in the TSShapeConstructor with it.

--Amr
#6
04/05/2007 (7:19 am)
Hi again Amr,

Thanks for the response. That's good info to know!!

-Gavin