Game Development Community

Activating morph animations?

by Karsten "Clocks" Viese · in Torque Game Engine · 09/26/2001 (4:51 am) · 9 replies

Hi guys (and girls if any)

I have made a flag in 3D studio Max with morphed waving animations.

Everything seems to be setup correct in 3DSMax

I then exported the model with a tick in the "allow morph" and the animation sequence set to cycle.

This works fine in the v12 -show viewer, the flag is there and its waving.

Then I added the shape in the editor only to see that the animation is gone.

Do I need to make a script with a datablock to activated the animations?

Any idea how to get the animations to show ingame?

// Clocks out.

#1
09/29/2001 (7:51 am)
Ok, I haven't tested this code, but this is the idea:
datablock ItemData(Flag)
{
   // Your version probably uses the mispelled
   // category field:
   catagory = "Item";
   shapeFile = "./flag.dts";
};

function Flag::onAdd(%this)
{
   // Play the sequence called "wave" on thead
   // # 0 (you get 4 threads on each shape).
   %this.playThread(0,"wave");
}
The SDK 1.0 doesn't have mission editor hooks for items, so you'll need the following for the mission editor to know how to construct an item (this is code from the demo):
function ItemData::create(%data)
{
   // The mission editor invokes this method
   // when it wants to create an object of
   // the given datablock type.  For the mission
   // editor we always create "static" re-spawnable
   // rotating objects.
   %obj = new Item() {
      dataBlock = %data;
      static = true;
      rotate = true;
   };
   return %obj;
}
You could do the same with the StaticShape class instead of Item if this isn't something your gong to carry around.
#2
09/29/2001 (8:16 am)
Nope I cant get it to work.
Im an modeler/animator so that could be the reason for that.

I added all 3 things to the player.cs
(was this wrong)

And this was only meant to be a static object.
Used primary for eyecandy and that kinda of non carryable stuff.

If this is going to work in the next release then I can wait. Got lots of other stuff to do in the meantime.

Thx anyway // Clocks out
#3
09/29/2001 (10:02 am)
Putting in player should have been fine, maybe one of our other intrepid scripters can get this working with StaticShapeData and post something?
#4
09/29/2001 (10:05 am)
Actually, Karsten, if you email me the dts and texture, I'd like to try it out here. I'll post the script afterwards for you to play with.
#5
09/29/2001 (7:13 pm)
The flag is zipped and shipped and should be in the mail by now.

// Clocks out
#6
09/30/2001 (9:44 am)
I've email Karsten a copy, but for those of you following this thread: I made a mistake in my earlier posts. This works: (test with the actual flag shape):
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 = "./blueflag.dts";
};

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...
   %obj.playThread(0,"wave");
}   

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);
}
This code needs to get executed after the server is created. For SDK v1.0: if you put this into a file, it should be executed from the createServer function in server/scripts/server.cs, or by putting into an existing script file executed by createServer, such as player.cs.

If you have version v1.1 or higher (which you won't at the time I'm posting this) you can add new files to the fps mod's createGame function mod in fps/server/scripts/game.cs

Don't forget to set the path to the flag.dts file.
#7
09/30/2001 (9:50 am)
Yup, now it working over here as well :)

Thx Tim

// Clocks out
#8
09/30/2001 (10:23 am)
I've posted this is a HowTo resource as well.
#9
10/01/2001 (6:45 pm)
Anyone with a working flag .dts they wanna share? :-)

(need a jolly roger...)