Game Development Community

Blender -> Dae -> Torque3d

by MJ-meo-dmt · in Torque 3D Beginner · 10/31/2013 (5:31 am) · 19 replies

I have seen many posts about Those 3 things...

Now I have searched and I tried plenty of stuff.. And nothing worked so Ima ask the people.

I have this model, its rigged with Armature from top to bottom with all the little details added. (Toes, fingers, etc)

I did manage to get the model into Torque3d just fine, inside the Shape Editor i opened it up (The basic model thats rigged) then i added a new seq. named Walk from the Anim i made in blender. And that showed up fine inside the Shape Editor. So basically everything seemed okay... But trying to use the anim. makes Torque3d crash with a not responding popup and then dont send>close

What I want to know is there someone here that work with Blender>Dae>Torque3d(ofc) that would be kind enough to give me a layout of the exact things(bone, armature, setup) blender>torque3d require?
Also I have to mention, currently I'm trying to make use of a model that would do only melee attacks "Clawing"

Things I tried:
So I took the Dae rigged model, saved it in a folder inside my gameartshapesactorstestModel
inside that folder i made a Anims folder and i went back to Blender and made a walking anim, nothing special. saved that inside the Anims folder.

Now this Model is pre-rigged by someone else, it's a free dae rigged model, so all the bones start "b_MF_Something" so I saw the one post about someone saying that it must be "Bip01_Something" so I renamed the whole armature structure to fit that, made no difference. I added n "bounds", "eye", "Mount", "mount01", basically all the ones that i saw thats missing, since i scanned the soldier_rigged.DAE.
I tried to make a copy of the basic soldier_rigged files, like the .cs files that get generated everything seemed okay, like the paths and so forth for the anim.


Thanks
MJ

About the author

Open minded; Independent Thinker / Analytical Thinker; A Dreamer; A friend.


#1
10/31/2013 (9:48 am)
All I know is this. Take a model in blender format export it to dae format(remember to bake the animations as well).

That have worked for me in the past(2.67a) without any issues.

Now at days I am a Milkshape 3D freak as I still prefer .dts format.

If possible you could ask for a fbx format and then open it with Ultimate Unwrap 3D Pro and then try to export it to dae(that works like a charm for me when rigged models in .fbx format are purchased).

Hope that helps out a little.
#2
10/31/2013 (11:13 am)
They do not need to be called bip01... etc that is just the default naming in 3dsmax I think. Important is just that you have nodes for "eye" and "mount" they eye is where you view through and the mount point is where items can get mounted, you can have multiple of them. Bounds don't seem to be necessary, they will be autogenerated I think.

Regarding the animations, you cannot just use the default soldiers animations, your model would need the same rig and even if you have the same rig, with same numbers of bones and same naming, it still can get messed up.
You will likely have to make new animations or retarget them for your model.
Also you can make your model animated without separate animation files, you can make all animations in the ambience animation and split them up later in the Torque editor, for example run= frame 1-20, jump 20-30 etc.
#3
11/01/2013 (1:25 am)
@ Dwarf King:
Hey thanks man, Yeah I baked them, I saw that in a video, only that guy did a cube thing... Ill try that thanks.

@ Duion:
Quote:Regarding the animations, you cannot just use the default soldiers animations, your model would need the same rig and even if you have the same rig, with same numbers of bones and same naming, it still can get messed up.

Yeah I didn't do that... I meant I used the soldiers model as a reference, the model i have is modeled and boned originally, i just thought the naming had stuff todo with it... anyway I added those two things, not that I need a "mount" for the model im making... But ill add it in anyway, i have added an "eye" node aswell and it made no different I'll redo everything and try again... Thanks though.


Basically it ends up that my animations get exported and imported (in torque) correctly, its when I want to use the shape file when it fks out... And makes the engine crash...

Im using a resource from some guy that did the Improved AI Guard... "Will search for his name"

#4
11/01/2013 (7:29 am)
Okay so I got it to work once... I somehow messed it up again, but anyway atleast I know it works.. :D

I have one more question though, Where is the animation calls stored? Like hmm I mean if you press 'w' where is the function that play calls the "Run" animation? or how do I add a new one...?

Thanks
MJ
#5
11/01/2013 (8:14 am)
the animation files are linked to art - datablocks - (youplayernamegoeshere).cs in

art - shapes - actor (youplayernamegoeshere).cs

these two .cs files share the same name, but in the art datablocks you find the stats and callback functions and in the art - shapes - actor you find:
if .dae model with animations
function playerDAE::onLoad(%this)
{
   %this.addSequence( "./Anims/PlayerAnim_run.dae run", "run", 0, -1);
   
etc.
etc.
}

and if dts model(from my own actual work so might be a bit messy, read ahead and see more detailed explanation)
singleton TSShapeConstructor(elfrangerDts)
{
   baseShape = "./elf-ranger.dts";
   sequence0 = "./elf-ranger_Idle_01.dsq idle";//root";
   sequence1 = "./elf-ranger_Idle_02.dsq Idle_02";
   sequence2 = "./elf-ranger_run.dsq run";
   
etc.
etc.
}

Now let us look at the syntax(i use the .dae example as that is what you use):
%this.addSequence( "./Anims/PlayerAnim_run.dae run", "run", 0, -1);
addSequence  ( string  source,  
               string  name,  
               int  start = 0,  
               int  end = -1,  
               bool  padRot = true,  
               bool  padTrans = false   
 )

some more detailed explanation from the best documentation ever :o)

source:
the name of an existing sequence, or the name of a DTS or DAE shape or DSQ sequence file. When the shape file contains more than one sequence, the desired sequence can be specified by appending the name to the end of the shape file. eg. "myShape.dts run" would select the "run" sequence from the "myShape.dts" file.
name:
name of the new sequence
start:
(optional) first frame to copy. Defaults to 0, the first frame in the sequence.
end:
(optional) last frame to copy. Defaults to -1, the last frame in the sequence.
padRot:
(optional) copy root-pose rotation keys for non-animated nodes. This is useful if the source sequence data has a different root-pose to the target shape, such as if one character was in the T pose, and the other had arms at the side. Normally only nodes that are actually rotated by the source sequence have keyframes added, but setting this flag will also add keyframes for nodes that are not animated, but have a different root-pose rotation to the target shape root pose.
padTrans:
(optional) copy root-pose translation keys for non-animated nodes. This is useful if the source sequence data has a different root-pose to the target shape, such as if one character was in the T pose, and the other had arms at the side. Normally only nodes that are actually moved by the source sequence have keyframes added, but setting this flag will also add keyframes for nodes that are not animated, but have a different root-pose position to the target shape root pose.


Now remember that root is the name of the animation the player is playing when added to the world. Hence an idle animation or idle combat animation would need to be set to looping and keep playing:

another .dae example:
%this.addSequence("ambient", "root", "464", "562", "1", "0");
%this.addSequence("ambient", "run", "390", "422", "1", "0");
So here I took root and run and drag it out from the long animation thread embedded in the .dae model. I also told the engine when to start and stop(I know this from the vendors who ship their models with that kind of documentation.., they should :o)). In the shape editor you then tick the loop for animations you wish to keep on playing or you hard script it with:

%this.setSequenceCyclic( "ambient", true );
%this.setSequenceCyclic( "shoot", false );

%this.addSequence("ambient", "falling", "678", "781", "1", "0");
%this.setSequenceCyclic("falling", "0");
where 0 = false and 1 = true

so in the case above ambient keeps on playing... and shoot plays once.

And for the falling animation we also only want that to happen once... no break dance here :o)
Now the run question :o)

In the scripts - clients config.cs you have the holy actionmap commands
moveMap.bind(keyboard, "w", moveforward_1);


so when you push "w" with you player model the engine will look for the identical (yourplayer).cs file under art -shapes - actor(if you placed it there) and use the run animation you declared as shown above. Oh and the "moveforward_1" is a method(java people)/function(C people)
function moveforward_1(%val)
{
  $move_fwd_1 = %val;
  moveforward();
}

Now ain't that just beautiful?

#6
11/01/2013 (12:13 pm)
@Dwarf King:
Thanks you so so much for that detailed explanation! I just read through it and it opened up so much :). I will go back to my codes and I'll try some stuff and I'll get back to you.

So to get some clear the "run" is that hardcoded? for instance if i made a creature with a "claw_attack" (melee) and I wanted to name my attack for that creature's anim. "claw_attack" how would the engine know that its an attack state. and then play that anim. Thats what i want to know.

How can I add my own custom stuff, Like I got the "run" to work with the model, and the "idle" and "look" but since theres nothing melee based in the full template i cant really use anything... I looked for something like "Fire" in hope that I can fake it into doing a melee instead of firing a weapon... That didnt work.. :P but again thanks for you reply it opened plenty of things.

(Just to say atm i have my AI, using a faked melee style, well basically they do a raycast if target inside range do damage, so what i thought i could do is in that function call another to play the attack anim.)

Thanks
MJ
#7
11/01/2013 (1:24 pm)
Take from the Torque3D script manual *.chm file.
Quote:
bool Player::setActionThread ( string name,
bool hold = false,
bool fsp = true
)

Set the main action sequence to play for this player.

Parameters:
name Name of the action sequence to set
hold Set to false to get a callback on the datablock when the sequence ends (PlayerData::animationDone()). When set to true no callback is made.
fsp True if first person and none of the spine nodes in the shape should animate. False will allow the shape's spine nodes to animate.

Returns:
True if succesful, false if failed
Note:
The spine nodes for the Player's shape are named as follows:
Bip01 Pelvis
Bip01 Spine
Bip01 Spine1
Bip01 Spine2
Bip01 Neck
Bip01 Head
You cannot use setActionThread() to have the Player play one of the motion determined action animation sequences. These sequences are chosen based on how the Player moves and the Player's current pose. The names of these sequences are:

root
run
side
side_right
crouch_root
crouch_forward
crouch_backward
crouch_side
crouch_right
prone_root
prone_forward
prone_backward
swim_root
swim_forward
swim_backward
swim_left
swim_right
fall
jump
standjump
land
jet
If the player moves in any direction then the animation sequence set using this method will be cancelled and the chosen mation-based sequence will take over. This makes great for times when the Player cannot move, such as when mounted, or when it doesn't matter if the action sequence changes, such as waving and saluting.

Example:
// Place the player in a sitting position after being mounted
%player.setActionThread( "sitting", true, true );

Movement animation is dynamically driven input from player.cpp (or copied in kind by aiplayer.cpp). If you want to add new moves, that's the "correct" way to do it.

You could of course stop the player/ai movement when the attack is called in script (maybe set setSpeed to zero - or whatever the speed modifier in default.bind.cs is called), play the attack animation, then give movement/input/setSpeed back. (but that is hacky - but if it works ... who cares)
#8
11/01/2013 (4:26 pm)
Thanks Steve:
Okay so its either a hacky way in the script or editing the source... #_#

O well.

#9
11/04/2013 (4:12 am)
Steve... I have been trying and was about to give in.. I also looked at the cpp source and its at this moment still to much, i started cpp about 2 weeks back just started on classes so its still a bit much #_#... Anyway so I'm really aiming to avoid doing any source editing for now.

I tried using the
%aiplayer.setActionThread("attack", true true);
it plays it once when the bot gets spawned.. which is weird because i have it in the attack function, with the idea it should fire only when the bot is in melee range.. anycase it didnt work, i tried the setSpeed to make it stop so that no other anim, interfere(? posible dono), same didn't work.

When i get the aiplayer.getState its usually in Stand or Move. sometimes its just Stand even with it moving around...

Also another thing when ever I name this:
%this.addSequence("ambient", "walk", "0", "20", "1", "0");

"run" instead of "walk" the engine crashes, on the level load right where it loads the datablocks.. so i dono whats up with that.

The only other thing I thought I could try is to make a invis. weapon. attack it to the zombie, and when it "Fires" it should play the attack animation of the zombie, like the fire and reload is done with the base models you get with the engine. Is that possible even?

I just don't know anymore.. I'm even considering changing the whole game idea and work without melee in total...

Thanks Again
MJ
#10
11/04/2013 (4:57 am)
Actually I got something to work now, I managed to make the animation play when in range and when doing damage. Thing now is it wont stop playing. I'm trying the playThread() functions but they dont seem to change much.. Looks like the setActionThread overwrites them?

Is there something similar for the setActionThread() that i could use.. or something to stop the animation so that it returns to the one before.

#Edit >>> 1
#----------------------#
I got it to work :D:D:D
I got the playThread, stopThread thing working so now its just a matter of setting them all up so that they work fine :D
Whoop whoop


Final Edit:
@ Steve that idea you said (^post) that would work great, then I don't have to write a state system for handling custom states, that is if I can figure out why the engine crashes when I try to use my "run" on the animated model... The "look" seems to work ok, also if i use a "root" it crashes.. in means.. If i open the model in the shape editor and i make a seq. "run" and "root" the engine crashes. But if i make "run and "look" its okay.

I don't know if the engine uses hardcoded names? or something or a certain amount of bones? needed for the model...
If this is so could someone tell me or point me to some doc or something?
Because atm I have to use playThread() to switch between running, attacking and idle... which is kinda a waste.

Thanks
MJ
#11
11/04/2013 (7:29 am)
The only hardcoded nodes are eye, cam, mount#, etc and the spinal structure (bip01_spine#, etc) but I think that's only for playing recoil from weapons.

If I ** vaguely ** remember, once playing a thread and you want to get out of it, you either set the thread to "look" or setArmThread("look"); <- and that snaps the model back into the root pose.

Look in the documentation under the art section and it gives detailed and somewhat baffling information on how player models should be setup and how it all works.
#12
11/04/2013 (7:32 am)
It's the "somewhat baffling" part that seems to be baffling people....
#13
11/04/2013 (8:55 am)
Quote:The only other thing I thought I could try is to make a invis. weapon. attack it to the zombie, and when it "Fires" it should play the attack animation of the zombie, like the fire and reload is done with the base models you get with the engine. Is that possible even?

Do a search for dummy weapon and read Steve's good resource here:

http://www.garagegames.com/community/resources/view/20273
#14
11/04/2013 (10:37 pm)
Guys thanks so much for the replies & help! Much appreciated.

@ Dwarf King: Yes that's the fake melee that I used for the zombie Ai, so i only used the ray test section and the doing damage part[]. Thus having that and only the animation, and atm the animation is just killing me #_#

@ Richard: Oh yes Sir, some of that are just baffling...

@ Steve: Thanks for all the help, I tried both those didn't change anything.

Here is the attack section, now I'm still rather new to all this, so meh...

f(%rtt < $AI_GUARD_IGNORE_DISTANCE)
    {

        //%obj.setActionThread("attack", true, true);
        %eyeVec = %obj.getEyeVector();

        %startPos = %obj.getEyePoint();
        %endPos = VectorAdd(%startPos, VectorScale(%eyeVec, 2));

        %target = ContainerRayCast(%startPos, %endPos, $melee_check2hit, %obj);
        %col = firstWord(%target);

        


        //echo("THIS IS THE doClawAttack Function: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
        //echo(%col);
        //echo(%target);

        // Do some damage
        
        if(%col.getType() & $TypeMasks::ShapeBaseObjectType)
        {

          %obj.setMoveSpeed(0.0);
          //%obj.playThread(3, "attack");
          %obj.setActionThread("attack", true, true);
          echo(%obj.botname);
          echo("------------------");
          echo(%obj.getState());
          %tgt.player.damage(%obj, %pos, 1, "attack");
          echo(%col.getName() & $TypeMasks::ShapeBaseObjectType);
          
          
        }
        
    }
    else
    {
    //There was a target when openfire was called, but now they're out of range so
    //we have no target. Call NoTarget to clear the bots aim.
    %obj.setMoveSpeed(1.0);
    %obj.setArmThread("look");
    //%obj.setActionThread("look", true, true);
    //%obj.stopThread(3);
    %obj.NoTarget(%obj);  
        
    }

I also tried a animationDone() call back in the datablock which worked great if i didnt play the attack animation as "looped", but that looked stupid...

/*
function DemoPlayer::animationDone(%this, %obj)
{
  //%obj.setActionThread("look", true, true);
  //%obj.setArmThread("look");
  //%obj.setMoveSpeed(1.0);
  %obj.stopThread(3);
  echo("Helloooo" SPC %this SPC %obj);
}
*/

Also last night I renamed all the bones again, and made it similar to the "soldier_rigged.DAE" so that made the "run" to work. So now when the Ai is moving "run" animation is playing just fine, it gets to me, stops perfectly then goes into "attack" animation. Does damage... And then when i move away from it, it stays in the "attack" animation (stuck).

Also should I be blending any animations? (will read the manual on that doesnt really matter atm i guess...)
#15
11/04/2013 (10:38 pm)
Sorry I had to post twice the "forum" complained, for my post was to long...

Here is the zombie.cs for the sake of it... its ugly as hell but who cares right.. :P

singleton TSShapeConstructor(Zombie_animDae)
{
   baseShape = "./zombie_anim.DAE";
   unit = "1";
   loadLights = "0";
};

function Zombie_animDae::onLoad(%this)
{
   %this.setSequenceCyclic("ambient", "0");
   %this.addSequence("ambient", "run", "0", "20", "1", "0");
   %this.addSequence("ambient", "look", "39", "40", "1", "0");
   %this.addSequence("ambient", "attack", "60", "80", "1", "0");
   %this.setSequenceCyclic("attack", "1");
   %this.setNodeTransform("eye", "6.10802e-016 0.0881601 0.919255 1 0 0 0.0111131", "1");
   %this.setNodeTransform("mount", "6.29996e-016 0.187414 0.9082 1 0 0 0.0111131", "1");
   %this.setSequenceCyclic("run", "1");
   %this.setNodeParent("b_MF_Root", "");
   %this.renameNode("b_MF_Root", "Bip01");
   %this.renameNode("b_MF_Pelvis", "Bip01_Pelvis");
   %this.renameNode("b_MF_Spine_01", "Bip01_Spine");
   %this.renameNode("B_MF_Spine_02", "Bip01_Spine1");
   %this.renameNode("b_MF_Spine_03", "Bip01_Spine2");
   %this.renameNode("b_MF_Neck", "Bip01_Neck");
   %this.setNodeParent("b_MF_Clavicle_L", "Bip01_Spine2");
   %this.setNodeParent("b_MF_Clavicle_R", "Bip01_Spine2");
   %this.renameNode("b_MF_Head", "Bip01_Head");
   %this.renameNode("b_MF_Clavicle_L", "Bip01_L_Clavicle");
   %this.renameNode("b_MF_Clavicle_R", "Bip01_R_Clavicle");
   %this.renameNode("b_MF_UpperArm_L", "Bip01_L_UpperArm");
   %this.renameNode("b_MF_Forearm_L", "Bip01_L_Forearm");
   %this.renameNode("b_MF_Hand_L", "Bip01_L_Hand");
   %this.renameNode("b_MF_Thumb_01_L", "Bip01_L_Finger0");
   %this.renameNode("b_MF_Finger_04_L", "Bip01_L_Finger1");
   %this.renameNode("b_MF_Finger_10_L", "Bip01_L_Finger2");
   %this.renameNode("b_MF_Finger_07_L", "Bip01_L_Finger3");
   %this.renameNode("b_MF_Finger_01_L", "Bip01_L_Finger4");
   %this.renameNode("b_MF_Weapon_L", "mount1");
   %this.renameNode("b_MF_Weapon_L_End", "mount2");
   %this.renameNode("b_MF_UpperArm_R", "Bip01_R_UpperArm");
   %this.renameNode("b_MF_Forearm_R", "Bip01_R_Forearm");
   %this.renameNode("b_MF_Hand_R", "Bip01_R_Hand");
   %this.renameNode("b_MF_Thumb_01_R", "Bip01_R_Finger0");
   %this.renameNode("b_MF_Finger_04_R", "Bip01_R_Finger1");
   %this.renameNode("b_MF_Finger_10_R", "Bip01_R_Finger2");
   %this.renameNode("b_MF_Finger_07_R", "Bip01_R_Finger3");
   %this.renameNode("b_MF_Finger_01_R", "Bip01_R_Finger4");
   %this.renameNode("b_MF_Thigh_L", "Bip01_L_Thigh");
   %this.renameNode("b_MF_Calf_L", "Bip01_L_Calf");
   %this.renameNode("b_MF_Foot_L", "Bip01_L_Foot");
   %this.renameNode("b_MF_Toe_L", "Bip01_L_Toe0");
   %this.renameNode("b_MF_Thigh_R", "Bip01_R_Thigh");
   %this.renameNode("b_MF_Calf_R", "Bip01_R_Calf");
   %this.renameNode("b_MF_Foot_R", "Bip01_R_Foot");
   %this.renameNode("b_MF_Toe_R", "Bip01_R_Toe0");
   %this.setNodeParent("Bip01_R_Thigh", "Bip01_Pelvis");
   %this.addSequence("ambient", "idle", "29", "30", "1", "0");
   %this.setNodeTransform("Bip01", "0 0 0 0.572174 0.587707 0.57203 2.07545", "1");
}

#Edit:
I forgot that If i set the currect "look" as "root" the engine crashes... SO i dono if thats the same as when i tried the "run" before. Maybe the model needs something or something is wrong with the bone setup or naming...
#16
11/05/2013 (6:12 am)
Note that "look" animations are designed to only control the head, spine, neck and arms - it's for aiming a weapon within a +/-80 degree vertical range - and may not include all of the nodes as it is a "blend" animation.
#17
11/05/2013 (6:30 am)
Ah I figured, anyway that model aint setup for that, I'm only using the "look" as it doesn't crash the engine. actually the "look" animation is just a 1 frame none look of the model standing...

Anyway I got the animation to work, but only after it does something else:
TO explain what I mean:

Spawn the Ai. Ai targets me comes at me, with no animation, just glides. When it does damage it does the attack animation, then when i move away from it it goes into the running animation which is great now, and back again to attacking when close to me. It's just that first section right after it spawned which doesnt work....

#18
11/05/2013 (6:40 am)
If you're not using a shipping build your "PacketRate" and "PacketSize" might be kinda low. There's a define for setting it to the max1500 in the code for shipping or you can do it manually in script. Search for info.

Also try spawning your Ai above the ground a bit.
#19
11/05/2013 (7:00 am)
PacketRate && PacketSize under networking?? I'll look into that.. Doesn't make sense though...

And yeah I tried that already with the hope that maybe if i can get it to play a animation right after spawn it would be okay from there on.. It does play the ambient right after spawn.. but nothing until the first attack.

Anyways I'll just make a simple state system or w/e you call it. So that the "run" "idle" "attack" "walk" and "death" is all custom handled via playThread/stop/destroy or something..

Thanks for the help
MJ