scaling an object with animation

Started by raft, May 27, 2007, 04:49:54 PM

Previous topic - Next topic

raft

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

hytparadisee

i dun quite get you. do you mean that when the mesh is scaled down, the animation runs faster / slower like that? ;)
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

raft

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

EgonOlsen

#3
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)?

hytparadisee

I was also wondering about it. I don't see this problem also, but i use md2 chars, not 3ds mesh sequences.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

raft

i see. seems as the problem arises from i re-set the rotation matrix every frame using direction vector. like:
Object3D.setRotationMatrix(direction.getRotationMatrix());

maybe Matrix.scalarMul(..) may help, but i'm not sure if it is meant for that

EgonOlsen

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);

raft

yeap, it effectively solved the issue :) thx