3D Space Environment

I am trying to create a navigatable universe consisting of stars and planets, but moving through the universe, and placing the planets/stars in perspective using gluPerspective(60, w/h, 1, 400);
but I can’t get it to plot where I want, and I can’t figure out how to move inward, and bacwards through the world, how can I go about doing this?

Read a f*cking book. Then post questions in the beginners forum.

don’t be an arschloch, I have plenty of C/opengl experience, I am just having trouble in the perpective part.

How can you not understand perspective if you have “plenty of opengl experience” ?

Your question doesn’t seem very precise… what is your problem exactly ?

Have a look at nehe.gamedev.net, there’s a few good basic tutorials. You need to understand how to use the modelview matrix to simulate a “camera”.


I am obviously not making myself clear. I am use to using glOrhto, and glFrustum, when I am programming, but I am trying to use gluPerspective, inorder to generate a more 3D experiene than glFrustum, but my book doesn’t explain it well enough that I can figure out how to plot on both the w, and h, as well as work with near, and far.

gluPerspective and glFrustum basically both do the same. They both define a perspective projection matrix, just with different parameters. In fact, gluPerspective is usually implemented using glFrustum

From Mesa:

gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
GLdouble xmin, xmax, ymin, ymax;

ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;

/* don’t call glFrustum() because of error semantics (covglu) */
frustum(xmin, xmax, ymin, ymax, zNear, zFar);

That’s the relationship between gluPerspective and glFrustum.

true, glFrustum/gluPerspective do the same thing: specify the view frustum frustum is that “capped pyramid” shape: the “small end”/near rectangle is your screen surface, the big/far one (pyramid base) is the end of the view “pyramid”… the relationship between rectangles defines your field/depth of view, their positions and orientations define the near/far clipping planes. feel free to mess around with it, there are some cool things you can do (for example, “zoom” in quake1/2/3 is litterally just field-of-view change). tip: start with a horizontal fov of about 60 degrees for minimal perspective distortion (assuming your monitor is at an average distance from you). hope this helps

btw, don’t others think that the guy got some fairly harsh (and ultimately useless) replies? after all, non-3d coding experience is still experience… for all you know, he might’ve done 37 sprite-based games

[This message has been edited by mattc (edited 10-28-2002).]

Thanx those to those of you willing to post useful messages. I think I have an idea as to how to do it now.