Game Development Community

Lightwave to DTS -- a bust :(

by Fenrir Wolf · in Torque Game Engine · 09/03/2003 (12:39 am) · 13 replies

I'm about ready to tear my hair out.

Is there anyone else out there who is using Lightwave and Torque and actually have IK-controlled skin meshes working?

Gnometech's plugin exports everything just fine. But I keep getting weird problems when I try to rotate or otherwise translate the model with sequences.

At first, I tried making my model use seperate layers for its arms and legs, like in the SpiderBot model that is included with the plugin. It worked -- except when I tried to move the body, which all layers were parented to. The bones move fine in LW, but in Torque the bones seem to "lag behind." Here's an example of what it looks like in LW and what it looks like in Torque:

www.gapingwolf.com/lwdts1.jpg

I sent an email to the guy who wrote the plugin for help. But after thinking about it for a moment, I thought, "Well, maybe Torque can't handle mixing skinned meshes with regular meshes." So, I decided to entirely redo my model's rig, so that it existed all in one layer, including the bones. I also connected all the bones together and made it look more like a typical LW character rig, so that everything was parented in a heirarchy.

Checking the DTS plugin's node map, it was exporting just one skin mesh with a bunch of bones attached to it. Great! Now, in theory, if I rotate the body, the childen bones should deform too, correct? I load it up into Torque with a simple torso rotate animation. The bones work. Woot! I'm close to finishing this!

Except...this new layout breaks my IK chains. Like so:

www.gapingwolf.com/lwdts2.jpg

My IK goals are parented to a "goal_Null" which is then parented to the base null that the object is parented to -- just like in the exporter's example dictates.

What really hampers me is the fact that the DTS files are one way. I can't SEE what's going on inside the files, how the nodes are being arranged.

Someone has gotten this to work in the past, surely? I've been working on this for the last two days and haven't gotten anywhere.

#1
09/05/2003 (12:55 am)
Aha! I finally figured it out.

Well, I figured out the second part. I never figured out the first part.

Anyway, here is the result:

www.gapingwolf.com/screenshot_00002.jpg

IK, animations, etc. all work now.
#2
09/05/2003 (8:45 am)
David by any chance have you gotten death animations to work without it crashing Torque?

If so could you provide me with a .lws
Even if it is a stick figure type model. I think i'm missing something in the scene that is causing it to crash during death animations. I have been going crazy for the past 2 weeks trying to figure it out and decided to take a small break from developing.

Thanks Coz
#3
09/07/2003 (2:59 am)
I'm seeing the same problem.

Looks like the LW animation built by the DTS exporter is missing something that's needed by the engine. I'm getting an unhandled exception in TSThread::getGround (called from Player::deathDelta) whenever I invoke a suicide/kill on my player model.

My guess is it has to do something with the ground-seeking code that lets bodies fall to the terrain/interior ground when they die. Some critical node or keyframe is missing from the DTS file.

It works fine if I do not add the deathX animations to my DTS file. (My player just stands there when he dies.)

The more I mess with Torque, the more I realize that I'm screwed without using 3ds Max. :( Gnometech's DTS exporter doesn't support triggers, for example. The source code to the old version is available for DL, but not the latest one, so I can't see about adding it.

Right now, I'm reaaaaaaally tired. But I will do a code-step debug tomorrow and see if I can't figure out exactly what is missing that's causing Torque to barf and die.
#4
09/07/2003 (5:37 am)
David I have done some investigating of the cause of the crash. I wrote about it in a previous post.
www.garagegames.com/mg/forums/result.thread.php?qt=12421

I hope this helps. It looks like you are correct about the engine not knowing how to put the players body on the ground because no values get passed on to it. Maybe next week I will try to go further into figuring this out.
#5
09/07/2003 (6:51 pm)
Right, that's the same thing I'm seeing.

If I do a debug trace, I'm getting an assert failure of "TSThread::selectKeyFrames: invalid keyframe!".

(Callback trace: TSThread::selectKeyFrames -> TSThread::setSequence -> TSShapeInstance::setSequence -> PlayerData::getGroundInfo -> PlayerData::preload)

So, it looks like the server is preloading my player datablock that points to my Lightwave-created .dts file and it's failing from there. (I don't get this assert when I load the demo's player.dts.)

Tracing a bit into the constructTSShape routine (that's invoked when a .dts file is loaded), I noticed that when the animation sequences are being read via TSShape::Sequence::read the variables firstGroundFrame and numGroundFrames are always zero for my .dts shapes.

But for the Realm Wars player.dts, there's at least one ground frame for some of the animations (maybe all, didn't trace that far).

I want to use dtsSDK to try to write a .dts file "explorer" so I can view all the components of a working player.dts and then compare against Gnometech's generated .dts files. But after trying to figure out how to read files with istreams and overloaded operators, I gave up. While I know C rather well, I'm still very real new to C++. :)

So yeah, this is looking more and more like something is missing from the exported .DTS file that's making Torque barf and die. I'm hoping the guy who wrote the DTS exporter is reading this forum and will take notice of what's going on.

I'm sure if we pool our resources we can nail this.

Strange, though, if others are using Lightwave with Torque, have they already overcome this hurdle but haven't told anyone else how? Or is nobody but Michael and I trying to use player.dts replacements that include death animations?
#6
09/07/2003 (7:42 pm)
Slight update: Ignore the part above where I mentioned selectKeyFrames. Seems the issue with the assertion had to do with a zero-length sequence that existed in my DTS file. Maybe the LW->DTS plugin should flag this was a problem and not let us write out zero-length sequences, if this is bad for Torque.

So far, everything I've seen is pointing to ground transforms. I don't think these are being written into the DTS files.
#7
09/07/2003 (8:06 pm)
Okay, last post for tonight, sorry for the triple-post!

Michael, you can "get around" the death animation crash by making a slight change to the code in tsThread.cc. I found another thread talking about death animation crashes in Milkshape-exported .dts files. (www.garagegames.com/mg/forums/result.thread.php?qt=9572)

On line 134 of tsThread.cc (in TSThread::getGround) you will see:

// similar to above, ground keyframe number 'frame+1' is actually offset by 'frame'
  p2 = &mShapeInstance->mShape->groundTranslations[sequence->firstGroundFrame + frame];
  q2 = &mShapeInstance->mShape->groundRotations[sequence->firstGroundFrame + frame].getQuatF(&rot2);

Change it to:

if(sequence->firstGroundFrame + frame < sequence->numGroundFrames) {
  // similar to above, ground keyframe number 'frame+1' is actually offset by 'frame'
  p2 = &mShapeInstance->mShape->groundTranslations[sequence->firstGroundFrame + frame];
  q2 = &mShapeInstance->mShape->groundRotations[sequence->firstGroundFrame + frame].getQuatF(&rot2);
} else {
  p2 = &unitTranslation;
  q2 = &unitRotation;
}

This avoids the reference to the null groundTranslation/Rotation. However, this isn't a permenant fix! First of all, it's hacky and second of all, your dead shape will sometimes slide and do other weird things.

Screenshot: www.gapingwolf.com/wmss5.jpg
#8
09/08/2003 (12:57 pm)
Thanks for the info David. That may explain things seeing that the LW Exporter is based on the Milkshape one. They must both be missing the necessary dts info for death animations to work correctly.
#9
09/08/2003 (1:50 pm)
Quote:Aha! I finally figured it out.

so enlighten us with what you were doing wrong or were not doing so we don't make the same mistake.
#10
09/08/2003 (3:52 pm)
Oh, I forgot to mention that. I didn't have my bones at their rest position for frame #0 of my Lightwave timeline. It was just a simple matter of going through each bone, doing a reset, and then keyframing it at 0. I started my animation at frame 1 and worked up from there.

It seems that plugin expects bones to start out at their initial rest positions at frame 0, and then I suppose it extrapolates their movements based upon that reference frame for each animation sequence that is defined later.

So, if your bones are already rotated/positioned outside of their defaults at frame zero, it will use those translations for all future bone calculations. Therefore, my arms orbited around my body, etc.
#11
09/08/2003 (8:48 pm)
Thanks for the insight David
#12
01/29/2005 (11:30 pm)
There is a solution to this death animation issue for Milkshape, 3DS Max and Maya exporters in this thread that does not require you to hack the engine at all.
#13
01/30/2005 (12:56 pm)
TorqueShowTool Pro is an excellent way to see what's going on inside your DTS shapes, btw.