Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Karthax

Need help understanding gl's coordinate system

This topic is 6344 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 all, I''m currently working on the begginings of a 3d engine. Right now I take in an ase object from 3d studio max, read in all of it''s vertexes, textures, etc then translate it to a -1 to 1 scale and translate it''s verticies to be centered on 0,0,0. This makes it so that every object I load in is 2 units tall/wide/deep at the most. I''ve been trying to figure out how i would set up a world system and I''m having a bit of trouble understanding what openGL does behind the scenes. How would I virtually set up say- a 50 by 50 world? From what i can tell opengl draws all of the coordinates somewhat arbitrarily.... like if you draw an object with coordinates that go as far as 50 units then you pretty much have to move the object "foward" 50 units or move the camera back 50 units. I have been messing around with glperspective and glfrustrum and don''t seem to be grasping they way they are working. If i set the values so that I have an x range of 10, a y range of 10, and a z range of 10 (0 being the close clipping plane) it does not seem to behave any different then if i set them to different numbers. I''ve been using gluLookat to position my camera relative to my object (just one object being displayed at a time right now.. some made of multiple subobjects). I''ve been able to start the camera at 0,0,3ish and look at 0,0,-z(pretty much any number works here) with y being up and use gltranslatef to move the object around. When I press various keys, the x,y,z position numbers are changed and the gltranslatef that gets called after glloaditentity on the modelview matrix works like you would expect. Recently my program has seemed to have adopted a very odd viewing volume and I can''t figure out why. It seems like my viewing volume is something like 2 by 2 because it gets clipped whenever i move it! I''ve tried setting the frustrum to (-100,100,-100,100,0,100,) but this seems to make no difference. Well enough ranting that has probably just confused the reader =).. If anyone can clarify openGLs coordinate system and the way viewing volumes work in openGL I would greatly appreciate it, I seem to have the wrong idea =(. thanks,

Share this post


Link to post
Share on other sites
Advertisement
Here''s a selection from my site that tries to explain gluPerspective.

http://tannara.2y.net/Graphics/OpenGL/Theory/Viewing%20Voulmes.htm

This page is relativly new so let me know if you don''t understand it and I''ll try to make it clearer. Sorry but I don''t understand glFrustrum myself so I haven''t written anything on that yet.

l8r,
Rob
http://tannara.2y.net/

Share this post


Link to post
Share on other sites
Well I fixed all of the problems I was having. Now I call glperspective with a 45 degree angle and use the screen height and width to get the ratio. The main thing I was doing wrong though it turns out is that i was not calling glperspective again after clearing the perspective matrix. As far as loading ase files in and reading them(in regards to a message above), the file is pretty self explainatory. You might need to brush up on some basic file i/o in c/c++ then set up the data structures to hold all of the vertexes, faces, materials, etc. When you read in the vertexes z and y are reveresed so if there is a line that says something like *MESH_VERTEX then three numbers, read the 2nd number in as z and the 3rd in as y. 3d studio max also has the negative z acess coming towards you, wheareas in opengl it goes into the monitor. To fix this simply multiply z by -1 as you are reading it in.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!