Original Post
Hi all,
I am creating my terrain vertices as follows:
m_xDim is the dimension of the map, now for some reason, what is drawn doesn't look like the heigh map I created in Terragen, anyone see what could be wrong here ?
I am using index buffers and tri-lists, my indices are created as follows where LOD is the level of detail (just using 1) :
And I get the height as follows :
Puzzling me ?
Kind regards,
Steve
[edited by - steg on May 20, 2003 7:15:34 AM]
[edited by - steg on May 20, 2003 7:16:25 AM]
for (int amount = 0; amount <= m_zDim; amount++)
{
for(int i = 0; i <= m_xDim; i++)
{
y = GetHeight(i,amount); // vary this amount for height
m_pTestQuad[i+index].x = x;
m_pTestQuad[i+index].y = y;
m_pTestQuad[i+index].z = z;
m_pTestQuad[i+index].DiffuseColor = RGB(0,0,220);
x+=16; // width of quad
}
x = 0;
z -= 20; // depth of quad
// y = 0;
index += m_xDim + 1; // next quad
}
void CTerrain::CreateLODIndices(int LOD)
{
int index = 0;
int offset = 0;
m_pLOD1Indices = new WORD[(m_xDim/LOD)*(m_zDim/LOD)*6];
m_LOD = LOD;
int x = m_xDim + 1;
for(int row=0; row < (m_zDim/LOD); row++)
{
for(int col=0; col < m_xDim/LOD; col++)
{
m_pLOD1Indices[index] = LOD * (col + offset);
m_pLOD1Indices[index+1] = LOD * (col + offset + x + 1);
m_pLOD1Indices[index+2] = LOD * (col + offset + x);
m_pLOD1Indices[index+3] = LOD * (col + offset + 1);
m_pLOD1Indices[index+4] = LOD * (col + offset + 1 + x);
m_pLOD1Indices[index+5] = LOD * (col + offset);
index += 6;
}
offset += x;
}
}
float CTerrain::GetHeight(int i, int j)
{
return g_HeightMap[i*(m_xDim)+j];
}