Jump to content
  • Advertisement
Sign in to follow this  
Nebu

OpenGL camera projection seems wrong

This topic is 3752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, im working on a simple 3d engine not using any api. some info - my matrix multiplication is as: a*b=rows of a*columns of b, z points into the screen, and im trying to implement a vector (uvn) camera first person view atm, controlled by arrows for movement and mouse for rotation. my camera code is partly taken from a tutorial for opengl which i dont know who wrote. the current problem im having is that after rotating the camera 45 degrees it seems as if it rotated 90. yet when i move forward, it seems to move to the right direction, 45 degrees. also the projection just seem naturally wrong but it seems to be fixed when the projection scale is set to 256 (this feels like more of a hack to me, as if you're hiding small inacurracies by making them smaller). anyways i was hoping someone could point the problem to me so i uploaded my code: download since the program loads objects from a file, you'll have to extract to the same directory i used which is C:\Ido\Aharon. code is a bit messy and needs some work, though it shouldnt be a problem. to make it easier for you some notes - VertexF is an array of triangles which is used to store the current object's faces to be drawn in 3d, and are then converted to screen space and stored in VertexI. game.cpp contains main loop, draw world function. matrix.cpp contains matrix related functions including calculation of view matrix and perspective conversion. some operation notes (mainXXX.exe) - 128 and 256 are the projection scales used in the two builds. use up,down,left,right to move move mouse left and right to rotate view press END key to exit the program if you cant see the problem do as following, open main.exe, rotate until you see ANGX=0,move left and backwards a bit so when you rotate objects wont get all over your screen, now rotate until 45 degrees, and see as it displays as if you rotated 90. by moving forward you'll see the movment is correct. tried to make this post as informative as possible, hope someone can help me with this because i haven't got a clue. thanks in advance [Edited by - Nebu on May 10, 2008 12:39:36 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!