Ejemplo n.º 1
0
        public static void AddDFF(ArchiveFile j)
        {
            if (ObjectDFFNames.Contains(j.Name))
            {
                RenderWareModelFile d = new RenderWareModelFile(j.Name);
                byte[] dffData        = j.DecompressThis();
                d.SetForRendering(ReadFileMethods.ReadRenderWareFile(dffData), dffData);

                if (DFFStream.ContainsKey(j.Name))
                {
                    MessageBox.Show("Object model " + j.Name + " has already been loaded and will be replaced.");

                    foreach (SharpMesh mesh in DFFStream[j.Name].meshList)
                    {
                        mesh.Dispose();
                    }

                    DFFStream[j.Name] = d;
                }
                else
                {
                    DFFStream.Add(j.Name, d);
                }
            }
        }
Ejemplo n.º 2
0
        private void SetShadowBSPList(SharpRenderer renderer, List <Archive> OpenShadowONEFiles)
        {
            Dispose();

            BSPList          = new List <RenderWareModelFile>();
            ShadowColBSPList = new List <RenderWareModelFile>();

            ReadFileMethods.isShadow = true;

            foreach (Archive f in OpenShadowONEFiles)
            {
                foreach (ArchiveFile file in f.Files)
                {
                    string ChunkName = Path.GetFileNameWithoutExtension(file.Name);

                    if (ChunkName.Contains("COLI"))
                    {
                        ReadFileMethods.isCollision = true;

                        RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);

                        foreach (string s in ChunkName.Split('_'))
                        {
                            try
                            {
                                TempBSPFile.ChunkNumber = Convert.ToByte(s);
                                break;
                            }
                            catch { TempBSPFile.ChunkNumber = -1; }
                        }

                        TempBSPFile.isShadowCollision = true;
                        try
                        {
                            byte[] data = file.DecompressThis();
                            TempBSPFile.SetForRendering(renderer.Device, ReadFileMethods.ReadRenderWareFile(data), data);
                        }
                        catch (Exception e)
                        {
                            System.Windows.Forms.MessageBox.Show("Error on opening " + file.Name + ": " + e.Message);
                        }
                        ShadowColBSPList.Add(TempBSPFile);

                        ReadFileMethods.isCollision = false;
                    }
                    else
                    {
                        RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);
                        TempBSPFile.SetChunkNumberAndName();
                        byte[] data = file.DecompressThis();
                        TempBSPFile.SetForRendering(renderer.Device, ReadFileMethods.ReadRenderWareFile(data), data);
                        BSPList.Add(TempBSPFile);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void AddDFF(ArchiveFile j)
        {
            if (ObjectDFFNames.Contains(j.Name))
            {
                RenderWareModelFile d = new RenderWareModelFile(j.Name);
                byte[] dffData        = j.DecompressThis();

                try
                {
                    d.SetForRendering(mainForm.renderer.Device, ReadFileMethods.ReadRenderWareFile(dffData), dffData);

                    if (DFFModels.ContainsKey(j.Name))
                    {
                        foreach (SharpMesh mesh in DFFModels[j.Name].meshList)
                        {
                            mesh.Dispose();
                        }

                        DFFModels[j.Name] = d;
                    }
                    else
                    {
                        DFFModels.Add(j.Name, d);
                    }
                }
                catch (Exception ex)
                {
                    // TODO: Investigate RenderWareFile failing to open certain DFFs.
                    MessageBox.Show($"RenderWareFile: Failed to open DFF model file; {j.Name} | Exception Message: {ex.Message}");
                }
            }
            else if (Path.GetExtension(j.Name).ToLower().Equals(".txd"))
            {
                try
                {
                    byte[] txdData = j.DecompressThis();

                    mainForm.LoadTexturesFromTXD(txdData);
                }
                catch (Exception ex)
                {
                    #if DEBUG
                    MessageBox.Show("Unable to load textures from TXD: " + ex.Message);
                    #endif
                }
            }
        }
Ejemplo n.º 4
0
        public void SetHeroesBSPList(SharpDevice device, Archive heroesONEfile)
        {
            Dispose();
            ReadFileMethods.isShadow = false;

            BSPList          = new List <RenderWareModelFile>(heroesONEfile.Files.Count);
            ShadowColBSPList = new List <RenderWareModelFile>();

            foreach (ArchiveFile file in heroesONEfile.Files)
            {
                if (!(new string[] { ".bsp", ".rg1", ".rx1" }.Contains(Path.GetExtension(file.Name).ToLower())))
                {
                    continue;
                }

                RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);
                TempBSPFile.SetChunkNumberAndName();
                byte[] uncompressedData = file.DecompressThis();
                TempBSPFile.SetForRendering(device, ReadFileMethods.ReadRenderWareFile(uncompressedData), uncompressedData);
                BSPList.Add(TempBSPFile);
            }
        }
Ejemplo n.º 5
0
        public static void SetHeroesMeshStream(Archive heroesONEfile)
        {
            foreach (RenderWareModelFile r in BSPStream)
            {
                foreach (SharpMesh mesh in r.meshList)
                {
                    mesh.Dispose();
                }
            }

            foreach (RenderWareModelFile r in ShadowCollisionBSPStream)
            {
                foreach (SharpMesh mesh in r.meshList)
                {
                    mesh.Dispose();
                }
            }

            LoadTextures(currentFileNamePrefix);

            ReadFileMethods.isShadow = false;

            ShadowCollisionBSPStream = new List <RenderWareModelFile>();
            BSPStream = new List <RenderWareModelFile>(heroesONEfile.Files.Count);

            foreach (ArchiveFile file in heroesONEfile.Files)
            {
                if (Path.GetExtension(file.Name).ToLower() != ".bsp")
                {
                    continue;
                }

                RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);
                TempBSPFile.SetChunkNumberAndName();
                byte[] uncompressedData = file.DecompressThis();
                TempBSPFile.SetForRendering(ReadFileMethods.ReadRenderWareFile(uncompressedData), uncompressedData);
                BSPStream.Add(TempBSPFile);
            }
        }
Ejemplo n.º 6
0
        public static void SetShadowMeshStream(List <Archive> OpenShadowONEFiles)
        {
            foreach (RenderWareModelFile r in BSPStream)
            {
                foreach (SharpMesh mesh in r.meshList)
                {
                    mesh.Dispose();
                }
            }

            foreach (RenderWareModelFile r in ShadowCollisionBSPStream)
            {
                foreach (SharpMesh mesh in r.meshList)
                {
                    mesh.Dispose();
                }
            }

            LoadTextures(currentShadowFolderNamePrefix);

            BSPStream = new List <RenderWareModelFile>();
            ShadowCollisionBSPStream = new List <RenderWareModelFile>();

            ReadFileMethods.isShadow = true;

            foreach (Archive f in OpenShadowONEFiles)
            {
                foreach (ArchiveFile file in f.Files)
                {
                    string ChunkName = Path.GetFileNameWithoutExtension(file.Name);

                    if (ChunkName.Contains("COLI"))
                    {
                        ReadFileMethods.isCollision = true;

                        RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);
                        try
                        {
                            TempBSPFile.ChunkNumber = Convert.ToByte(ChunkName.Split('_').Last());
                        }
                        catch { TempBSPFile.ChunkNumber = -1; };

                        TempBSPFile.isShadowCollision = true;
                        try
                        {
                            byte[] data = file.DecompressThis();
                            TempBSPFile.SetForRendering(ReadFileMethods.ReadRenderWareFile(data), data);
                        }
                        catch (Exception e)
                        {
                            System.Windows.Forms.MessageBox.Show("Error on opening " + file.Name + ": " + e.Message);
                        }
                        ShadowCollisionBSPStream.Add(TempBSPFile);

                        ReadFileMethods.isCollision = false;
                    }
                    else
                    {
                        RenderWareModelFile TempBSPFile = new RenderWareModelFile(file.Name);
                        TempBSPFile.SetChunkNumberAndName();
                        byte[] data = file.DecompressThis();
                        TempBSPFile.SetForRendering(ReadFileMethods.ReadRenderWareFile(data), data);
                        BSPStream.Add(TempBSPFile);
                    }
                }
            }
        }