www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: raft on May 27, 2007, 04:49:54 pm

Title: scaling an object with animation
Post by: raft on May 27, 2007, 04:49:54 pm
hello,

is it possible to scale an animation ? simply scaling an Object3D doesnt work because the Animation is not scaled. maybe Object3D.animate(..) methods may use scale information when animating ?

thx
Title: Re: scaling an object with animation
Post by: hytparadisee on May 27, 2007, 05:34:45 pm
i dun quite get you. do you mean that when the mesh is scaled down, the animation runs faster / slower like that? ;)
Title: Re: scaling an object with animation
Post by: raft on May 27, 2007, 05:47:28 pm
no. say you have an Object3D which is 10 units high with an Animation attached to it. the frames of animation should also be around 10 units high (unless you make some special animation). now if you scale the object by 2, it's 20 units high but when you animate it, it uses the meshes in animation sequence which are still 10 units high. so our scaling is reset (not the variable but the result) when we animate the object
Title: Re: scaling an object with animation
Post by: EgonOlsen on May 27, 2007, 06:53:18 pm
When using the normal scale/setScale-methods in Object3D? That shouldn't happen...the scaling is part of the rotation matrix. It's applied to the mesh when rendering it, it's not permanent. Animated or not, it should simply scale the object. Do you have a test case that shows this problem (I can't verify it. I tried to scale the animated object in the "advanced example"(tm) and it works just fine)?
Title: Re: scaling an object with animation
Post by: hytparadisee on May 27, 2007, 07:01:43 pm
I was also wondering about it. I don't see this problem also, but i use md2 chars, not 3ds mesh sequences.
Title: Re: scaling an object with animation
Post by: raft on May 27, 2007, 07:07:33 pm
i see. seems as the problem arises from i re-set the rotation matrix every frame using direction vector. like:
Code: [Select]
Object3D.setRotationMatrix(direction.getRotationMatrix());
maybe Matrix.scalarMul(..) may help, but i'm not sure if it is meant for that
Title: Re: scaling an object with animation
Post by: EgonOlsen on May 27, 2007, 07:09:37 pm
Yes, that causes it. From the docs for setRotationMatrix():

Sets the rotation matrix for the object. Usually, this is not required as long as the rotateX/Y/Z() methods are satisfying your needs. If you do this, make sure to reset the scale by calling setScale(1f) is you previously modified it.

So i suggest to do something like setScale(1f);setRotationMatrix(...);setScale(yourScale);
Title: Re: scaling an object with animation
Post by: raft on May 27, 2007, 07:15:22 pm
yeap, it effectively solved the issue :) thx