0

First off, all of my code can be found here, it's in 3 files.

flythrough.cpp, support.cpp, support.h

Okay... so if you run that, it seems to work, but a few things are really bugging me!

The camera is starting off in a strange location, I try to change all kinds of variables, but it doesn't seem to have an effect.

The biggest issue right now is moving the camera. At this point in time... the camera WILL move left and right, but NOT forward or backward. When I try to move forward, it's like the pixels are doing the correct thing, the object will eventually vanish as I move forward, like I've moved past it, but the object itself is not "appearing larger" as I get closer. Same for moving backward.

Please let me know if you can come up with anything.

I'd like to add that a majority of this code comes from my textbook. With modifications from myself.

Thanks!

ardavis
  • 9,842
  • 12
  • 58
  • 112

2 Answers2

4

Its an orthographic camera, therefore you cannot move along the Z axis. You need to change your camera type to do what your trying to do.

Ref: Line 33, flythrough.cpp

glOrtho(-2.0 * 64 / 48.0, 2.0 * 64 / 48.0, -2.0, 2.0, 100, 100.0);

Typically, just uncomment this line, then write the following:

gluPerspective(60.0, 640.0 / 480.0, 0.1, 1000.0);

This will multiply a perspective matrix by the currently loaded identity matrix (LoadIdentity()).

Ref: http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml

hiddensunset4
  • 5,825
  • 3
  • 39
  • 61
  • Thanks for pointing me in the right direction. Do you know what it should be changed to? I'm still learning the syntax and structure. – ardavis Feb 16 '11 at 05:46
  • Thanks! I'll give that a shot! EDIT: Now, I'm also noticing that in support.cpp, in Camera :: setProjectionMatrix, I do use gluPerspective. – ardavis Feb 16 '11 at 05:48
  • Okay, adding what you said did work, I'm making much more progress than before. It doesn't seem to function as intended still though. It seems everything is moving around a single point or something strange. I appreciate your help! – ardavis Feb 16 '11 at 05:51
  • Yes that function contains what you want, instead of your glOrtho line (comment/delete it), put Camera::setProjectionMatrix(). But those lines in the pastie you posted are currently commented out. – hiddensunset4 Feb 16 '11 at 05:51
  • Define moving around a single point? Your code contains multiple glRotated(...) functions. I suggest you start with something simpler, and build the example one at time, instead of all of them at once and trying to figure out why your world may be spinning :) – hiddensunset4 Feb 16 '11 at 05:52
  • Okay, I noticed my first mistake, when trying to move through Z, I accidentally was moving through Y. I think this is working much better. – ardavis Feb 16 '11 at 05:54
  • +1 for not being as lazy as me, and actually taking the time to confirm it was an ortho camera that was the problem :) – Mac Feb 16 '11 at 06:25
0

Without trying to work out your axis, have you tried moving the camera back and forwards along the Z axis instead of Y. Perhaps your depth axis is setup to be Z not Y.

Ben Trengrove
  • 8,191
  • 3
  • 40
  • 58
  • If you're referring to: "myCamera.slide(0, -manipulator, 0);" Yes, I have tried "myCamera.slide(0, 0, -manipulator);", but it moves the camera up, not forward or backward. – ardavis Feb 16 '11 at 05:17