Archived

This topic is now archived and is closed to further replies.

Problem with texturing landscape.

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

I've just recently added texturing code to my landscape/quadtree and while it works it doesn't match up quite right. The texture does not match the landscape. I create the texture and the heightmap in PSP 8, I create the heightmap first, copy and past it as a new image and create the texture from that. I thought it would line up because it has the exact same properties as the heightmap, but it doesn't. Here is my drawing code. Edit: My heightmap spacing is 32.0f and my texture size is 512x512.

glBegin(GL_TRIANGLES);
   for(int i=0; i < nNumTriangles*3; i+=3)
   {
      if(bSwitch)
      {
      //   glColor4f(0.0f, (pvVerts[i]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f(((pvVerts[i]->x/32.0f)/512.0f), 1.0f - ((pvVerts[i]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i]->z/32.0f)/500.0f, (pvVerts[i]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i]->x, pvVerts[i]->y, pvVerts[i]->z);
       
     //    glColor4f(0.0f, (pvVerts[i+1]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f((pvVerts[i+1]->x/32.0f)/512.0f, 1.0f - ((pvVerts[i+1]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i+1]->z/32.0f)/500.0f, (pvVerts[i+4]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i+1]->x, pvVerts[i+1]->y, pvVerts[i+1]->z);
         
     //    glColor4f(0.0f, (pvVerts[i+2]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f((pvVerts[i+2]->x/32.0f)/512.0f, 1.0f - ((pvVerts[i+2]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i+2]->z/32.0f)/500.0f, (pvVerts[i+2]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i+2]->x, pvVerts[i+2]->y, pvVerts[i+2]->z);
      }
      else
      {
     //    glColor4f(0.0f, (pvVerts[i+2]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f((pvVerts[i+2]->x/32.0f)/512.0f, 1.0f - ((pvVerts[i+2]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i+2]->z/32.0f)/500.0f, (pvVerts[i+2]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i+2]->x, pvVerts[i+2]->y, pvVerts[i+2]->z);


       //  glColor4f(0.0f, (pvVerts[i+1]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f((pvVerts[i+1]->x/32.0f)/512.0f, 1.0f - ((pvVerts[i+1]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i+1]->z/32.0f)/500.0f, (pvVerts[i+1]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i+1]->x, pvVerts[i+1]->y, pvVerts[i+1]->z);

      //   glColor4f(0.0f, (pvVerts[i]->y/3.5f)/256.0f, 0.0f, 1.0f);

         glTexCoord2f((pvVerts[i]->x/32.0f)/512.0f, 1.0f - ((pvVerts[i]->z/32.0f)/512.0f));
//         glTexCoord2f((pvVerts[i]->z/32.0f)/500.0f, (pvVerts[i]->x/32.0f)/500.0f);

         glVertex3f(pvVerts[i]->x, pvVerts[i]->y, pvVerts[i]->z);  
      }
      bSwitch = !bSwitch;
   }
   glEnd();

 

"There aint gonna be no tea and crumpets!" [edited by - griffenjam on June 4, 2003 2:49:48 PM] [edited by - griffenjam on June 4, 2003 2:50:47 PM]

Share this post


Link to post
Share on other sites
Why do you take 1.0f - the Z texture coordinate? Wouldn''t this cause the texture map to be inverted compared to the heightmap?
Not sure if that is true, but just a thought!

I should probably be working now...

Share this post


Link to post
Share on other sites