Пример #1
0
 public tabFile(EFile a_File)
 {
     m_File = a_File;
     changed = false;
     Stream MS = a_File.Open(FileAccess.Read);
     fileheader = new BinaryStreamReader(MS).Read<tabheader>();
     uint Columns = readUint(MS);
     header = new List<string>((int)Columns);
     data = new List<List<string>>();
     for (int i = 0; i < Columns; i++)
     {
         byte b = (byte)MS.ReadByte();
         if (b != 0)
         {
             ushort tmp = readShort(MS);
             string q = readString(MS);
             header.Add(q);
             int rows = (int)readUint(MS);
             List<string> d = new List<string>(rows);
             for (int j = 0; j < rows; j++)
                 d.Add(readString(MS));
             data.Add(d);
         }
     }
     a_File.Close();
 }
Пример #2
0
        static public EFile GetCompanyLogo(string companyID)
        {
            using var context = new SMySQLContext();
            EFile eFile = context.Files.SingleOrDefault(x => x.companyID == companyID);

            return(eFile);
        }
Пример #3
0
 public XmatWrapper(EFile E)
 {
     file = E;
     eCFile stream = new eCFile(E);
     Mat = new xshmat(stream);
     stream.Close();
 }
Пример #4
0
        public void SaveAll()
        {
            BusinessProcess bp = GetBP();

            if (!IsVirtualFM && this.CurrentFile != null && this.CurrentFile.RowState == DataRowState.Added)
            {
                bp.AddForUpdate(this.EFile);


                bp.AddForUpdate(this.GetFileXRef());

                this.GetActivity().Update(bp);
            }
            else
            {
                this.GetActivity().Update(bp);

                //efile must be update again at the end to save the filestructxml changes
                bp.AddForUpdate(this.EFile);
            }

            foreach (BEManager be in this.MyMngrs.Values)
            {
                be.Update(bp);
            }


            bp.Update();

            if (!IsVirtualFM && this.CurrentFile != null)
            {
                this.CurrentFile.FileStructXml = EFile.CalcFileStructXml(this.CurrentFile, true, false).OuterXml;
                this.CurrentFile.AcceptChanges();
            }
        }
Пример #5
0
 public XmatWrapper(EFile a_Handle, eCShaderDefault.GenericSampler a_Diffuse, eCShaderDefault.GenericSampler a_Opacity, eCShaderDefault.GenericSampler a_Specular, eCShaderDefault.GenericSampler a_SpecularPower)
 {
     file = a_Handle;
     Mat = new xshmat(DateTime.Now);
     Mat.propObj = new bCAccessorPropertyObject(new eCMaterialResource2());
     Mat.dataObj = new bCAccessorPropertyObject(new eCShaderDefault(a_Diffuse, a_Opacity, a_Specular, a_SpecularPower));
     add0();
     add1();
 }
Пример #6
0
 public tabFile(EFile a, params string[] columns)
 {
     fileheader = new tabheader(1);
     header = new List<string>(columns);
     changed = true;
     data = new List<List<string>>();
     for (int i = 0; i < columns.Length; i++)
         data.Add(new List<string>());
     m_File = a;
 }
Пример #7
0
 private void appendPak(EFile a_File, TreeNode parentTN)
 {
     TreeNode v_N = null;
     if (parentTN == null)
         v_N = treeView1.Nodes.Add(a_File.Name);
     else v_N = parentTN.Nodes.Add(a_File.Name);
     v_N.Tag = a_File;
     if (a_File.IsDirectory)
         foreach (EFile f in a_File.Children)
             appendPak(f, v_N);
 }
Пример #8
0
        public void FileStructureEFileTest()
        {
            const EFile expected = EFile.FileG;
            var         f        = new F(expected);
            var         actual   = f.Value;

            Assert.Equal(expected, actual);

            f      = expected;
            actual = f.Value;
            Assert.Equal(expected, actual);
        }
Пример #9
0
        public void FileStructureIntTest()
        {
            const int   val      = 3;
            const EFile expected = (EFile)val;
            var         f        = new F(val);
            var         actual   = f.Value;

            Assert.Equal(expected, actual);

            f      = val;
            actual = f.Value;
            Assert.Equal(expected, actual);
        }
Пример #10
0
        public EFile GetCompanyLogoByURL([FromBody] string url)
        {
            var eCompany = SCompanies.GetByLabSite(url);

            if (eCompany == null)
            {
                SLogger.LogError("(GetCompanyLogoByURL)não foi possível encontrar pela url: " + url);
                return(null);
            }
            EFile eFile = SFiles.GetCompanyLogo(eCompany.id);

            eFile.companyName   = eCompany.name;
            eFile.contentBase64 = Convert.ToBase64String(eFile.content);
            return(eFile);
        }
        public IHttpActionResult UploadFiles([FromUri] string reference, [FromUri] string orderType, [FromUri] string fileName, [FromUri] string version)
        {
            var fileGetter = new FilesGetter();

            var path = fileGetter.GetAndSaveSingleFileFromHttpRequest(@"D:\eFolder\");

            var newFileRecord = new EFile();

            if (version == "V1")
            {
                //newFileRecord.CustomizedFileName = fileName + "-" + DateTime.Now.ToString("hhmmss");
                newFileRecord.CustomizedFileName = path.Split('\\').Last().Split('-')[1];
                newFileRecord.FileName           = path.Split('\\').Last();
                newFileRecord.RootPath           = @"D:\eFolder\";
                newFileRecord.UploadBy           = _userName;
                newFileRecord.UploadDate         = DateTime.Now;
                newFileRecord.Status             = FBAStatus.Valid;
            }
            else
            {
                throw new Exception("The system does not support version:" + version + ".");
            }

            if (orderType == FBAOrderType.MasterOrder)
            {
                var masterOrderInDb = _context.FBAMasterOrders.SingleOrDefault(x => x.Container == reference);
                newFileRecord.FBAMasterOrder = masterOrderInDb;
            }
            else if (orderType == FBAOrderType.ShipOrder)
            {
                var shipOrderInDb = _context.FBAShipOrders.SingleOrDefault(x => x.ShipOrderNumber == reference);
                newFileRecord.FBAShipOrder = shipOrderInDb;
            }
            else
            {
                throw new Exception("The system does not support order type:" + orderType + ".");
            }

            _context.EFiles.Add(newFileRecord);
            _context.SaveChanges();

            return(Ok(Mapper.Map <EFile, EFileDto>(newFileRecord)));
        }
Пример #12
0
 void DoThreading(EFile[] a_Files, List<LrentFile> a_FilesFin, API_Device D)
 {
     HWND v_MainBlock = ThreadManager.CreateSemaphore(0, 1);
     Queue<EFile> m_Files = new Queue<EFile>(a_Files.Length);
     foreach (EFile f in a_Files)
         m_Files.Enqueue(f);
     int c = Math.Max(Environment.ProcessorCount - 2, 1);
     c = Math.Min(c, m_Files.Count);
     c = 1;
     HWND[] m_Threads = new HWND[c];
     object[] O = new object[] { m_Files, a_FilesFin, v_MainBlock, D};
     for (int i = 0; i < m_Threads.Length; i++)
     {
         m_Threads[i] = ThreadManager.CreateThread(DoThreading2);
         ThreadManager.StartThread(m_Threads[i], O);
     }
     ThreadManager.WaitForSingleObject(v_MainBlock);
     ThreadManager.AbortObject(v_MainBlock);
 }
Пример #13
0
        public Texture2D LoadTextureFromFile(EFile s, API_Device D)
        {
            Stream fStream = s.Open(FileAccess.Read);
            fStream.Position = 16L;
            int i0 = fStream.ReadInt();
            int i1 = fStream.ReadInt();
            fStream.Position = i0;
            Texture2D T = Texture2D.FromStream(D.HadrwareDevice(), fStream, i1);
            s.Close();
            return T;
            /*
            BinaryReader bReader = new BinaryReader(fStream);

            char[] ResMagic = bReader.ReadChars(4);
            char[] ResClass = bReader.ReadChars(4);
            int PropOffset = bReader.ReadInt32();
            int PropLength = bReader.ReadInt32();
            int DataOffset = bReader.ReadInt32();
            int DataLength = bReader.ReadInt32();
            long RawDateTime = bReader.ReadInt64();
            char[] RawFileExt = bReader.ReadChars(8);

            bReader.BaseStream.Position = PropOffset;
            byte[] Buffer = new byte[PropLength];
            for (int i = 0; i < PropLength; i++)
                Buffer[i] = bReader.ReadByte();

            bReader.BaseStream.Position = DataOffset;
            byte[] Surface = new byte[DataLength];
            for (int i = 0; i < DataLength; i++)
                Surface[i] = bReader.ReadByte();
            fStream.Close();
            bReader.Close();

            DataStream ds = new DataStream(Surface, true, true);
            Texture2D t11 = Texture2D.FromStream(D.HadrwareDevice(), ds, (int)ds.Length);
            ds.Dispose();
            Surface = null;
            ds = null;
            return t11;*/
        }
Пример #14
0
 public async Task <IActionResult> UploadFile(IFormFile upload, string tag, string id, string user)
 {
     //здесь пока что нет вообще никакой безопасности
     if (upload != null)
     {
         if (upload.Length >= 10485760)
         {
             return(RedirectToAction("Index", new { DiscId = id, FileError = true }));
         }
         var    euser   = await(from u in DBContext.Users where u.Email.ToLower() == user.ToLower() select u).FirstOrDefaultAsync();
         string t       = tag;
         string outpath = Environment.WebRootPath + "/DisciplineFiles/" + "id" + id + "/" + tag + "/";
         if (!Directory.Exists(outpath))
         {
             Directory.CreateDirectory(outpath);
         }
         outpath += upload.FileName;
         using (var fileStream = new FileStream(outpath, FileMode.Create))
         {
             await upload.CopyToAsync(fileStream);
         }
         var efile = new EFile()
         {
             DateLoad = DateTime.Today.ToShortDateString(),
             UserLoad = euser,
             Tag      = tag,
             Path     = outpath,
             Name     = upload.FileName
         };
         var disc = await(from di in DBContext.Disciplines.Include(f => f.Files)
                          where di.Id.ToString() == id
                          select di).FirstOrDefaultAsync();
         DBContext.Update(disc).Entity.Files.Add(efile);
         await DBContext.SaveChangesAsync();
     }
     return(RedirectToAction("Index", new { DiscId = id }));
 }
Пример #15
0
        public RisenPak(EFile F, Dictionary<string, RisenPakFile> files, bool DoOverwrite = false)
        {
            rootFolderLoc = F.Path.Replace(FileManager.g_pGamepath, "").ToLower().Replace(".pak", "") + "\\";
            m_Stream = F.Open(FileAccess.Read);
            BinaryReader bReader = new BinaryReader(m_Stream);
            m_Stream.Position = 24L;
            long DataOffset = m_Stream.ReadLong();
            long RootOffset = m_Stream.ReadLong();
            long VolumeSize = m_Stream.ReadLong();
            bReader.BaseStream.Position = (long)RootOffset;
            root = new RisenPakDirectory(bReader, null, this);
            if (files == null)
                return;

            Stack<RisenPakDirectory> dirs = new Stack<RisenPakDirectory>();
            dirs.Push(root);
            while (dirs.Count != 0)
            {
                RisenPakDirectory cd = dirs.Pop();
                foreach (RisenPakFilePart q in cd.Children)
                {
                    if (q is RisenPakDirectory)
                    {
                        dirs.Push(q as RisenPakDirectory);
                    }
                    else if(q is RisenPakFile)
                    {
                        if (!files.ContainsKey(q.nameCAP))
                            files.Add(q.nameCAP, (RisenPakFile)q);
                        else if (DoOverwrite)
                            files[q.nameCAP] = (RisenPakFile)q;
                        else throw new Exception();
                    }
                }
            }
        }
Пример #16
0
        private atriumDB.EFileRow CreateFile(FileManager parentFile)
        {
            try
            {
                ParentFile = parentFile;
                atriumDB.EFileRow drFile = (atriumDB.EFileRow)EFile.Add(parentFile.CurrentFile);

                atriumDB.FileXRefRow fxr = (atriumDB.FileXRefRow)GetFileXRef().Add(parentFile.CurrentFile);
                fxr.LinkType    = 0;
                fxr.FileId      = parentFile.CurrentFile.FileId;
                fxr.OtherFileId = drFile.FileId;
                if (!drFile.IsNull("FileNumber"))
                {
                    fxr.Name           = drFile.FileNumber;
                    fxr.FullFileNumber = drFile.FullFileNumber;
                }

                return(drFile);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Пример #17
0
 public void Load(EFile F, API_Device D)
 {
     BinaryStream s = F.Open(FileAccess.Read).CopyToBin();
     HeaderXmot a = new HeaderXmot(s);
     //a.data.
 }
Пример #18
0
        public static void InitFileManager(D3DApplication a_App, string a_Basepath = null)
        {
            NotifyOnPhysicalWatch = true;
            g_pApp = a_App;
            API_Device D = a_App.Device;

            e_MatEffect = new EffectWrapper("matCombiner.fx", D);
            r_MatTarget = new RenderTarget(2048, 2048, 1, SlimDX.Direct3D11.BindFlags.RenderTarget, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D);

            D.Content.FileHandleCreator = getHandle;
            D.Content.RegisterMaterialLoader(new XmatLoader());
            D.Content.RegisterModelLoader(new XMACLoader());
            D.Content.RegisterModelLoader(new XMSHLoader());
            D.Content.RegisterTextureLoader(new XIMGLoader());

            string basePath2 = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Deep Silver\Risen\", "INSTALL_DIR", string.Empty) as string;
            if (basePath2 != null && Directory.Exists(basePath2))
            {//registry based
                g_pGamepath = basePath2.Replace(@"\bin", @"\");
            }
            else if(!string.IsNullOrEmpty(a_Basepath))
            {//ini file based
                g_pGamepath = a_Basepath + @"\";
            }
            else
            {
                var msg = "Couldn't find risen directory. Terminating";
                SystemLog.Append(LogImportance.System, msg);
                SystemLog.Flush();
                MessageBox.Show(msg);
                throw new Exception();
            }

            m_Paks = new Dictionary<string, RisenPak>();
            DirectoryInfo[] Ds = new DirectoryInfo[] { new DirectoryInfo(g_pGamepath + "/data/common"), new DirectoryInfo(g_pGamepath + "/data/compiled") };
            for (int i = 0; i < Ds.Length; i++)
            {
                if (!Ds[i].Exists)
                    continue;

                int n = -1;
                while (true)
                {
                    string a = n.ToString().PadLeft(2, '0');
                    FileInfo[] Fs = Ds[i].GetFiles(n < 0 ? ("*.pak") : ("*.p" + a));
                    foreach (FileInfo f in Fs)
                    {
                        string key = Ds[i].Name + @"\" + f.Name.Replace(f.Extension, "") + (n < 0 ? "" : a);
                        RisenPak val = new RisenPak(FileManager.GetFile(f.FullName), _Files, n >= 0);
                        m_Paks.Add(key, val);
                    }
                    n++;
                    if (Fs.Length == 0)
                        break;
                }
            }

            m_Watcher.Path = g_pGamepath;
            m_Watcher.IncludeSubdirectories = true;
            m_Watcher.NotifyFilter = NotifyFilters.FileName;
            m_Watcher.Created += W_Created;
            m_Watcher.Deleted += W_Created;
            m_Watcher.Renamed += W_Created;
            m_Watcher.EnableRaisingEvents = true;

            initFinished = true;

            StdFileReader S = new StdFileReader();
            Dictionary<string, EFile> _PhyFiles = new Dictionary<string, EFile>();
            List<EFile> newFiles = new List<EFile>();
            Stack<DirectoryInfo> Dirs = new Stack<DirectoryInfo>();
            Dirs.Push(new DirectoryInfo(g_pGamepath + "/Data"));
            while (Dirs.Count != 0)
            {
                DirectoryInfo d = Dirs.Pop();
                DirectoryInfo[] _d = d.GetDirectories();
                FileInfo[] _f = d.GetFiles();
                foreach (DirectoryInfo q0 in _d)
                    Dirs.Push(q0);
                foreach (FileInfo q1 in _f)
                {
                    string k = q1.Name.ToUpper();
                    if (!isArchiveExtension(q1))
                    {
                        EFile e = new EFile(q1.FullName, S);
                        if (_PhyFiles.ContainsKey(k))
                        {
                            SystemLog.Append(LogImportance.System, "Two identical physical files found!");
                            throw new Exception("Two identical physical files found!");
                        }
                        _PhyFiles.Add(k, e);
                        if (!FileManager._PhyFiles.ContainsKey(k))
                            newFiles.Add(e);
                    }
                }
            }
            FileManager._PhyFiles = _PhyFiles;

            List<EFile> tabfiles = new List<EFile>();
            System.IO.StreamReader tr = new System.IO.StreamReader(g_pGamepath + "data\\ini\\loc.ini");
            while (!tr.EndOfStream)
            {
                string l = tr.ReadLine();
                while (!tr.EndOfStream && string.IsNullOrEmpty(l))
                    l = tr.ReadLine();
                if (tr.EndOfStream)
                    break;
                string prefix = tr.ReadLine().Replace("prefix=", ""), csv = tr.ReadLine().Replace("csv=", ""), bin = tr.ReadLine().Replace("bin=", "");
                EFile a = GetFile(bin.Replace(@"#G3:/", ""));
                if (!a.IsOpenable)
                    SystemLog.Append(LogImportance.Warning, "Tab file not found : " + a.Name);
                tabFile b = new tabFile(a);
                tab_files.Add(a.Name, b);
                tab_FilesPrefix.Add(prefix.ToLower(), b);
            }
            tr.Close();
        }
Пример #19
0
 public static EFile GetPhysicalFileLocation(string a_PakFilePath, bool a_Create = true)
 {
     FileInfo F = new FileInfo(g_pGamepath + a_PakFilePath);
     if (!F.Directory.Exists)
         F.Directory.Create();
     string a = F.Directory.FullName + "\\" + F.Name;
     EFile b = new EFile(a, new StdFileReader());
     if (a_Create)
         b.Create(FileMode.Create);
     return b;
 }
Пример #20
0
        public Material LoadMaterial(EFile _File, API_Device D)
        {
            if (_File.IsOpenable)
            {
                ShaderResourceTexture T = null;
                if (_File.Name == "Nat_Stone_Rock_01_Diffuse_01_Specular._xmat")
                    T = new ShaderResourceTexture("Nat_Stone_Rock_01_Diffuse_01._ximg", D);
                else if (_File.Name == "Special_Water_Swamp_01_Diffuse_01._xmat")
                    T = new ShaderResourceTexture("Special_Water_Caustics_01_Diffuse_01._ximg", D);
                else
                {
                    XmatWrapper W = new XmatWrapper(_File);

                    bCGuid src_Diffuse = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcDiffuse.Token;
                    bCGuid src_Normal = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcNormal.Token;
                    bCGuid src_Specular = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcSpecular.Token;
                    if (src_Diffuse.IsValid)
                    {
                        eCShaderDefault shader = (W.Mat.dataObj.Class as eCShaderDefault);
                        eCShaderEllementBase ellement = shader.GetEllementByGuid(shader.ColorSrcDiffuse.Token);
                        if (ellement is subClassBase)
                            T = (ellement as subClassBase).CreateTexture(D);
                    }
                    if (T == null)
                        T = ShaderResourceTexture.WhiteTexture;
                }
                return new Material(T);
            }
            else
            {
                return new Material("42", true, D);
            }
        }
Пример #21
0
        static void W_Created(object sender, FileSystemEventArgs e)
        {
            if (!File.Exists(e.FullPath))
                return;
            EFile e2 = null;
            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                e2 = new EFile(e.FullPath, new StdFileReader());
                if(!_PhyFiles.ContainsKey(e2.Name.ToUpper()))
                    //lock (m_PhyBlock)
                    {
                        _PhyFiles.Add(e.Name.ToUpper(), e2);
                    }
            }
            else if (e.ChangeType == WatcherChangeTypes.Renamed)
            {
                e2 = new EFile(e.FullPath, new StdFileReader());
                if (!_PhyFiles.ContainsKey(e2.Name.ToUpper()))
                    //lock (m_PhyBlock)
                    {
                        _PhyFiles.Add(e.Name.ToUpper(), e2);
                    }
            }
            else if (e.ChangeType == WatcherChangeTypes.Deleted)
            {

            }
            if (NotifyOnPhysicalWatch && NewFilesFound != null && e2 != null)
                NewFilesFound(new List<EFile>() { e2});
        }
Пример #22
0
 public static void Read(EFile _File, Form1 C, List<EFile> _Files)
 {
     SystemLog.Append(LogImportance.Information, "Sec file imported : " + _File.Name);
     SecFile S = new SecFile(_File);
     foreach (string s in S.LrentFiles)
         _Files.Add(FileManager.GetFile(s));
 }
Пример #23
0
 LrentFile Read(EFile file, API_Device D)
 {
     SystemLog.Append(LogImportance.Information, "Lrent file imported : " + file.Name);
     if (file.Name.Contains("Levelmesh_Water_Rivermesh.lrent") || file.Name.Contains("OutMain_Nav.lrent") || !file.IsOpenable)
         return null;
     return new LrentFile(file, D);
 }
Пример #24
0
 public ximg(ShaderResourceTexture T, EFile rawFile)
 {
     Prop = new bCAccessorPropertyObject(new eCImageResource2());
     header = new ximgHeader();
     Prop.Properties.addProperty("Width", "int", T.Width);
     Prop.Properties.addProperty("Height", "int", T.Height);
     Prop.Properties.addProperty("SkipMips", "long", 0);
     Prop.Properties.addProperty("PixelFormat", "bTPropertyContainer<enum eCGfxShared::eEColorFormat>", eCImageResource2_eCGfxShared_eEColorFormat.eEColorFormat_DXT1);
     var s = rawFile.Open(System.IO.FileAccess.Read);
     tgaData = s.GetAllBytes();
     rawFile.Close();
 }
Пример #25
0
 public ximg(EFile e)
 {
     eCFile s = new eCFile(e);
     deSerialize(s);
     s.Close();
 }
Пример #26
0
        public void LoadModel(EFile file, API_Device D)
        {
            //fStream = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            fStream = file.Open(FileAccess.Read);
            bReader = new BinaryReader(fStream);

            Seek(136);
            UInt32 xacFileSize = bReader.ReadUInt32();
            char[] cs = bReader.ReadChars(3);
            string s = cs[0].ToString() + cs[1].ToString() + cs[2].ToString();
            if (s != "XAC")
                throw new Exception("This is not a valid XMAC file.");
            Seek(146);
            if (bReader.ReadByte() != 0)
            {
                long p = bReader.BaseStream.Position;
                bReader = new bReader2(fStream);
                bReader.BaseStream.Position = p;
            }
            Seek(148);
            while ((xacFileSize + 140) != Tell())
            {
                UInt32 secID = bReader.ReadUInt32();
                if (secID == 1)
                { // Mesh.
                    readMeshSection();
                }
                else if (secID == 2)
                { // Weighting.
                    readWeightingSection();
                }
                else if (secID == 7)
                { // General scene information.
                    readInfoSection();
                }
                else if (secID == 11)
                { // Nodes.
                    readNodesSection();
                }
                else if (secID == 13)
                { // Mats.
                    readMatsSection();
                }
                // (secID == 3) would belong to "MatSection" but all of them are read by readMatsSection().
                //else throw new EngineError("Unknown Error", EngineErrorType.NoInformation);
                else break;//this prevents it from crashing while loading faces, some other models can't be seen when this is activated due to some problems
            }

            var tmp = SubObj.CreateData(Vertices, TVertices, Normals, Tris);
            for (int i = 0; i < Materials.Count; i++)
            {
                if ((Materials[i].n.Contains("EMFX")) || (Materials[i].n.Contains("collision", StringComparison.CurrentCultureIgnoreCase)))
                    continue;
                string qs = Materials[i].n;
                SubObj so = new SubObj(qs, i);
                so.CreateVertexBuffer(tmp, true);
                so.LoadMaterial(D);
                SubObjekte.Add(so);
                //Matrix rm = Matrix.RotationAxis(Vector3.UnitY, MathHelper.PiOver2);
                //for (int i2 = 0; i2 < so.Vertices.Length; i2++)
                //    so.Vertices[i2].Position = Core.TransformVec3(so.Vertices[i2].Position.ToVec3(), rm).ToVec4(1.0f);
            }
            SubObjekte.Remove(null);
        }
Пример #27
0
        public void LoadModel(EFile file, API_Device D)
        {
            List<List<Vector3>> verts = new List<List<Vector3>>();
            List<List<Vector3>> tverts = new List<List<Vector3>>();
            List<List<int>> faces = new List<List<int>>();
            List<int> vcounts = new List<int>();
            List<int> icounts = new List<int>();
            List<string> matnames = new List<string>();
            int allinds = 0;
            int allverts = 0;
            int numoldverts = 0;
            float x = 0, y = 0, z = 0, u = 0, v = 0, w = 0;

            this.SubObjekte = new List<SubObj>();
            //FileStream fStream = new FileStream(file., FileMode.Open, FileAccess.Read);
            Stream fStream = file.Open(FileAccess.Read);
            bReader = new BinaryReader(fStream);
            Skip(70);
            int vd = bReader.ReadInt32();
            Skip(53);
            numSubMehshes = bReader.ReadInt32();
            for (int h = 0; h < numSubMehshes; h++)
            {
                verts.Add(new List<Vector3>());
                tverts.Add(new List<Vector3>());
                faces.Add(new List<int>());
                Suche((int)vd, 77, 97, 116, 101, 114, 105, 97, 108);
                Skip(20);
                short len = Math.Abs(bReader.ReadInt16());
                //string name = bReader.ReadString();
                //matnames.Add(name.Replace("._xmat", ".dds"));
                byte[] namebs = bReader.ReadBytes(len);
                string name = new System.Text.ASCIIEncoding().GetString(namebs);
                matnames.Add(name);
                Suche((int)vd, 73, 110, 100, 101, 120, 67, 111, 117, 110, 116);
                Skip(12);
                int indcount = Math.Abs(bReader.ReadInt32());
                icounts.Add(indcount);
                allinds += indcount;
                Skip(54);
                int vertcount = Math.Abs(bReader.ReadInt32());
                vcounts.Add(vertcount);
                allverts += vertcount;
            }
            bReader.BaseStream.Position = (vd + 202);
            int vdsize = Math.Abs(bReader.ReadInt32());
            Skip(12);
            int o = Math.Abs(bReader.ReadInt32());
            o /= 4;
            Skip(56);
            int svd = (int)bReader.BaseStream.Position;
            for (int ii = 0; ii < numSubMehshes; ii++)
            {
                for (int i = 0; i < (o * vcounts[ii]) ; i++)
                {
                    float f = bReader.ReadSingle();
                    int id = (i + 1) % o;
                    if (id == 1)
                    {
                        y = -f;
                    }
                    if (id == 2)
                    {
                        z = f;
                    }
                    if (id == 3)
                    {
                        x = f;
                        verts[ii].Add(new Vector3(x,y,z));
                    }
                    if (o == 13)
                    {
                        if (id == 11)
                        {
                            w = f;
                        }
                        if (id == 12)
                        {
                            u = f;
                        }
                        if (id == 0)
                        {
                            v = f;//v = 1 - f;
                            tverts[ii].Add(new Vector3(u,v,w));
                        }
                    }
                   if (o == 15)
                    {
                        if (id == 11)
                        {
                             w = f;
                        }
                        if (id == 12)
                        {
                            u = f;
                        }
                        if (id == 13)
                        {
                            v = f;
                            tverts[ii].Add(new Vector3(u,v,w));
                        }
                    }
                }
            }
            for (int jj = 0; jj < numSubMehshes; jj++)
            {
                for (int n = 0; n < icounts[jj]; n++)
                {
                    int f = (int)bReader.ReadUInt32();
                    f -= numoldverts;
                    float id = (n + 1) % 3;
                    if (id == 1)
                    {
                        x = f;
                    }
                    if (id == 2)
                    {
                        y = f;
                    }
                    if (id == 0)
                    {
                        z = f;
                        faces[jj].Add((int)x);
                        faces[jj].Add((int)y);
                        faces[jj].Add((int)z);
                    }
                }
                numoldverts += vcounts[jj];
            }
            for (int s = 0; s < numSubMehshes; s++)
            {
                SubObj so = new SubObj(matnames[s], s);
                List<Tri> ts = new List<Tri>();
                for (int fl = 0; fl < faces[s].Count; fl += 3)
                    ts.Add(new Tri(faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], s));
                int c = verts[s].Count + 1;
                Vector3[] vtmp = new Vector3[c];
                List<Vector3> ns = new List<Vector3>(vtmp);
                for (int h = 0; h < verts[s].Count; h++)
                    verts[s][h] = Vector3.Transform(verts[s][h], mRot).ToVec3();
                var tmp = SubObj.CreateData(verts[s], tverts[s], ns, ts);
                so.CreateVertexBuffer(tmp, true);
                so.LoadMaterial(D);
                SubObjekte.Add(so);
            }
            file.Close();
        }
Пример #28
0
 public static EFile[] GetFiles(params string[] Names)
 {
     EFile[] F = new EFile[Names.Length];
     for (int i = 0; i < Names.Length; i++)
         F[i] = GetFile(Names[i]);
     return F;
 }
Пример #29
0
 void recAdd(EFile e, TreeNode n)
 {
     if (e.Extension == ".wrldatasc")
         return;
     TreeNode N = null;
     if (n == null)
     {
         N = new TreeNode(e.Name);
         treeView1.Nodes.Add(N);
     }
     else N = n.Nodes.Add(e.Name);
     N.ImageIndex = _ImgIndex(N);
     if (e.IsDirectory)
         foreach (EFile c in e.Children)
             recAdd(c, N);
 }
Пример #30
0
 public TpleFile(EFile F)
 {
     eCArchiveFile a_Stream = new eCArchiveFile(F);
     a_Stream.Position = 14;
     magic = a_Stream.Read<char>(8);
     Version = a_Stream.Read<short>();
     count = a_Stream.Read<int>();
     headers = new List<TempHeader>();
     contents = new List<TempContent>();
     for (int i = 0; i < count; i++)
     {
         headers.Add(new TempHeader(a_Stream));
         contents.Add(new TempContent(a_Stream));
     }
 }