1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| private void CreateTextureMap()
{
Surface srcSurf = null;
Surface destSurf = null;
Texture[] tex = new Texture[4];
Rectangle srcRect;
Rectangle destRect;
tex[0] = TextureLoader.FromFile(device, "eau.dds");
tex[1] = TextureLoader.FromFile(device, "terre.dds");
tex[2] = TextureLoader.FromFile(device, "roche.dds");
tex[3] = TextureLoader.FromFile(device, "herbe.dds");
// grande texture principale
texMap = new Texture(device, size.Width , size.Height , 1, 0, Format.A8R8G8B8, Pool.Default);
// surface de destination -> texMap
destSurf = device.CreateOffscreenPlainSurface(size.Width * 16, size.Height * 16, Format.A8R8G8B8, Pool.Default);
destSurf = texMap.GetSurfaceLevel(0);
srcRect = new Rectangle(0, 0, 16, 16);
for (int j = 0; j < size.Height; j++)
{
for (int i = 0; i < size.Width; i++)
{
srcSurf = device.CreateOffscreenPlainSurface(16, 16, Format.A8R8G8B8, Pool.Default);
if(altMap[i,j]<=0.25f) // eau
srcSurf = tex[0].GetSurfaceLevel(0);
else if (altMap[i, j] <= 0.5f) // herbe
srcSurf = tex[3].GetSurfaceLevel(0);
else if (altMap[i, j] <= 0.75f) // terre
srcSurf = tex[1].GetSurfaceLevel(0);
else // roche
srcSurf = tex[2].GetSurfaceLevel(0);
destRect = new Rectangle(i * 16, j * 16, 16, 16);
SurfaceLoader.FromSurface(destSurf, destRect, srcSurf, srcRect, Filter.None, 0);
}
}
//texMap = TextureLoader.FromFile(device, "eau.dds");
} |
Partager