Original Post
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.
"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]
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]