Esempio n. 1
0
        public void LoadFromStream(EndianBinaryReader reader, bool dumpTextures = false, bool dumpShaders = false)
        {
            // Read the J3D Header
            Magic           = new string(reader.ReadChars(4));
            StudioType      = new string(reader.ReadChars(4));
            m_totalFileSize = reader.ReadInt32();
            int tagCount = reader.ReadInt32();

            // Skip over an unused tag ("SVR3") which is consistent in all models.
            reader.Skip(16);

            LoadTagDataFromFile(reader, tagCount, dumpTextures, dumpShaders);

            // Rendering Stuff
            m_hardwareLightBuffer = GL.GenBuffer();
            m_textureOverrides    = new Dictionary <string, Texture>();
            m_colorWriteOverrides = new Dictionary <string, bool>();
            m_tevColorOverrides   = new TevColorOverride();
            m_boneAnimations      = new ObservableCollection <BCK>();
            m_materialAnimations  = new ObservableCollection <BTK>();
            m_externalMaterials   = new ObservableCollection <BMT>();
            m_registerAnimations  = new ObservableCollection <BRK>();

            // Mark this as true when we first load so it moves non-animated pieces into the right area.
            m_skinningInvalid = true;
        }
Esempio n. 2
0
        protected virtual void Dispose(bool manualDispose)
        {
            if (!m_hasBeenDisposed)
            {
                if (manualDispose)
                {
                    // Dispose managed state (managed objects).
                    foreach (var texture in TEX1Tag.Textures)
                    {
                        texture.Dispose();
                    }

                    foreach (var shape in SHP1Tag.Shapes)
                    {
                        shape.Dispose();
                    }

                    foreach (var kvp in m_textureOverrides)
                    {
                        kvp.Value.Dispose();
                    }

                    foreach (var material in MAT3Tag.MaterialList)
                    {
                        if (material.Shader != null)
                        {
                            material.Shader.Dispose();
                        }
                    }

                    foreach (var externalMaterial in m_externalMaterials)
                    {
                        externalMaterial.Dispose();
                    }
                }

                GL.DeleteBuffer(m_hardwareLightBuffer);

                // Null out our large managed arrays since we keep a lot of data in them.
                INF1Tag = null;
                VTX1Tag = null;
                MAT3Tag = null;
                SHP1Tag = null;
                JNT1Tag = null;
                TEX1Tag = null;
                EVP1Tag = null;
                DRW1Tag = null;

                m_boneAnimations     = null;
                m_materialAnimations = null;
                m_tevColorOverrides  = null;
                m_textureOverrides   = null;
                m_externalMaterials  = null;

                m_hasBeenDisposed = true;
            }
        }