A qyery about Spatial's rotation method

Hell All,



I am a new bie in game development and just started learning the trade.

In my program, I am using rotation method as:



Box box1 = new Box( new Vector3f(3,0,0), 1,2,1);

Geometry blue = new Geometry(“Box”, box1);





Node pivot = new Node(“pivot”);

rootNode.attachChild(pivot);

pivot.attachChild(blue);



pivot.move(3,0,0);



now if i write

blue.rotate(0,0,FastMath.HALF_PI);

or

pivot.rotate(0,0,FastMath.HALF_PI);



positioning of geometry is same in both cases.

Why is it so?

Can someone please throw light on it?Like what is axis of rotation etc…?



Thanks in anticipation.



With regards

Manish

You attach the blue geom to the pivot, before translating the pivot.

The blue geom just follow its parent and ends up at the exact same position. that’s why rotating one or the other ends up yielding the same result.

Translate the pivot before attaching the blue geom and it should work as you expect.



Ignore this if you already read it, but this might be of interest :

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

thanka a lot nehon.

but i still not clear abt rotation functionality. it rotates a spatial abt what…global coordinate or spatial’s own geometrical centre.

and how it differs from setlocalrotation?



manish

hehe I guess you need to read this too

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies



The rotate method will combine the given rotation with the spatial actual rotation while setLocaRotation sets the spatial rotation.

Local transforms are relative to the parent Node, world transforms are relative to the world 0,0,0 coordinates.

Thanks Nehon.