Exemple #1
0
        public M2Info(string modelName)
        {
            ModelPath = modelName;
            mFile = new Stormlib.MPQFile(modelName);
            Header = mFile.Read<M2Header>();

            BoundingBox = new SlimDX.BoundingBox(Header.VertexMin, Header.VertexMax);

            mFile.Position = Header.ofsName;
            byte[] data = mFile.Read(Header.lenName - 1);
            ModelName = Encoding.UTF8.GetString(data);

            FileDirectory = System.IO.Path.GetDirectoryName(modelName) + "\\";
            var vertices = new M2Vertex[Header.nVertices];
            mFile.Position = Header.ofsVertices;
            mFile.Read(vertices);

            LoadTextures();
            ParseVertices(vertices);
            LoadSkins();
        }
Exemple #2
0
        public M2Info(string modelName)
        {
            ModelPath = modelName;
            mFile     = new Stormlib.MPQFile(modelName);
            Header    = mFile.Read <M2Header>();

            BoundingBox = new SlimDX.BoundingBox(Header.VertexMin, Header.VertexMax);

            mFile.Position = Header.ofsName;
            byte[] data = mFile.Read(Header.lenName - 1);
            ModelName = Encoding.UTF8.GetString(data);

            FileDirectory = System.IO.Path.GetDirectoryName(modelName) + "\\";
            var vertices = new M2Vertex[Header.nVertices];

            mFile.Position = Header.ofsVertices;
            mFile.Read(vertices);

            LoadTextures();
            ParseVertices(vertices);
            LoadSkins();
        }
Exemple #3
0
        public bool TourRoles(SlimDX.BoundingBox absBox, List <SlimDX.Matrix> invMatList, UInt32 actorTypes, FOnVisitRole visit, object arg)
        {
            if (invMatList.Count == 0)
            {
                return(true);
            }

            var mapCells = GetMapCell(absBox.Minimum.X, absBox.Minimum.Z, absBox.Maximum.X, absBox.Maximum.Z);

            if (mapCells == null)
            {
                return(false);
            }

            for (var i = 0; i < mapCells.Count(); i++) //方便查看第几个格子
            {
                if (false == TourCellInner(mapCells[i], invMatList, actorTypes, visit, arg))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #4
0
        private void AsyncLoadProc()
        {
            mFile = new Stormlib.MPQFile(FileName);
            SeekChunk("DHOM");
            mFile.Position += 4;
            mHeader         = mFile.Read <MOHD>();

            BoundingBox = new SlimDX.BoundingBox(new SlimDX.Vector3(mHeader.MinPosition.X, mHeader.MinPosition.Y, mHeader.MinPosition.Z),
                                                 new SlimDX.Vector3(mHeader.MaxPosition.X, mHeader.MaxPosition.Y, mHeader.MaxPosition.Z));

            SeekChunk("XTOM");
            uint numBytes = mFile.Read <uint>();

            byte[] texData  = mFile.Read(numBytes);
            var    fullStr  = Encoding.UTF8.GetString(texData);
            var    textures = fullStr.Split('\0');

            uint curPos = 0;

            foreach (var tex in textures)
            {
                if (tex != "")
                {
                    mTextureNames.Add(curPos, tex);
                }

                curPos += (uint)tex.Length + 1;
            }

            SeekChunk("TMOM");
            mFile.Position += 4;

            for (uint i = 0; i < mHeader.nMaterials; ++i)
            {
                MOMT mat = mFile.Read <MOMT>();
                mMaterials.Add(mat);
            }

            Game.GameManager.GraphicsThread.CallOnThread(
                () =>
            {
                foreach (var mat in mMaterials)
                {
                    if (mCustomTextureMgr == null)
                    {
                        mTextures.Add(Video.TextureManager.GetTexture(mTextureNames[mat.ofsTexture1]));
                    }
                    else
                    {
                        mTextures.Add(mCustomTextureMgr.LoadTexture(mTextureNames[mat.ofsTexture1]));
                    }
                }
            }
                );

            SeekChunk("IGOM");
            mFile.Position += 4;

            for (uint i = 0; i < mHeader.nGroups; ++i)
            {
                MOGI mogi = mFile.Read <MOGI>();
                mGroupInfos.Add(mogi);

                WMOGroup group = new WMOGroup(FileName, i, this);
                if (group.LoadGroup())
                {
                    lock (mGroups) mGroups.Add(group);
                }
            }

            isLoadFinished = true;
        }
 public static Microsoft.Xna.Framework.BoundingBox xna(this SlimDX.BoundingBox v)
 {
     return(new Microsoft.Xna.Framework.BoundingBox(v.Minimum.xna(), v.Maximum.xna()));
 }
Exemple #6
0
        private void AsyncLoadProc()
        {
            mFile = new Stormlib.MPQFile(FileName);
            SeekChunk("DHOM");
            mFile.Position += 4;
            mHeader = mFile.Read<MOHD>();

            BoundingBox = new SlimDX.BoundingBox(new SlimDX.Vector3(mHeader.MinPosition.X, mHeader.MinPosition.Y, mHeader.MinPosition.Z),
                new SlimDX.Vector3(mHeader.MaxPosition.X, mHeader.MaxPosition.Y, mHeader.MaxPosition.Z));

            SeekChunk("XTOM");
            uint numBytes = mFile.Read<uint>();
            byte[] texData = mFile.Read(numBytes);
            var fullStr = Encoding.UTF8.GetString(texData);
            var textures = fullStr.Split('\0');

            uint curPos = 0;
            foreach (var tex in textures)
            {
                if (tex != "")
                    mTextureNames.Add(curPos, tex);

                curPos += (uint)tex.Length + 1;
            }

            SeekChunk("TMOM");
            mFile.Position += 4;

            for (uint i = 0; i < mHeader.nMaterials; ++i)
            {
                MOMT mat = mFile.Read<MOMT>();
                mMaterials.Add(mat);
            }

            Game.GameManager.GraphicsThread.CallOnThread(
                () =>
                {
                    foreach (var mat in mMaterials)
                    {
                        if (mCustomTextureMgr == null)
                            mTextures.Add(Video.TextureManager.GetTexture(mTextureNames[mat.ofsTexture1]));
                        else
                            mTextures.Add(mCustomTextureMgr.LoadTexture(mTextureNames[mat.ofsTexture1]));

                    }
                }
            );

            SeekChunk("IGOM");
            mFile.Position += 4;

            for (uint i = 0; i < mHeader.nGroups; ++i)
            {
                MOGI mogi = mFile.Read<MOGI>();
                mGroupInfos.Add(mogi);

                WMOGroup group = new WMOGroup(FileName, i, this);
                if (group.LoadGroup())
                {
                    lock (mGroups) mGroups.Add(group);
                }
            }

            isLoadFinished = true;
        }