rotate and translate opengl difficulties - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: rotate and translate opengl difficulties (/thread-7748.html)
rotate and translate opengl difficulties - furballphat - May 23, 2002 03:15 PM
I am currently writing an openGL 3D terrain viewer which will hopefully be turned into a game. Currently I have a large square filled with tiles of random height.
I have it set up so that with keyboard control you can rotate the camera on the x and y axis and translate on the y axis. No problems here. I then added in a feature to let you scroll along the map by moving the cursor to the screen edge (as seen in most RTS games).
My problem is that I have to rotate on the y and then translate to make the camera rotate and not the map, but that means the axis have changed and when I translate the map, it veers off in the wrong direction if the camera has been rotated away from the zero position.
I would appreciate any help, furballphat.
rotate and translate opengl difficulties - Jeff Binder - May 24, 2002 05:06 AM
The key to understanding this is to think that you're really moving the terrain, not the camera. Anyway, rotating and then translating is the right way to do this.
What you're probably doing is moving the camera as if it weren't rotated at all. You probably want to change the direction of camera movement so it lines up with the rotation:
rotate and translate opengl difficulties - furballphat - May 24, 2002 05:19 PM
Thanks. I tried using trig functions before, but I now realize that the reason it wasn't working was because I was only translating on one axis at a time. I need to brush up on my trig.