Need help with animation in loader

I need some help with my loader. Position animation works fine, but scaling and rotating don’t really work correctly. The way animation works in my loader (or doesn’t work :P), is that I have have an AnimationGroup class that contains a reference to the TransformGroup and Transform3D of an object that will be animated. Then a setTime() function is called indirectly by the user of TDSModel (though setCurrentFrame), which calls the setTime function of all AnimationGroups:

public void setTime(float time) {
            if (rotTransform != null)
                  rotTransform.setTime(time);
            
            if (posTransform != null)
                  posTransform.setTime(time);
            
            if (scaleTransform != null)
                  scaleTransform.setTime(time);

            objectOfTransform.setTransform(transformOfObject);
      }

This, as you can see, calls the setTime function of all the different types of animation. Each of the classes that the setTime is called on, have a reference back to their “parent” AnimationGroup class, so that they can directly manipulate the object’s Transform3D. So first the rotation is applied like so: parent.transformOfObject.setRotation(AxisAngle4f). Then posTransform sets the postion like so: parent.transformOfObject.setTranslation(Vector3f). Then scaleTransform sets the scale of the object like so: parent.transformOfObject.setScale(floatScale).

Then finally AnimationGroup sets the Transform3D onto the TransformGroup object: objectOfTransform.setTransform(transformOfObject);

Now, in animations from models that i’m testing, I’m getting funky results. If I animate just the position, it works fine. However, if I animate just the scaling, then the object scales, but it also moves in some direction (even when the position is not being animated), instead of just scaling in place. And the rotation also does not rotate the object in place, but rather moves and rotates it (again, even with the other two animations off).

So obviously I think I’m doing something wrong here, but what is it?

If you want to look at the actual code then click my sig and download the loader (even if you already have, I just re-uploaded a “new” v1.2 with the changes in animation. It’s currently set to just animate the postion–which it does correctly)

Relevant classes:
TimedTransform
PosTransform
RotTransform
ScaleTransform
AnimationGroup
RotationChunk – enable/disable rotation animation
PositionChunk – enable/disable position animation
ScaleChunk – enable/disable scale animation
TDSModel

You need to load your geometry relitive to the pivot point of the groups. Or to put it another way, you need to offset the vertex coords by the coordinate of the pivot point for each group.

I had this problem with the ASE loader as well. If you look at the ASE loader code, you will see how I solved this.

Specifically, in AseMesh - look for “pivotPoint”

Once the geometry has been offset so it is relitive to the pivotPoint, I then add a transform so it is moved back to the pivot point (i.e. where it should be) (the method applyPivotTranslation() in AseGeom).

Good luck! I think I will use this loader for some animated units in my game if you get it working.

Will.

Mmmm yes… but the problem is that for this model all of the pivots that PivotChunk reads are <0, 0, 0> :frowning:

Then it is rather hard to animate the model in this way!

Why are the pivots all (0,0,0)?

Will.

good question :slight_smile:
I asked my 3D artist that, and he realized he didn’t set them. So now he set them for this shape I’ll be testing and things should hopefully go well :slight_smile: The loader does read the pivot now.

You know what would probably help, understanding the mul method on all Transform3D’s. I know I should know what this is, but I’m completely new to 3D stuff and Xith, and I’ve gotten this far without it… So, what’s the difference between mul and add and what do they do? You might need to explain how these matricies work as well…

Grab a Java3D book or read a good tute. Most of them have a good section on Transformations (indeed with Transform3D) Alternativly, find a matrix maths site. mul is normally what is used. In this area, Java3D and Xith3D are very similar.

Will.

Mmmm… I don’t really want to spend money on this just to learn what the mul method does. If anyone has a good tutorial on this, or could just spare some time to explain to me how the method is used (as I understand, to combine transforms), it’d be greatly appreciated, and would probably help me finish this dang loader faster.

have you tried google?

I can’t lay my hands on any, but I know there is a metric ton out there.

Have you read my tute on TG animation using the ASE loader?

Will.

Hmmm… thanks for the google link :slight_smile: I didn’t know exactly what to search for. I found several sites that look pretty complicated mathematically, but I’m in multi-variable calculus right now so I think I should be able to handle it.

Also, it seems to me that the loader is loading the wrong pivot point. Rather, when my animator sets the pivot point, what gets changed is the origin of the object (in AxisChunk), while the PivotChunk doesn’t, and has some weird small value that’s incorrect.

I have a bazillion other things to work on right now, and i’m tired of working on this loader when I have other things looming over my head. So I’m going to put it on hold, finish my other stuff, learn about all these matricies and quaternions and what-not, and then maybe in a week finish the bloody thing. Unless someone wants to do it for me, which would be greatly appreciated :slight_smile:

jME has a working 3DS Loader…why dont you try and see the difference between that and yours and try and solve the issue from there…

DP

Because:

  1. jME is very different from Xith
  2. jME has an exporter for 3DS, which then exports it to an XML file in their own jME format which is then read by a loader.
  3. I know what the problem is, and I vaguely know how to solve it, but I’m just tired of trying all these different things, especially when I don’t know how the matricies work. I could be overlooking an obvious solution because of this, so I’m going to take a break and learn about Matricies and Quaternions, finish up this other thing I’m working on, and then finish this loader.

im only trying to give suggestions…no need to blast my head off

Sorry, I didn’t mean to come off like that. :frowning: