当前位置: 首页>>代码示例>>C#>>正文


C# RenderTexture.AddListener方法代码示例

本文整理汇总了C#中RenderTexture.AddListener方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTexture.AddListener方法的具体用法?C# RenderTexture.AddListener怎么用?C# RenderTexture.AddListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderTexture的用法示例。


在下文中一共展示了RenderTexture.AddListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateReflectionTexture

        void CreateReflectionTexture()
        {
            DestroyReflectionTexture();

            Vec2i textureSize = GetRequiredReflectionTextureSize();

            //create render texture

            string textureName = TextureManager.Instance.GetUniqueName( "WaterPlaneReflection" );

            bool hdr = RendererWorld.Instance.DefaultViewport.GetCompositorInstance( "HDR" ) != null;

            reflectionTexture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D,
                textureSize, 1, 0, hdr ? PixelFormat.Float16RGB : PixelFormat.R8G8B8,
                Texture.Usage.RenderTarget );

            reflectionRenderTexture = reflectionTexture.GetBuffer().GetRenderTarget();

            //create camera
            reflectionCamera = SceneManager.Instance.CreateCamera();
            reflectionCamera.AllowFrustumTestMode = true;

            //add viewport
            reflectionViewport = reflectionRenderTexture.AddViewport( reflectionCamera );
            reflectionViewport.ShadowsEnabled = false;
            reflectionViewport.MaterialScheme = MaterialSchemes.Low.ToString();

            //add listener
            renderTargetListener = new ReflectionRenderTargetListener( this );
            reflectionRenderTexture.AddListener( renderTargetListener );

            reflectionRenderTexture.AutoUpdate = Visible;
        }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:33,代码来源:WaterPlane.cs

示例2: CreateRenderTarget

        bool CreateRenderTarget()
        {
            DestroyRenderTarget();

            if( RendererWorld.Instance == null )
                return false;

            Vec2I textureSize = GetDemandTextureSize();
            if( textureSize.X < 1 || textureSize.Y < 1 )
                return false;

            string textureName = TextureManager.Instance.GetUniqueName( "WPFRenderTexture" );

            int hardwareFSAA = 0;
            if( !RendererWorld.InitializationOptions.AllowSceneMRTRendering )
            {
                if( !int.TryParse( RendererWorld.InitializationOptions.FullSceneAntialiasing, out hardwareFSAA ) )
                    hardwareFSAA = 0;
            }

            texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize,
                1, 0, Engine.Renderer.PixelFormat.R8G8B8, Texture.Usage.RenderTarget, false, hardwareFSAA );

            if( texture == null )
                return false;

            currentTextureSize = textureSize;

            renderTexture = texture.GetBuffer().GetRenderTarget();
            renderTexture.AutoUpdate = false;
            renderTexture.AllowAdditionalMRTs = true;

            camera = SceneManager.Instance.CreateCamera(
                SceneManager.Instance.GetUniqueCameraName( "UserControl" ) );
            camera.Purpose = Camera.Purposes.MainCamera;

            //update camera settings
            camera.NearClipDistance = cameraNearFarClipDistance.Minimum;
            camera.FarClipDistance = cameraNearFarClipDistance.Maximum;
            camera.AspectRatio = (float)texture.Size.X / (float)texture.Size.Y;
            camera.FixedUp = cameraFixedUp;
            camera.Position = cameraPosition;
            camera.Direction = cameraDirection;
            camera.Fov = cameraFov;
            camera.ProjectionType = cameraProjectionType;
            camera.OrthoWindowHeight = cameraOrthoWindowHeight;

            viewport = renderTexture.AddViewport( camera );

            //Initialize HDR compositor for HDR render technique
            if( EngineApp.RenderTechnique == "HDR" )
            {
                viewport.AddCompositor( "HDR", 0 );
                viewport.SetCompositorEnabled( "HDR", true );
            }

            //Initialize Fast Approximate Antialiasing (FXAA)
            {
                bool useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering;
                string fsaa = RendererWorld.InitializationOptions.FullSceneAntialiasing;
                if( ( useMRT && ( fsaa == "" || fsaa == "RecommendedSetting" ) && IsActivateFXAAByDefault() ) ||
                    fsaa == "FXAA" )
                {
                    if( RenderSystem.Instance.HasShaderModel3() )
                        InitializeFXAACompositor();
                }
            }

            //add listener
            renderTargetListener = new ViewRenderTargetListener( this );
            renderTexture.AddListener( renderTargetListener );

            if( guiRenderer == null )
                guiRenderer = new GuiRenderer( viewport );
            else
                guiRenderer.ChangeViewport( viewport );

            if( controlManager == null )
                controlManager = new ScreenControlManager( guiRenderer );

            //initialize D3DImage output
            if( d3dImageIsSupported && allowUsingD3DImage )
            {
                // create a D3DImage to host the scene and monitor it for changes in front buffer availability
                if( d3dImage == null )
                {
                    d3dImage = new D3DImage();
                    d3dImage.IsFrontBufferAvailableChanged += D3DImage_IsFrontBufferAvailableChanged;
                    CompositionTarget.Rendering += D3DImage_OnRendering;
                }

                // set output to background image
                Background = new ImageBrush( d3dImage );

                // set the back buffer using the new scene pointer
                HardwarePixelBuffer buffer = texture.GetBuffer( 0, 0 );
                GetD3D9HardwarePixelBufferData data = new GetD3D9HardwarePixelBufferData();
                data.hardwareBuffer = buffer._GetRealObject();
                data.outPointer = IntPtr.Zero;
                unsafe
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:SDK,代码行数:101,代码来源:RenderTargetUserControl.xaml.cs

示例3: CreateRenderTexture

            ///////////////

            private bool CreateRenderTexture()
            {
                Vec2I size = new Vec2I(512, 256);

                string textureName = TextureManager.Instance.GetUniqueName("RenderToTextureExample");
                texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, size, 1, 0,
                    PixelFormat.R8G8B8, Texture.Usage.RenderTarget);
                if (texture == null)
                    return false;

                renderTexture = texture.GetBuffer().GetRenderTarget();
                //you can update render texture manually by means renderTexture.Update() method. For this task set AutoUpdate = false;
                renderTexture.AutoUpdate = true;

                //create camera
                string cameraName = SceneManager.Instance.GetUniqueCameraName("RenderToTextureExample");
                camera = SceneManager.Instance.CreateCamera(cameraName);
                camera.Purpose = Camera.Purposes.Special;
                camera.AllowMapCompositorManager = false;

                //add viewport
                viewport = renderTexture.AddViewport(camera);
                viewport.BackgroundColor = new ColorValue(0, 0, 0, 1);
                viewport.ShadowsEnabled = false;
                viewport.MaterialScheme = "";

                //add listener
                renderTargetListener = new SceneRenderTargetListener(this);
                renderTexture.AddListener(renderTargetListener);

                return true;
            }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:34,代码来源:GUISamples2Window.cs


注:本文中的RenderTexture.AddListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。