#openGL camera issue?

3 messages · Page 1 of 1 (latest)

humble spoke
#

I'm having a super hard time wrapping my head around this. I have a top-down isometric view game and I finally got my GL camera centered and facing my player, and my mouse moving influences camera movement correctly, however after applying my rotation, my character's movement true north (-x and -y) visually only moves the camera diagonally (-y) the camera coordinates are correct though, so it's something to do with after rotation translation.
In the video is my example

`
void Camera::centerCam(Input &input, Player &player)
{

float window_offset_x = input.mouse_screen_pos_x - app_ptr->window_center_x;
float window_offset_y = input.mouse_screen_pos_y - app_ptr->window_center_y;

glm::vec3 mouse_world_pos(window_offset_x * zoom_amount, window_offset_y * zoom_amount, 0.0f);

center_x = player.pos_x + mouse_world_pos.x;
center_y = player.pos_y + mouse_world_pos.y;

origin_x = center_x - app_ptr->window_center_x;
origin_y = center_y - app_ptr->window_center_y;

std::cout << "Camera Center: (" << center_x << ", " << center_y << ")\n";

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(camera_pos.x - origin_x, camera_pos.y - origin_y, camera_pos.z);
glRotatef(45, 1, 0, 0);
glRotatef(45, 0, 0, 1);
}
`

stoic jewelBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

humble spoke