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


C# Texture2D.SetSize方法代码示例

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


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

示例1: SetupViewport

        void SetupViewport()
        {
            var renderer = GetSubsystem<Renderer>();
            var cache = GetSubsystem<ResourceCache>();

            renderer.SetViewport(0, new Viewport(scene, CameraNode.GetComponent<Camera>()));

            // Create a mathematical plane to represent the water in calculations

            waterPlane = new Plane(waterNode.WorldRotation * new Vector3(0.0f, 1.0f, 0.0f), waterNode.WorldPosition);
            // Create a downward biased plane for reflection view clipping. Biasing is necessary to avoid too aggressive clipping
            waterClipPlane = new Plane(waterNode.WorldRotation * new Vector3(0.0f, 1.0f, 0.0f), waterNode.WorldPosition - new Vector3(0.0f, 0.1f, 0.0f));

            // Create camera for water reflection
            // It will have the same farclip and position as the main viewport camera, but uses a reflection plane to modify
            // its position when rendering
            reflectionCameraNode = CameraNode.CreateChild();
            var reflectionCamera = reflectionCameraNode.CreateComponent<Camera>();
            reflectionCamera.FarClip = 750.0f;
            reflectionCamera.ViewMask= 0x7fffffff; // Hide objects with only bit 31 in the viewmask (the water plane)
            reflectionCamera.AutoAspectRatio = false;
            reflectionCamera.UseReflection = true;
            reflectionCamera.ReflectionPlane = waterPlane;
            reflectionCamera.UseClipping = true; // Enable clipping of geometry behind water plane
            reflectionCamera.ClipPlane = waterClipPlane;
            // The water reflection texture is rectangular. Set reflection camera aspect ratio to match
            reflectionCamera.AspectRatio = (float)graphics.Width / graphics.Height;
            // View override flags could be used to optimize reflection rendering. For example disable shadows
            //reflectionCamera.ViewOverrideFlags = ViewOverrideFlags.DisableShadows;

            // Create a texture and setup viewport for water reflection. Assign the reflection texture to the diffuse
            // texture unit of the water material
            int texSize = 1024;
            Texture2D renderTexture = new Texture2D();
            renderTexture.SetSize(texSize, texSize, Graphics.GetRGBFormat(), TextureUsage.TEXTURE_RENDERTARGET);
            renderTexture.FilterMode = TextureFilterMode.FILTER_BILINEAR;
            RenderSurface surface = renderTexture.RenderSurface;
            var rttViewport = new Viewport(scene, reflectionCamera);
            surface.SetViewport(0, rttViewport);
            var waterMat = cache.Get<Material>("Materials/Water.xml");
            waterMat.SetTexture(TextureUnit.TU_DIFFUSE, renderTexture);
        }
开发者ID:Type1J,项目名称:AtomicExamples,代码行数:42,代码来源:23_Water.cs

示例2: CreateScene


//.........这里部分代码省略.........
                    Rotator rotator = new Rotator();
                    boxNode.AddComponent(rotator);
                    rotator.SetRotationSpeed(new Vector3(10.0f, 20.0f, 30.0f));
                }

                // Create a camera for the render-to-texture scene. Simply leave it at the world origin and let it observe the scene
                rttCameraNode = rttScene.CreateChild("Camera");
                Camera camera = rttCameraNode.CreateComponent<Camera>();
                camera.FarClip = 100.0f;

                // Create a point light to the camera scene node
                Light light = rttCameraNode.CreateComponent<Light>();
                light.LightType = LightType.LIGHT_POINT;
                light.Range = 30.0f;
            }

            {
                // Create the scene in which we move around

                scene = new Scene();

                // Create octree, use also default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
                scene.CreateComponent<Octree>();

                // Create a Zone component for ambient lighting & fog control
                Node zoneNode = scene.CreateChild("Zone");
                Zone zone = zoneNode.CreateComponent<Zone>();
                zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
                zone.AmbientColor = new Color(0.1f, 0.1f, 0.1f);
                zone.FogStart = 100.0f;
                zone.FogEnd = 300.0f;

                // Create a directional light without shadows
                Node lightNode = scene.CreateChild("DirectionalLight");
                lightNode.SetDirection(new Vector3(0.5f, -1.0f, 0.5f));
                Light light = lightNode.CreateComponent<Light>();
                light.LightType = LightType.LIGHT_DIRECTIONAL;
                light.Color = new Color(0.2f, 0.2f, 0.2f);
                light.SpecularIntensity = 1.0f;

                // Create a "floor" consisting of several tiles
                for (int y = -5; y <= 5; ++y)
                {
                    for (int x = -5; x <= 5; ++x)
                    {
                        Node floorNode = scene.CreateChild("FloorTile");
                        floorNode.Position = new Vector3(x*20.5f, -0.5f, y*20.5f);
                        floorNode.Scale = new Vector3(20.0f, 1.0f, 20.0f);
                        StaticModel floorObject = floorNode.CreateComponent<StaticModel>();
                        floorObject.Model = cache.Get<Model>("Models/Box.mdl");
                        floorObject.SetMaterial(cache.Get<Material>("Materials/Stone.xml"));
                    }
                }

                // Create a "screen" like object for viewing the second scene. Construct it from two StaticModels, a box for the frame
                // and a plane for the actual view
                {
                    Node boxNode = scene.CreateChild("ScreenBox");
                    boxNode.Position = new Vector3(0.0f, 10.0f, 0.0f);
                    boxNode.Scale = new Vector3(21.0f, 16.0f, 0.5f);
                    StaticModel boxObject = boxNode.CreateComponent<StaticModel>();
                    boxObject.Model = cache.Get<Model>("Models/Box.mdl");
                    boxObject.SetMaterial(cache.Get<Material>("Materials/Stone.xml"));

                    Node screenNode = scene.CreateChild("Screen");
                    screenNode.Position = new Vector3(0.0f, 10.0f, -0.27f);
                    screenNode.Rotation = new Quaternion(-90.0f, 0.0f, 0.0f);
                    screenNode.Scale = new Vector3(20.0f, 0.0f, 15.0f);
                    StaticModel screenObject = screenNode.CreateComponent<StaticModel>();
                    screenObject.Model = cache.Get<Model>("Models/Plane.mdl");

                    // Create a renderable texture (1024x768, RGB format), enable bilinear filtering on it
                    Texture2D renderTexture = new Texture2D();
                    renderTexture.SetSize(1024, 768, Graphics.GetRGBFormat(), TextureUsage.TEXTURE_RENDERTARGET);
                    renderTexture.FilterMode = TextureFilterMode.FILTER_BILINEAR;

                    // Create a new material from scratch, use the diffuse unlit technique, assign the render texture
                    // as its diffuse texture, then assign the material to the screen plane object
                    Material renderMaterial = new Material();
                    renderMaterial.SetTechnique(0, cache.Get<Technique>("Techniques/DiffUnlit.xml"), 0, 0);
                    renderMaterial.SetTexture(TextureUnit.TU_DIFFUSE, renderTexture);
                    screenObject.SetMaterial(renderMaterial);

                    // Get the texture's RenderSurface object (exists when the texture has been created in rendertarget mode)
                    // and define the viewport for rendering the second scene, similarly as how backbuffer viewports are defined
                    // to the Renderer subsystem. By default the texture viewport will be updated when the texture is visible
                    // in the main view
                    RenderSurface surface = renderTexture.RenderSurface;
                    Viewport rttViewport = new Viewport(rttScene, rttCameraNode.GetComponent<Camera>());
                    surface.SetViewport(0, rttViewport);
                }

                // Create the camera. Limit far clip distance to match the fog
                CameraNode = scene.CreateChild("Camera");
                var camera = CameraNode.CreateComponent<Camera>();
                camera.FarClip = 300.0f;
                // Set an initial position for the camera scene node above the plane
                CameraNode.Position = new Vector3(0.0f, 7.0f, -30.0f);
            }
        }
开发者ID:Type1J,项目名称:AtomicExamples,代码行数:101,代码来源:10_RenderToTexture.cs

示例3: CreateVideoTexturePlaceholder

		void CreateVideoTexturePlaceholder(int width, int height)
		{
			cameraTexture = new Texture2D(this.Context);
			cameraTexture.SetNumLevels(1);
			cameraTexture.SetSize(width, height, Urho.Graphics.RGBFormat, TextureUsage.Dynamic);
			var material = new Material();
			material.SetTexture(TextureUnit.Diffuse, cameraTexture);
			material.SetTechnique(0, CoreAssets.Techniques.Diff, 0, 0);
			planeNode = scene.CreateChild();
			planeNode.Position = new Vector3(0, 0, 7);
			const float xScale = 5;
			planeNode.Scale = new Vector3(xScale, xScale * height / width, xScale);
			var planeModel = planeNode.CreateComponent<StaticModel>();
			planeModel.Model = CoreAssets.Models.Box;
			planeModel.SetMaterial(material);
		}
开发者ID:cianmulville,项目名称:urho-samples,代码行数:16,代码来源:UrhoApp.cs


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