Very basic animation issue
by timmport · in Artist Corner · 12/30/2005 (10:33 pm) · 10 replies
I have been trying to get my maya/dts animation to work in Torque with no luck. While I can see the geometry animating fine in show tools it simply does not move at all in the demo.
I created a rotating cube called "animCube.dts" within that I created a sequence node which contains my animation info called "Sequence_anim0". I export the dts and the sequence (i.e. the dsq file) and place both in a shapes folder. Then I have paced a text file called "animCube.cs" in the same folder as the other 2 previous files. The "animCube.cs" basically contains the same scripting from "Ambient Animations with the StaticShape Class" example found at : http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1522.
Here is what my version of that scripting says:
datablock StaticShapeData(animCube)
{
category = "Misc";
shapeFile = "./animCube.dts";
};
function animCube::onAdd(%this,%obj)
{
%obj.playThread(0,"Sequence_anim0");
}
function StaticShapeData::create(%block)
{
%obj = new StaticShape()
{
dataBlock = %block;
};
return(%obj);
}
When I fire up Torque I find the animShape under the static shape folder in the hierarchy from which I place it into the scene and it does not animate. Any help figuring out why this does not animae would be appreicated.
Also I have read on the forums that there is a way of saving the data that otherwise would go into a seperate dsq file into the dts file it is animating. Does anyone have any pointers that tell specifically how to this?
I created a rotating cube called "animCube.dts" within that I created a sequence node which contains my animation info called "Sequence_anim0". I export the dts and the sequence (i.e. the dsq file) and place both in a shapes folder. Then I have paced a text file called "animCube.cs" in the same folder as the other 2 previous files. The "animCube.cs" basically contains the same scripting from "Ambient Animations with the StaticShape Class" example found at : http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1522.
Here is what my version of that scripting says:
datablock StaticShapeData(animCube)
{
category = "Misc";
shapeFile = "./animCube.dts";
};
function animCube::onAdd(%this,%obj)
{
%obj.playThread(0,"Sequence_anim0");
}
function StaticShapeData::create(%block)
{
%obj = new StaticShape()
{
dataBlock = %block;
};
return(%obj);
}
When I fire up Torque I find the animShape under the static shape folder in the hierarchy from which I place it into the scene and it does not animate. Any help figuring out why this does not animae would be appreicated.
Also I have read on the forums that there is a way of saving the data that otherwise would go into a seperate dsq file into the dts file it is animating. Does anyone have any pointers that tell specifically how to this?
#2
the reason you can still instantiate the object is because all dts files in the game directories show up as static shapes in the mission editor. when you load one of these, you're not really loading an object which uses predefined datablock, your actually just loading a generic static shape which uses that particular dts file. for animation, you need to define the behavior for your object using a datablock.
12/31/2005 (8:17 am)
Make sure youre exec'ing this script file at the right point. i think the problem is that youre not creating your datablock at the right part of the loading process. you don't create your datablock at the same time that your object is created. functionality can be defined at any point but datablocks must all be created ahead of time and sent to the server during mission loading. after the mission has been loaded, objects can be instantiated from script or console which use the previously defined datablocks. make sure youre exec'ing this script file in server/game.cs in the onServerCreated() function along with the other datablock files.the reason you can still instantiate the object is because all dts files in the game directories show up as static shapes in the mission editor. when you load one of these, you're not really loading an object which uses predefined datablock, your actually just loading a generic static shape which uses that particular dts file. for animation, you need to define the behavior for your object using a datablock.
#3
function onServerCreated()
{
// Server::GameType is sent to the master server.
// This variable should uniquely identify your game and/or mod.
$Server::GameType = "FPS Starter Kit";
// Server::MissionType sent to the master server. Clients can
// filter servers based on mission type.
$Server::MissionType = "Deathmatch";
// GameStartTime is the sim time the game started. Used to calculated
// game elapsed time.
$Game::StartTime = 0;
// Load up all datablocks, objects etc. This function is called when
// a server is constructed.
exec("./audioProfiles.cs");
exec("./camera.cs");
exec("./markers.cs");
exec("./triggers.cs");
exec("./inventory.cs");
exec("./shapeBase.cs");
exec("./item.cs");
exec("./health.cs");
exec("./staticShape.cs");
exec("./weapon.cs");
exec("./radiusDamage.cs");
exec("./crossbow.cs");
exec("./player.cs");
exec("./chimneyfire.cs");
exec("./aiPlayer.cs");
exec("./animCube.cs"); //++++++ this line is the script that I wrote++++++++++++++++++++++++
exec("./superbomb.cs"); //++++++ this line is an example script that I got from another tutorial+++++
// Keep track of when the game started
$Game::StartTime = $Sim::Time;
}
The super bomb executes just like it is supposed to in the game while the animCube does not even though it runs in show tools. I think it is the script itself.
12/31/2005 (2:12 pm)
I put it in my scene as an exec script. Just to test it out I also added the superbomb tutorial script directly afterwards to see if that will work. If you scoll to the botom you will see the exec script that I added:function onServerCreated()
{
// Server::GameType is sent to the master server.
// This variable should uniquely identify your game and/or mod.
$Server::GameType = "FPS Starter Kit";
// Server::MissionType sent to the master server. Clients can
// filter servers based on mission type.
$Server::MissionType = "Deathmatch";
// GameStartTime is the sim time the game started. Used to calculated
// game elapsed time.
$Game::StartTime = 0;
// Load up all datablocks, objects etc. This function is called when
// a server is constructed.
exec("./audioProfiles.cs");
exec("./camera.cs");
exec("./markers.cs");
exec("./triggers.cs");
exec("./inventory.cs");
exec("./shapeBase.cs");
exec("./item.cs");
exec("./health.cs");
exec("./staticShape.cs");
exec("./weapon.cs");
exec("./radiusDamage.cs");
exec("./crossbow.cs");
exec("./player.cs");
exec("./chimneyfire.cs");
exec("./aiPlayer.cs");
exec("./animCube.cs"); //++++++ this line is the script that I wrote++++++++++++++++++++++++
exec("./superbomb.cs"); //++++++ this line is an example script that I got from another tutorial+++++
// Keep track of when the game started
$Game::StartTime = $Sim::Time;
}
The super bomb executes just like it is supposed to in the game while the animCube does not even though it runs in show tools. I think it is the script itself.
#4
12/31/2005 (5:52 pm)
Have you tried instantiating the objects through script or the console rather than inserting them through the editor?
#5
maybe the way your setting it up :)
just change the paths and stuff to yours..
12/31/2005 (5:58 pm)
Try this..datablock StaticShapeData(arrow)
{
category = "animatedItems";
shapefile = "~/data/shapes/arrows/yellowAniArrow.dts";
computeCRC = true;
isInvincible = true;
};
function arrow::onAdd(%this,%obj)
{
%obj.playThread(0,"arrow");
%obj.collideable = true;
}maybe the way your setting it up :)
just change the paths and stuff to yours..
#6
12/31/2005 (6:09 pm)
It's simple. The objects in the mission editor are mislabeled, so he's putting in a raw .dts TSShape Instance instead of the StaticShape he created. Look under the Shapes menu in the mission editor instead of the StaticShapes menu. All .dts objects can be placed manually from the editor, but you want the object you created in script. That's what it's always been in the past for me anyways.
#7
You have:
shapeFile = "./animCube.dts";
You might want to have:
shapeFile = "~/data/shapes/animatedCubesFolder/animCube.dts"; (or wherever you put it)
12/31/2005 (8:31 pm)
In addition to looking in Shapes > Misc (not Static Shapes) in the editor, you might want to make sure about how you designate the path to the dts.You have:
shapeFile = "./animCube.dts";
You might want to have:
shapeFile = "~/data/shapes/animatedCubesFolder/animCube.dts"; (or wherever you put it)
#8
*****Note how is witten as:
"%obj.playThread(0,"anim1");"
and not
"%obj.playThread(0,"Sequence_anim1");"
even though it is refering to a sequence node called "Sequence_anim1".
01/04/2006 (10:25 pm)
Ok after massive wheel spinning I have solved the issue. While my sequence node name must start with "Sequence_ " you do not refer to write "Sequence_" when you refer to the node in your script. E.G. I have a maya animation with a sequence node called "Sequence_anim1". If I want to play this animation in Torque I must refer to it in the script as:datablock StaticShapeData(aSphere)
{
category = "Animation";
shapeFile = "~/data/simple/mySphere.dts";
};
function aSphere::onAdd(%this,%obj)
{
%obj.playThread(0,"anim1");
}*****Note how is witten as:
"%obj.playThread(0,"anim1");"
and not
"%obj.playThread(0,"Sequence_anim1");"
even though it is refering to a sequence node called "Sequence_anim1".
#9
I am trying to make a running animation work when you press the move left or right keys which is (a, d)
Now going off of what you said in your code example would you just make a function to call the animation? Or do you also call the animation when the button is pressed??? Im having a lot of trouble with this any help would be greatly appreciated.
Thanks
for example
function playerRun::onAdd(%this)
{
%this.playThread(0,forward.dsq run);
}
moveMap.bindCmd(keyboard, "a", "PlayerLeft(playerRun);", "PlayerLeftStop();");
moveMap.bindCmd(keyboard,"d","PlayerRight(playerRun);","PlayerRightStop();");
01/25/2010 (4:04 am)
Not sure if anyone still will reply to this thread but i am having animation issues. I am trying to make a running animation work when you press the move left or right keys which is (a, d)
Now going off of what you said in your code example would you just make a function to call the animation? Or do you also call the animation when the button is pressed??? Im having a lot of trouble with this any help would be greatly appreciated.
Thanks
for example
function playerRun::onAdd(%this)
{
%this.playThread(0,forward.dsq run);
}
moveMap.bindCmd(keyboard, "a", "PlayerLeft(playerRun);", "PlayerLeftStop();");
moveMap.bindCmd(keyboard,"d","PlayerRight(playerRun);","PlayerRightStop();");
#10
01/25/2010 (12:23 pm)
Just as a heads up, the engine should be coded that any sequence called "ambient" will automatically be found and played when the object is added to the scene.
Torque Owner N R Bharathae
As I understand it there's not much you can't do with DTS that you can do using DSQ's. You can even pack all of your DSQ's into a DTS model rather than separate them out as individual files for player models.