Creating 3d objects
i have code that works but i dont understand why the dumb object is soo close to the camera....i tried gltranslatef() thingy but it didnt like it.
my code is here:
http://www.angelfire.com/scifi2/wfa/glsample.cpp
and
http://www.angelfire.com/scifi2/wfa/test.cpp
i know its not like the NEHE code but i like this code better. Also if there is anything i could improve on this please tell me...and no im not including the glaux junk unless its absolutely necessary.
well you have this line:
glTranslatef(0.0f,0.0f,0.0f); // Move Left And Into The Screen
but it''s not going to transalte anything cause they''re all zero
You can try this:
glLoadIdentity(); //reset
glTranslatef(0.0f,0.0f,-3.0f); //3 units into the screen
A CRPG in development...
Need help? Well, go FAQ yourself.
"I''m gay, please convert me." - Nes8bit
glTranslatef(0.0f,0.0f,0.0f); // Move Left And Into The Screen
but it''s not going to transalte anything cause they''re all zero
You can try this:
glLoadIdentity(); //reset
glTranslatef(0.0f,0.0f,-3.0f); //3 units into the screen
A CRPG in development...
Need help? Well, go FAQ yourself.
"I''m gay, please convert me." - Nes8bit
well i''ve tried the
glLoadIdentity(); //reset
glTranslatef(0.0f,0.0f,-3.0f); //3 units into the screen
and whenever i change the third(z axis) more than 1 unit in or out of the screen, i don''t see it anymore....the polygon completely dissapears...but between 0.0f and 1.0f and -1.0f...there is no difference for me.
im guessing maybee i need a newer version of OpenGL? or the libs?
glLoadIdentity(); //reset
glTranslatef(0.0f,0.0f,-3.0f); //3 units into the screen
and whenever i change the third(z axis) more than 1 unit in or out of the screen, i don''t see it anymore....the polygon completely dissapears...but between 0.0f and 1.0f and -1.0f...there is no difference for me.
im guessing maybee i need a newer version of OpenGL? or the libs?
quote:Original post by Phillk6751
im guessing maybee i need a newer version of OpenGL? or the libs?
Or maybe you need to check the zNear and zFar values you pass to gluPerspective() ...
quote:Original post by Phillk6751
zNear and zFar?
From MSDN:
void gluPerspective(
GLdouble fovy, // The field of view angle, in degrees, in the y-direction.
GLdouble aspect, // The aspect ratio that determines the field of view in the x-direction. The aspect ratio is the ratio of x (width) to y (height).
GLdouble zNear, // The distance from the viewer to the near clipping plane (always positive).
GLdouble zFar // The distance from the viewer to the far clipping plane (always positive).
);
zNear and zFar define the clipping planes of the view frustum. Polygons that are farther away (from the "camera" position) than zFar units or closer than zNear units are clipped. I''m guessing your zFar value is too small.
I changed that...actually had to add the call. and it still doesn't like it, i changed it to like...
gluPerspective(90.0f,(GLfloat)width/(GLfloat)height, 0.5f, 50.0f);
right before the main loop....should it be inside of the loop? i don't understand whats going on
also if i put 2 programs side by side(windowed) neither make any difference between the one with "glTranslatef(0.0f,0.0f,1.0f);" and "glTranslatef(0.0f,0.0f,-1.0f);" wheres there should be a somewhat noticeable difference...right?
[edited by - phillk6751 on May 10, 2002 7:19:17 PM]
gluPerspective(90.0f,(GLfloat)width/(GLfloat)height, 0.5f, 50.0f);
right before the main loop....should it be inside of the loop? i don't understand whats going on
also if i put 2 programs side by side(windowed) neither make any difference between the one with "glTranslatef(0.0f,0.0f,1.0f);" and "glTranslatef(0.0f,0.0f,-1.0f);" wheres there should be a somewhat noticeable difference...right?
[edited by - phillk6751 on May 10, 2002 7:19:17 PM]
I'm not sure if this is the problem, but 90 degrees is pretty big. I used 45.
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
also my gluPerspective() is called when the window is first created and when the window is resized: case WM_SIZE in winproc()
not in the main loop
A CRPG in development...
Need help? Well, go FAQ yourself.
"I'm gay, please convert me." - Nes8bit
[edited by - Nazrix on May 10, 2002 12:45:53 AM]
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
also my gluPerspective() is called when the window is first created and when the window is resized: case WM_SIZE in winproc()
not in the main loop
A CRPG in development...
Need help? Well, go FAQ yourself.
"I'm gay, please convert me." - Nes8bit
[edited by - Nazrix on May 10, 2002 12:45:53 AM]
"I''m not sure if this is the problem, but 90 degrees is pretty big. I used 45."
Try playing quake with 45 deg. FOV =)
Personally i think 90 is fine.
-=[ Megahertz ]=-
Try playing quake with 45 deg. FOV =)
Personally i think 90 is fine.
-=[ Megahertz ]=-
quote:Original post by Phillk6751
i don''t understand whats going on
Sounds like you could use a good manual...
Read this:
http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG
Chapter 3 (Viewing) has a great explanation on how to set up the camera.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement