Jump to content
  • Advertisement
Sign in to follow this  
WWakerFAN

Sin wave quads

This topic is 4612 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!