Advertisement

LOL, Rough Terrain!

Started by March 15, 2001 10:08 PM
5 comments, last by Nibbles 23 years, 11 months ago
Hey! My first poor attempt at a terrain generator

Can anyone point me in the right direction for terrain related stuff? Thanks, Scott

Hey whats wrong with that! Superman''s pad!..
hehe
Advertisement
LOL that = silly
WOOHOO! much better






Sweet

Scott

Much better, how are you doing it now?
prolly not the best.. cause it''s not easy to change the size of the map yet but:

  int generate_landscape() {	GLfloat x, y;	int i=0;	for (y=-size/2;y<size/2;y+=1.0f)		for (x=-size/2;x<size/2;x+=1.0f) {			p[i].x = x;			p[i].y = y;			i++;		}	for (i=0;i<size*size;i++) {			p[i].z = randFloat(-1.0f, 2.0f);	}	return TRUE;}int draw_landscape() {	int i;	glPushMatrix();	for (i=0;i<size*size;i++) {		if (i != 5 && i != 11 && i != 17 && i != 23 && i != 29 && i != 35) {			if (i != 30 && i != 31 && i != 32 && i != 33 && i != 34 && i != 35) {				glBegin(GL_QUADS);					glTexCoord2f(0.0f, 1.0f);	glVertex3f(p[i].x, p[i].y, p[i].z);					glTexCoord2f(1.0f, 1.0f);	glVertex3f(p[i+1].x, p[i+1].y, p[i+1].z);					glTexCoord2f(1.0f, 0.0f);	glVertex3f(p[i+size+1].x, p[i+size+1].y, p[i+size+1].z);					glTexCoord2f(0.0f, 0.0f);	glVertex3f(p[i+size].x, p[i+size].y, p[i+size].z);				glEnd();			}		}	}	glPopMatrix();	// water	glPushMatrix();	//glColor3f(0.0f, 0.0f, 1.0f);	glDisable(GL_TEXTURE_2D);		glBegin(GL_QUADS);		glVertex3f(p[0].x, p[0].y, waterheight);		glVertex3f(p[5].x, p[5].y, waterheight);		glVertex3f(p[35].x, p[35].y, waterheight);		glVertex3f(p[30].x, p[30].y, waterheight);	glEnd();	glEnable(GL_TEXTURE_2D);	glPopMatrix();	return TRUE;}  


this code will prolly get garbled, but what can ya do

Scott
Advertisement
I finally got it working with different sized maps! yes! a lot easier than i first assumed no wonder it''s hard to find a good tutorial on terrains.. dont need ''em

Scott

This topic is closed to new replies.

Advertisement