Original Post
Hi, I'm having trouble generating textures coordinates for the cells of my terrain Here is the code : I divide coordU and coordV by 16.0 but it is just a random number to test In fact the problem is that coordU has no influence, I can set it to what ever I want it doesn't change anything..... But coordV does work fine, the coordinates are not good at all! If you have any ideas....... Thanx. [Edited by - Grigou on August 13, 2008 4:28:00 PM]
int v_index = 0;
int HeightIndex = 0;
CDXObjects::Instance().getDevice()->CreateVertexBuffer(NumVertices*sizeof(TerrainVertex),D3DUSAGE_WRITEONLY,TerrainVertex::FVF,D3DPOOL_DEFAULT,&pNode->vBuffer,NULL);
TerrainVertex * v = NULL;
pNode->vBuffer->Lock(0,0,(void**)&v,0);
int i = 0;
for(int z = (int)pNode->vBoundingCoords[0].y; z <= (int)pNode->vBoundingCoords[3].y; z += vertexSpacing)
{
int j = 0;
for(int x = (int)pNode->vBoundingCoords[0].x; x <= (int)pNode->vBoundingCoords[3].x; x += vertexSpacing)
{
v_index = i * numVerticePerSide + j;
coordU = ((float)j)/16.0f;
coordV = ((float)i)/16.0f;
HeightIndex = ((i * FileWidth)+(FileWidth*(pNode->vBoundingCoords[0].y/vertexSpacing))) + (j+(pNode->vBoundingCoords[0].x/vertexSpacing));
v[v_index] = TerrainVertex((float)x,(float)0,(float)z,coordU,coordV);
j++;
}
i++;
}
pNode->vBuffer->Unlock();
return;