Hey guys
I am working on a 3D terrain engine, and so far it loads a wireframe, colored island onto the screen based on a heightmap.
The color settings use the height by a few simple ifs:
if (CV[x + (y * WIDTH)].Z == 0) { CV[x + (y * WIDTH)].Color = Colorif0.ToArgb();}
if (CV[x + (y * WIDTH)].Z == 1) { CV[x + (y * WIDTH)].Color = Colorif1.ToArgb();}
if (CV[x + (y * WIDTH)].Z == 2) { CV[x + (y * WIDTH)].Color = Colorif2.ToArgb();}
if (CV[x + (y * WIDTH)].Z >= 3) { CV[x + (y * WIDTH)].Color = Colorif3.ToArgb();}
but now i need to texture it instead of just colour it, so i sorted out the texture coordinates etc so it would basically render the whole thing in one texture, but when i tried to do the same sort of thing by doing the following:
for (int xy = 0; xy < WIDTH * HEIGHT; xy++)
{
if (vertices[xy].Z == 0)
{
device.SetTexture(0, tWater);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,4,0, indices.Length/3);
}
if (vertices[xy].Z == 1)
{
device.SetTexture(0, tSand);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, indices.Length / 3);
}
if (vertices[xy].Z == 2)
{
device.SetTexture(0, tGrass);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, indices.Length / 3);
}
if (vertices[xy].Z >= 3)
{
device.SetTexture(0, tRock);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, indices.Length / 3);
}
It will only render the top-most texture.
I have tried changing the numVertices parameter in DrawIndexedPrimitives (currently "4") from 1, to the maximum vertices but it has the same result.
Can anyone offer any pointers (oh god i miss pointers) on this?
}
JUST-CODE-IT.NETManaged DirectX & C# TutorialsForumsArticlesLinksSamples