Game Development Community

StaticShape with animation mounted to vehicle issues

by Gibby · in Torque 3D Professional · 11/17/2012 (3:59 pm) · 9 replies

Greet All:

As the title suggests, i have an issue with mounting an animated rotor to a helicopter body.

I have mounted it using the similar convention used on the cheetah.

In the datablocks I add:

datablock StaticShapeData(RotorShape01)
{
   // Basic Item properties
   shapeFile = "art/shapes/vehicles/Air-vehicles/rotor01_anim.dts";
};

 
   %obj.rotor = new StaticShape() {
      datablock = "RotorShape01";
   };

   %didMount = %obj.mountObject(%obj.rotor,5);
   %obj.rotor.playThread( 0, "ambient");
   %obj.rotor.setThreadTimeScale( 0, 2.0 );  

	//remainder of generic ::onAdd goes here, blah, blah, blah...

In the following video, you see the rotor blades render in different positions relative to the heli, most dramatically at 00:06 when it's framed against blue sky. Any insight as to what would cause this? As a control experiment/ learning excersise I fixed this issue using afx as documented here, but I may need this model in a non-AFX setting and want to know what the issue is.


#1
11/17/2012 (9:17 pm)
Okay, check StaticShape::processTick:
...
   if (isMounted()) {
      MatrixF mat;
      mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat );
      Parent::setTransform(mat);
      Parent::setRenderTransform(mat);
   }

Each tick, the position is set to the mount's position. Same happens in interpolateTick, which happens every frame IIRC. But if the helicopter is processed after the rotor, then the rotot will always lag behind. The rotor updates its position to be that of the helicopter, then the helicopter moves.

I thought that mounted objects were set to process after their mounts, but apparently not. Not even sure if that would affect interpolation in any case.

The solution, I think, is to hijack getRenderTransform (and probably also getTransform) and adjust the returned value based on the mount. I thought that's what Player and other classes used to do, but either my memory is faulty or someone decided against that.
#2
11/18/2012 (12:22 am)
I have seen this effect with shapes mounted on objects that move relatively slowly. I was using a regular shape and mounting parts for arms, legs, body, etc and I could see the mounted objects be slightly behind the object it was mounted to. I never did pursue this.
#3
11/18/2012 (3:43 am)
Oh goodness, I did I find a bug I didn't cause myself? What's the best way to confirm/ticket this?
#4
11/18/2012 (11:59 am)
Well, I think your video confirms it, though it's probably best to take a video using stock T3D. Since it's a fairly code-related issue, you could stick it on Github with a link to this thread and a short description of the issue. Or, if you're making code changes, fork T3D, create a new branch off development, and pull-request the fix!

Might be nice for someone at GG to confirm this as well.
#5
11/18/2012 (3:39 pm)
I don't *think* it's so much a bug, as that no consideration was ever given to StaticShapes that move (mounted or not). What happens if you animate and move a mounted Item class (or some deriviative), or an Image?
#6
11/18/2012 (3:46 pm)
Item does not mount. Image will work, since it's not an actual object with a transform - to render images, getImageTransform or something like that is called, which uses the node transform as you'd expect.
#7
11/18/2012 (3:50 pm)
Perhaps a more intuitive "ScriptedShape" that one would expect to be moved and animated should be a consideration in the future?
#8
11/18/2012 (4:19 pm)
I think this mounting issue is significant in its own right. I've long meant to do something about that. (For the record, I think we should expect everything to be mountable, and Item especially.) Back in TGE I actually totally refactored mounting into a system that was much more transparent and flexible, IMO. But I digress.

An intuitive base shape class would be a good idea, though. As well as reducing bloat - I think ShapeBase is nearly Turing-complete.
#9
11/21/2012 (8:08 am)
Hey All.

Object mounting used to be at the ShapeBase level IIRC. At some point in T3D's development, mounting was moved out to the SceneObject level to allow all objects to mount. However, I don't know if all objects down the chain were tested to make sure they work with the change.

And I suppose that a case could be made for all "static" named objects to not support mounting.

But I'm of the mind that if the object supports mounting -- and I don't really see why not -- then we should make sure it works. Please file a bug report on GitHub. Thanks!

- Dave