Example #1
0
 public TexturePtr(TexturePtr r) : this(OgrePINVOKE.new_TexturePtr__SWIG_2(TexturePtr.getCPtr(r)), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #2
0
        //unsafe
        //{
        //    void* pointer = buffer.Lock(0, image.Width * image.Height * 4, HardwareBuffer.LockOptions.HBL_NORMAL);
        //    PixelBox pBox = buffer.CurrentLock;
        //    pBox.format = PixelFormat.PF_X8R8G8B8;

        //    //PixelBox imagBox = image.GetPixelBox();

        //    Marshal.Copy(imgBytes, 0, pBox.data, imgBytes.Length);

        //    //Marshal.Copy(imagBox.data,pBox. 0, pBox.data, (int)imagBox.GetConsecutiveSize());
        //}

        //TexturePtr lTextureWithRtt = lTextureManager.CreateManual(pathRelFile + "_temp_rtt",
        //    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
        //    TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8,
        //   (int)Mogre.TextureUsage.TU_DYNAMIC_WRITE_ONLY, null, false, 0);

        //TexturePtr lIntermediateTexture = lTextureManager.CreateManual(pathRelFile + "_temp_inter",
        //    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
        //    TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8,
        //   (int)Mogre.TextureUsage.TU_DYNAMIC_WRITE_ONLY, null, false, 0);



        //buffer.
        //TexturePtr texturePtr = TextureManager.Singleton.LoadImage(pathRelFile, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, image);
        //fs2.Close();
        //fs.Close();
        //lock (allTextures)
        //{
        //    return allTextures.Add(texturePtr);
        //}
        //ResourcePtr rp2 = MaterialManager.Singleton.Create("MATERIAL_CUSTOM_DYN", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
        //MaterialPtr mat3 = (MaterialPtr)rp2;
        //TextureUnitState tState2 = mat3.GetTechnique(0).GetPass(0).CreateTextureUnitState("test2");
        //ent.SetMaterialName("MATERIAL_CUSTOM_DYN");
        //public static void ReplaceTexture(HardwarePixelBuffer buffer, byte[] frame, int ancho, int alto)
        //{
        //    unsafe
        //    {

        //        buffer.Lock(HardwareBuffer.LockOptions.HBL_NORMAL);
        //        PixelBox pBox = buffer.CurrentLock;
        //        //pBox.format = PixelFormat.PF_BYTE_BGRA;
        //        pBox.format = PixelFormat.PF_X8R8G8B8;



        //        //Marshal.Copy(frame, 0, pBox.data, (alto * ancho * 4));
        //        Marshal.Copy(frame, 0, pBox.data, frame.Length);

        //        buffer.Unlock();
        //    }
        //}
        //public void ShowImageOnTexture(System.Drawing.Image img, Entity ent)
        //{
        //    ent.SetMaterialName("MATERIAL_CUSTOM_DYN");
        //    MemoryStream ms = new MemoryStream();
        //    img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
        //    ReplaceTexture("DynTexture", ms.ToArray(), img.Width, img.Height);
        //}
        public int Add(TexturePtr o)
        {
            lock (allTextures)
            {
                return(allTextures.Add(((TexturePtr)o)));
            }
        }
Example #3
0
        public MaterialPtr RenderPreview()
        {
            string textureName  = "RttTex_Character_" + Guid.NewGuid().ToString();
            string materialName = "RttMat_Character_" + Guid.NewGuid().ToString();

            TexturePtr rttTexture =
                TextureManager.Singleton.CreateManual(
                    textureName,
                    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                    TextureType.TEX_TYPE_2D,
                    GameManager.Instance.renderWindow.Width,
                    GameManager.Instance.renderWindow.Height,
                    0,
                    PixelFormat.PF_R8G8B8,
                    (int)TextureUsage.TU_RENDERTARGET);

            RenderTexture renderTexture = rttTexture.GetBuffer().GetRenderTarget();

            renderTexture.AddViewport(camera);
            renderTexture.GetViewport(0).SetClearEveryFrame(false);
            renderTexture.GetViewport(0).BackgroundColour = new ColourValue(0, 0, 0, 0);
            renderTexture.Update();

            MaterialPtr materialPtr = MaterialManager.Singleton.Create(materialName, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            materialPtr.GetTechnique(0).GetPass(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            materialPtr.GetTechnique(0).GetPass(0).CreateTextureUnitState().SetTextureName(textureName);

            return(materialPtr);
        }
Example #4
0
        public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size)
        {
            this.texture = TextureManager.Singleton.CreateManual(
                name + "Texture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)size.Width,
                (uint)size.Height,
                0,
                PixelFormat.PF_A8R8G8B8);

            this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name);
            this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            this.material.SetDepthCheckEnabled(false);

            this.billboardSet = sceneMgr.CreateBillboardSet();
            this.billboardSet.SetMaterialName(this.material.Name);
            this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

            this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO);
            this.billboard.SetDimensions(size.Width, size.Height);
            this.billboard.Colour = ColourValue.ZERO;

            node.AttachObject(this.billboardSet);
            this.sceneMgr = sceneMgr;
            this.size     = size;
        }
Example #5
0
        public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size)
        {
            this.texture = TextureManager.Singleton.CreateManual(
                name + "Texture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)size.Width,
                (uint)size.Height,
                0,
                PixelFormat.PF_A8R8G8B8);

            this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name);
            this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            this.material.SetDepthCheckEnabled(false);

            this.billboardSet = sceneMgr.CreateBillboardSet();
            this.billboardSet.SetMaterialName(this.material.Name);
            this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

            this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO);
            this.billboard.SetDimensions(size.Width, size.Height);
            this.billboard.Colour = ColourValue.ZERO;

            node.AttachObject(this.billboardSet);
            this.sceneMgr = sceneMgr;
            this.size = size;
        }
Example #6
0
        void CreateCubeMap()
        {
            // create the camera used to render to our cubemap
            _cubeCamera             = _sceneManager.CreateCamera("CubeMapCamera", true, true);
            _cubeCamera.FOVy        = new Degree(90);
            _cubeCamera.AspectRatio = 1.0f;
            _cubeCamera.SetFixedYawAxis(false);
            _cubeCamera.NearClipDistance = 5.0f;
            _cubeCamera.FarClipDistance  = /*100*/ 10000;

            using (TexturePtr tex = TextureManager.Singleton.CreateManual("dyncubemap", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_CUBE_MAP, 512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET))
            {
                CompositorManager2 compositorManager = _root.CompositorManager2;
                const string       workspaceName     = "CompositorSampleCubemap_cubemap";
                if (!compositorManager.HasWorkspaceDefinition(workspaceName))
                {
                    CompositorWorkspaceDef workspaceDef = compositorManager.AddWorkspaceDefinition(workspaceName);
                    //"CubemapRendererNode" has been defined in scripts.
                    //Very handy (as it 99% the same for everything)
                    workspaceDef.ConnectOutput("CubemapRendererNode", 0);
                }

                CompositorChannel channel = new CompositorChannel
                {
                    target = tex.GetBuffer(0).GetRenderTarget()
                };
                channel.textures.Add(tex);
                _cubemapWorkspace = compositorManager.AddWorkspace(_sceneManager, channel, _cubeCamera, workspaceName, false);
            }
        }
Example #7
0
 public void copyToTexture(TexturePtr target)
 {
     OgrePINVOKE.TexturePtr_copyToTexture(swigCPtr, TexturePtr.getCPtr(target));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
        private bool queueBackgroundImageLoad(String source, IntPtr rocketTexture, ref Vector2i size)
        {
            try
            {
                //On main thread, load image info
                var streamPtr = OgreResourceGroupManager.getInstance().openResource(source, "Rocket.Common", true);
                int width, height;
                ImageUtility.ImageFormat format = ImageUtility.GetImageInfo(streamPtr.Value, out width, out height);
                size = new Vector2i(width, height);
                ThreadManager.RunInBackground(() =>
                {
                    //Process the image itself in a background thread
                    Image image = new Image();
                    try
                    {
                        image.load(streamPtr.Value, format.ToString().ToLowerInvariant());
                        ThreadManager.invoke(() =>
                        {
                            //Commit the texture to ogre and alert libRocket we are done loading, back in the main thread
                            TexturePtr texture = null;
                            try
                            {
                                texture = TextureManager.getInstance().loadImage(source, "Rocket.Common", image);
                            }
                            catch (OgreException)
                            {
                            }
                            finally
                            {
                                RenderInterfaceOgre3D_finishTextureLoad(rocketTexture, texture != null ? texture.HeapSharedPtr : IntPtr.Zero);
                                if (image != null)
                                {
                                    image.Dispose();
                                }
                                if (texture != null)
                                {
                                    texture.Dispose();
                                }
                                RocketInterface.Instance.fireTextureLoaded();
                            }
                        });
                    }
                    finally
                    {
                        if (streamPtr != null)
                        {
                            streamPtr.Dispose();
                        }
                    }
                });

                return(true);
            }
            catch (OgreException ex)
            {
                return(false);
            }
        }
Example #9
0
        public static void CalculateAlphas(TexturePtr texturePtr)
        {
            if (texturePtr == null)
            {
                return;
            }

            CalculateAplha(texturePtr.Target);
        }
Example #10
0
        public OverlayContainer createStaticImage(Vector2 pos, String imageName)
        {
            TexturePtr t      = TextureManager.Singleton.Load(imageName, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            uint       width  = t.SrcWidth;
            uint       height = t.SrcHeight;

            t = null;
            return(createStaticImage(new Vector4(pos.x, pos.y, width, height), imageName));
        }
Example #11
0
        public TexturePtr load(string name, string group)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_load__SWIG_6(swigCPtr, name, group), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #12
0
        public TexturePtr load(string name, string group, TextureType texType, int numMipmaps, float gamma)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_load__SWIG_3(swigCPtr, name, group, (int)texType, numMipmaps, gamma), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #13
0
        public TexturePtr load(string name, string group, TextureType texType, int numMipmaps, float gamma, bool isAlpha, PixelFormat desiredFormat, bool hwGammaCorrection)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_load__SWIG_0(swigCPtr, name, group, (int)texType, numMipmaps, gamma, isAlpha, (int)desiredFormat, hwGammaCorrection), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #14
0
        public TexturePtr prepare(string name, string group, TextureType texType)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_prepare__SWIG_5(swigCPtr, name, group, (int)texType), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #15
0
        public TexturePtr getByName(string name)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_getByName__SWIG_1(swigCPtr, name), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #16
0
 private void destroyTexture()
 {
     if (physicalTexture != null)
     {
         buffer.Dispose();
         TextureManager.getInstance().remove(physicalTexture);
         physicalTexture.Dispose();
         physicalTexture = null;
     }
 }
Example #17
0
        public TexturePtr getTextureInstance(string name, uint mrtIndex)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.Compositor_getTextureInstance(swigCPtr, name, mrtIndex), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #18
0
        public TexturePtr getPooledTexture(string name, string localName, uint w, uint h, PixelFormat f, uint aa, string aaHint, bool srgb, SWIGTYPE_p_std__setT_Ogre__Texture_p_t texturesAlreadyAssigned, CompositorInstance inst, CompositionTechnique.TextureScope scope)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.CompositorManager_getPooledTexture(swigCPtr, name, localName, w, h, (int)f, aa, aaHint, srgb, SWIGTYPE_p_std__setT_Ogre__Texture_p_t.getCPtr(texturesAlreadyAssigned), CompositorInstance.getCPtr(inst), (int)scope), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #19
0
        public virtual TexturePtr loadImage(string name, string group, Image img, TextureType texType, int numMipmaps, float gamma, bool isAlpha, PixelFormat desiredFormat)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_loadImage__SWIG_1(swigCPtr, name, group, Image.getCPtr(img), (int)texType, numMipmaps, gamma, isAlpha, (int)desiredFormat), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #20
0
        public virtual TexturePtr loadImage(string name, string group, Image img, TextureType texType, int numMipmaps)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_loadImage__SWIG_4(swigCPtr, name, group, Image.getCPtr(img), (int)texType, numMipmaps), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #21
0
        public TexturePtr create(string name, string group, bool isManual, ManualResourceLoader loader)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_create__SWIG_1(swigCPtr, name, group, isManual, ManualResourceLoader.getCPtr(loader)), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #22
0
        public virtual TexturePtr loadImage(string name, string group, Image img)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_loadImage__SWIG_6(swigCPtr, name, group, Image.getCPtr(img)), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #23
0
        public TexturePtr createManual(string name, string group, TextureType texType, uint width, uint height, int numMipmaps, PixelFormat format)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_createManual__SWIG_11(swigCPtr, name, group, (int)texType, width, height, numMipmaps, (int)format), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #24
0
        public TexturePtr _getWarningTexture()
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager__getWarningTexture(swigCPtr), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #25
0
        public TexturePtr createManual(string name, string group, TextureType texType, uint width, uint height, int numMipmaps, PixelFormat format, int usage, ManualResourceLoader loader, bool hwGammaCorrection)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_createManual__SWIG_8(swigCPtr, name, group, (int)texType, width, height, numMipmaps, (int)format, usage, ManualResourceLoader.getCPtr(loader), hwGammaCorrection), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #26
0
        public virtual TexturePtr loadRawData(string name, string group, DataStreamPtr stream, ushort width, ushort height, PixelFormat format)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_loadRawData__SWIG_4(swigCPtr, name, group, DataStreamPtr.getCPtr(stream), width, height, (int)format), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #27
0
        public virtual TexturePtr loadRawData(string name, string group, DataStreamPtr stream, ushort width, ushort height, PixelFormat format, TextureType texType, int numMipmaps, float gamma, bool hwGammaCorrection)
        {
            TexturePtr ret = new TexturePtr(OgrePINVOKE.TextureManager_loadRawData__SWIG_0(swigCPtr, name, group, DataStreamPtr.getCPtr(stream), width, height, (int)format, (int)texType, numMipmaps, gamma, hwGammaCorrection), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="font"></param>
        /// <param name="viewport"></param>
        /// <remarks>Deprecated!</remarks>
        /// <returns></returns>
        public static Vector2 GetTextDimensions(String text, Font font, Viewport viewport)
        {
            TexturePtr fontTexture = (TexturePtr)TextureManager.Singleton.GetByName(font.GetMaterial().GetTechnique(0).GetPass(0).GetTextureUnitState(0).TextureName);
            float      charHeight  = Mogre.StringConverter.ParseReal(font.GetParameter("size"));


            Box[]     GlyphTexCoords = new Box[text.Length];
            FloatRect glypheTexRect;
            uint      charheight = 0;
            uint      charwidth  = 0;

            for (int i = 0; i < text.Length; i++)
            {
                if ((text[i] != '\t') && (text[i] != '\n') && (text[i] != ' '))
                {
                    glypheTexRect            = font.GetGlyphTexCoords(text[i]);
                    GlyphTexCoords[i].left   = (uint)(glypheTexRect.left * fontTexture.SrcWidth);
                    GlyphTexCoords[i].top    = (uint)(glypheTexRect.top * fontTexture.SrcHeight);
                    GlyphTexCoords[i].right  = (uint)(glypheTexRect.right * fontTexture.SrcWidth);
                    GlyphTexCoords[i].bottom = (uint)(glypheTexRect.bottom * fontTexture.SrcHeight);

                    if (GlyphTexCoords[i].Height > charheight)
                    {
                        charheight = GlyphTexCoords[i].Height;
                    }
                    if (GlyphTexCoords[i].Width > charwidth)
                    {
                        charwidth = GlyphTexCoords[i].Width;
                    }
                }
            }
            //   charwidth = charheight / 3;



            Vector2 result = new Vector2(0, 0);

            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == 0x0020)
                {
                    result.x += font.GetGlyphAspectRatio(0x0030);
                }
                else
                {
                    result.x += font.GetGlyphAspectRatio(text[i]);
                }
            }

            result.x = (result.x * charwidth) / (float)viewport.ActualWidth;
            result.y = charHeight / (float)viewport.ActualHeight;

            return(result);
        }
Example #29
0
        public VideoTexture(SceneManager scm, float width, float height, string aviFileName)
        {
            AviManager aviMgr = new AviManager(aviFileName, true);

            Stream = aviMgr.GetVideoStream();

            TexturePtr VideoTexture = TextureManager.Singleton.CreateManual(
                "Video",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D, Convert.ToUInt32(Stream.Width), Convert.ToUInt32(Stream.Height), 0, PixelFormat.PF_R8G8B8A8, (int)TextureUsage.TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
            MaterialPtr VideoMat = MaterialManager.Singleton.Create(
                "VideoMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            VideoMat.GetTechnique(0).GetPass(0).LightingEnabled = false;
            VideoMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("Video");

            PixelBuffer = VideoTexture.GetBuffer();

            screen         = scm.CreateManualObject("Screen");
            screen.Dynamic = true;
            screen.Begin("VideoMat", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            screen.Position(0, 0, 0);
            screen.TextureCoord(0, 0);

            screen.Position(width, 0, 0);
            screen.TextureCoord(1, 0);

            screen.Position(width, height, 0);
            screen.TextureCoord(1, 1);

            screen.Triangle(0, 1, 2);

            screen.Position(0, 0, 0);
            screen.TextureCoord(0, 0);

            screen.Position(width, height, 0);
            screen.TextureCoord(1, 1);

            screen.Position(0, height, 0);
            screen.TextureCoord(0, 1);

            screen.Triangle(3, 4, 5);

            screen.End();

            SceneNode node = scm.RootSceneNode.CreateChildSceneNode();

            node.Position = new Vector3(0, 0, 0);
            node.AttachObject(screen);

            Stream.GetFrameOpen();
            FrameNum = 0;
        }
Example #30
0
 public Boolean Contains(TexturePtr a)
 {
     foreach (TexturePtr tex in allTextures)
     {
         if (tex.Name == a.Name)
         {
             return(true);
         }
     }
     return(false);
 }
Example #31
0
 private void destroyColorTexture()
 {
     if (colorTexture != null)
     {
         sensorManager.SensorColorFrameReady -= sensorManager_SensorColorFrameReady;
         setColorImageIcon(); //Because we set this to something with an actual texture, it will replace the texture set when created (that happens in the function called).
         RenderManager.Instance.destroyTexture(colorTexture.Value.getName());
         pixelBox.Dispose();
         hwBuffer.Dispose();
         colorTexture.Dispose();
         colorTexture = null;
     }
 }
Example #32
0
        /// <summary>
        /// Converts a TexturePtr to a System.Drawing.Bitmap.
        /// </summary>
        /// <param name="texturePtr">The TexturePtr.</param>
        /// <returns>A System.Drawing.Bitmap.</returns>
        public static unsafe Bitmap MogreTexturePtrToBitmap(TexturePtr texturePtr)
        {
            var bitmap = new Bitmap((int)texturePtr.Width, (int)texturePtr.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
              var rgbValues = new byte[texturePtr.Width * 4 * texturePtr.Height];
              fixed (byte* ptr = &rgbValues[0])
              {
            var pixelBox = new PixelBox(texturePtr.Width, texturePtr.Height, 1, Mogre.PixelFormat.PF_A8R8G8B8,
                                    (IntPtr)ptr);

            texturePtr.GetBuffer().BlitToMemory(pixelBox);
              }
              var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, (int)texturePtr.Width, (int)texturePtr.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
              Marshal.Copy(rgbValues, 0, bitmapData.Scan0, rgbValues.Length);
              bitmap.UnlockBits(bitmapData);

              return bitmap;
        }
Example #33
0
        private void DisposeRenderTarget()
        {
            if (this.renTarget != null)
            {
                this.renTarget.RemoveAllListeners();
                this.renTarget.RemoveAllViewports();
                this.root.RenderSystem.DestroyRenderTarget(renTarget.Name);
                this.renTarget = null;
            }

            if (this.texture != null)
            {
                TextureManager.Singleton.Remove(this.texture.Handle);
                this.texture.Dispose();
                this.texture = null;
            }
        }
Example #34
0
        protected void ReInitRenderTarget()
        {
            DetachRenderTarget(true, false);
            DisposeRenderTarget();

            _texture = TextureManager.Singleton.CreateManual(
                "OgreImageSource RenderTarget",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)ViewportSize.Width, (uint)ViewportSize.Height,
                0, Mogre.PixelFormat.PF_A8R8G8B8,
                (int)TextureUsage.TU_RENDERTARGET);

            _renTarget = _texture.GetBuffer().GetRenderTarget();

            _reloadRenderTargetTime = 0;
        }
Example #35
0
        public void ReInitRenderTarget()
        {
            DetachRenderTarget(true, false);

            MogitorsRoot.Instance.OnPreRenderTargetChanged();
            DisposeRenderTarget();

            this.texture = TextureManager.Singleton.CreateManual(
                "OgreImageSource RenderTarget",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)ViewportSize.Width,
                (uint)ViewportSize.Height,
                0,
                Mogre.PixelFormat.PF_A8R8G8B8,
                (int)TextureUsage.TU_RENDERTARGET);

            this.renTarget = this.texture.GetBuffer().GetRenderTarget();
            MogitorsRoot.Instance.RenderTarget = this.renTarget;

            MogitorsRoot.Instance.OnPostRenderTargetChanged();

            this.reloadRenderTargetTime = 0;
        }
Example #36
0
        protected void DisposeRenderTarget()
        {
            if (_renTarget != null)
            {
                CompositorManager.Singleton.RemoveCompositorChain(_viewport);
                _renTarget.RemoveAllListeners();
                _renTarget.RemoveAllViewports();
                _root.RenderSystem.DestroyRenderTarget(_renTarget.Name);
                _renTarget = null;
                _viewport = null;
            }

            if (_texture != null)
            {
                TextureManager.Singleton.Remove(_texture.Handle);
                _texture.Dispose();
                _texture = null;
            }
        }
Example #37
0
        public static void CalculateAlphas(TexturePtr texturePtr)
        {
            if (texturePtr == null) return;

            CalculateAplha(texturePtr.Target);
        }
Example #38
0
        public void Dispose()
        {
            this.billboardSet.DetachFromParent();
            this.sceneMgr.DestroyBillboardSet(this.billboardSet);
            this.billboardSet.Dispose();
            this.billboardSet = null;
            this.sceneMgr = null;

            this.material.Unload();
            MaterialManager.Singleton.Remove(this.material.Handle);
            this.material.Dispose();
            this.material = null;

            this.texture.Unload();
            TextureManager.Singleton.Remove(this.texture.Handle);
            this.texture.Dispose();
            this.texture = null;

            GC.SuppressFinalize(this);
        }
Example #39
0
 //unsafe
 //{
 //    void* pointer = buffer.Lock(0, image.Width * image.Height * 4, HardwareBuffer.LockOptions.HBL_NORMAL);
 //    PixelBox pBox = buffer.CurrentLock;
 //    pBox.format = PixelFormat.PF_X8R8G8B8;
 //    //PixelBox imagBox = image.GetPixelBox();
 //    Marshal.Copy(imgBytes, 0, pBox.data, imgBytes.Length);
 //    //Marshal.Copy(imagBox.data,pBox. 0, pBox.data, (int)imagBox.GetConsecutiveSize());
 //}
 //TexturePtr lTextureWithRtt = lTextureManager.CreateManual(pathRelFile + "_temp_rtt",
 //    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
 //    TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8,
 //   (int)Mogre.TextureUsage.TU_DYNAMIC_WRITE_ONLY, null, false, 0);
 //TexturePtr lIntermediateTexture = lTextureManager.CreateManual(pathRelFile + "_temp_inter",
 //    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
 //    TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8,
 //   (int)Mogre.TextureUsage.TU_DYNAMIC_WRITE_ONLY, null, false, 0);
 //buffer.
 //TexturePtr texturePtr = TextureManager.Singleton.LoadImage(pathRelFile, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, image);
 //fs2.Close();
 //fs.Close();
 //lock (allTextures)
 //{
 //    return allTextures.Add(texturePtr);
 //}
 //ResourcePtr rp2 = MaterialManager.Singleton.Create("MATERIAL_CUSTOM_DYN", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
 //MaterialPtr mat3 = (MaterialPtr)rp2;
 //TextureUnitState tState2 = mat3.GetTechnique(0).GetPass(0).CreateTextureUnitState("test2");
 //ent.SetMaterialName("MATERIAL_CUSTOM_DYN");
 //public static void ReplaceTexture(HardwarePixelBuffer buffer, byte[] frame, int ancho, int alto)
 //{
 //    unsafe
 //    {
 //        buffer.Lock(HardwareBuffer.LockOptions.HBL_NORMAL);
 //        PixelBox pBox = buffer.CurrentLock;
 //        //pBox.format = PixelFormat.PF_BYTE_BGRA;
 //        pBox.format = PixelFormat.PF_X8R8G8B8;
 //        //Marshal.Copy(frame, 0, pBox.data, (alto * ancho * 4));
 //        Marshal.Copy(frame, 0, pBox.data, frame.Length);
 //        buffer.Unlock();
 //    }
 //}
 //public void ShowImageOnTexture(System.Drawing.Image img, Entity ent)
 //{
 //    ent.SetMaterialName("MATERIAL_CUSTOM_DYN");
 //    MemoryStream ms = new MemoryStream();
 //    img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
 //    ReplaceTexture("DynTexture", ms.ToArray(), img.Width, img.Height);
 //}
 public int Add(TexturePtr o)
 {
     lock (allTextures)
     {
         return allTextures.Add(((TexturePtr)o));
     }
 }
Example #40
0
 public Boolean Contains(TexturePtr a)
 {
     foreach (TexturePtr tex in allTextures)
     {
         if (tex.Name == a.Name)
         {
             return true;
         }
     }
     return false;
 }