Ejemplo n.º 1
0
    static void Main(string[] args)
    {
        Demos.TestMode = args.Length > 0 && args[0].ToLower() == "-test";

        StereoKitApp.settings.assetsFolder = Program.Root;
        if (!StereoKitApp.Initialize("StereoKit C#", Demos.TestMode ? Runtime.Flatscreen : Runtime.MixedReality, true))
        {
            Environment.Exit(1);
        }
        CommonInit();

        Demos.FindDemos();
        Demos.SetActive(args.Length > 0 ? args[0] : "Geo");
        Demos.Initialize();

        while (StereoKitApp.Step(() =>
        {
            Demos.Update();
            CommonUpdate();
        }))
        {
            ;
        }

        Demos.Shutdown();
        CommonShutdown();

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Initialize StereoKit
            StereoKitApp.settings.assetsFolder = "Assets";
            if (!StereoKitApp.Initialize("ContextualAssistanceV2", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            camera = new UdpFRCamera();
            _      = camera.Start();

            socket = new DisplayUdpSocket();
            socket.OnReceivedDisplayCommand += Program.OnReceivedDisplayCommand;

            _ = camera.Connect("172.22.192.1", "9999");
            _ = socket.Connect("172.22.192.1", "9998");

            // Core application loop
            while (StereoKitApp.Step(() =>
            {
            }))
            {
                ;
            }
            StereoKitApp.Shutdown();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Model cubeModel;
            Model sphereModel;

            if (!StereoKitApp.Initialize("MessingWithBounds", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            // Creating models
            cubeModel = Model.FromMesh(
                Mesh.GenerateCube(Vec3.One * 0.25f),
                Default.Material
                );
            sphereModel = Model.FromMesh(
                Mesh.GenerateSphere(0.15f),
                Default.Material
                );

            // Creating grabbable versions of the above models
            Grabbable grabbableCube   = new Grabbable(ref cubeModel, new Vec3(-0.25f, 0f, 0f));
            Grabbable grabbableSphere = new Grabbable(ref sphereModel, new Vec3(0.25f, 0f, 0f));

            while (StereoKitApp.Step(() =>
            {
                grabbableCube.Update();
                grabbableSphere.Update();
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 4
0
    static void Main(string[] args)
    {
        StereoKitApp.settings.shaderCache = Program.Root;
        if (!StereoKitApp.Initialize("StereoKit C#", Runtime.Flatscreen, true))
        {
            Environment.Exit(1);
        }
        CommonInit();

        activeScene = new DemoUI();
        activeScene.Initialize();

        while (StereoKitApp.Step(() =>
        {
            if (nextScene != null)
            {
                activeScene.Shutdown();
                nextScene.Initialize();
                activeScene = nextScene;
                nextScene = null;
            }
            CommonUpdate();
            activeScene.Update();
        }))
        {
            ;
        }

        activeScene.Shutdown();
        CommonShutdown();

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("ex01", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            Solid solid = new Solid(Vec3.Zero, Quat.Identity);

            Model cube = Model.FromMesh(
                Mesh.GenerateRoundedCube(Vec3.One, 0.2f),
                Default.Material);

            Plane floor = new Plane(Vec3.Up, 10);

            solid.AddBox(Vec3.One);

            while (StereoKitApp.Step(() =>
            {
                Log.Info(String.Format("normal: {0}", floor.normal));
                cube.SetTransform(0, solid.GetPose().ToMatrix());
                cube.Draw(Matrix.TS(Vec3.Zero, 0.1f));
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // Initialize StereoKit! Before initialization, we can prepare a few settings,
            // like the assetsFolder. This is the folder that StereoKit will look for assets
            // in when provided a relative folder name. Then we just Initialize StereoKit with
            // the name of our app! Initialize can also be told to make a flatscreen app, or
            // how to behave if the preferred initialization mode fails.
            StereoKitApp.settings.assetsFolder = "Assets";
            if (!StereoKitApp.Initialize("StereoKitPaintTutorial"))
            {
                Environment.Exit(1);
            }

            // This is a simple radial hand menu where we'll store some quick actions! It's
            // activated by a grip motion, and is great for fast, gesture-like activation
            // of menu items. It also can be used with multiple HandRadialLayers to nest
            // commands in sub-menus.
            //
            // Steppers are classes that implement the IStepper interface, and once added to
            // StereoKit's stepper list, will have their Step method called each frame! This
            // is a great way to add fire-and-forget objects or systems that need to update
            // each frame.
            StereoKitApp.AddStepper(new HandMenuRadial(
                                        new HandRadialLayer("Root", -90,
                                                            new HandMenuItem("Undo", null, () => activePainting?.Undo()),
                                                            new HandMenuItem("Redo", null, () => activePainting?.Redo()))));

            // Initialize the palette menu, see PaletteMenu.cs! This class manages the palette
            // UI object for manipulating our brush stroke size and color.
            paletteMenu = new PaletteMenu();

            // Step the application each frame, until StereoKit is told to exit! The callback
            // code here is called every frame after input and system events, but before the
            // draw events!
            while (StereoKitApp.Step(() =>
            {
                // Send input information to the painting, it will handle this info to create
                // brush strokes. This will also draw the painting too!
                activePainting.Step(Handed.Right, paletteMenu.PaintColor, paletteMenu.PaintSize);

                // Step our palette UI!
                paletteMenu.Step();

                // Step our application's menu! This includes Save/Load Clear and Quit commands.
                StepMenuWindow();
            }))
            {
                ;
            }

            // We're done! Clean up StereoKit and all its resources :)
            StereoKitApp.Shutdown();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("Day00_ex01", Runtime.Flatscreen))
            {
                Environment.Exit(1);
            }

            //Cube cube = new Cube(0);
            //Cube cube1 = new Cube(0.2f);
            //Cube cube2 = new Cube(-0.2f);

            CubeList cubeList       = new CubeList();
            Vec3     collision_size = new Vec3(5, 2, 1);
            Vec3     collision_pos  = new Vec3(0, -0.5f, 0);

            // Setting transparency, for some reason
            // the cube goes transparent in the area of
            // the colliding hand

            Material trans = Default.Material;

            trans.Transparency = Transparency.None;

            //creating the collision box

            Model collision_box = Model.FromMesh(
                Mesh.GenerateRoundedCube(collision_size, 0),
                trans);

            while (StereoKitApp.Step(() =>
            {
                //cube.Step();
                //cube1.Step();
                //cube2.Step();
                cubeList.Step();
                collision_box.Draw(Matrix.TS(collision_pos, 0.1f));

                cubeList.DeleteCube();
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("StereoKitProject_ballon", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }
            ObjectSet ObjectBlowing = new ObjectSet();

            while (StereoKitApp.Step(() =>
            {
                ObjectBlowing.Update();
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("StereoKit C#", Runtime.MixedReality, true))
            {
                Environment.Exit(1);
            }

            Model cube = new Model(Mesh.GenerateRoundedCube(Vec3.One, 0.1f), Material.Find("default/material"));

            while (StereoKitApp.Step(() =>
            {
                Renderer.Add(cube, Matrix.Identity, Color.White);
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("MessingWithSolids", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            ObjectSpawner ObjectSpawner = new ObjectSpawner();

            while (StereoKitApp.Step(() =>
            {
                ObjectSpawner.Update();
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 11
0
    static void Main(string[] args)
    {
        StereoKitApp.settings.shaderCache = Program.Root;
        if (!StereoKitApp.Initialize("StereoKit C#", Runtime.MixedReality, true))
        {
            Environment.Exit(1);
        }
        CommonInit();

        while (StereoKitApp.Step(() =>
        {
            CommonUpdate();
        }))
        {
            ;
        }

        CommonShutdown();

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("Project", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            Model cube = Model.FromMesh(
                Mesh.GenerateRoundedCube(Vec3.One, 0.2f),
                Material.Find(DefaultIds.material));

            while (StereoKitApp.Step(() =>
            {
                cube.Draw(Matrix.TS(Vec3.Zero, 0.1f));
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 13
0
    /// :End:

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

    static void Main(string[] args)
    {
        Tests.IsTesting = args.Length > 0 && args[0].ToLower() == "-test";
        Time.Scale      = Tests.IsTesting ? 0 : 1;

        /// :CodeSample: Log.Subscribe Log
        /// Then you add the OnLog method into the log events like this in your initialization
        /// code!
        Log.Subscribe(OnLog);
        /// :End:
        Log.Filter = LogLevel.Diagnostic;
        Log.Write(LogLevel.Diagnostic, "Temp path: " + System.IO.Path.GetTempPath());
        StereoKitApp.settings.assetsFolder = Program.Root;
        if (!StereoKitApp.Initialize("StereoKit C#", Tests.IsTesting ? Runtime.Flatscreen : Runtime.MixedReality, true))
        {
            Environment.Exit(1);
        }

        CommonInit();

        Tests.FindTests();
        Tests.SetTestActive(args.Length > 0 ? args[0] : "Lines");
        Tests.Initialize();

        while (StereoKitApp.Step(() =>
        {
            Tests.Update();
            CommonUpdate();
        }))
        {
            ;
        }

        Tests.Shutdown();
        CommonShutdown();

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            // Initialize StereoKit
            StereoKitApp.settings.assetsFolder = "Assets";
            if (!StereoKitApp.Initialize("SKTemplate_UWP_Name", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }


            // Create assets used by the app
            Pose  cubePose = new Pose(0, 0, -0.5f, Quat.Identity);
            Model cube     = Model.FromMesh(
                Mesh.GenerateRoundedCube(Vec3.One * 0.1f, 0.02f),
                Default.MaterialUI);

            Matrix   floorTransform = Matrix.TS(new Vec3(0, -1.5f, 0), new Vec3(30, 0.1f, 30));
            Material floorMaterial  = new Material(Shader.FromFile("floor.hlsl"));

            floorMaterial.Transparency = Transparency.Blend;


            // Core application loop
            while (StereoKitApp.Step(() =>
            {
                if (StereoKitApp.System.displayType == Display.Opaque)
                {
                    Default.MeshCube.Draw(floorMaterial, floorTransform);
                }

                UI.Handle("Cube", ref cubePose, cube.Bounds);
                cube.Draw(cubePose.ToMatrix());
            }))
            {
                ;
            }
            StereoKitApp.Shutdown();
        }
Ejemplo n.º 15
0
    /// :End:

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

    static void Main(string[] args)
    {
        Demos.TestMode = args.Length > 0 && args[0].ToLower() == "-test";
        Time.Scale     = Demos.TestMode ? 0 : 1;

        Log.Filter = LogLevel.Diagnostic;
        StereoKitApp.settings.assetsFolder = Program.Root;
        if (!StereoKitApp.Initialize("StereoKit C#", Demos.TestMode ? Runtime.Flatscreen : Runtime.MixedReality, true))
        {
            Environment.Exit(1);
        }

        if (Demos.TestMode)
        {
            Input.HandVisible(Handed.Max, false);
        }

        CommonInit();

        Demos.FindDemos();
        Demos.SetActive(args.Length > 0 ? args[0] : "Lines");
        Demos.Initialize();

        while (StereoKitApp.Step(() =>
        {
            Demos.Update();
            CommonUpdate();
        }))
        {
            ;
        }

        Demos.Shutdown();
        CommonShutdown();

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 16
0
    ///////////////////////////////////////////

    static void Main(string[] args)
    {
        StereoKitApp.settings.assetsFolder = "Assets";
        if (!StereoKitApp.Initialize("StereoKit_BingMaps", Runtime.MixedReality))
        {
            Environment.Exit(1);
        }

        Model cube = Model.FromMesh(
            Mesh.GenerateRoundedCube(Vec3.One, 0.2f),
            Default.Material);

        cylinderMesh = Mesh.GenerateCylinder(1, 1, Vec3.Up, 64);
        compassModel = Model.FromFile("Compass.glb");

        terrain            = new Terrain(128, 1, 3);
        terrain.ClipRadius = 0.3f;

        LoadLocation(0);

        while (StereoKitApp.Step(() =>
        {
            UI.AffordanceBegin("Terrain", ref terrainPose, new Bounds(new Vec3(terrain.ClipRadius * 2, 0.1f, terrain.ClipRadius * 2)));
            terrainPose.orientation = Quat.Identity;
            UI.AffordanceEnd();

            Hand hand = Input.Hand(Handed.Right);
            if (hand.IsJustPinched)
            {
                justStart = terrain.Translation;
                justFinger = hand[FingerId.Index, JointId.Tip].position;
            }
            if (hand.IsPinched)
            {
                Vec3 newPos = justStart + (hand[FingerId.Index, JointId.Tip].position - justFinger);
                newPos.y = 0;
                terrain.Translation = newPos;
                terrain.ClipCenter = -newPos;
            }
            terrain.Update();
            cylinderMesh.Draw(Default.Material, Matrix.TS(Vec3.Up * -0.04f, new Vec3(terrain.ClipRadius * 2, 0.05f, terrain.ClipRadius * 2)), Color.White * 0.25f);

            Vec3 pos = Vec3.Zero;
            Vec3 dir = (Input.Head.position - pos);
            dir.y = 0;
            dir.Normalize();

            float angle = MathF.Atan2(dir.z, dir.x) * Units.rad2deg;
            if (angle < 0)
            {
                angle = 360 + angle;
            }

            angle = (int)(angle / 60) * 60 + 30;
            dir = Vec3.AngleXZ(angle);
            Vec3 lookat = dir + Vec3.Up;
            Vec3 menuAt = pos + dir * (terrain.ClipRadius + 0.04f);
            compassModel.Draw(Matrix.TS(pos + dir * (terrain.ClipRadius + 0.01f) + Vec3.Up * 0.02f, 0.4f));
            Pose uiPose = new Pose(menuAt, Quat.LookDir(lookat));

            UI.WindowBegin("TerrainOptions", ref uiPose, new Vec2(30, 0) * Units.cm2m, false);

            // Show location buttons
            Vec2 btnSize = new Vec2(6, 3) * Units.cm2m;
            if (UI.Radio("Kauai", locationId == 0, btnSize))
            {
                LoadLocation(0);
            }

            UI.SameLine();
            if (UI.Radio("Grand Canyon", locationId == 1, btnSize))
            {
                LoadLocation(1);
            }

            UI.SameLine();
            if (UI.Radio("Mt. Everest", locationId == 2, btnSize))
            {
                LoadLocation(2);
            }

            UI.SameLine();
            if (UI.Radio("Machu Picchu", locationId == 3, btnSize))
            {
                LoadLocation(3);
            }

            // Scale slider to zoom in and out
            if (UI.HSlider("Scale", ref uiWorldScale, 0.00002f, 0.00004f, 0, 27 * Units.cm2m))
            {
                SetScale(uiWorldScale);
            }

            UI.WindowEnd();
        }))
        {
            ;
        }

        StereoKitApp.Shutdown();
    }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("StereoKit_day00", Runtime.Flatscreen))
            {
                Environment.Exit(1);
            }


            Balloon balloon    = new Balloon(1f);
            String  txt_format = String.Format("Game Over!\nBallon life was: " + (int)Time.Total + " secs\n Tap again to exit");
            bool    gameOver   = false;

            //Time.SetTime
            //Time.SetTime(0);
            while (StereoKitApp.Step(() =>
            {
                Hand right_hand = Input.Hand(Handed.Right);
                if (right_hand.IsPinched && !balloon.GetGameStarted())
                {
                    Console.WriteLine("GAME STARTED");
                    Time.SetTime(0.0f);
                }
                Console.WriteLine(Time.Total);
                if (balloon.balloonAir > 5f)
                {
                    if (!gameOver)
                    {
                        txt_format = String.Format("Game Over!\nBallon life was: " + (int)Time.Total + " secs\n Tap again to exit");
                    }
                    Text.Add(
                        txt_format,
                        Matrix.TRS(Vec3.Zero,
                                   Quat.LookDir(0, 0, 1)));
                    gameOver = true;
                    if (right_hand.IsJustPinched)
                    {
                        StereoKitApp.Quit();
                    }
                }
                else if (balloon.balloonAir < 0.5f)
                {
                    //Matrix
                    //Quat
                    Text.Add(
                        "YOU LOST!\n",
                        Matrix.TRS(Vec3.Zero,
                                   Quat.LookDir(0, 0, 1)));
                    if (right_hand.IsJustPinched)
                    {
                        StereoKitApp.Quit();
                    }
                    gameOver = true;
                }
                if (!gameOver)
                {
                    balloon.DrawBalloon();
                    balloon.Steps(right_hand);
                }
            }))
            {
                ;
            }

            StereoKitApp.Shutdown();
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            if (!StereoKitApp.Initialize("ex00", Runtime.MixedReality))
            {
                Environment.Exit(1);
            }

            Model balloon = Model.FromMesh(
                Mesh.GenerateSphere(1, 1),
                Default.Material);

            balloon.AddSubset(Mesh.GenerateCylinder(0.05f, 2, new Vec3(0, 1, 0)), Default.Material, Matrix.T(0, -1, 0));

            /*Model clone = Clone.Duplicate(ref balloon);*/

            /*   Grabbable grabBalloon = new Grabbable(ref clone);*/

            /*     grabBalloon.SetOnGrabStart(() => {
             *       grabBalloon._color = Color.Black;
             *   });
             *
             *   grabBalloon.SetOnGrabEnd(() => {
             *       grabBalloon._color = Color.White;
             *   });*/

            float score = 0;
            float scale = 0.25f;
            float air   = 1f;
            Hand  hand  = Input.Hand(Handed.Right);

            while (StereoKitApp.Step(() =>
            {
                if (scale > 0 && scale <= 0.5f)
                {
                    if (air > 0 && balloon.Bounds.Contains(hand.palm.position))
                    {
                        scale += 0.01f;
                        air -= 0.05f;
                    }
                    scale -= Time.Elapsedf / 10;
                    balloon.Draw(Matrix.TS(Vec3.Zero, scale));
                    /* clone.Draw(Matrix.TS(new Vec3(0.5f, 0, 0), scale));*/
                    if (air < 1)
                    {
                        air += 0.01f;
                    }
                }
                else
                {
                    if (score == 0)
                    {
                        score = Time.Totalf;
                    }
                    GameOver();
                }
                /* grabBalloon.Update();*/
            }))
            {
                ;
            }
            StereoKitApp.Shutdown();

            void GameOver()
            {
                Text.Add(String.Format("Game Over!\nScore: {0}", score), Matrix.T(new Vec3(0, 0, 0)));
            }
        }