Author Topic: scaling an object with animation  (Read 5052 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
scaling an object with animation
« 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

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: scaling an object with animation
« Reply #1 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? ;)
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: scaling an object with animation
« Reply #2 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: scaling an object with animation
« Reply #3 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)?
« Last Edit: May 27, 2007, 06:57:52 pm by EgonOlsen »

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: scaling an object with animation
« Reply #4 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.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: scaling an object with animation
« Reply #5 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: scaling an object with animation
« Reply #6 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);

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: scaling an object with animation
« Reply #7 on: May 27, 2007, 07:15:22 pm »
yeap, it effectively solved the issue :) thx