public CompositionPass createPass()
        {
            global::System.IntPtr cPtr = OgrePINVOKE.CompositionTargetPass_createPass__SWIG_1(swigCPtr);
            CompositionPass       ret  = (cPtr == global::System.IntPtr.Zero) ? null : new CompositionPass(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #2
0
 protected void createEffectHeatVision()
 {
     /// Heat vision effect
     CompositorPtr comp4 = new CompositorPtr(ResourcePtr.getCPtr(CompositorManager.Instance.GetAsResourceManager().Create(
                                                                     "Heat Vision", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)).Handle, false);
     CompositionTechnique t = comp4.Get().createTechnique();
     {
         CTTextureDefinition def = t.CreateTextureDefinition("scene");
         def.setWidth(256);
         def.setHeight(256);
         def.setFormat(OgreDotNet.PixelFormat.PF_R8G8B8);
     }
     {
         CTTextureDefinition def = t.CreateTextureDefinition("temp");
         def.setWidth(256);
         def.setHeight(256);
         def.setFormat(OgreDotNet.PixelFormat.PF_R8G8B8);
     }
     /// Render scene
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
         tp.SetOutputName("scene");
     }
     /// Light to heat pass
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         tp.SetOutputName("temp");
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setIdentifier(0xDEADBABE);                               /// Identify pass for use in listener
             pass.setMaterialName("Fury/HeatVision/LightToHeat");
             pass.setInput(0, "scene");
         }
     }
     /// Display result
     {
         CompositionTargetPass tp = t.getOutputTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setMaterialName("Fury/HeatVision/Blur");
             pass.setInput(0, "temp");
         }
     }
 }
예제 #3
0
            /// <see cref="Translator.Translate"/>
            public override void Translate(ScriptCompiler compiler, AbstractNode node)
            {
                var obj = (ObjectAbstractNode)node;

                this._Pass = (CompositionPass)obj.Parent.Context;

                // Should be no parameters, just children
                if (obj.Values.Count != 0)
                {
                    compiler.AddError(CompileErrorCode.UnexpectedToken, obj.File, obj.Line);
                }

                foreach (var i in obj.Children)
                {
                    if (i is ObjectAbstractNode)
                    {
                        processNode(compiler, i);
                    }
                    else if (i is PropertyAbstractNode)
                    {
                        var prop = (PropertyAbstractNode)i;
                        switch ((Keywords)prop.Id)
                        {
                            #region ID_CHECK

                        case Keywords.ID_CHECK:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            var val = false;
                            if (getBoolean(prop.Values[0], out val))
                            {
                                this._Pass.StencilCheck = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_CHECK

                            #region ID_COMP_FUNC

                        case Keywords.ID_COMP_FUNC:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            CompareFunction func;
                            if (getEnumeration <CompareFunction>(prop.Values[0], compiler, out func))
                            {
                                this._Pass.StencilFunc = func;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_COMP_FUNC

                            #region ID_REF_VALUE

                        case Keywords.ID_REF_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }

                            int val;
                            if (getInt(prop.Values[0], out val))
                            {
                                this._Pass.StencilRefValue = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_REF_VALUE

                            #region ID_MASK

                        case Keywords.ID_MASK:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }
                            int val;
                            if (getInt(prop.Values[0], out val))
                            {
                                this._Pass.StencilMask = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_MASK

                            #region ID_FAIL_OP

                        case Keywords.ID_FAIL_OP:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            StencilOperation val;
                            if (getEnumeration <StencilOperation>(prop.Values[0], compiler, out val))
                            {
                                this._Pass.StencilFailOp = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_FAIL_OP

                            #region ID_DEPTH_FAIL_OP

                        case Keywords.ID_DEPTH_FAIL_OP:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            StencilOperation val;
                            if (getEnumeration <StencilOperation>(prop.Values[0], compiler, out val))
                            {
                                this._Pass.StencilDepthFailOp = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_DEPTH_FAIL_OP

                            #region ID_PASS_OP

                        case Keywords.ID_PASS_OP:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            StencilOperation val;
                            if (getEnumeration <StencilOperation>(prop.Values[0], compiler, out val))
                            {
                                this._Pass.StencilPassOp = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_PASS_OP

                            #region ID_TWO_SIDED

                        case Keywords.ID_TWO_SIDED:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }

                            bool val;
                            if (getBoolean(prop.Values[0], out val))
                            {
                                this._Pass.StencilTwoSidedOperation = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_TWO_SIDED

                        default:
                            compiler.AddError(CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
                                              "token \"" + prop.Name + "\" is not recognized");
                            break;
                        }
                    }
                }
            }
예제 #4
0
 public CompositionPassStencilTranslator()
     : base()
 {
     this._Pass = null;
 }
예제 #5
0
            /// <see cref="Translator.Translate"/>
            public override void Translate(ScriptCompiler compiler, AbstractNode node)
            {
                var obj = (ObjectAbstractNode)node;

                var target = (CompositionTargetPass)obj.Parent.Context;

                this._Pass  = target.CreatePass();
                obj.Context = this._Pass;

                // The name is the type of the pass
                if (obj.Values.Count == 0)
                {
                    compiler.AddError(CompileErrorCode.StringExpected, obj.File, obj.Line);
                    return;
                }
                var type = string.Empty;

                if (!getString(obj.Values[0], out type))
                {
                    compiler.AddError(CompileErrorCode.InvalidParameters, obj.File, obj.Line);
                    return;
                }

                this._Pass.Type = (CompositorPassType)ScriptEnumAttribute.Lookup(type, typeof(CompositorPassType));
                if (this._Pass.Type == CompositorPassType.RenderCustom)
                {
                    var customType = string.Empty;
                    //This is the ugly one liner for safe access to the second parameter.
                    if (obj.Values.Count < 2 || !getString(obj.Values[1], out customType))
                    {
                        compiler.AddError(CompileErrorCode.StringExpected, obj.File, obj.Line);
                        return;
                    }
                    this._Pass.CustomType = customType;
                }
                else
                {
                    compiler.AddError(CompileErrorCode.InvalidParameters, obj.File, obj.Line,
                                      "pass types must be \"clear\", \"stencil\", \"render_quad\", \"render_scene\" or \"render_custom\".");
                    return;
                }

                foreach (var i in obj.Children)
                {
                    if (i is ObjectAbstractNode)
                    {
                        processNode(compiler, i);
                    }
                    else if (i is PropertyAbstractNode)
                    {
                        var prop = (PropertyAbstractNode)i;
                        switch ((Keywords)prop.Id)
                        {
                            #region ID_MATERIAL

                        case Keywords.ID_MATERIAL:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                var val = string.Empty;
                                if (getString(prop.Values[0], out val))
                                {
                                    ScriptCompilerEvent evt =
                                        new ProcessResourceNameScriptCompilerEvent(ProcessResourceNameScriptCompilerEvent.ResourceType.Material, val);

                                    compiler._fireEvent(ref evt);
                                    this._Pass.MaterialName = ((ProcessResourceNameScriptCompilerEvent)evt).Name;
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_MATERIAL

                            #region ID_INPUT

                        case Keywords.ID_INPUT:
                            if (prop.Values.Count < 2)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 3)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                AbstractNode i0 = getNodeAt(prop.Values, 0),
                                             i1 = getNodeAt(prop.Values, 1),
                                             i2 = getNodeAt(prop.Values, 2);
                                var id          = 0;
                                var name        = string.Empty;
                                if (getInt(i0, out id) && getString(i1, out name))
                                {
                                    var index = 0;

                                    if (!getInt(i2, out index))
                                    {
                                        compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                        return;
                                    }

                                    this._Pass.SetInput(id, name, index);
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_INPUT

                            #region ID_IDENTIFIER

                        case Keywords.ID_IDENTIFIER:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                uint val;
                                if (getUInt(prop.Values[0], out val))
                                {
                                    this._Pass.Identifier = val;
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_IDENTIFIER

                            #region ID_FIRST_RENDER_QUEUE

                        case Keywords.ID_FIRST_RENDER_QUEUE:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                uint val;
                                if (getUInt(prop.Values[0], out val))
                                {
                                    this._Pass.FirstRenderQueue = (RenderQueueGroupID)val;
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_FIRST_RENDER_QUEUE

                            #region ID_LAST_RENDER_QUEUE

                        case Keywords.ID_LAST_RENDER_QUEUE:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                uint val;
                                if (getUInt(prop.Values[0], out val))
                                {
                                    this._Pass.LastRenderQueue = (RenderQueueGroupID)val;
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_LAST_RENDER_QUEUE

                            #region ID_MATERIAL_SCHEME

                        case Keywords.ID_MATERIAL_SCHEME:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                string val;
                                if (getString(prop.Values[0], out val))
                                {
                                    this._Pass.MaterialScheme = val;
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_MATERIAL_SCHEME

                            #region ID_QUAD_NORMALS

                        case Keywords.ID_QUAD_NORMALS:
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.StringExpected, prop.File, prop.Line);
                                return;
                            }
                            else if (prop.Values.Count > 1)
                            {
                                compiler.AddError(CompileErrorCode.FewerParametersExpected, prop.File, prop.Line);
                                return;
                            }
                            else
                            {
                                if (prop.Values[0] is AtomAbstractNode)
                                {
                                    var atom = (AtomAbstractNode)prop.Values[0];
                                    if (atom.Id == (uint)Keywords.ID_CAMERA_FAR_CORNERS_VIEW_SPACE)
                                    {
                                        this._Pass.SetQuadFarCorners(true, true);
                                    }
                                    else if (atom.Id == (uint)Keywords.ID_CAMERA_FAR_CORNERS_WORLD_SPACE)
                                    {
                                        this._Pass.SetQuadFarCorners(true, false);
                                    }
                                    else
                                    {
                                        compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                    }
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            break;

                            #endregion ID_QUAD_NORMALS

                        default:
                            compiler.AddError(CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
                                              "token \"" + prop.Name + "\" is not recognized");
                            break;
                        }
                    }
                }
            }
예제 #6
0
            /// <see cref="Translator.Translate"/>
            public override void Translate(ScriptCompiler compiler, AbstractNode node)
            {
                var obj = (ObjectAbstractNode)node;

                this._Pass = (CompositionPass)obj.Parent.Context;

                // Should be no parameters, just children
                if (obj.Values.Count != 0)
                {
                    compiler.AddError(CompileErrorCode.UnexpectedToken, obj.File, obj.Line);
                }

                foreach (var i in obj.Children)
                {
                    if (i is ObjectAbstractNode)
                    {
                        processNode(compiler, i);
                    }
                    else if (i is PropertyAbstractNode)
                    {
                        var prop = (PropertyAbstractNode)i;
                        switch ((Keywords)prop.Id)
                        {
                            #region ID_BUFFERS

                        case Keywords.ID_BUFFERS:
                        {
                            FrameBufferType buffers = 0;
                            foreach (var k in prop.Values)
                            {
                                if (k is AtomAbstractNode)
                                {
                                    switch ((Keywords)((AtomAbstractNode)k).Id)
                                    {
                                    case Keywords.ID_COLOUR:
                                        buffers |= FrameBufferType.Color;
                                        break;

                                    case Keywords.ID_DEPTH:
                                        buffers |= FrameBufferType.Depth;
                                        break;

                                    case Keywords.ID_STENCIL:
                                        buffers |= FrameBufferType.Stencil;
                                        break;

                                    default:
                                        compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                        break;
                                    }
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            this._Pass.ClearBuffers = buffers;
                        }
                        break;

                            #endregion ID_BUFFERS

                            #region ID_COLOUR_VALUE

                        case Keywords.ID_COLOUR_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }

                            var val = ColorEx.White;
                            if (getColor(prop.Values, 0, out val))
                            {
                                this._Pass.ClearColor = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_COLOUR_VALUE

                            #region ID_DEPTH_VALUE

                        case Keywords.ID_DEPTH_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }
                            Real val = 0;
                            if (getReal(prop.Values[0], out val))
                            {
                                this._Pass.ClearDepth = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_DEPTH_VALUE

                            #region ID_STENCIL_VALUE

                        case Keywords.ID_STENCIL_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }

                            var val = 0;
                            if (getInt(prop.Values[0], out val))
                            {
                                this._Pass.ClearStencil = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_STENCIL_VALUE

                        default:
                            compiler.AddError(CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
                                              "token \"" + prop.Name + "\" is not recognized");
                            break;
                        }
                    }
                }
            }
예제 #7
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CompositionPass obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #8
0
 protected void createEffectMotionBlur()
 {
     /// Motion blur effect
     CompositorPtr comp3 = new CompositorPtr(ResourcePtr.getCPtr(CompositorManager.Instance.GetAsResourceManager().Create(
                                                                     "Motion Blur", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)).Handle, false);
     CompositionTechnique t = comp3.Get().createTechnique();
     {
         CTTextureDefinition def = t.CreateTextureDefinition("scene");
         def.setWidth(0);
         def.setHeight(0);
         def.setFormat(PixelFormat.PF_R8G8B8);
     }
     {
         CTTextureDefinition def = t.CreateTextureDefinition("sum");
         def.setWidth(0);
         def.setHeight(0);
         def.setFormat(PixelFormat.PF_R8G8B8);
     }
     {
         CTTextureDefinition def = t.CreateTextureDefinition("temp");
         def.setWidth(0);
         def.setHeight(0);
         def.setFormat(PixelFormat.PF_R8G8B8);
     }
     /// Render scene
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
         tp.SetOutputName("scene");
     }
     /// Initialisation pass for sum texture
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
         tp.SetOutputName("sum");
         tp.setOnlyInitial(true);
     }
     /// Do the motion blur
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         tp.SetOutputName("temp");
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setMaterialName("Ogre/Compositor/Combine");
             pass.setInput(0, "scene");
             pass.setInput(1, "sum");
         }
     }
     /// Copy back sum texture
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         tp.SetOutputName("sum");
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setMaterialName("Ogre/Compositor/Copyback");
             pass.setInput(0, "temp");
         }
     }
     /// Display result
     {
         CompositionTargetPass tp = t.getOutputTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setMaterialName("Ogre/Compositor/MotionBlur");
             pass.setInput(0, "sum");
         }
     }
 }