Esempio n. 1
0
        IResource IResourceLoader.Load(FileSystemNode n)
        {
            StreamReader r = new StreamReader(n.getStream());
            string line;

            string header = r.ReadLine().Trim();
            if (header != "TERRAINTEXT")
                return null;

            IHeightMap hm = null;
            Texture color = null;
            Texture detail = null;
            float size = 1;
            float heightscale = 1;
            int patchsize = 33;

            while ((line = r.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.Length == 0 || line.StartsWith("#"))
                    continue;

                string[] split = line.Split(new char[] { ':' });
                string key = split[0].Trim();
                string val = split[1].Trim();

                switch (key)
                {
                    case "colormap":
                        color = Root.Instance.ResourceManager.LoadTexture(val);
                        break;
                    case "heightmap":
                        hm = Root.Instance.ResourceManager.LoadHeightMap(val);
                        break;
                    case "detailmap":
                        detail = Root.Instance.ResourceManager.LoadTexture(val);
                        break;
                    case "patchsize":
                        patchsize = int.Parse(val);
                        break;
                    case "heightscale":
                        heightscale = float.Parse(val);
                        break;
                    case "size":
                        size = float.Parse(val);
                        break;
                }

            }

            Terrain t = new Terrain(hm, color, detail,size,heightscale,patchsize);

            return t;
        }
Esempio n. 2
0
 public Patch(Terrain master,int x,int y)
 {
     PatchGridPosition=new Point(x,y);
     Master=master;
     ib=new IndexBuffer[master.Levels];
     ibfixed=new IndexBuffer();
 }