コード例 #1
0
ファイル: GameApplication.cs プロジェクト: NKXLAB/WPF45URHO
        protected override void Start()
        {
            Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
            base.Start();
            if (Platform == Platforms.Android ||
                Platform == Platforms.iOS ||
                Options.TouchEmulation)
            {
                //InitTouchInput();
            }
            Input.Enabled = true;
            MonoDebugHud  = new MonoDebugHud(this);
            MonoDebugHud.Show();

            cache = ResourceCache;
            CreateInfo();
            //SetWindowAndTitleIcon();
            CreateConsoleAndDebugHud();
            //Input.SubscribeToKeyDown(HandleKeyDown);
            Input.KeyDown += HandleKeyDown;

            CreateScene();
            //SimpleCreateInstructionsWithWasd(", use PageUp PageDown keys to zoom.");
            SetupViewport();
        }
コード例 #2
0
        protected override void Start()
        {
            Log.LogLevel = LogLevel.Debug;
            ResourceCache.AutoReloadResources = true;

            var xml = ResourceCache.GetXmlFile("UI/DefaultStyle.xml");

            console = Engine.CreateConsole();
            console.DefaultStyle       = xml;
            console.Background.Opacity = 0.8f;
            debugHud = Engine.CreateDebugHud();
            debugHud.DefaultStyle = xml;

            var hud = new MonoDebugHud(this);

            CreateScene(null);

            Input.KeyDown           += OnKeyDown;
            Input.MouseWheel        += OnMouseWheel;
            Input.MouseMoved        += OnMouseMoved;
            Engine.PostRenderUpdate += args => { if (DrawDebugFrame)
                                                 {
                                                     Renderer.DrawDebugGeometry(false);
                                                 }
            };
        }
コード例 #3
0
        protected override void Start()
        {
            Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
            base.Start();
            if (Platform == Platforms.Android ||
                Platform == Platforms.iOS ||
                Options.TouchEmulation)
            {
                InitTouchInput();
            }
            Input.Enabled = true;

            cache = ResourceCache;

#if DEBUG
            MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
            CreateConsoleAndDebugHud();
#endif

            // TODO
            //var icon = cache.GetImage("Textures/UrhoIcon.png");
            //Graphics.SetWindowIcon(icon);
            Graphics.WindowTitle = "Tests";

            Input.SubscribeToKeyDown(HandleKeyDown);
        }
コード例 #4
0
        protected override void Start()
        {
            // 3d scene with octree and ambient light
            var scene  = new Scene(Context);
            var octree = scene.CreateComponent <Octree>();

            zone = scene.CreateComponent <Zone>();
            zone.AmbientColor = new Color(1, 1, 1) * 0.2f;

            //my comments

            // Camera
            var cameraNode = scene.CreateChild(name: "Camera");
            var camera     = cameraNode.CreateComponent <Urho.Camera>();

            // Light
            var lightNode = cameraNode.CreateChild();

            lightNode.SetDirection(new Vector3(1f, -1.0f, 1f));
            var light = lightNode.CreateComponent <Light>();

            light.Range             = 10;
            light.LightType         = LightType.Directional;
            light.CastShadows       = true;
            Renderer.ShadowMapSize *= 4;

            // Viewport
            viewport = new Viewport(Context, scene, camera, null);
            Renderer.SetViewport(0, viewport);

            // ARCore component
            ArCore = new ARCoreComponent();
            ArCore.ARFrameUpdated  += OnARFrameUpdated;
            ArCore.ConfigRequested += ArCore_ConfigRequested;
            ArCore.Camera           = camera;
            scene.AddComponent(ArCore);

            // Mutant
            mutantNode          = scene.CreateChild();
            mutantNode.Position = new Vector3(0, -0.5f, 0.5f);             // 50cm Y, 50cm Z
            mutantNode.SetScale(0.3f);
            var model = mutantNode.CreateComponent <AnimatedModel>();

            model.CastShadows = true;
            model.Model       = ResourceCache.GetModel("Models/Mutant.mdl");
            model.Material    = ResourceCache.GetMaterial("Materials/mutant_M.xml");
            var ani = mutantNode.CreateComponent <AnimationController>();

            ani.Play("Animations/Mutant_HipHop1.ani", 0, true, 1f);

            fps = new MonoDebugHud(this);
            fps.Show(Color.Blue, 20);

            // Add some post-processing (also, see CorrectGamma())
            viewport.RenderPath.Append(CoreAssets.PostProcess.FXAA2);

            Input.TouchBegin += OnTouchBegin;
            Input.TouchEnd   += OnTouchEnd;
        }
コード例 #5
0
        protected override void Start()
        {
            base.Start();

            MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
            Input.KeyDown           += HandleKeyDown;
            Engine.PostRenderUpdate += RenderDebug;
        }
コード例 #6
0
        protected override void Start()
        {
            MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
            Input.MouseWheel += Input_MouseWheel;

            _lightType     = LightType.Spot;
            _model         = ResourceCache.GetModel("Models/MaterialGraphEditor/MaterialPreview.mdl", false);
            _animatedModel = false;
        }
コード例 #7
0
        protected override async void Start()
        {
            _sceneChanges = new Subject <SceneChangeEventArgs>();
            base.Start();

#if DEBUG
            var MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
#endif
            //await Navigation.PushAsync(new ScenePage("No scene.xml",false));
        }
コード例 #8
0
        //public void Dispose()
        //{
        //	Urho.IO.Log.Write(LogLevel.Debug, "Game disposed.");
        //	base.Dispose();
        //}

        void SetConfigOptions()
        {
            int monitor = Graphics.CurrentMonitor;

            if (Config.DebugHUD)
            {
                monoDebugHud = new MonoDebugHud(this);
                monoDebugHud.Show();
            }

            Config.SetGraphicsMode(Graphics);
        }
コード例 #9
0
        protected override void Start()
        {
            debugHud = new MonoDebugHud(this)
            {
                FpsOnly = true
            };
            debugHud.Show();

            scene = new Scene();
            scene.CreateComponent <Octree>();
            var zone = scene.CreateComponent <Zone>();

            zone.AmbientColor = new Color(0.5f, 0.5f, 0.5f);

            cameraNode = scene.CreateChild();
            var camera = cameraNode.CreateComponent <Camera>();

            var viewport = new Viewport(scene, camera, null);

            // viewport.SetClearColor(Color.White);
            Renderer.SetViewport(0, viewport);

            lightNode          = scene.CreateChild();
            lightNode.Position = new Vector3(0, 3, 0);
            var light = lightNode.CreateComponent <Light>();

            light.LightType  = LightType.Directional;
            light.Brightness = 0.6f;
            light.Range      = 200;

            environmentNode = scene.CreateChild();
            environmentNode.SetScale(0.1f);

            humanNode          = environmentNode.CreateChild();
            humanNode.Position = new Vector3(0, -1f, 0);
            humanNode.SetScale(1f);
            var model = humanNode.CreateComponent <StaticModel>();

            model.Model = ResourceCache.GetModel("Jack.mdl");

            material = Material.FromColor(new Color(72 / 255f, 99 / 255f, 142 / 255f));

            yaw   = -65;
            pitch = 55;
            cameraNode.Position = new Vector3(0.6f, 1.3f, -0.4f);
            cameraNode.Rotation = new Quaternion(pitch, yaw, 0);

            lightNode.SetDirection(new Vector3(-1, -1f, 0));
            InitTouchInput();
            var pointer = scene.CreateComponent <CubePointer>();

            pointer.PositionChanged += Pointer_PositionChanged;
        }
コード例 #10
0
ファイル: Game.cs プロジェクト: zzm0101/UnityLockstep
        protected override void Start()
        {
            Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
            base.Start();

            Input.Enabled = true;
            MonoDebugHud  = new MonoDebugHud(this);
            MonoDebugHud.Show();

            cache = ResourceCache;
            CreateConsoleAndDebugHud();
            Input.KeyDown += HandleKeyDown;
        }
コード例 #11
0
ファイル: MyGame.cs プロジェクト: teocot/RenderCube
        protected override void Start()
        {
            // Set style to the UI root so that elements will inherit it
            UI.Root.SetDefaultStyle(ResourceCache.GetXmlFile("UI/DefaultStyle.xml"));
            MaterialXml = new Dictionary <string, XmlFile>
            {
                { "Default", ResourceCache.GetXmlFile("Materials/DefaultMaterial.xml") },
                // {"BoxMaterial",  new MaterialHelper(ResourceCache.GetXmlFile("Materials/BoxMaterial.xml")) },
                // {"TeapotMaterial",  new MaterialHelper(ResourceCache.GetXmlFile("Materials/TeapotMaterial.xml")) }
            };

            Models = new Dictionary <string, Model>
            {
                { "Sphere", ResourceCache.GetModel("Models/Sphere.mdl") },
                { "Cube", ResourceCache.GetModel("Models/Box.mdl") },
                { "Suzanne", ResourceCache.GetModel("Models/Suzanne.mdl") },
                { "Teapot", ResourceCache.GetModel("Models/Teapot.mdl") },
            };

            UserNodes = new Dictionary <string, Node> {
            };

            Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
            TouchEnabled    = true;
            if (Platform == Platforms.Android ||
                Platform == Platforms.iOS ||
                Options.TouchEmulation)
            {
                InitTouchInput();
            }
            if (Platform == Platforms.Windows)
            {
                Input.SetMouseVisible(true, false);
                SimpleCreateInstructions("Control The Camera with WASD");
            }
            Input.Enabled = true;
            MonoDebugHud  = new MonoDebugHud(this);
            MonoDebugHud.Show();

            SetWindowAndTitleIcon();
            CreateConsoleAndDebugHud();
            Input.KeyDown += HandleKeyDown;
            CreateScene();
            //debugHud.ToggleAll();


            base.Start();
        }
コード例 #12
0
        protected override async void Start()
        {
            base.Start();

#if DEBUG
            var MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();
#endif

            UI.Root.SetDefaultStyle(ResourceCache.GetXmlFile("UI/DefaultStyle.xml"));

            await CurrentPageContainer.SetLoadingPageAsync(new LoadingScenePage(ResourceCache));

            _menuPage = new MenuScenePage(Navigation);
            _gamePage = new GameScenePage(Navigation, _menuPage);
            await Navigation.PushAsync(_gamePage);
        }
コード例 #13
0
        protected override void Start()
        {
            base.Start();

            this.Log.LogLevel = LogLevel.Warning;
            var planeNode = RootNode.CreateChild();

            planeNode.Scale = new Vector3(20, 1, 20);
            var plane = planeNode.CreateComponent <Urho.Shapes.Plane>();

            plane.Material = ResourceCache.GetMaterial("Materials/Stone.xml");

            pointerNode = Scene.CreateChild();
            pointerNode.SetScale(0.1f);
            var pointer = pointerNode.CreateComponent <Sphere>();

            pointer.Color    = Color.Cyan;
            pointerNode.Name = "RulerPoint";

            textNode = pointerNode.CreateChild();
            textNode.SetScale(3);
            textNode.Translate(Vector3.UnitY * 2);
            textNode.AddRef();
            var text = textNode.CreateComponent <Text3D>();

            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment   = VerticalAlignment.Top;
            text.TextEffect          = TextEffect.Stroke;
            text.EffectColor         = Color.Black;
            text.SetColor(Color.White);
            text.SetFont(CoreAssets.Fonts.AnonymousPro, 50);

            Input.KeyUp += Input_KeyUp;

            var hud = new MonoDebugHud(this);

            hud.Show(Color.Red, 24);

            /*RenderPathCommand rpc = new RenderPathCommand(RenderCommandType.Quad);
             * rpc.SetTextureName(TextureUnit.Diffuse, "Textures/UrhoDecal.dds");
             * rpc.Type = RenderCommandType.Quad;
             * rpc.VertexShaderName = (UrhoString)"CopyFramebuffer";
             * rpc.PixelShaderName = (UrhoString)"CopyFramebuffer";
             * rpc.SetOutput(0, "viewport");
             * Viewport.RenderPath.InsertCommand(1, rpc);*/
        }
コード例 #14
0
        protected override void Start()
        {
            var scene  = new Scene(Context);
            var octree = scene.CreateComponent <Octree>();

            var cameraNode = scene.CreateChild(name: "Camera");
            var camera     = cameraNode.CreateComponent <Urho.Camera>();

            zone = scene.CreateComponent <Zone>();
            zone.AmbientColor = new Color(1, 1, 1) * 0.2f;

            var lightNode = cameraNode.CreateChild();

            lightNode.SetDirection(new Vector3(1f, -1.0f, 1f));
            var light = lightNode.CreateComponent <Light>();

            light.Range             = 10;
            light.LightType         = LightType.Directional;
            light.CastShadows       = true;
            Renderer.ShadowMapSize *= 4;

            // Viewport
            viewport = new Viewport(Context, scene, camera, null);
            Renderer.SetViewport(0, viewport);

            // ARCore component
            ArCore = scene.CreateComponent <ARCoreComponent>();
            ArCore.ARFrameUpdated  += OnARFrameUpdated;
            ArCore.ConfigRequested += ArCore_ConfigRequested;
            ArCore.Run();

            var mutantNode = scene.CreateChild();

            mutantNode.Position = new Vector3(0, -0.5f, 0.5f); // 50cm Y, 50cm Z
            mutantNode.SetScale(0.3f);
            var model = mutantNode.CreateComponent <StaticModel>();

            model.CastShadows = true;
            model.Model       = ResourceCache.GetModel("Models/Box.mdl");
            model.Material    = ResourceCache.GetMaterial("Materials/DefaultGrey.xml");


            fps         = new MonoDebugHud(this);
            fps.FpsOnly = true;
            fps.Show(Color.Blue, 25);
        }
コード例 #15
0
ファイル: ArkitApp.cs プロジェクト: iosdv/ARKitXamarinDemo
        void CreateArScene()
        {
            // 3D scene with Octree and Zone
            Scene             = new Scene(Context);
            Octree            = Scene.CreateComponent <Octree>();
            Zone              = Scene.CreateComponent <Zone>();
            Zone.AmbientColor = Color.White * 0.2f;

            // Light
            LightNode = Scene.CreateChild(name: "DirectionalLight");
            LightNode.SetDirection(new Vector3(0.8f, -1.0f, 0f));
            Light                   = LightNode.CreateComponent <Light>();
            Light.LightType         = LightType.Directional;
            Light.CastShadows       = true;
            Light.Brightness        = 1.5f;
            Light.ShadowResolution  = 4;
            Light.ShadowIntensity   = 0.8f;
            Renderer.ShadowMapSize *= 2;

            // Camera
            CameraNode = Scene.CreateChild(name: "Camera");
            Camera     = CameraNode.CreateComponent <Camera>();

            // Viewport
            Viewport = new Viewport(Context, Scene, Camera, null);
            Viewport.SetClearColor(Color.Transparent);
            Renderer.SetViewport(0, Viewport);

            DebugHud         = new MonoDebugHud(this);
            DebugHud.FpsOnly = true;
            DebugHud.Show(Color.Black, 45);

            AnchorsNode             = Scene.CreateChild();
            FeaturePointsCloudeNode = Scene.CreateChild();

            loadingLabel = new Text
            {
                Value = "Detecting planes...",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };
            loadingLabel.SetColor(new Color(0f, 1f, 0f));
            loadingLabel.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 42);
            UI.Root.AddChild(loadingLabel);
        }
コード例 #16
0
ファイル: Sample.cs プロジェクト: zeadion/urho-samples
        protected override void Start()
        {
            base.Start();
            if (Platform == Platforms.Android ||
                Platform == Platforms.iOS ||
                Options.TouchEmulation)
            {
                InitTouchInput();
            }

            MonoDebugHud = new MonoDebugHud(this);
            MonoDebugHud.Show();

            CreateLogo();
            SetWindowAndTitleIcon();
            CreateConsoleAndDebugHud();
            Input.SubscribeToKeyDown(HandleKeyDown);
        }
コード例 #17
0
ファイル: Sample.cs プロジェクト: cianmulville/urho-samples
		protected override void Start ()
		{
			base.Start();
			if (Platform == Platforms.Android || 
				Platform == Platforms.iOS || 
				Options.TouchEmulation)
			{
				InitTouchInput();
			}

			MonoDebugHud = new MonoDebugHud(this);
			MonoDebugHud.Show();

			CreateLogo ();
			SetWindowAndTitleIcon ();
			CreateConsoleAndDebugHud ();
			Input.SubscribeToKeyDown (HandleKeyDown);
		}
コード例 #18
0
ファイル: Sample.cs プロジェクト: gleblebedev/UrhoSharpEditor
    protected override void Start()
    {
        base.Start();

        if (Platform == Platforms.Android ||
            Platform == Platforms.iOS ||
            Options.TouchEmulation)
        {
            InitTouchInput();
        }
        Input.Enabled = true;

        MonoDebugHud = new MonoDebugHud(this);
        MonoDebugHud.Show();

        CreateScene();
        SetupViewport();
    }
コード例 #19
0
ファイル: ARCoreSample.cs プロジェクト: woychukb/urho
        protected override async void Start()
        {
            base.Start();

            arCore = Scene.CreateComponent <ARCoreComponent>();

            var boxNode = Scene.CreateChild();

            boxNode.Position = new Vector3(0, 0, 0.5f);
            boxNode.CreateComponent <Pyramid>();
            boxNode.SetScale(0.1f);

            hud = new MonoDebugHud(this);
            hud.Show(Color.Green, 40);

            Input.TouchEnd += Input_TouchEnd;
            await arCore.Run(Camera);
        }
コード例 #20
0
ファイル: Sample.cs プロジェクト: dertom95/Urho.Net-Samples
        protected override void Start()
        {
            Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
            base.Start();
            if (Platform == Platforms.Android ||
                Platform == Platforms.iOS ||
                Options.TouchEmulation)
            {
                InitTouchInput();
            }
            Input.Enabled = true;
            MonoDebugHud  = new MonoDebugHud(this);
            MonoDebugHud.Show();

            CreateLogo();
            SetWindowAndTitleIcon();
            CreateConsoleAndDebugHud();
            Input.KeyDown += HandleKeyDown;
        }
コード例 #21
0
        protected override async void Start()
        {
            //Renderer.SetDefaultRenderPath(CoreAssets.RenderPaths.ForwardHWDepth);
            var scene = new Scene();

            scene.CreateComponent <Octree>();

            // Box
            var boxNode = scene.CreateChild();

            boxNode.Position = new Vector3(0, 0, 5);
            boxNode.Rotation = new Quaternion(60, 0, 30);
            boxNode.SetScale(1f);
            var modelObject = boxNode.CreateComponent <StaticModel>();

            modelObject.Model = ResourceCache.GetModel("Models/Box.mdl");

            boxNode.RunActions(new RepeatForever(new RotateBy(1, 0, 90, 0)));
            //await Task.Delay(1000);
            //await ToMainThreadAsync();

            // Light
            var lightNode = scene.CreateChild(name: "light");

            lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
            lightNode.CreateComponent <Light>();

            // Camera
            var cameraNode = scene.CreateChild(name: "camera");
            var camera     = cameraNode.CreateComponent <Camera>();

            // Viewport
            Renderer.SetViewport(0, new Viewport(scene, camera, null));

            // DebugHud
            debugHud = new MonoDebugHud(this);
            debugHud.Show();

            Input.TouchMove       += Input_TouchMove;
            Input.TouchBegin      += InputOnTouchBegin;
            Input.MouseMoved      += Input_MouseMove;
            Input.MouseButtonDown += InputOnMouseButtonDown;
        }
コード例 #22
0
        protected override async void Start()
        {
            Renderer.SetDefaultRenderPath(CoreAssets.RenderPaths.ForwardHWDepth);
            var scene = new Scene();

            scene.CreateComponent <Octree>();

            // Box
            var boxNode = scene.CreateChild();

            boxNode.Position = new Vector3(0, 0, 5);
            boxNode.Rotation = new Quaternion(60, 0, 30);
            boxNode.SetScale(1f);
            var modelObject = boxNode.CreateComponent <StaticModel>();

            modelObject.Model = ResourceCache.GetModel("Models/Box.mdl");
            modelObject.SetMaterial(ResourceCache.GetMaterial("Materials/StoneSmall.xml"));

            await Task.Delay(1000);

            await ToMainThreadAsync();

            // Light
            var lightNode = scene.CreateChild(name: "light");

            lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
            lightNode.CreateComponent <Light>();

            // Camera
            var cameraNode = scene.CreateChild(name: "camera");
            var camera     = cameraNode.CreateComponent <Camera>();

            // Viewport
            Renderer.SetViewport(0, new Viewport(scene, camera, null));

            // DebugHud
            var debugHud = new MonoDebugHud(this);

            debugHud.Show();
        }
コード例 #23
0
    protected override void Start()
    {
        base.Start();

        if (Platform == Platforms.Android ||
            Platform == Platforms.iOS ||
            Options.TouchEmulation)
        {
            InitTouchInput();
        }
        Input.Enabled = true;

        MonoDebugHud = new MonoDebugHud(this);
        MonoDebugHud.Show();

        CreateScene();
        SetupViewport();

        _input            = new TopDownInput(Input, new SimpleInputEnvironment(CameraNode.GetComponent <Camera>(), Graphics));
        _cameraController = new TopDownCameraController(_input, Graphics, CameraNode);
        _input.Enable();
    }
コード例 #24
0
        public void SetupUI()
        {
            AvatarStatusElement = new UIElement();
            UI.Root.AddChild(AvatarStatusElement);

            AvatarStatusElement.EnableAnchor = true;
            AvatarStatusElement.SetMaxAnchor(0.125f, 0.125f);
            AvatarStatusElement.SetMinAnchor(0, 0);

            var text = new Text();

            text.Value = "Walking";
            text.HorizontalAlignment = HorizontalAlignment.Left;
            text.VerticalAlignment   = VerticalAlignment.Top;
            text.SetFont(ResourceCache.GetFont("fonts/Open_Sans/OpenSans-Regular.ttf"), 14);
            text.Position = new IntVector2(10, 0);
            text.SetColor(Color.Gray);
            text.SetMaxAnchor(1, 1);
            text.SetMinAnchor(0, 0);
            AvatarStatusElement.AddChild(text);

            PlayerNode.GetComponent <PlayerAvatarController>().FlightStatusChanged += new EventHandler((o, e) => text.Value = (o as PlayerAvatarController).Flying ? "Flying" : "Walking");

            PostionGUI       = new Text();
            PostionGUI.Value = "X0 Y0 Z0";
            PostionGUI.HorizontalAlignment = HorizontalAlignment.Left;
            PostionGUI.VerticalAlignment   = VerticalAlignment.Top;
            PostionGUI.SetFont(ResourceCache.GetFont("fonts/Open_Sans/OpenSans-Regular.ttf"), 14);
            PostionGUI.Position = new IntVector2(10, 20);
            PostionGUI.SetColor(Color.Gray);
            PostionGUI.SetMaxAnchor(1, 1);
            PostionGUI.SetMinAnchor(0, 0);
            AvatarStatusElement.AddChild(PostionGUI);

            var debug = new MonoDebugHud(this);

            debug.Show(Color.Gray);
        }
コード例 #25
0
        void CreateArScene()
        {
            // 3D scene with Octree and Zone
            Scene             = new Scene(Context);
            Octree            = Scene.CreateComponent <Octree>();
            Zone              = Scene.CreateComponent <Zone>();
            Zone.AmbientColor = Color.White * 0.4f;
            Scene.CreateComponent <PhysicsWorld>();

            // Camera
            CameraNode = Scene.CreateChild(name: "Camera");
            Camera     = CameraNode.CreateComponent <Camera>();

            // Light
            LightNode = Scene.CreateChild(name: "DirectionalLight");
            LightNode.SetDirection(new Vector3(0.75f, -1.0f, 1f));
            Light                   = LightNode.CreateComponent <Light>();
            Light.LightType         = LightType.Directional;
            Light.CastShadows       = true;
            Light.Brightness        = 1.4f;
            Light.ShadowResolution  = 4;
            Light.ShadowIntensity   = 0.5f;
            Renderer.ShadowMapSize *= 4;

            // Viewport
            Viewport = new Viewport(Context, Scene, Camera, null);
            Viewport.SetClearColor(Color.Transparent);
            Renderer.SetViewport(0, Viewport);

            DebugHud         = new MonoDebugHud(this);
            DebugHud.FpsOnly = true;
            //DebugHud.Show(Color.Black, 40);

            AnchorsNode             = Scene.CreateChild();
            FeaturePointsCloudeNode = Scene.CreateChild();
        }
コード例 #26
0
        /// <summary>
        /// Initialize the urho foreground scene
        /// </summary>
        void CreateScene()
        {
            fgScene = new Scene();
            fgScene.CreateComponent <Octree>();

            fgZone = fgScene.CreateComponent <Zone>();
            fgZone.AmbientColor = Color.White * 0.25f;

            var cameraNode = fgScene.CreateChild();

            cameraNode.Position = new Vector3(0, 0, 0);
            cameraNode.LookAt(new Vector3(0, 0, 1), new Vector3(0, 1, 0));
            fgCamera = cameraNode.CreateComponent <Camera>();

            var lightNode = fgScene.CreateChild();

            lightNode.Position = new Vector3(0, 0, -10);

            var light = lightNode.CreateComponent <Light>();

            light.LightType         = LightType.Directional;
            light.SpecularIntensity = 0.5f;

            // Note that we delete the clear from the render path so we can see through to the first viewport that is rendering the background
            fgViewport            = new Viewport(Context, fgScene, fgCamera, null);
            fgViewport.RenderPath = fgViewport.RenderPath.Clone();
            fgViewport.SetClearColor(Color.Transparent);
            fgViewport.RenderPath.RemoveCommand(0);

            // The foreground is at index 1, the background is added by the EasyAR component as index 0
            Renderer.SetViewport(1, fgViewport);

            debugHud         = new MonoDebugHud(this);
            debugHud.FpsOnly = true;
            debugHud.Show(Color.Black, 40);
        }
コード例 #27
0
        protected unsafe override void Start()
        {
            // Create scene
            var scene = new Scene();

            scene.CreateComponent <Octree>();

            // Create a node for the Earth
            var earthNode = scene.CreateChild();

            earthNode.Position = new Vector3(0, 0, 1.5f);
            earthNode.SetScale(0.3f);

            // Add light
            var lightNode = scene.CreateChild(name: "light");

            lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
            lightNode.CreateComponent <Light>();

            var earth         = earthNode.CreateComponent <Sphere>();
            var earthMaterial = ResourceCache.GetMaterial("Materials/Earth.xml");

            earth.SetMaterial(earthMaterial);

            var moonNode = earthNode.CreateChild();

            moonNode.SetScale(0.27f);
            moonNode.Position = new Vector3(1.2f, 0, 0);

            var moon = moonNode.CreateComponent <Sphere>();

            moon.SetMaterial(ResourceCache.GetMaterial("Materials/Moon.xml"));

            // Camera
            this.CameraNode     = scene.CreateChild(name: "camera");
            _camera             = this.CameraNode.CreateComponent <Camera>();
            _camera.Fov         = 27.15f;
            _camera.NearClip    = 0.1f;
            _camera.FarClip     = 1000.0f;
            _camera.AspectRatio = (float)VIDEO_WIDTH_LOW / VIDEO_HEIGHT_LOW;

            // Viewport
            var viewport       = new Viewport(scene, _camera, null);
            var renderPathFile = ResourceCache.GetXmlFile("RenderPaths/CustomRenderPath.xml");

            viewport.SetRenderPath(renderPathFile);
            Renderer.SetViewport(0, viewport);

            // Video feed background
            _videoPlayer = new VideoPlayer();
            var videoTexture = _videoPlayer.GetTexture();

            videoTexture.Name = "video_feed";

            // Add render texture to res cache so it's available to render path
            ResourceCache.AddManualResource(videoTexture);

            // DebugHud
            debugHud = new MonoDebugHud(this);
            debugHud.Show();
        }
コード例 #28
0
        protected override async void Start()
        {
            base.Start();

            hud = new MonoDebugHud(this);
            hud.Show(Color.Yellow, 24);

            var timeLabel = new Text {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top
            };

            timeLabel.SetColor(new Color(0f, 1f, 0f));
            timeLabel.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 30);
            UI.Root.AddChild(timeLabel);

            var azAltLabel = new Text {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            azAltLabel.SetColor(new Color(0f, 1f, 0f));
            azAltLabel.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 30);
            UI.Root.AddChild(azAltLabel);

            ResourceCache.AutoReloadResources = true;
            Viewport.SetClearColor(Color.Black);

            earthNode = RootNode.CreateChild();
            earthNode.SetScale(5f);
            earthNode.Rotation = new Quaternion(0, -180, 0);
            var earthModel = earthNode.CreateComponent <Sphere>();

            earthModel.Material = Material.FromImage("Textures/Earth.jpg");

            Zone.AmbientColor = new Color(0.2f, 0.2f, 0.2f);
            LightNode.ChangeParent(Scene);
            LightNode.Position = Vector3.Zero;
            Light.Range        = 10;
            Light.Brightness   = 1f;
            Light.LightType    = LightType.Directional;

            AddMarker(0, 0, "(0, 0)");
            AddMarker(53.9045f, 27.5615f, "Minsk");
            AddMarker(51.5074f, 0.1278f, "London");
            AddMarker(40.7128f, -74.0059f, "New-York");
            AddMarker(37.7749f, -122.4194f, "San Francisco");
            AddMarker(39.9042f, 116.4074f, "Beijing");
            AddMarker(-31.9505f, 115.8605f, "Perth");

            var sunNode      = RootNode.CreateChild();
            var sunModelNode = sunNode.CreateChild();

            sunModelNode.Position = new Vector3(0, 4, 0);
            sunModelNode.SetScale(1);

            var sun = sunModelNode.CreateComponent <Sphere>();

            sun.Color = new Color(15, 10, 5);

            // update the Sun's position based on time
            var   time = DateTime.Now;
            float alt, az;

            SunPosition.CalculateSunPosition(time, 0f, 0f, out az, out alt);
            sunNode.Rotation = new Quaternion(-az, 0, alt);
            LightNode.SetDirection(RootNode.WorldPosition - sunModelNode.WorldPosition);

            timeLabel.Value  = time.ToShortTimeString();
            azAltLabel.Value = $"Azimuth: {az:F1},  Altitude: {alt:F1}";
        }
コード例 #29
0
ファイル: Sample.cs プロジェクト: xamarin/urho-samples
		protected override void Start ()
		{
			Log.LogMessage += e => Debug.WriteLine($"[{e.Level}] {e.Message}");
			base.Start();
			if (Platform == Platforms.Android || 
				Platform == Platforms.iOS || 
				Options.TouchEmulation)
			{
				InitTouchInput();
			}
			Input.Enabled = true;
			MonoDebugHud = new MonoDebugHud(this);
			MonoDebugHud.Show();

			CreateLogo ();
			SetWindowAndTitleIcon ();
			CreateConsoleAndDebugHud ();
			Input.SubscribeToKeyDown (HandleKeyDown);
		}