Need help understanding gl's coordinate system
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,
Not sure what to do. You probably know more about OpenGL than I do. I was just wondering how you load the 3D Studio MAX files.
L.I.G. == Life Is Good
I think I know what you mean. they glTranslatef(0.0f,0.0f,-100.0f); that''ll give you a -50 to 50 scale on the x and y axes.
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/
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/
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement