Archived

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

steve_bruce

Rotating Starfield

Recommended Posts

I have put together a little OpenGL program with a cool looking planet earth with a cloud atmosphere and it''s looking pretty realistic. what I need to know is how do you make a starfield that rotates through all possible angles when viewing the earth. I want an effect like on Nehe''s Meteors screensaver. How has he done that?? Please help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I drew my starfield by generating 2000 random x y and z coords.... then I created a display list with the stars using this idea.

glPushMatrix();
glBegin(GL_LINES);
for(int i = 0; i < STARS; i++){
drawstar(i);
}
glEnd();
glPopMatrix();


void drawstar(int star){
glNormal3f(1,0,0); // I think this is right?
glVertex3f(x[star], y[star], z[star]);
glVertex3f(x[star], y[star], z[star]-speed);
}

store that into a display list then destroy the x y and z coords, then just rotate it like it were a box because you created one big display list...

I coded all this right now so some of it may be slightly coded wrong. (ie the normal)

good luck, btw this is for a starfield that you dont fly through... obviously you can fly out of this one...

Share this post


Link to post
Share on other sites
Thanks TipTup. It seems like a pretty good way of doing it. But what I really wanted to know is how to show a Textured starfield, not one you create yourself. A starfield like in Nehe''s Meteor''s Screensaver. Is it just a big quad with a lot of stars mapped onto it?? How has he made it so it ALWAYS in the background of the screen. Is there some way in OpenGL of setting a background picture of stars. And how on earth does he get the illusion that this textured starfield is rotating around all 360 degrees of rotation. Hope someone can help me out.

Share this post


Link to post
Share on other sites
tiptup your dumbass. i''ve seen your so called game. the star field is stupid looking not realistic at all why do you draw lines.why don''t you use points and then use fog to fade when they get far so they feel like get when farther away.
this is the way i would set it up.

first setup data structure for stars
struct stars_typ
{
float x,y,z;
};

global variable
stars_typ stars[MAXSTARS];//MAXSTARS is just how stars you want

next setup the star coordinates like this
for(int index=0;index{
stars[index].x=-400+rand()%800;//these stars can range
stars[index].y=-400+rand()%800;//from anywhere you want
stars[index].z=-400+rand()%800;
}

then draw them like this
glBegin(GL_POINTS)
for(int index=0;index {
glVertex3f(stars[index].x,stars[index].y,stars[index].z);
}
glEnd();

thats about it for a star field. it''s really easy.

Styles

Share this post


Link to post
Share on other sites
hey dumber ass
alternatively u can use the point parameters extension

GL_EXT_point_parameters

to fade / make smaller points the further they are away from the camera

a couple oif examples on me site
http://members.xoom.com/myBollux/home.html defender, builder?

Share this post


Link to post
Share on other sites