Esempio n. 1
0
 public static void SetMap(Vertex[,] data)
 {
     map=data;
 }
Esempio n. 2
0
        /*  private void LoadTextureArray(StreamReader file)
        {
            int nrTex = Convert.ToInt32(file.ReadLine());
            D3D10.ImageLoadInformation loadInfo = new SlimDX.Direct3D10.ImageLoadInformation();
            loadInfo.BindFlags = D3D10.BindFlags.None;
            loadInfo.CpuAccessFlags = D3D10.CpuAccessFlags.None;
            loadInfo.Usage = D3D10.ResourceUsage.Default;
            loadInfo.MipLevels = 2;
            loadInfo.FirstMipLevel = 0;
            loadInfo.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
            texInfos = new TextureInfo[nrTex];
            for (int i = 0; i < nrTex; i++)
            {
                texInfos[i] = new TextureInfo();

                TextureInfo.texCoordMul[i] = (float)Convert.ToDouble(file.ReadLine());
                texInfos[i].name = file.ReadLine();
                using (D3D10.Texture2D temp = D3D10.Texture2D.FromFile(Game.gameClass.GetDevice(), "Resources\\Textures\\" + texInfos[i].name, loadInfo))
                    textures = ResourceManager.mainManager.AddToTexture2D("textures", temp, i, nrTex);
            }
        }*/
        private void LoadVertexInfo()
        {
            //vertex buffer
            using (Bitmap normalMap = ResourceManager.mainManager.LoadBitmap(Path.GetDirectoryName(Game.gameClass.GetLvLFilePath()) + "\\normals.png"))
            {
                map = new Vertex[Globals.mapSize + 1, Globals.mapSize + 1];
                    for (int i = 0; i <= Globals.mapSize; i++)
                    {
                        for (int j = 0; j <= Globals.mapSize; j++)
                        {
                            Color temp;
                            if (i == Globals.mapSize || j == Globals.mapSize)
                                temp = new Color4(0, 0, 1, 0).ToColor();
                            else
                                temp = normalMap.GetPixel(i, j);
                            map[i, j] = new Vertex(new Vector3(i, temp.A, j), new Vector3((temp.R - 127) / 127f, (temp.G - 127) / 127f, (temp.B - 127) / 127f));
                        }
                    }
            }
        }