示例#1
0
        private fileType LoadFile(System.IO.FileInfo fi, string requestedName, out string varname, out Bitmap output)
        {
            fileType returnType = fileType.ImageMdl;

            varname = "";
            output  = null;
            if (fi.Name.EndsWith(".mdl"))
            {
                MDL.MDLFile test  = new MDL.MDLFile();
                bool        valid = test.ReadFromFile(fi.FullName);
                if (valid)
                {
                    currentBinaryMDL = test;
                    returnType       = fileType.ModelMdl;
                    if (test.RootObject.Where(x => x.type == MDLType.mdl_image).Count() > 0)
                    {
                        output     = test.RootObject.First(x => x.type == MDLType.mdl_image).image.myBitmap;
                        returnType = fileType.ImageMdl;
                    }
                }
                else
                {
                    currentBinaryMDL = null;
                    System.IO.FileStream fs;
                    try
                    {
                        fs = fi.OpenRead();
                        using (System.IO.BinaryReader br = new System.IO.BinaryReader(fs))
                        {
                            br.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                            output     = LoadTextBmpMDL(fi, out currentReferencedFiles, requestedName, out varname);
                            returnType = fileType.TextMdl;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                returnType       = fileType.Image;
                currentBinaryMDL = null;
                output           = (Bitmap)Bitmap.FromFile(fi.FullName);
            }

            return(returnType);
        }
示例#2
0
 public BinaryMDL(MDL.MDLFile mdlf)
 {
     this.binaryHeader._1_MDLMagic           = 0xDEBADF00;
     binaryHeader._2_MDLVersion              = mdlf.header.MDLVersion;
     binaryHeader._3_ImportedNameSpacesCount = mdlf.header.ImportedNameSpacesCount;
     binaryHeader._4_ImportedSymbolCount     = mdlf.header.ImportedSymoblCount;
     binaryHeader._5_ExportedSymbolCount     = mdlf.header.ExportedSymbolCount;
     binaryHeader._6_OtherObjectCount        = mdlf.header.OtherObjectsCount;
     if (mdlf.Lights != null)
     {
         lights = new List <MDLLight>(mdlf.Lights);
     }
     if (mdlf.FrameDatas != null)
     {
         frames = new List <MDLFrameData>(mdlf.FrameDatas);
     }
     if (mdlf.Textures != null)
     {
         textures = new List <string>(mdlf.Textures);
     }
     mainObject = mdlf.RootObject;
     FrameVal   = mdlf.FrameVal;
 }