예제 #1
0
        void RebuildImage()
        {
            if (mAtlas != null)
            {
                mAtlas.FreeAll();
            }

            mAtlas = new TexAtlas(mGD, (int)AtlasX.Value, (int)AtlasY.Value);

            bool bAllWorked = true;

            List <string> textures = mSK.GetTexture2DList();

            for (int i = 0; i < mGridData.Count; i++)
            {
                HeightMap.TexData gd = mGridData[i];
                if (textures.Contains(gd.TextureName))
                {
                    if (!mSK.AddTexToAtlas(mAtlas, gd.TextureName, mGD,
                                           out gd.mScaleU, out gd.mScaleV, out gd.mUOffs, out gd.mVOffs))
                    {
                        bAllWorked = false;
                        break;
                    }
                }
            }

            if (!bAllWorked)
            {
                return;
            }

            AtlasPic01.Image = mAtlas.GetAtlasImage(mGD.DC);

            mAtlas.Finish(mGD);
        }
예제 #2
0
        void LoadTerrainTextureStuff(string path)
        {
            string noExt = FileUtil.StripExtension(path);

            string fname = noExt + ".TerTexData";

            FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read);

            if (fs == null)
            {
                return;
            }

            BinaryReader br = new BinaryReader(fs);

            if (br == null)
            {
                return;
            }


            UInt32 magic = br.ReadUInt32();

            if (magic != 0x7EC5DA7A)
            {
                br.Close();
                fs.Close();
                return;
            }

            //atlas size
            int atlasX = br.ReadInt32();
            int atlasY = br.ReadInt32();

            //transition height
            int transitionHeight = br.ReadInt32();

            TexAtlas ta = new TexAtlas(mGD, atlasX, atlasY);

            //load into a temp list first
            List <HeightMap.TexData> gridStuffs = new List <HeightMap.TexData>();

            int count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                HeightMap.TexData td = new HeightMap.TexData();

                td.BottomElevation = br.ReadSingle();
                td.TopElevation    = br.ReadSingle();
                td.Steep           = br.ReadBoolean();
                td.ScaleFactor     = br.ReadSingle();
                td.TextureName     = br.ReadString();
                td.mScaleU         = br.ReadDouble();
                td.mScaleV         = br.ReadDouble();
                td.mUOffs          = br.ReadDouble();
                td.mVOffs          = br.ReadDouble();

                gridStuffs.Add(td);
            }

            br.Close();
            fs.Close();

            List <string> textures = mSK.GetTexture2DList();

            for (int i = 0; i < gridStuffs.Count; i++)
            {
                HeightMap.TexData gd = gridStuffs[i];
                if (textures.Contains(gd.TextureName))
                {
                    if (!mSK.AddTexToAtlas(ta, gd.TextureName, mGD,
                                           out gd.mScaleU, out gd.mScaleV, out gd.mUOffs, out gd.mVOffs))
                    {
                        //todo something here
                    }
                }
            }

            ta.Finish(mGD);

            Texture(ta, gridStuffs, transitionHeight);
        }