www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: arash on September 18, 2013, 02:40:44 pm

Title: setRotationPivot translates my object
Post by: arash on September 18, 2013, 02:40:44 pm
Hi,

I am having a very hard time understanding how setRotationPivot works on AE version

When I do the following

Code: [Select]
xConeRight.setRotationPivot(new SimpleVector(15, 15, ,15));
it is the same as if I was doing

Code: [Select]
xConeRight.translate(30, 0, 0);
and then when I call rotateX or rotateY the object actually rotates around point (15, 0 ,0 )

I appreciate any help.
Title: Re: setRotationPivot translates my object
Post by: EgonOlsen on September 19, 2013, 07:23:42 am
setRotationPivot sets the point around which the object will be rotated in OBJECT space. It has nothing to do with translations in world space albeit it might be possible that a rotation around the origin followed by a translation will lead to the same result as a rotation only around some other pivot.
I'm not sure what you mean by your last sentence. A rotation around an axis can't rotate around a point... ???
Title: Re: setRotationPivot translates my object
Post by: arash on September 19, 2013, 01:12:46 pm
Thanks for the quick response. but I really get my objects translated with the setRotationPivot method.

This code

Code: [Select]
xConeLeft = Primitives.getCone(90, 2);
xConeRight = Primitives.getCone(90, 2);
xConeRight.setAdditionalColor(new RGBColor(0, 0, 255));
xConeLeft.setAdditionalColor(new RGBColor(255, 0, 0));
xConeRight.rotateZ((float) -Math.PI/2);
xConeLeft.rotateZ((float) Math.PI/2);
xConeRight.strip();
xConeLeft.strip();
xConeRight.build();
xConeLeft.build();
world.addObject(xConeRight);
world.addObject(xConeLeft);

xConeRight.setRotationPivot(new SimpleVector(10, 10, 10));

results in this image:
(http://www.jpct.net/forum2/index.php?action=dlattach;topic=3590.0;attach=612)


and this code
Code: [Select]
xConeLeft = Primitives.getCone(90, 2);
xConeRight = Primitives.getCone(90, 2);
xConeRight.setAdditionalColor(new RGBColor(0, 0, 255));
xConeLeft.setAdditionalColor(new RGBColor(255, 0, 0));
xConeRight.rotateZ((float) -Math.PI/2);
xConeLeft.rotateZ((float) Math.PI/2);
xConeRight.strip();
xConeLeft.strip();
xConeRight.build();
xConeLeft.build();
world.addObject(xConeRight);
world.addObject(xConeLeft);
results in this image
(http://www.jpct.net/forum2/index.php?action=dlattach;topic=3590.0;attach=610)

however If I don't have xConeRight.rotateZ((float) -Math.PI/2);
then it all works fine.



[attachment deleted by admin]
Title: Re: setRotationPivot translates my object
Post by: EgonOlsen on September 19, 2013, 01:21:10 pm
but I really get my objects translated with the setRotationPivot method.
No, you don't. If you rotate something around a point in space that's far outside of the object itself, it will move in space. Maybe you are confused by the order...well, it doesn't matter. There's no difference between rotateZ(...);setRotationPivot(); and setRotationPivot();rotateZ(...);. Rotations will be executed at runtime and only the current rotation pivot counts. Rotations are cumulative, pivots are not.
Title: Re: setRotationPivot translates my object
Post by: arash on September 19, 2013, 02:05:32 pm
Ahaa... got it.  ;D
Thanks man.