Game Development Community

Animation Question TGEA

by Foestar · in Artist Corner · 11/15/2010 (9:47 pm) · 19 replies

Howdy, so I made a Windmill for a simple object to place in my mission. I made the building itself in constructor. But made the blades in 3DS Max. Finished animating the blades and it works when I load it into Showtool. But I was having trouble getting this to work in TGEA. I have my files in my folder, created a cs file for the windmill. And tried a few things to get it to play when the mission starts. But it never does.
datablock TSShapeConstructor(windmillbladesDts)
{
   baseShape = "./windmillblades.dts";
   sequence0 = "~/data/shapes/Windmill/windmillblades.dsq SimpleAnimation";
};

Pretty much all I have atm is a sequence of the blades spinning that shows in showtool but I have no idea how to get it to work in TGEA and all the threads I've found under search aren't complete with dead links. So any info on how to get my sequence working in TGEA would be helpful.

#1
11/16/2010 (2:11 am)
You don't have the complete code needed.

This may help:
datablock StaticShapeData(AmericanFlagShape)
{
   category = "Flag";
   className = "myFlag";
   shapeFile = "~/data/shapes/amFlag/AmericanFlag.dts";
   isPlaying = 1;
};

function myFlag::onAdd(%this, %obj)
{
	%obj.playthread(0, "Ambient"); // the name of your animation.
}
#2
11/16/2010 (5:39 am)
Mike nailed it, you need to start the sequence in an onAdd() function. This onAdd() function can have a class, classname, or either a datablock namespace -- depends on how you organize your code.

Note for reference to T3D users: a TSStatic can do this automagically :)
#3
11/16/2010 (8:25 am)
Hmmm, so I'm still doing something wrong. I get the general idea what it is I am doing now I think. I create a datablock for the dts and activate the sequence though the onAdd function. Though it's not working still. Under showtool my animation is called SimpleAnimation even though the dsq is called windmillblades. And when creating a sequence I name it SimpleAnimation. But no matter what I've tried so far nothing got it working.

Gonna keep playing around until I get something. I do have one other question though. What is the onAdd function doing exactly? Is it when the function is run it plays? Or when the object is added?

EDIT: I think I got a little closer. Seemed like the function wasn't recognized for a while there. But now it stops on loading objects.
#4
11/16/2010 (9:16 am)
Make sure you aren't getting any errors in your code. (console or console.log)
Also, make sure the name of your animation (SimpleAnimation) is spelt exactly as it is in the dsq. (caps and lower case are different)
I had one that drove me nuts for a week until I found that I was typing a cap where a lower case should have been.
#5
11/16/2010 (10:31 am)
Hmmm, well I got it to at least load into the mission without problems again. The only error showing up in the console is:
Namespace::unlinkClass - cannot unlink namespace parent linkage for windmillblades for MillBlades.
Error: cannont change namespace parent linkage of windmillblades from MillBlades to TSStatic.
#6
11/16/2010 (8:18 pm)
You are naming things wrong.

Try this:

01.datablock StaticShapeData(windmillBladesDts)   
02.{   
03.   category = "windmillblades";   
04.   className = "mywindmill";   
05.   shapeFile = "~/data/shapes/Windmill/windmillblades.dts";   
06.   isPlaying = 1;   
07.};   
08.  
09.function mywindmill::onAdd(%this, %obj)   
10.{   
11.    %obj.playthread(0, "SimpleAnimation"); // the name of your animation.   
12.}

See if that works. Also, make sure your dsq is in the same folder as your windmill.dts
#7
11/16/2010 (9:23 pm)
Well you were right. I was naming things wrong and now that only error is no longer there.

However, the windmillblades still don't spin which is making me think, despite the fact that it's working in showtool, something must be up with my model. It must be having trouble locating the object or something. I have all my windmill files in the same folder "Windmill". I did exec the cs file running the code. It just doesn't seem to work.
#8
11/16/2010 (10:36 pm)
Your animation is named inside your dts? and matches the dsq?
#9
11/17/2010 (3:19 am)
The animation in my dts is called SimpleAnimation. Is my dsq supposed to be named that too? I just called that windmillblades as well. What I did was within the same animated file I exported the dts and sequence after setting it up. But saved both the dts and dsq as windmillblades and the animation inside is SimpleAnimation.
#10
11/17/2010 (2:58 pm)
For such a standalone animation as this why not keep it contained within the .dts file itself? I personally I only use .dsq sequences for complex & reusable animations such as those for a player. Since you are using a .dsq sequence you will make sure that you use a TSShapeConstructor so that your shape knows about the sequence. Look at one of the player TSShapeConstructor's for an example. This would be the script file that is located in the shape's directory.
Quote:
cannont change namespace parent linkage of windmillblades from MillBlades to TSStatic.
I think you may be placing the wrong object (type) in the scene. You cannot have script interaction with a TSStatic. In order for your onAdd() callback to start the animation sequence for you, you will have to add the shape as a StaticShape; which in TGEa would be through the "Shapes" menu and not the "Static Shapes" menu (which can be confusing). All script accessible shapes such as Items, StaticShapes, RigidShapes, Vehicles, etc are automatically added to the "Shapes" menu when you create and exec the script -- going by Mike's example, the category property of "windmillblades" tells the Editor where to place the object under the shapes menu.. The objects found under the "Static Shapes" menu are simply the object's meshes: these would be shapes that don't require interaction and are primarily used as props.

#11
11/18/2010 (4:42 am)
I think after reading what you said Michael I may have found the problem. I think my code is fine after what Mike pointed out to me. It's just that now I was trying to use a static shape which as you put it is simply the mesh. But that's where I'm having a problem now. You said the way Mike's example is should tell the Editor it under the shapes menu... but it only puts it under the static shapes. It seems no matter what I do I can't seem to get it to show up under the normal shapes. And I think that's actually why it isn't working.

Also, I didn't realize you could do animations for simple dts. That's cool! How does that work?
#12
11/18/2010 (10:09 pm)
My example is setup for using an animation that's inside your mesh. It may not work for a dsq animation. I've never tried it.
Your tree (in the editor) should look like:

shapes
windmillblades // another folder
windmillblades // your blades dts
#13
11/20/2010 (4:13 pm)
Quote:
I didn't realize you could do animations for simple dts. That's cool! How does that work?
By simply leaving the animation "inside" the shape instead of exporting as a dsq sequence.

Quote:
You said the way Mike's example is should tell the Editor it under the shapes menu... but it only puts it under the static shapes. It seems no matter what I do I can't seem to get it to show up under the normal shapes.
Offhand I would say to make sure that you're exec'ing the file that contains your datablock and script methods needed for the shape.
#14
11/21/2010 (12:22 pm)
By storing the animation sequence inside the DTS binary....it's pretty much the same as using the TSShapeConstructor object to 'load' the DSQ binary into the DTS binary at runtime. You use your modeling package to export the keyframes of motion inside the DTS binary....depending upon your choice of modeling packages and exporters...buyer beware!

For a few 'simple' animations that do NOT need to be shared between DTS binaries...storing the sequence in the DTS shape is the 'preferred' method.

Also, don't mix up the Static Shapes folder.....in the asset tree...a very confusing part of the 'early days' of Torque....the objects appear in both 'category's...and you can have a fully 'working'/scripted shape[and not realize it, ;)]...and it is fine...but won't do ANYTHING, since it was added from the asset tree from the Static folder...."..those are not the 'Static Shape' you're looking for...", to quote a Jedi Master! LOL....

So, your scripted, animated shape 'could' be working fine....it's just that you've placed the object in the Mission file from the 'wrong' category....EVERY DTS binary in the asset tree can be placed as a 'Static' object....and not receive it's 'scripting'....Static category and giving a namingConvention of Static Shape obejct was very confusing when starting out with the engines...in my opinion...but the convention is probably so 'ingrained' in the C++ code; to sort out the 'names'...or resort them....might prove futile and why we are left with this slight confusion about 'static shapes'.

To me...a scripted 'static shape' should have been something more intuitive...like 'game shape' or something that shows it's capable of more than just 'rendering'...my 3 cents...always try to give you a bit more...lol.

Good luck!

NB: for debugging art assets and scripting...it can really help if you supply the binaries, so a helper can see exactly what you're doing...more 'eyes' are better than more 'ears'/voices on a website, ;)!
#15
11/22/2010 (12:12 pm)
Yeah, I've been at it for days now and still nothing. I've tried following everyones advice and even followed a link when searching google and this site.

I think I understand all the info you guys have given, yet obviously I don't understand it as much as I thought I did because still no success. I understand now that I need the coding which is in my cs file which is executed. I also checked my model and it's set up in 3DS Max and it looks good. Working in showtool no problem. I also understand as a few of you have put it that I have to make sure to use the object in shapes and not staticshapes as Rex put it. By doing that your code simply wont work on the object because it's static and simply the mesh. But that's where my problem is. My object, no matter what I do, will not show up under anything else except static.

I even tried following a link by Todd Pickens who oddly enough was trying to do a windmill as well. I tried looking over the code they used
//This is the part that asigns your new shape, in its animated form to the SHAPES catagory in the "Creator" //list, 
//NOTE: Do not use the shape (even if it is the same one) that is in the Static area of the "Creator" 
//window [b]IT WILL NOT ANIMATE![/b]
// Again just to make it clear. THIS PLACES THE ANIMATED SHAPE UNDER [b]SHAPES[/b] IN THE CREATOR //WINDOW, NOT UNDER STATIC SHAPES! The catagory asigned is "MISC", as oposed to "ITEM" ETC..

datablock StaticShapeData(Flag)
{
   // The category variable determins where the item
   // shows up in the mission editor's creator tree.
   // (this is misspelled in v1.0, v1.1 or higher should
   // use the correct spelling "category")
   catagory = "Misc";
   shapeFile = "./flag.dts";
};

// This function trigers the animation when the object is created in the world. Thats all it does.
// Things to be aware of is that the ___::onadd needs to have the SAME NAME as the function that sets it up //as a StaticShapeData in this case its FLAG... Also, You MUST have an animation In the DTS for this to work, 
//or merged DSQ (but we wont go over that here)... The animation this is trying to play is "wave" , this MUST 
//match the name OF the animation IN the object Exicitly! When you animated your shape, you should have 
//wretten down the name of the animation Case and all. And replace "wave" with that name. Wave being the 
//name of the animation. The 0 (zero) is the SEQUANCE NUMBER, this MUST MATCH, you cant play (1,"wave") 
//becouse wave is not sequance 1. its 0 (zero). If you want the animation to loop, this must be speficed on 
//export (whatever exporter you are using).

function Flag::onAdd(%this,%obj)
{
   // %obj is the object being added to the world
   // with %this datablock.  Start up a thread on the
   // new object.  Since the wave sequence is cyclic
   // this animation will run continously.
   %obj.playThread(0,"wave");
}   


//this may or may not be defined somewere elese, it most likeley is, but its allways good to include it, unless //it will run the risk of over wrighting it.

function StaticShapeData::create(%block)
{
   // The mission editor invokes this method when it
   // wants to create an object of the given datablock
   // type.  You only need one of these methods for any
   // class/datablock type (in this case StaticShape).
   %obj = new StaticShape()
   {
      dataBlock = %block;
   };
   return(%obj);
}
And still to no prevail. So at this point since Turkey day is coming up and I have a lot on my plate I decided to step away for a bit. If anyone wants to give it a try or check my files you can find them all in a compressed folder at this URL.

http://www.sendspace.com/file/71gk7i/68df393f0a72e1d07a66045ae6845572
#16
11/22/2010 (5:48 pm)
oh...I think I found 'IT'!...


#    catagory = "Misc";  
#    shapeFile = "./flag.dts";  
# };

CatEEEgory...category is spelled incorrectly....fix that, rinse; repeat...with the correct spelling of "category"; your animated object should appear and work! Hmm...guess that miss spelling is only in the Todd Pickens example??
#17
11/22/2010 (9:04 pm)
Facepalm! That did it..... and of course once it finally showed up I realized I had linked the datablock to the wrong dts. I have several similar name models in separate folders so when it finally showed it showed the wrong one. O_o

Though I don't know what I was doing wrong in my original cs file since I spelled category correct. Maybe there was a mistype in that too. Anyways, thanks a bunch for all the info and help!
#18
11/23/2010 (8:56 pm)
Glad you got it working. It's all a learning process. (not to mention a lot of head banging) :-)
#19
11/24/2010 (12:30 am)
...no problem; Foestar. It's what we do here in 'TorqueTown'! Glad I could hep.