Reputation: 11
Here is the rotation code when initialising the model matrix:
_model = translate(_position) *
( rotate(_rotation.data[0], 1.0f, 0.0f, 0.0f) *
rotate(_rotation.data[1], 0.0f, 1.0f, 0.0f) *
rotate(_rotation.data[2], 0.0f, 0.0f, 1.0f)) *
scale(_scale);
Basically, I have got a 3D level and I want to rotate the level and all the objects in it around the same pivot point.
How could I do this?
Upvotes: 0
Views: 110
Reputation: 181715
This is typically done by the concatenation (i.e. multiplication) of three matrices:
T
: Translate the desired pivot to the origin (0, 0, 0).R
: Apply the rotation.Tinv
: Translate back.Because of the way OpenGL matrices are structured, the right order is Tinv * R * T
. Premultiply your view matrix by that.
Upvotes: 1