Dsq loading/playing for non player
by kyriptic · in Technical Issues · 05/04/2008 (11:06 pm) · 4 replies
I have a flyingVehicle that i'm using as my player and I have made a couple dsq sequences to try and playback while doing basic movements like moving left or right. I've looked at the player.cs file and tried to mimic that, but none of those actions are defined for flyingvehicles. So basicly is there anyway on how to define an action and what sequence it plays on the scripting end and if so how? If not is editing the engine source the only way to do this?
#2
05/05/2008 (2:12 pm)
Thats perfect for what I need. I been looking into the Thread stuff, but still can't seem to get it to play. My setup right now involves a DTS base and then .DSQ's for animations. Do you have some simple examples that shows how to load the .DSQ files so it can be called with playThread with a keyBind action? All the examples I come across have all the Threads in one DTS and all they do is load that shape and it seems to work?
#3
As in the comments below, there was a forum thread on how the ShapeConstructors work.
www.garagegames.com/mg/forums/result.thread.php?qt=28457
(Unfortunately, this is a SDK-only thread. I don't think that the excerpt below is sensitive.)
The basic idea as far as I understand, is that the TSShapeConstructor causes the DSQ files to be loaded when the DTS file associated with it is loaded.
This is an example using the Elf character from one of the demos. It may be OK for your purposes as it uses the base class as constructed, rather than running the player (I think - again, I haven't worked the external DSQ loading all the way through.) I believe you should be able to replace this DTS with any other one that has a TSShapeConstructor defining its DSQ files.
The TDN article is accessible, I believe, even without an SDK license.
tdn.garagegames.com/wiki/DTS/Scripting/AddingObjects
Assuming you have the TorqueShowToolPro, it is very convenient for debugging animations that are embedded in the DTS file. I believe that you can also get it to work with animations via the TSShapeConstructors, but I haven't done this.
Getting test code to work with a DTS with an internal animation might be the first step, then you know that the animation is good and have tested a lot of the driving code and can then go back to getting the external DSQ loading to work.
Sorry for all the qualifiers. Hopefully someone with real experience can chime in! :)
05/05/2008 (2:46 pm)
The player is an example of loading DSQ files via a TSShapeConstructor. I believe this is handled in the ShapeBase parent class. As in the comments below, there was a forum thread on how the ShapeConstructors work.
www.garagegames.com/mg/forums/result.thread.php?qt=28457
(Unfortunately, this is a SDK-only thread. I don't think that the excerpt below is sensitive.)
The basic idea as far as I understand, is that the TSShapeConstructor causes the DSQ files to be loaded when the DTS file associated with it is loaded.
// Forum Thread: TSShapeConstructor
//http://www.garagegames.com/mg/forums/result.thread.php?qt=28457
//The file is executed. Try grepping for player.cs.
//All extant TSShapeConstructors are transmitted like datablocks when a client connects,
//defining important animation information for the models they describe.
//The name is unimportant, just the file they reference.
//Have you tried reading the source for the Constructors?
//- Ben Garney
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./xxxxx.dts";
sequence0 = "./root.dsq root";
sequence1 = "./runing.dsq run";
sequence2 = "./back.dsq back";
sequence3 = "./side.dsq side";
sequence4 = "./fall.dsq fall";
sequence5 = "./jump.dsq jump";
sequence6 = "./standjump.dsq standjump";
sequence7 = "./land.dsq land";
excerpt - incompleteThis is an example using the Elf character from one of the demos. It may be OK for your purposes as it uses the base class as constructed, rather than running the player (I think - again, I haven't worked the external DSQ loading all the way through.) I believe you should be able to replace this DTS with any other one that has a TSShapeConstructor defining its DSQ files.
The TDN article is accessible, I believe, even without an SDK license.
tdn.garagegames.com/wiki/DTS/Scripting/AddingObjects
// following: http://tdn.garagegames.com/wiki/DTS/Scripting/AddingObjects
// adds a static player that can have its animations run for testing
function serverCmdAddShape()
{
%obj = new StaticShapeData()
{
datablock = ElfDts;
position = "0 242 2";
rotation = "1 0 0 0";
};
echo("Create new Elf id: ",%obj);
MissionCleanup.add(%obj);
%obj.playThread(0,"dance");
}Assuming you have the TorqueShowToolPro, it is very convenient for debugging animations that are embedded in the DTS file. I believe that you can also get it to work with animations via the TSShapeConstructors, but I haven't done this.
Getting test code to work with a DTS with an internal animation might be the first step, then you know that the animation is good and have tested a lot of the driving code and can then go back to getting the external DSQ loading to work.
Sorry for all the qualifiers. Hopefully someone with real experience can chime in! :)
#4
05/14/2008 (11:26 pm)
Thanks for the help. Got it working with everything in a DTS file and thanks for pointing me in the right direction.
Torque 3D Owner Matthew Jessick
Players often have complicated animation requirements that might best be implemented in code. For example, the walking player has to respond to all those input commands and figure out what best animation to play at any particular time.
If all you have to do is play single animations in sequence, then these base class methods might be adequate.