Axe position


i want to rotate a sphere and i use:

setLocalRotation method.

what i have to do if i want to rotate sphere but around another axe. for example sphere is in point 0, 0, -80 and a want to rotate around axe in point 0, 0, 0.

The easiest solution is to leverage the scene graph design and use multiple nodes. Set the local translation of your sphere to (0, 0, -80) and then apply your rotation to the parent node. There is a test named TestRotateAboutPoint which should help you out.

ok thanks.

Using nodes to 'automate' complex math like that seems like cheating to me…

(and I am ONE cheating mofo :D)

basixs said:

(and I am ONE cheating mofo :D)


so i have question. how do it "porofesional" :smiley:

several ways, but the most basic 'professional' way would be to translate the orbit object to the location of the origin object, then apply the same rotation to both the origin and orbit object, then reapply the original translation to the orbit object.  (Basically, clear translation - apply rotation - reapply translation; this is all done in local space, NOT world space.)

I would recommend using Nodes the way Nymon described (and I joked about), not only does it save you from having to do a lot of math, it uses openGL matrix arithmetic (very fast).  However, if you are wanting to learn how its done, then by all means try doing that (maybe even try in pure openGL, then you get to play with pushing and popping the stack also :)).

ok and another question.

How can i add Camer to Node??

i want rotate camera around Center axe like my sphere.

i can add sphere but Camera don't inherit form Spatial ??

you can create a CameraNode, see jmetest/renderer/