jPCT-AE - a 3d engine for Android > Support

setRotationPivot translates my object

(1/1)

arash:
Hi,

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

When I do the following


--- Code: ---xConeRight.setRotationPivot(new SimpleVector(15, 15, ,15));
--- End code ---

it is the same as if I was doing


--- Code: ---xConeRight.translate(30, 0, 0);
--- End code ---

and then when I call rotateX or rotateY the object actually rotates around point (15, 0 ,0 )

I appreciate any help.

EgonOlsen:
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... ???

arash:
Thanks for the quick response. but I really get my objects translated with the setRotationPivot method.

This code


--- Code: --- 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));

--- End code ---

results in this image:



and this code

--- Code: --- 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);

--- End code ---
results in this image


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



[attachment deleted by admin]

EgonOlsen:

--- Quote from: arash on September 19, 2013, 01:12:46 pm ---but I really get my objects translated with the setRotationPivot method.

--- End quote ---
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.

arash:
Ahaa... got it.  ;D
Thanks man.

Navigation

[0] Message Index

Go to full version