Ejemplo n.º 1
0
        protected void updateDebugRTTWindow()
        {
            // Clear listbox
            mDebugRTTListbox.resetList();
            // Clear imagesets
            mDebugRTTStaticImage.setImage(null);
            foreach (CeguiDotNet.Imageset imgset in mDebugRTTImageSets)
            {
                CeguiDotNet.ImagesetManager.getSingleton().destroyImageset(imgset);
            }
            mDebugRTTImageSets.Clear();
            // Add an entry for each render texture for all active compositors
            Viewport        vp    = mRenderWindow.GetViewport(0);
            CompositorChain chain = CompositorManager.Instance.getCompositorChain(vp);

            OgreDotNet.CompositorInstancesIteratorWrap it = chain.getCompositors();
            while (it.hasMoreElements())
            {
                CompositorInstance inst = it.getNext();
                if (inst.getEnabled())
                {
                    CTTextureDefinitionsIterator texIt =
                        inst.getTechnique().GetTextureDefinitionIterator();
                    while (texIt.hasMoreElements())
                    {
                        CTTextureDefinition texDef = texIt.getNext();

                        // Get instance name of texture
                        string instName = inst.getTextureInstanceName(texDef.getName());
                        // Create CEGUI texture from name of OGRE texture
                        CeguiDotNet.Texture tex = mGuiRenderer.createTexture(new CeguiDotNet.String(instName));
                        // Create imageset
                        CeguiDotNet.Imageset imgSet =
                            ImagesetManager.getSingleton().createImageset(instName, tex);
                        mDebugRTTImageSets.Add(imgSet);
                        imgSet.defineImage("RttImage",
                                           new CEGUIVector2(0.0f, 0.0f),
                                           new CeguiDotNet.Size(tex.getWidth(), tex.getHeight()),
                                           new CEGUIVector2(0.0f, 0.0f));

                        CeguiDotNet.ListboxTextItem item = new ListboxTextItem(texDef.getName(), 0, Imageset.getCPtr(imgSet).Handle);
                        item.setSelectionBrushImage("TaharezLook", "ListboxSelectionBrush");
                        item.setSelectionColours(new CeguiDotNet.colour(0.0f, 0.0f, 1.0f));
                        //the is so we dont have to keep track of the ListboxTextItem
                        //if we loose the reference to the DotNet object CeguiDotNet.ListboxTextItem(leaving scope of the while statement),
                        //The swig generated code will delete the c++ object, we dont want this.
                        //So calling the static function RemoveOwnership will stop the swig generated
                        // code from deleteing the c++ object and the dotnet object can delete normaly.
                        ListboxTextItem.RemoveOwnership(item);
                        //make sure the c++ object will be deleted with its parent
                        item.setAutoDeleted(true);
                        mDebugRTTListbox.addItem(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void notifyCompositor(CompositorInstance instance)
        {
            // Get some RTT dimensions for later calculations
            CTTextureDefinitionsIterator defIter = instance.getTechnique().GetTextureDefinitionIterator();

            while (defIter.hasMoreElements())
            {
                CTTextureDefinition def = defIter.getNext();
                // store the sizes of downscaled textures (size can be tweaked in script)
                if (OgreDotNet.StringUtil.startsWith(def.getName(), "rt_lum", false))
                {
                    int idx = System.Convert.ToInt32(def.getName().Substring(6, 1));
                    mLumSize[idx] = (int)def.getWidth();                     // should be square
                }
                else if (def.getName() == "rt_bloom0")
                {
                    mBloomSize = (int)def.getWidth();                     // should be square
                    // Calculate gaussian texture offsets & weights
                    float deviation = 3.0f;
                    float texelSize = 1.0f / (float)mBloomSize;

                    // central sample, no offset
                    mBloomTexOffsetsHorz[0] = 0.0f;
                    mBloomTexOffsetsHorz[1] = 0.0f;
                    mBloomTexWeights[0]     = mBloomTexWeights[1] =
                        mBloomTexWeights[2] = OgreDotNet.OgreMath.gaussianDistribution(0, 0, deviation);
                    mBloomTexWeights[3]     = 1.0f;

                    // 'pre' samples
                    for (int i = 1; i < 8; ++i)
                    {
                        mBloomTexWeights[(i * 4) + 0]     = mBloomTexWeights[(i * 4) + 1] =
                            mBloomTexWeights[(i * 4) + 2] = 1.25f * OgreDotNet.OgreMath.gaussianDistribution(i, 0, deviation);
                        mBloomTexWeights[(i * 4) + 3]     = 1.0f;
                        mBloomTexOffsetsHorz[(i * 4) + 0] = (float)i * texelSize;
                        mBloomTexOffsetsHorz[(i * 4) + 1] = 0.0f;
                        mBloomTexOffsetsVert[(i * 4) + 0] = 0.0f;
                        mBloomTexOffsetsVert[(i * 4) + 1] = (float)i * texelSize;
                    }
                    // 'post' samples
                    for (int i = 8; i < 15; ++i)
                    {
                        mBloomTexWeights[(i * 4) + 0]     = mBloomTexWeights[(i * 4) + 1] =
                            mBloomTexWeights[(i * 4) + 2] = mBloomTexWeights[((i - 7) * 4) + 0];
                        mBloomTexWeights[(i * 4) + 3]     = 1.0f;

                        mBloomTexOffsetsHorz[(i * 4) + 0] = -mBloomTexOffsetsHorz[((i - 7) * 4) + 0];
                        mBloomTexOffsetsHorz[(i * 4) + 1] = 0.0f;
                        mBloomTexOffsetsVert[(i * 4) + 0] = 0.0f;
                        mBloomTexOffsetsVert[(i * 4) + 1] = -mBloomTexOffsetsVert[((i - 7) * 4) + 1];
                    }
                }
            }
        }
Ejemplo n.º 3
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");
         }
     }
 }
Ejemplo n.º 4
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");
         }
     }
 }