# www.jpct.net

## jPCT-AE - a 3d engine for Android => Support => Topic started by: Darai on July 24, 2014, 10:40:13 am

Title: Scale - not sure if I have it right
Post by: Darai 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
(http://[url=http://imageshack.us/photo/my-images/538/41c7b5.png]http://imageshack.us/photo/my-images/538/41c7b5.png[/url])

Title: Re: Scale - not sure if I have it right
Post by: EgonOlsen 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.
Title: Re: Scale - not sure if I have it right
Post by: Darai 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
Title: Created contribution for the wiki
Post by: Darai 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 (http://www.jpct.net/wiki/index.php/User:Darai)

Thanks,
Darai.
Title: Re: Scale - not sure if I have it right
Post by: Uncle Ray on August 06, 2014, 03:32:57 am
I have read it,which is very useful for me,thanks very much.