Sign in to follow this  
WWakerFAN

Sin wave quads

Recommended Posts

WWakerFAN    108
for(int i=0;i<1;i+=STEP_SIZE) {
			for(int j=0;j<100;j+=STEP_SIZE) {
                glBegin(GL_QUADS);
                    glTexCoord2f(0,0);
                    glVertex3f(j,6,i+sin(50+(waterX+(j/STEP_SIZE*2+2)*5)*5 * M_PI/180));
                    glTexCoord2f(0,1);
                    glVertex3f(j,6,i+STEP_SIZE+sin(50+(waterX+(j/STEP_SIZE*2)*5)*5 * M_PI/180));
                    glTexCoord2f(1,1);
                    glVertex3f(j+STEP_SIZE,6,i+STEP_SIZE+sin(50+(waterX+(j/STEP_SIZE*2)*5)*5 * M_PI/180));
                    glTexCoord2f(1,0);
                    glVertex3f(j+STEP_SIZE,6,i+sin(50+(waterX+(j/STEP_SIZE*2+2)*5)*5 * M_PI/180));
                glEnd();
            }
		}
the probalem i'm having is each strip of quads seems to as if they are joined separately instead of acting like they're joined together

Share this post


Link to post
Share on other sites
Enigma    1410
The right hand edges of the first strip bases its height off of j while the left hand side of the second strip, which is at the same x & y coordinates bases its height off of j + STEP_SIZE.
for (int i=0; i < 1; i += STEP_SIZE)
{
for(int j=0; j < 100; j += STEP_SIZE)
{
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(j, 6, i + sin(50 + (waterX + (j / STEP_SIZE * 2 + 2) * 5) * 5 * M_PI / 180));
glTexCoord2f(0, 1);
glVertex3f(j, 6, i + STEP_SIZE + sin(50 + (waterX + (j / STEP_SIZE * 2) * 5) * 5 * M_PI / 180));
glTexCoord2f(1, 1);
glVertex3f(j + STEP_SIZE, 6, i + STEP_SIZE + sin(50 + (waterX + ((j + STEP_SIZE) / STEP_SIZE * 2) * 5) * 5 * M_PI / 180));
glTexCoord2f(1, 0);
glVertex3f(j + STEP_SIZE, 6, i + sin(50 + (waterX + ((j + STEP_SIZE) / STEP_SIZE * 2 + 2) * 5) * 5 * M_PI/180));
glEnd();
}
}

Enigma

Share this post


Link to post
Share on other sites

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