Example #1
0
        internal void Initialize()
        {
            PlatformInitialize();

            // Force set the default render states.
            _blendStateDirty  = _depthStencilStateDirty = _rasterizerStateDirty = true;
            BlendState        = BlendState.Opaque;
            DepthStencilState = DepthStencilState.Default;
            RasterizerState   = RasterizerState.CullCounterClockwise;

            // Clear the texture and sampler collections forcing
            // the state to be reapplied.
            VertexTextures.Clear();
            VertexSamplerStates.Clear();
            Textures.Clear();
            SamplerStates.Clear();

            // Clear constant buffers
            _vertexConstantBuffers.Clear();
            _pixelConstantBuffers.Clear();

            // Force set the buffers and shaders on next ApplyState() call
            _indexBufferDirty  = true;
            _vertexBufferDirty = true;
            _vertexShaderDirty = true;
            _pixelShaderDirty  = true;

            // Set the default scissor rect.
            _scissorRectangleDirty = true;
            ScissorRectangle       = _viewport.Bounds;

            // Set the default render target.
            ApplyRenderTargets(null);
        }
Example #2
0
 public void ClearResources()
 {
     Textures.Clear();
     Fonts.Clear();
     SoundBuffers.Clear();
     Sounds.Clear();
 }
Example #3
0
        internal void Initialize()
        {
            PlatformInitialize();

            // Clear the texture and sampler collections forcing
            // the state to be reapplied.
            VertexTextures.Clear();
            VertexSamplerStates.Clear();
            Textures.Clear();
            SamplerStates.Clear();

            // Clear constant buffers
            _vertexConstantBuffers.Clear();
            _pixelConstantBuffers.Clear();

            // Force set the buffers and shaders on next ApplyState() call
            _vertexBuffers = new VertexBufferBindings(_maxVertexBufferSlots);
            //            _vertexBuffersDirty = true;
            _indexBufferDirty  = true;
            _vertexShaderDirty = true;
            _pixelShaderDirty  = true;

            // Set the default scissor rect.
            _scissorRectangleDirty = true;
            ScissorRectangle       = _viewport.Bounds;

            // Set the default render target.
            ApplyRenderTargets(null);
        }
Example #4
0
File: Tdb.cs Project: GMMan/libdgf
        public void Read(BinaryReader br)
        {
            var startPos = br.BaseStream.Position;

            Flags = (TdbFlags)br.ReadByte();
            Textures.Clear();
            byte numTextures = br.ReadByte();

            for (int i = 0; i < numTextures; ++i)
            {
                var tex = new TdbTexture();
                tex.Read(br);
                Textures.Add(tex);
            }
            var read    = br.BaseStream.Position - startPos;
            var aligned = (read + 15) & ~15;

            br.BaseStream.Seek(aligned - read, SeekOrigin.Current);

            if ((Flags & TdbFlags.SkipBoundingBox) == 0)
            {
                BoundingBox = br.ReadBoundingBox();
            }

            Mesh = new Db2();
            Mesh.Read(br);
        }
Example #5
0
        public override void ReadMetadata(BinaryReader stream, int totalSize)
        {
            var version = stream.ReadUInt32();

            BillboardGuid = stream.ReadGuid();
            var subVersion = stream.ReadUInt32();

            UnknownUint1      = stream.ReadUInt32();
            Flags             = stream.ReadStringList();
            UnknownUint2      = stream.ReadUInt32();
            VertexLayoutFlags = stream.ReadStringList();
            BlendMode         = stream.ReadSizedString();
            Shader            = new AssetDependence <Shader>(stream.ReadGuid());
            var texCount = stream.ReadInt32();

            Textures.Clear();
            for (int i = 0; i < texCount; i++)
            {
                var index   = stream.ReadInt32();
                var texGuid = stream.ReadGuid();
                Textures[index] = new AssetDependence <Texture>(texGuid);
            }

            AlphaTest           = stream.ReadSingle();
            ShaderMaterialFlags = stream.ReadStringList();
            ExtraMaterialSettings.Load(stream, subVersion);
        }
Example #6
0
        internal void Initialize()
        {
            _renderState.BlendState      = BlendState.Opaque;
            _renderState.RasterizerState = RasterizerState.CullCounterClockwise;

            Textures.Clear();
        }
Example #7
0
        //Filtering Materials
        private void tbFilter_TextChanged(object sender, EventArgs e)
        {
            filterword = tbFilter.Text;
            count      = filterword.Length;

            if (count > 1)
            {
                filterword = char.ToUpper(filterword[0]) + filterword.Substring(1);
            }


            count = Materials.IndexOf(filterword);
            switch (count)
            {
            case -1:
                pictureBox1.Image = null;
                lbOptions.Items.Clear();
                populateMaterials();
                break;

            default:
                lbMaterials.Items.Clear();
                lbMaterials.Items.Add(Materials[count]);

                Textures.Clear();
                CurrentMaterial   = Materials[count];
                CurrentPath       = TexturePath + "\\" + CurrentMaterial;
                pictureBox1.Image = null;
                loadTextures();
                break;
            }
        }
Example #8
0
        // New one with id AND playfield as filter
        public new void readTexturesfromSQL()
        {
            SqlWrapper ms = new SqlWrapper();
            AOTextures m_tex;

            Textures.Clear();

            DataTable dt = ms.ReadDT("SELECT textures0, textures1, textures2, textures3, textures4 from " + getSQLTablefromDynelType() + " WHERE ID=" + ID.ToString() + " AND playfield=" + PlayField.ToString());

            if (dt.Rows.Count > 0)
            {
                m_tex = new AOTextures(0, (Int32)dt.Rows[0]["textures0"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(1, (Int32)dt.Rows[0]["textures1"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(2, (Int32)dt.Rows[0]["textures2"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(3, (Int32)dt.Rows[0]["textures3"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(4, (Int32)dt.Rows[0]["textures4"]);
                Textures.Add(m_tex);
            }
        }
Example #9
0
        public void InitTextures(bool allTextures, bool noMaskFilter)
        {
            Textures.Clear();
            String texDir = allTextures ? rem.TexturePathFromREM(Parser.RemPath) : null;

            if (allTextures && texDir != null)
            {
                DirectoryInfo dir = new DirectoryInfo(texDir);
                foreach (FileInfo file in dir.EnumerateFiles())
                {
                    string fileName = file.Name.ToLower();
                    if (!noMaskFilter || !fileName.Contains("_mask") && !fileName.Contains("_shade"))
                    {
                        Textures.Add(file.Name);
                    }
                }
            }
            else
            {
                foreach (remMaterial mat in Parser.MATC)
                {
                    if (mat.texture != null && !Textures.Contains(mat.texture))
                    {
                        Textures.Add(mat.texture);
                    }
                }
            }
        }
Example #10
0
 public void Clear()
 {
     TimeSource.Clear();
     Shaders.Clear();
     Textures.Clear();
     uniforms.Clear();
     ShaderKeyframes.Clear();
 }
Example #11
0
 private void lbMaterials_SelectedIndexChanged(object sender, EventArgs e)
 {
     Textures.Clear();
     CurrentMaterial   = lbMaterials.SelectedItem.ToString();
     CurrentPath       = TexturePath + "\\" + CurrentMaterial;
     pictureBox1.Image = null;
     loadTextures();
 }
Example #12
0
        /*public static void UpdateAudioBuffers(double time)
         * {
         *      foreach (KeyValuePair<string, AudioBuffer> pair in Audio)
         *      {
         *              pair.Value.Update(time);
         *      }
         * }
         *
         * public static void StopAllAudio()
         * {
         *      foreach (KeyValuePair<string, AudioBuffer> pair in Audio)
         *      {
         *              pair.Value.Stop();
         *              pair.Value.Looping = false;
         *      }
         * }*/

        public static void UnloadTextures()
        {
            foreach (KeyValuePair <string, Texture> pair in Textures)
            {
                pair.Value.Unload();
            }

            Textures.Clear();
        }
 public void Reset()
 {
     Textures.Clear();
     Indices.Clear();
     Vertices.Clear();
     RenderBatches.Clear();
     OptimizedDraws.Clear();
     UnknownShorts1.Clear();
     UnknownVectors1.Clear();
     TileOccluderInfos.Clear();
 }
Example #14
0
 void Clear()
 {
     foreach (var texturesValue in Textures.Values)
     {
         ((Texture2D)texturesValue).Dispose();
     }
     Textures.Clear();
     Sounds.Clear();
     Fonts.Clear();
     Music.Clear();
     MonoContentManager.Unload();
 }
Example #15
0
        // MAIN LOAD METHOD
        public void Load(ContentManager content)
        {
            OnStartLoad(EventArgs.Empty);

            LoadingProgress = 0f;
            IsLoaded        = false;
            IsLoading       = true;
            Textures.Clear();

            Thread loadThread = new Thread(() => LoadOnOtherThread(content));

            loadThread.Start();
        }
Example #16
0
 public void Dispose()
 {
     Frames.Clear();
     if (Materials != null)
     {
         Materials.Clear();
     }
     if (Textures != null)
     {
         Textures.Clear();
     }
     Parser = null;
 }
Example #17
0
        public void Dispose()
        {
            if (_file != null)
            {
                _file.Dispose();
            }

            foreach (var texture in this)
            {
                texture.Dispose();
            }

            Textures.Clear();
        }
Example #18
0
        protected virtual void Dispose(bool disposing)
        {
            if (Textures != null)
            {
                Textures.Clear();
                Textures = null;
            }

            Vertices         = null;
            AlphaValues      = null;
            HoleValues       = null;
            TextureScales    = null;
            DoodadReferences = null;
            Parent           = null;
        }
Example #19
0
        /// <summary>
        /// Configures <see cref="Devices"/> and <see cref="Textures"/> from <see cref="Ids"/>.
        /// </summary>
        public void Configure()
        {
            IsStarted    = false;
            IsConfigured = true;

            Devices.Clear();
            Textures.Clear();
            Textures2D.Clear();

            foreach (int webcamId in Ids)
            {
                var webcamDevice = WebCamTexture.devices[webcamId];
                Devices.Add(webcamDevice);
                Textures.Add(new WebCamTexture(webcamDevice.name));
            }
        }
        public override void Dispose()
        {
            Console.WriteLine("Disposing " + this.Name);

            foreach (BfresModelAsset model in Models)
            {
                model.Destroy();
            }
            foreach (var tex in Textures.Values)
            {
                tex.RenderableTex?.Dispose();
            }

            Models.Clear();
            Textures.Clear();
        }
Example #21
0
        public static void Clear()
        {
            // Clear Resource Directories
            ModelDirectories.Clear();
            ResourceDirectories.Clear();

            // Clear Viewport Models/Instances
            Viewport.SelectedInstances.Clear();
            DefaultCube.Instances.Clear();
            DefaultTerrainGroup.Clear();
            TerrainGroups.Clear();
            Objects.Clear();

            // Clear Resources
            Materials.Clear();
            Textures.Clear();
        }
Example #22
0
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            Textures.Clear();
            Fonts.Clear();
            SoundEffects.Clear();
            Songs.Clear();

            ContentManager.Unload();
#if DEBUG
            SpartaDebug.DebugFont = null;
#endif
            backgroundImage = null;

            base.UnloadContent();

            GC.Collect();
        }
Example #23
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         TextureThreadContextReady.Close();
         Printer.Dispose();
         PendingTextures.Close();
         Prims.Clear();
         Textures.Clear();
         glControl.Context.Dispose();
         glControl.Dispose();
         renderer = null;
         GLMode   = null;
         components.Dispose();
     }
     base.Dispose(disposing);
 }
Example #24
0
        public void Purge(Game game)
        {
            Textures.Clear();
            Texture2Ds.Clear();
            Texture3Ds.Clear();
            Models.Clear();
            Effects.Clear();
            Fonts.Clear();

            Textures   = new List <ContentResource <Texture> >();
            Texture2Ds = new List <ContentResource <Texture2D> >();
            Texture3Ds = new List <ContentResource <Texture3D> >();
            Models     = new List <ContentResource <Model> >();
            Effects    = new List <ContentResource <Effect> >();
            Fonts      = new List <ContentResource <SpriteFont> >();

            game.Content.Unload();
        }
        // Methods

        /// <summary>
        /// Configures <see cref="Devices"/> and <see cref="Textures"/> from <see cref="Ids"/>.
        /// </summary>
        public void Configure()
        {
            IsStarted    = false;
            IsConfigured = true;

            Devices.Clear();
            Textures.Clear();
            Textures2D.Clear();

            print("Configuring webcam...");
            foreach (var webcamId in Ids)
            {
                var webcamDevice = WebCamTexture.devices[webcamId];
                Devices.Add(webcamDevice);
                //Textures.Add(new WebCamTexture(webcamDevice.name));
                //HACK: pass in our webcam
                Textures.Add(CamFeed.Instance.GetWebCamTexture());
            }
        }
Example #26
0
        // New one with id AND playfield as filter
        public void readTexturesfromSQLfast(DataRow row)
        {
            Textures.Clear();
            AOTextures m_tex;

            m_tex = new AOTextures(0, (Int32)row["textures0"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(1, (Int32)row["textures1"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(2, (Int32)row["textures2"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(3, (Int32)row["textures3"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(4, (Int32)row["textures4"]);
            Textures.Add(m_tex);
        }
Example #27
0
        private void LoadAnim(MaterialAnim anim)
        {
            Initialize();

            MaterialAnim = anim;
            FrameCount   = MaterialAnim.FrameCount;
            Text         = anim.Name;

            Textures.Clear();
            if (anim.TextureNames != null)
            {
                foreach (var name in anim.TextureNames)
                {
                    Textures.Add(name);
                }
            }

            Materials.Clear();
            foreach (var matanim in anim.MaterialAnimDataList)
            {
                var mat = new MaterialAnimEntry(matanim.Name);
                mat.MaterialAnimData = matanim;
                Materials.Add(mat);

                foreach (var param in matanim.ParamAnimInfos)
                {
                    FSHU.BfresParamAnim paramInfo = new FSHU.BfresParamAnim(param.Name);
                    mat.Params.Add(paramInfo);

                    paramInfo.Type = AnimationType.ShaderParam;

                    //There is no better way to determine if the param is a color type afaik
                    if (param.Name.Contains("Color") || param.Name.Contains("color") || param.Name == "multi_tex_reg2")
                    {
                        paramInfo.Type = AnimationType.Color;
                    }
                    else if (AnimType == AnimationType.TexturePattern)
                    {
                        paramInfo.Type = AnimationType.TexturePattern;
                    }
                    else if (AnimType == AnimationType.TextureSrt)
                    {
                        paramInfo.Type = AnimationType.TextureSrt;
                    }
                    else
                    {
                        paramInfo.Type = AnimationType.ShaderParam;
                    }

                    //Get constant anims
                    for (int constant = 0; constant < param.ConstantCount; constant++)
                    {
                        int index = constant + param.BeginConstant;

                        Animation.KeyGroup keyGroup = new Animation.KeyGroup();
                        keyGroup.Keys.Add(new Animation.KeyFrame()
                        {
                            InterType = InterpolationType.CONSTANT,
                            Frame     = 0,
                            Value     = matanim.Constants[index].Value,
                        });

                        paramInfo.Values.Add(new Animation.KeyGroup()
                        {
                            AnimDataOffset = matanim.Constants[index].AnimDataOffset,
                            Keys           = keyGroup.Keys,
                        });
                    }

                    for (int curve = 0; curve < param.FloatCurveCount + param.IntCurveCount; curve++)
                    {
                        int index = curve + param.BeginCurve;

                        Animation.KeyGroup keyGroup = CurveHelper.CreateTrack(matanim.Curves[index]);
                        keyGroup.AnimDataOffset = matanim.Curves[index].AnimDataOffset;

                        paramInfo.Values.Add(new Animation.KeyGroup()
                        {
                            AnimDataOffset = keyGroup.AnimDataOffset,
                            Keys           = keyGroup.Keys,
                        });
                    }
                }

                foreach (TexturePatternAnimInfo SamplerInfo in matanim.TexturePatternAnimInfos)
                {
                    BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, this, mat);
                    mat.Samplers.Add(sampler);


                    int textureIndex = 0;

                    if (SamplerInfo.BeginConstant != 65535)
                    {
                        textureIndex = matanim.Constants[SamplerInfo.BeginConstant].Value;

                        sampler.Keys.Add(new Animation.KeyFrame()
                        {
                            Frame = 0, Value = textureIndex
                        });
                        sampler.Constant       = true;
                        sampler.AnimDataOffset = matanim.Constants[SamplerInfo.BeginConstant].AnimDataOffset;
                    }
                    if (SamplerInfo.CurveIndex != 65535)
                    {
                        int index = (int)SamplerInfo.CurveIndex;

                        Animation.KeyGroup keyGroup = CurveHelper.CreateTrack(matanim.Curves[index]);

                        sampler.AnimDataOffset = matanim.Curves[index].AnimDataOffset;
                        sampler.Keys           = keyGroup.Keys;
                    }
                }
            }
        }
Example #28
0
        private void LoadAnim(TexPatternAnim anim)
        {
            CanReplace = true;
            CanExport  = true;
            CanDelete  = true;
            CanRename  = true;

            Text = anim.Name;

            TexPatternAnim = anim;
            FrameCount     = anim.FrameCount;

            Materials.Clear();
            Textures.Clear();
            if (anim.TextureRefNames != null)
            {
                foreach (var tex in anim.TextureRefNames)
                {
                    Textures.Add(tex.Name);
                }
            }

            if (anim.TextureRefs != null)
            {
                foreach (var tex in anim.TextureRefs)
                {
                    Textures.Add(tex.Key);
                }
            }


            foreach (TexPatternMatAnim matanim in anim.TexPatternMatAnims)
            {
                var mat = new MaterialAnimEntry(matanim.Name);
                mat.TexPatternMatAnim = matanim;
                Materials.Add(mat);

                foreach (PatternAnimInfo SamplerInfo in matanim.PatternAnimInfos)
                {
                    BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, this);
                    mat.Samplers.Add(sampler);

                    int textureIndex = 0;

                    if (SamplerInfo.SubBindIndex != -1)
                    {
                        textureIndex = SamplerInfo.SubBindIndex;

                        sampler.Keys.Add(new Animation.KeyFrame()
                        {
                            Frame = 0, Value = textureIndex
                        });
                        sampler.Constant = true;
                    }
                    if (SamplerInfo.CurveIndex != -1)
                    {
                        int index = (int)SamplerInfo.CurveIndex;

                        Animation.KeyGroup keyGroup = CurveHelper.CreateTrackWiiU(matanim.Curves[index]);
                        sampler.AnimDataOffset = matanim.Curves[index].AnimDataOffset;
                        sampler.Keys           = keyGroup.Keys;

                        foreach (var ind in keyGroup.Keys)
                        {
                            Console.WriteLine($"{SamplerInfo.Name} {ind.Value}");
                        }
                    }
                }
            }
        }
Example #29
0
        /// <summary>
        /// Combines the textures in this model into one bitmap and modifies all the referenced skins and texture coordinates to use the combined texture.
        /// This modifies the model object.
        /// </summary>
        private void CombineTextures()
        {
            if (!Textures.Any())
            {
                return;
            }
            // Calculate the dimension of the combined texture
            var width      = 0;
            var height     = 0;
            var heightList = new Dictionary <int, int>();

            foreach (var texture in Textures)
            {
                width = Math.Max(texture.Width, width);
                heightList.Add(texture.Index, height);
                height += texture.Height;
            }

            // Create the combined texture and draw all the textures onto it
            var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            using (var g = Graphics.FromImage(bmp))
            {
                var y = 0;
                foreach (var texture in Textures)
                {
                    g.DrawImage(texture.Image, 0, y);
                    y += texture.Height;
                }
            }

            // Create the texture object and replace the existing textures
            var tex = new Texture
            {
                Flags  = Textures[0].Flags,
                Height = height,
                Width  = width,
                Image  = bmp,
                Index  = 0,
                Name   = "Combined Texture"
            };

            foreach (var texture in Textures)
            {
                texture.Image.Dispose();
            }
            Textures.Clear();
            Textures.Insert(0, tex);

            // Update all the meshes with the new texture and alter the texture coordinates as needed
            foreach (var mesh in GetActiveMeshes())
            {
                if (!heightList.ContainsKey(mesh.SkinRef))
                {
                    mesh.SkinRef = -1;
                    continue;
                }
                var i    = mesh.SkinRef;
                var yVal = heightList[i];
                foreach (var v in mesh.Vertices)
                {
                    v.TextureV += yVal;
                }
                mesh.SkinRef = 0;
            }
            // Reset the texture indices
            for (var i = 0; i < Textures.Count; i++)
            {
                Textures[i].Index = i;
            }
        }
Example #30
0
 /// <summary>
 /// Clears all spawn points, textures and tiles.
 /// </summary>
 public void Clear()
 {
     SpawnPoints.Clear();
     Textures.Clear();
     Tiles.Clear();
 }