Ejemplo n.º 1
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // setup the camera
            var camera = new TestUICamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor)
            {
                Yaw = 0, Pitch = 0, Position = new Vector3(0, 0, 1000), MoveSpeed = 100
            };

            CameraComponent = camera.Camera;
            Script.Add(camera);

            UIRoot.Transform.Rotation = Quaternion.RotationX(MathUtil.Pi / 3f);
            UIComponent.Page          = new UIPage {
                RootElement = new ImageElement {
                    Source = (SpriteFromTexture) new Sprite(Content.Load <Texture>("uv"))
                }
            };
            UIComponent.IsFullScreen = false;
            UIComponent.IsBillboard  = false;
            UIComponent.Resolution   = new Vector3(200, 200, 100);
            UIRoot.Transform.Scale   = new Vector3(200, 200, 100);

            var cube = new Entity {
                new ModelComponent {
                    Model = Content.Load <Model>("cube Model")
                }
            };

            cube.Transform.Scale    = new Vector3(10000);
            cube.Transform.Position = new Vector3(0, 0, 10);
            Scene.Entities.Add(cube);

            var font        = Content.Load <SpriteFont>("CourierNew12");
            var textBlockZ0 = new TextBlock {
                Font = font, TextColor = Color.Black, TextSize = 20, Text = "At depth 0", VerticalAlignment = VerticalAlignment.Center, SynchronousCharacterGeneration = true, BackgroundColor = Color.Red
            };
            var entity1 = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = textBlockZ0
                    }, IsFullScreen = false, IsBillboard = false, Resolution = new Vector3(150)
                }
            };

            entity1.Transform.Scale    = new Vector3(150);
            entity1.Transform.Position = new Vector3(-500, 0, 0);
            Scene.Entities.Add(entity1);

            var textBlockZ500 = new TextBlock {
                Font = font, TextColor = Color.Black, TextSize = 20, Text = "At depth 300", VerticalAlignment = VerticalAlignment.Center, SynchronousCharacterGeneration = true, BackgroundColor = Color.Red
            };
            var entity2 = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = textBlockZ500
                    }, IsFullScreen = false, IsBillboard = false, Resolution = new Vector3(150)
                }
            };

            entity2.Transform.Scale    = new Vector3(150);
            entity2.Transform.Position = new Vector3(300, 0, 300);
            Scene.Entities.Add(entity2);

            var textBlockZM500 = new TextBlock {
                Font = font, TextColor = Color.Black, TextSize = 20, Text = "At depth -300", VerticalAlignment = VerticalAlignment.Center, SynchronousCharacterGeneration = true, BackgroundColor = Color.Red
            };
            var entity3 = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = textBlockZM500
                    }, IsFullScreen = false, IsBillboard = false, Resolution = new Vector3(150)
                }
            };

            entity3.Transform.Scale    = new Vector3(150);
            entity3.Transform.Position = new Vector3(0, 300, -300);
            Scene.Entities.Add(entity3);

            elements.Add(entity1);
            elements.Add(entity2);
            elements.Add(entity3);
        }
Ejemplo n.º 2
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var cube = new Entity {
                new ModelComponent {
                    Model = Content.Load <Model>("cube Model")
                }
            };

            cube.Transform.Scale    = new Vector3(10000);
            cube.Transform.Position = new Vector3(0, 0, 10);
            Scene.Entities.Add(cube);

            var imageElement = new ImageElement {
                Source = (SpriteFromTexture) new Sprite(Content.Load <Texture>("uv"))
            };
            var imageEntity = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = imageElement
                    }, IsFullScreen = false, Resolution = new Vector3(150)
                }
            };

            imageEntity.Transform.Scale    = new Vector3(150);
            imageEntity.Transform.Position = new Vector3(-500, 0, 0);
            Scene.Entities.Add(imageEntity);

            var imageEntity2 = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = imageElement
                    }, IsFullScreen = false, Resolution = new Vector3(200)
                }
            };

            imageEntity2.Transform.Position = new Vector3(0, 250, 0);
            imageEntity2.Transform.Scale    = new Vector3(200);
            Scene.Entities.Add(imageEntity2);

            var imageEntity3 = new Entity {
                new UIComponent {
                    Page = new UIPage {
                        RootElement = imageElement
                    }, IsFullScreen = false, Resolution = new Vector3(250)
                }
            };

            imageEntity3.Transform.Position = new Vector3(0, 0, -500);
            imageEntity3.Transform.Scale    = new Vector3(250);
            Scene.Entities.Add(imageEntity3);

            // setup the camera
            var camera = new TestUICamera(Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor)
            {
                Yaw = MathUtil.Pi / 4, Pitch = MathUtil.Pi / 4, Position = new Vector3(500, 500, 500), MoveSpeed = 100
            };

            camera.SetTarget(cube, true);
            CameraComponent = camera.Camera;
            Script.Add(camera);
        }