Sign in to follow this  

I need help with heightMap!

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

Can anyone pls expalin to me how does this code works? This code will show a mountain range. I tried to edit it to something that i want, but it doesnt work. Which is the part that i need to change to make the mountains flater and not so many mountains. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); for (int z = 0; z < TERRAIN_SIZE - 1; ++z) { glBegin(GL_TRIANGLE_STRIP); for (int x = 0; x < TERRAIN_SIZE; ++x) { GLfloat scaledHeight = heightmap[z * TERRAIN_SIZE + x] / SCALE_FACTOR; GLfloat nextScaledHeight = heightmap[(z + 1)*TERRAIN_SIZE + x] /SCALE_FACTOR; // assign texture coordinates for texture unit 0 glMultiTexCoord2f(GL_TEXTURE0, x * TC_SCALE, z * TC_SCALE); glVertex3f((GLfloat)x - TERRAIN_SIZE/2, scaledHeight, (GLfloat)z - TERRAIN_SIZE/2); // assign texture coordinates for texture unit 0 glMultiTexCoord2f(GL_TEXTURE0, x * TC_SCALE, (z+1) * TC_SCALE); glVertex3f((GLfloat)x - TERRAIN_SIZE/2, nextScaledHeight, (GLfloat)(z + 1) - TERRAIN_SIZE/2); } glEnd(); } // disable texture unit 1 and switch back to texture unit 0 glDisable(GL_TEXTURE_1D); glActiveTexture(GL_TEXTURE0); //draw the water. only one texture will be applied (from texture unit 0). glBindTexture(GL_TEXTURE_2D, m_waterTexture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(-TERRAIN_SIZE/2.1f, WATER_HEIGHT, TERRAIN_SIZE/2.1f); glTexCoord2f(TERRAIN_SIZE/4.0f, 0.0); glVertex3f(TERRAIN_SIZE/2.1f, WATER_HEIGHT, TERRAIN_SIZE/2.1f); glTexCoord2f(TERRAIN_SIZE/4.0f, TERRAIN_SIZE/4.0f); glVertex3f(TERRAIN_SIZE/2.1f, WATER_HEIGHT, -TERRAIN_SIZE/2.1f); glTexCoord2f(0.0, TERRAIN_SIZE/4.0f); glVertex3f(-TERRAIN_SIZE/2.1f, WATER_HEIGHT, -TERRAIN_SIZE/2.1f); glEnd();

Share this post


Link to post
Share on other sites
TERRAIN_SIZE will decrease your size of terrain. and you need to change SCALE_FACTOR to reduce the height or increase it. HTH not sure if that is what you wanted...

Share this post


Link to post
Share on other sites

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