Sign in to follow this  

my current terrain work (need a little help)

This topic is 3859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm working on some terrain and am having trouble. I have some stuff that looks like terrain but will constantly redraw as different terrain. It's hard to explain so here's some code: ints:
bool	keys[256];								// Array Used For The Keyboard Routine
bool	active=TRUE;								// Window Active Flag Set To TRUE By Default
bool	fullscreen=TRUE;							// Fullscreen Flag Set To Fullscreen Mode By Default
double   az = 0.25;
double   ax = 0.0;
float   ay = rand()%5;
double   bz = .25;
double   bx = 2.0;
float   by = rand()%5;
double   cz = 0.0;
double   cx = 2.0;
float   cy = rand()%5;
double   dz = 0.0;
double   dx = 0.0;
float   dy = rand()%5;
double xwidth = 2.0;
double zwidth = 2.0;
int    xdrawn = 0;
bool goon = false;
GLfloat	xrot;				// X Rotation
GLfloat	yrot;				// Y Rotation
GLfloat xspeed;				// X Rotation Speed
GLfloat yspeed;				// Y Rotation Speed


I used the double int because i got warnings saying converting from int to double so I figured it's best to fix warnings. rendering:
int DrawGLScene(GLvoid)							
{
    if(goon==false)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				glLoadIdentity();							// Reset The Current Modelview Matrix
    glTranslatef(0.0f,0.0f,-8.0f);					glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(xrot,1.0f,0.0f,0.0f);     
    glBegin(GL_QUADS);
    glColor3f(0.2f,0.6f,0.2f);
    glVertex3f(ax, ay, az);
    glVertex3f(bx, by, bz);
    glVertex3f(cx, cy, cz);
    glVertex3f(dx, dy, dz);
    glEnd();
	xrot+=xspeed;
	yrot+=yspeed;
    ay = by;
    dy = cy;
    by = rand()%5;
    cy = rand()%5;	
    xdrawn++;
    glTranslatef(0.25f,0.0f,0.0f);
    if(xdrawn==xwidth)
    {
     goon==true;
    }    
	return TRUE;							// Keep Going
}
}


and input handling:
					SwapBuffers(hDC);			// Swap Buffers (Double Buffering)
				if (keys[VK_UP])
				{
					xspeed-=0.001f;
				}
				if (keys[VK_DOWN])
				{
					xspeed+=0.001f;
				}
				if (keys[VK_RIGHT])
				{
					yspeed+=0.001f;
				}
				if (keys[VK_LEFT])
				{
					yspeed-=0.001f;
				}					
				}
			}


I came up with the idea for it one night as I started falling asleep and wrote it down. It just makes some random starting values for 4 points, than draws it, translates over, makes the new left points the same as the old rights, and makes the rights random and does that until the max width is the same as the amount drawn. please help me out. If you want some more description, I'll get out the notepad I wrote it on. Thanks in advance. [Edited by - brandonman on May 20, 2007 1:13:40 PM]

Share this post


Link to post
Share on other sites

This topic is 3859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this