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); } } } }
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]; } } } }