Scale - not sure if I have it right

Started by Darai, July 24, 2014, 10:40:13 AM

Previous topic - Next topic

Darai

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:

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]

EgonOlsen

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.

Darai

Thanks for the hint,

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

Thanks again.
Darai

Darai

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.

Uncle Ray

I have read it,which is very useful for me,thanks very much.