public CompositionTechnique(Compositor parent) { this.parent = parent; textureDefinitions = new List<CompositionTextureDefinition>(); targetPasses = new List<CompositionTargetPass>(); outputTarget = new CompositionTargetPass(this); instances = new List<CompositorInstance>(); }
public CompositorInstance( CompositionTechnique technique, CompositorChain chain ) { this.compositor = technique.Parent; this.technique = technique; this.chain = chain; this.enabled = false; var logicName = technique.CompositorLogicName; if ( !String.IsNullOrEmpty( logicName ) ) { CompositorManager.Instance.CompositorLogics[ logicName ].CompositorInstanceCreated( this ); } this.localTextures = new Dictionary<string, Texture>(); this.renderSystemOperations = new List<QueueIDAndOperation>(); }
/// <see cref="Translator.Translate"/> public override void Translate( ScriptCompiler compiler, AbstractNode node ) { ObjectAbstractNode obj = (ObjectAbstractNode)node; if ( obj != null ) { if ( string.IsNullOrEmpty( obj.Name ) ) { compiler.AddError( CompileErrorCode.ObjectNameExpected, obj.File, obj.Line ); return; } } else { compiler.AddError( CompileErrorCode.ObjectNameExpected, obj.File, obj.Line ); return; } // Create the compositor object compObject; ScriptCompilerEvent evt = new CreateCompositorScriptCompilerEvent( obj.File, obj.Name, compiler.ResourceGroup ); bool processed = compiler._fireEvent( ref evt, out compObject ); if ( !processed ) { //TODO // The original translated implementation of this code block was simply the following: // _Compositor = (Compositor)CompositorManager.Instance.Create( obj.Name, compiler.ResourceGroup ); // but sometimes it generates an excepiton due to a duplicate resource. // In order to avoid the above mentioned exception, the implementation was changed, but // it need to be checked when ResourceManager._add will be updated to the lastest version Compositor checkForExistingComp = (Compositor)CompositorManager.Instance.GetByName( obj.Name ); if ( checkForExistingComp == null ) _Compositor = (Compositor)CompositorManager.Instance.Create( obj.Name, compiler.ResourceGroup ); else _Compositor = checkForExistingComp; } else _Compositor = (Compositor)compObject; if ( _Compositor == null ) { compiler.AddError( CompileErrorCode.ObjectAllocationError, obj.File, obj.Line ); return; } // Prepare the compositor _Compositor.RemoveAllTechniques(); _Compositor.Origin = obj.File; obj.Context = _Compositor; foreach ( AbstractNode i in obj.Children ) { if ( i is ObjectAbstractNode ) { _processNode( compiler, i ); } else { compiler.AddError( CompileErrorCode.UnexpectedToken, i.File, i.Line, "token not recognized" ); } } }
public CompositorTranslator() : base() { _Compositor = null; }
public CompositorInstance(Compositor filter, CompositionTechnique technique, CompositorChain chain) { this.compositor = filter; this.technique = technique; this.chain = chain; this.enabled = false; localTextures = new Dictionary<string, Texture>(); renderSystemOperations = new List<QueueIDAndOperation>(); listeners = new List<CompositorInstanceListener>(); }
public CompositorInstance AddCompositor(Compositor filter, int addPosition) { return AddCompositor(filter, addPosition, bestCompositor); }
///<summary> /// Apply a compositor. Initially, the filter is enabled. ///</summary> ///<param name="filter">Filter to apply</param> ///<param name="addPosition">Position in filter chain to insert this filter at; defaults to the end (last applied filter)</param> ///<param name="technique">Technique to use; CompositorChain::BEST (default) chooses to the best one /// available (first technique supported) ///</param> CompositorInstance AddCompositor(Compositor filter, int addPosition, int technique) { // Init on demand if (originalScene == null) { viewport.Target.BeforeUpdate += BeforeRenderTargetUpdate; // viewport.Target.AfterUpdate += AfterRenderTargetUpdate; viewport.Target.BeforeViewportUpdate += BeforeViewportUpdate; viewport.Target.AfterViewportUpdate += AfterViewportUpdate; /// Create base "original scene" compositor Compositor baseCompositor = (Compositor)CompositorManager.Instance.LoadExisting("Ogre/Scene"); originalScene = baseCompositor.GetSupportedTechnique(0).CreateInstance(this); } filter.Touch(); if (technique >= filter.SupportedTechniques.Count) { /// Warn user LogManager.Instance.Write("CompositorChain: Compositor " + filter.Name + " has no supported techniques."); return null; } CompositionTechnique tech = filter.GetSupportedTechnique(technique); CompositorInstance t = tech.CreateInstance(this); if (addPosition == lastCompositor) instances.Add(t); else { Debug.Assert(addPosition <= instances.Count); instances.Insert(addPosition, t); } dirty = true; anyCompositorsEnabled = true; return t; }
public CompositorInstance AddCompositor(Compositor filter) { return AddCompositor(filter, lastCompositor, bestCompositor); }
///<summary> /// Required by the ResourceManager base class ///</summary> public override Resource Create(string name, bool isManual) { Compositor ret = new Compositor(name); Add(ret); return ret; }
///<summary> /// Apply a compositor. Initially, the filter is enabled. ///</summary> ///<param name="filter">Filter to apply</param> ///<param name="addPosition">Position in filter chain to insert this filter at; defaults to the end (last applied filter)</param> ///<param name="technique">Technique to use; CompositorChain::BEST (default) chooses to the best one /// available (first technique supported) ///</param> ///<param name="scheme"></param> private CompositorInstance AddCompositor( Compositor filter, int addPosition, int technique, string scheme ) { filter.Touch(); CompositionTechnique tech = filter.GetSupportedTechniqueByScheme( scheme ); if ( tech == null ) { LogManager.Instance.DefaultLog.Write( "CompositorChain: Compositor " + filter.Name + " has no supported techniques." ); } var t = new CompositorInstance( tech, this ); if ( addPosition == lastCompositor ) { addPosition = this.instances.Count; } else { Debug.Assert( addPosition <= this.instances.Count, "Index out of bounds." ); } this.instances.Insert( addPosition, t ); this.dirty = true; this.anyCompositorsEnabled = true; return t; }
///<summary> /// Apply a compositor. Initially, the filter is enabled. ///</summary> ///<param name="filter">Filter to apply</param> ///<param name="addPosition">Position in filter chain to insert this filter at; defaults to the end (last applied filter)</param> ///<param name="technique">Technique to use; CompositorChain::BEST (default) chooses to the best one /// available (first technique supported) ///</param> private CompositorInstance AddCompositor( Compositor filter, int addPosition, int technique ) { return AddCompositor( filter, addPosition, technique, string.Empty ); }
///<summary> /// Apply a compositor. Initially, the filter is enabled. ///</summary> ///<param name="filter">Filter to apply</param> public CompositorInstance AddCompositor( Compositor filter ) { return AddCompositor( filter, lastCompositor, bestCompositor, string.Empty ); }