scrolling a map

Started by
1 comment, last by bzulu 18 years, 5 months ago
Good evening! I'm new to Gamedev.net and first I have to say sorry cause my english isn't the best! I'm not only new to gamedev, yes, I'm even new to OpenGL. So here is my first question I have to ask: I created a simple 3d map (really simple) and try to code some scroll and rotate functions for it. My Problem is when I rotate my map about e.g 180° and I want to scroll left, now I have to push the "right"-key. If I rotate it back again about 180° and I press the "left"-key, it works how I want it to works. So, I really can imagine where are my mistakes, but I can't get any ideas to fix that little bug (maybe cause I'm just new to OpenGL). There also is to say I don't use a camera-rotation, I used to rotate each quad :D If anybody have ideas, urls or sourcecode which matches to my problem I would be really happy.. I say thanks to everyone who reads this and wants to give me some useful tips! greetings for everybody, bzulu (If anybody wants to know: I use to work with windows and visual c++ 6.0)
Advertisement
Quote:Original post by bzulu
There also is to say I don't use a camera-rotation, I used to rotate each quad :D


What exactly do you mean by that. Do you mean that you're not calling gluLookAt() with an updated camera position, but instead glRotatef() for the map.

gluLookAt() is a splendid way to place your camera objectively in the scene without having to worry about modifying the rest of the geometry.

When calling glRotatef(), however, make sure that you call glLoadIdentity() every time you want to reset the rendering pipeline. Also make sure you're not calling glPushMatrix() and glPopMatrix() carelessly. The simplest way to achieve this would be to use the following structure:

glClear(...);
glLoadIdentity();

gluLookAt(camera.pos, camera.orientation, camera.up);

glPushMatrix();
renderScene();
glPopMatrix();



If you're not calculating the camera position and orientation in your application, I suggest taking a look at a camera class - I'm sure you could find many examples on the web.

Just remember:

glRotatef(yang, 0, 1, 0);
glRotatef(xang, 1, 0, 0);

gives you a totally different result than, say:

glPushMatrix();
glRotatef(yang, 0, 1, 0);
glPopMatrix();
glRotatef(xang, 1, 0, 0);

so think before you rotate.

And, yes, the order of the axes on which you rotate can be very important.

Also, only try to use glRotatef() when you're doing truly camera-independednt rotations - for instance, to rotate the wheel of a car. That should make things a whole lot more simple.
Quote:What exactly do you mean by that. Do you mean that you're not calling gluLookAt() with an updated camera position, but instead glRotatef() for the map.

Yes, correct, that's what I mean. I know, it's stupid rotating each tile of my map, it's better to rotate the camera. I'd found some nice sources about it..and I'll try to do it like this!
Thanks for your gluLookAt() tip, helps me alot, didn't know about it till now

Quote:Also, only try to use glRotatef() when you're doing truly camera-independednt rotations - for instance, to rotate the wheel of a car. That should make things a whole lot more simple.

..I will keep it, your right!
Grettings!

This topic is closed to new replies.

Advertisement