Author Topic: Scale - not sure if I have it right  (Read 2580 times)

Offline Darai

  • byte
  • *
  • Posts: 45
    • View Profile
Scale - not sure if I have it right
« on: July 24, 2014, 10:40:13 am »
Hi guys,

I am fighting with scale for some time, so I created a simple example and was surprised bz the result. The Object3D was a triangle, created by addTriangle method, I created a clone of the same object and scaled it, expecting the 0,0,0 point to be still on the same spot. Surprise surprise this didnot happend and I am trying to understand why and what I have to do to get the result I expected.

Source code:
Code: [Select]
Object3D o1 = new Object3D(1);
o1.addTriangle(   new SimpleVector(-10f,-10f,0), 0, 0,
            new SimpleVector(-10f,10f,0), 0, 1,
            new SimpleVector(0f,0f,0), 1, 1,
            texID);
o1.setScale(1);
world.addObject(o1);

Object3D o2 = new Object3D(o1);
o2.setScale(2);
world.addObject(o2);
The result is in attachment. Short to say, the triangles are scaled from theirs centers, not from the 0,0,0 point.

Thanks,
Darai


[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Scale - not sure if I have it right
« Reply #1 on: July 24, 2014, 01:09:12 pm »
Think of scaling as a multiplication of a vector with a rotation matrix multiplied by the scale value. That means that even if there's no actual rotation applied to an object, the rotation pivot still has an influence on the scaling result. Add a call to Object3D.setRotationPivot(new SimpleVector(0,0,0)); after calling build(). That should give you the desired behaviour.

Offline Darai

  • byte
  • *
  • Posts: 45
    • View Profile
Re: Scale - not sure if I have it right
« Reply #2 on: July 24, 2014, 01:22:48 pm »
Thanks for the hint,

this will probably be enough for me to solve this out.

Thanks again.
Darai

Offline Darai

  • byte
  • *
  • Posts: 45
    • View Profile
Created contribution for the wiki
« Reply #3 on: August 05, 2014, 02:52:14 pm »
Hello,

so ok, I made the contribution for the wiki in the "parsonal page" called "User:Darai"... can you edit it and moved it whereever you think it can be useful?
http://www.jpct.net/wiki/index.php/User:Darai

Thanks,
Darai.

Offline Uncle Ray

  • int
  • **
  • Posts: 81
    • View Profile
Re: Scale - not sure if I have it right
« Reply #4 on: August 06, 2014, 03:32:57 am »
I have read it,which is very useful for me,thanks very much.