Example #1
0
        protected override async void Start()
        {
            base.Start();

            //creating empty PHP context for utility use
            var ctx = Pchp.Core.Context.CreateEmpty();

            //The PHP app class containing all the application
            phpApp = new App(ctx, "Hey from C#");
            phpApp.Start();

            // Earth and Moon
            phpApp.createEarthTexture();
            phpApp.createMoon();

            //Clouds material...texture needs to be loaded from here
            var cloudsMaterial = new Material();

            cloudsMaterial.SetTexture(TextureUnit.Diffuse, ResourceCache.GetTexture2D("Textures/Earth_Clouds.jpg"));
            cloudsMaterial.SetTechnique(0, CoreAssets.Techniques.DiffAddAlpha);

            //Create assets rom PHP
            phpApp.createClouds(cloudsMaterial);
            phpApp.createLight();
            phpApp.createCameraAndView();

            //Create the references to objects created in PHP inside MyApp UrhoSharp Application
            CreatePHPReferences();

            // Text created in php proj updated here
            helloText.SetColor(new Color(0.5f, 1.0f, 1.0f, 1.0f));
            helloText.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 48);
            // Necessary to call from here because of UI belonging to extended Application class
            UI.Root.AddChild(helloText);

            //// Viewport
            var viewport = new Viewport(scene, cameraNode.GetComponent <Camera>(), null);

            Renderer.SetViewport(0, viewport);
            ////viewport.RenderPath.Append(CoreAssets.PostProcess.FXAA2);

            // Setting Application properties
            Input.Enabled = true;
            // FPS
            new MonoDebugHud(this).Show(Color.Green, 25);
            CreateSkybox();

            // Run a an action to spin the Earth (7 degrees per second)
            phpApp.runRotations(-7, 1);
            await rootNode.RunActionsAsync(new EaseOut(new MoveTo(2f, new Vector3(0, 0, 12)), 1));

            phpApp.AddCity(0, 0, "(0, 0)", earthNode.Scale.Y / 2, Vector3.Up);
            phpApp.AddCity(53.9045f, 27.5615f, "Minsk", earthNode.Scale.Y / 2f, Vector3.Up);
            phpApp.AddCity(51.5074f, 0.1278f, "London", earthNode.Scale.Y / 2f, Vector3.Up);
            phpApp.AddCity(40.7128f, -74.0059f, "New-York", earthNode.Scale.Y / 2f, Vector3.Up);
            phpApp.AddCity(37.7749f, -122.4194f, "San Francisco", earthNode.Scale.Y / 2f, Vector3.Up);
            phpApp.AddCity(39.9042f, 116.4074f, "Beijing", earthNode.Scale.Y / 2f, Vector3.Up);
            phpApp.AddCity(-31.9505f, 115.8605f, "Perth", earthNode.Scale.Y / 2f, Vector3.Up);
        }