0
votes

I'm using OpenGL to draw an object in my scene, but I can't seem to get it to rotate around the camera rather than just rotating in place.

What can I do to have it rotate around the camera instead? I know that I can draw it in camera/view space, but I need to get the object's position and rotation from after the transformation (so that I can give that object a rigid body with Bullet). If the position and rotation can still be retrieved from an object rendered in the view space, then please disregard the first part of the post.

In other words, how can I move and rotate the object around the camera and get it's coordinates and rotation from the ModelMatrix so that I can fill these:

glm::vec3 objectPosition;
glm::quat objectRotation;

I've seen similar posts online that use older OpenGL/not the MVP framework, so I'm not sure how to do this. Cheers.

1
You need to translate to the negative camera position, rotate, and translate back. Otherwise you move the object to the origin and then rotating it will of course only around its own axis. Try commenting out your first line.Psi
I don't seem to have any luck with that. I tried translating with -getPosition() first, rotating and then translating to getPosition() (if that's what you meant) but with no luck.Jack Phipps

1 Answers

0
votes

Have you tried using MVP2 without the projection matrix? The projection matrix splats it on to the screen. So, taking that out might help.