groverburger / g3d

Simple and easy 3D engine for LÖVE.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rotate objects from a point different of the origin

gustavostuff opened this issue · comments

The demo makes it look (just by looking at it) as if the moon is just being rotated in the Z axis, using a point close to the earth. I see this is not the case since setTranslation is being used along with some sin and cos calculations.

commented

There is no built-in functionality for this in g3d. You need to do some math to figure out the way you want your models to rotate. In the case of the Earth and Moon demo, the moon rotates at the same rate it rotates around the Earth, so that it appears to be rotating around Earth.

Using model:setAxisAngleRotation() allows you to pass a vector along with an amount to rotate the model around the vector. This might help you in your use case, but most of the time I simply use model:setRotation().