Skip to main content
gamedev.net
🔒 Locked

Problem with texturing landscape.

Started by griffenjam Jun 4, 2003 at 1:49 PM 0 replies 450+ views
Original Post
griffenjam
griffenjam
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]
stu_pb
stu_pb
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...
I should probably be working now...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.