Esempio n. 1
0
        private void DisplayButtonPanel()
        {
            Vec3 headPosition   = Input.Head.position;
            Vec3 windowPosition = new Vec3(0.4f, 0f, 0.1f);
            Pose windowPose     = new Pose(windowPosition, Quat.LookAt(windowPosition, headPosition));

            UI.WindowBegin("Button Panel", ref windowPose, new Vec2(25f, 25f) * Units.cm2m, false);
            if (UI.Button("Cube"))
            {
                whichObject = "cube";
            }
            if (UI.Button("Sphere"))
            {
                whichObject = "sphere";
            }
            if (UI.Button("Reset"))
            {
                spawnedModels.Clear();
                objects.Clear();
                spawnedModels.Add(Model.FromMesh(
                                      Mesh.GenerateCube(new Vec3(20f, 1f, 20f)),
                                      Default.Material
                                      ));
                objects.Add(floor);
            }
            if (UI.Button("Exit"))
            {
                StereoKitApp.Quit();
            }
            UI.WindowEnd();
        }
Esempio n. 2
0
    public static void Update()
    {
        if (nextScene != null)
        {
            activeScene.Shutdown();
            if (IsTesting)
            {
                Input.HandVisible(Handed.Max, false);
            }

            nextScene.Initialize();
            activeScene = nextScene;
            nextScene   = null;
        }
        activeScene.Update();

        if (IsTesting && FinishedWithTest())
        {
            testIndex += 1;
            if (testIndex >= allTests.Count)
            {
                StereoKitApp.Quit();
            }
            else
            {
                SetTestActive(allTests[testIndex].Name);
            }
        }
    }
Esempio n. 3
0
 /// :End:
 ///
 void ShowWindow()
 {
     /// :CodeDoc: Guides User Interface
     /// Then we'll move over to the application step where we'll do the rest of the UI code!
     ///
     /// We'll start with a window titled "Window" that's 20cm wide, and auto-resizes on the
     /// y-axis. The Units class is pretty helpful here, as it allows us to reason more visually
     /// about the units we're using! StereoKit uses meters as its base unit, which look a little
     /// awkward, especially in the millimeter range.
     ///
     /// We'll also use a toggle to turn the window's header on and off! The value from that toggle
     /// is passed in here via the showHeader field.
     ///
     UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * Units.cm2m, windowShowHeader);
     ///
     /// When you begin a window, all visual elements are now relative to that window! UI takes advantage
     /// of the Hierarchy class and pushes the window's pose onto the Hierarchy stack. Ending the window
     /// will pop the pose off the hierarchy stack, and return things to normal!
     ///
     /// Here's that toggle button! You'll also notice our use of 'ref' values in a lot of the UI
     /// code. UI functions typically follow the pattern of returning true/false to indicate they've
     /// been interacted with during the frame, so you can nicely wrap them in 'if' statements to
     /// react to change!
     ///
     /// Then with the 'ref' parameter, we let you pass in the current state of the UI element. The UI
     /// element will update that value for you based on user interaction, but you can also change it
     /// yourself whenever you want to!
     ///
     UI.Toggle("Show Header", ref windowShowHeader);
     ///
     /// Here's an example slider! We start off with a label element, and tell the UI to
     /// keep the next item on the same line. The slider clamps to the range [0,1], and
     /// will step at intervals of 0.2. If you want it to slide continuously, you can just set
     /// the `step` value to 0!
     ///
     UI.Label("Slide");
     UI.SameLine();
     UI.HSlider("slider", ref windowSlider, 0, 1, 0.2f, 72 * Units.mm2m);
     ///
     /// Here's how you use a simple button! Just check it with an 'if'. Any UI method
     /// will return true on the frame when their value or state has changed.
     ///
     if (UI.ButtonRound("Exit", windowPowerSprite))
     {
         StereoKitApp.Quit();
     }
     ///
     /// And for every begin, there must also be an end! StereoKit will log errors when this
     /// occurs, so keep your eyes peeled for that!
     ///
     UI.WindowEnd();
     /// :End:
 }
Esempio n. 4
0
        static void StepMenuWindow()
        {
            // Begin the application's menu window
            UI.WindowBegin("Menu", ref menuPose, new Vec2(20, 0) * Units.cm2m);

            // When the user presses the save button, lets show a save file dialog! When a file
            // name and folder have been selected, it'll make a call to SavePainting with the
            // file's path name with the .skp extension.
            if (UI.Button("Save"))
            {
                FilePicker.Show(
                    FilePickerMode.Save,
                    defaultFolder,
                    SavePainting,
                    new FileFilter("Painting", "*.skp"));
            }

            // And on that same line, we'll have a load button! This'll let the user pick out
            // any .skp files, and will call LoadPainting with the selected file.
            UI.SameLine();
            if (UI.Button("Load"))
            {
                FilePicker.Show(
                    FilePickerMode.Open,
                    defaultFolder,
                    LoadPainting,
                    new FileFilter("Painting", "*.skp"));
            }

            // Clear is easy! Just create a new Painting object!
            if (UI.Button("Clear"))
            {
                activePainting = new Painting();
            }

            // And if they want to quit? Just tell StereoKit! This will let StereoKit finish the
            // the frame properly, and then break out of the Step loop above.
            if (UI.Button("Quit"))
            {
                StereoKitApp.Quit();
            }

            // And end the window!
            UI.WindowEnd();
        }
        private void DisplayButtonPanel()
        {
            Vec3 headPosition   = Input.Head.position;
            Vec3 windowPosition = new Vec3(0.4f, 0f, 0.1f);
            Pose windowPose     = new Pose(windowPosition, Quat.LookAt(windowPosition, headPosition));

            UI.WindowBegin("Button Panel", ref windowPose, new Vec2(20f, 20f) * Units.cm2m, false);

            if (UI.Button("Start"))
            {
                start = true;
            }

            if (UI.Button("Exit"))
            {
                StereoKitApp.Quit();
            }
            UI.WindowEnd();
        }
Esempio n. 6
0
    static void CommonUpdate()
    {
        if (Input.Key(Key.Esc).IsJustActive())
        {
            StereoKitApp.Quit();
        }

        // If we can't see the world, we'll draw a floor!
        if (StereoKitApp.System.displayType == Display.Opaque)
        {
            Renderer.Add(floorMesh, floorTr, Color.White);
        }

        // Skip selection window if we're in test mode
        if (Tests.IsTesting)
        {
            return;
        }

        // Make a window for demo selection
        UI.WindowBegin("Demos", ref demoSelectPose, new Vec2(50 * U.cm, 0));
        for (int i = 0; i < Tests.DemoCount; i++)
        {
            string name = Tests.GetDemoName(i).Substring("Demo".Length);

            if (UI.Button(name))
            {
                Tests.SetDemoActive(i);
            }
            UI.SameLine();
        }
        UI.WindowEnd();

        RulerWindow();
        DebugToolWindow.Step();
        /// :CodeSample: Log.Subscribe Log
        /// And in your Update loop, you can draw the window.
        LogWindow();
        /// And that's it!
        /// :End:
    }
Esempio n. 7
0
    public static void Update()
    {
        if (nextScene != null)
        {
            activeScene.Shutdown();
            nextScene.Initialize();
            activeScene = nextScene;
            nextScene   = null;
        }
        activeScene.Update();

        if (TestMode)
        {
            testIndex += 1;
            if (testIndex >= Count)
            {
                StereoKitApp.Quit();
            }
            else
            {
                SetActive(testIndex);
            }
        }
    }
Esempio n. 8
0
    public void Update()
    {
        if (Demos.TestMode)
        {
            Renderer.Screenshot(new Vec3(-0.325f, -0.00f, .075f), new Vec3(-.4f, -0.05f, 0), 600, 400, "../../../docs/img/screenshots/GuideUserInterface.jpg");
            Renderer.Screenshot(new Vec3(0.225f, 0.0f, .175f), new Vec3(.4f, 0.0f, 0), 400, 600, "../../../docs/img/screenshots/GuideUserInterfaceCustom.jpg");
        }

        /// :CodeDoc: Guides User Interface
        /// Then we'll move over to the application step where we'll do the rest of the UI code!
        ///
        /// We'll start with a window titled "Window" that's 20cm wide, and auto-resizes on the
        /// y-axis. The Units class is pretty helpful here, as it allows us to reason more visually
        /// about the units we're using! StereoKit uses meters as its base unit, which look a little
        /// awkward, especially in the millimeter range.
        ///
        /// We'll also use a toggle to turn the window's header on and off! The value from that toggle
        /// is passed in here via the showHeader field.
        ///
        UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * Units.cm2m, showHeader);
        ///
        /// When you begin a window, all visual elements are now relative to that window! UI takes advantage
        /// of the Hierarchy class and pushes the window's pose onto the Hierarchy stack. Ending the window
        /// will pop the pose off the hierarchy stack, and return things to normal!
        ///
        /// Here's that toggle button! You'll also notice our use of 'ref' values in a lot of the UI
        /// code. UI functions typically follow the pattern of returning true/false to indicate they've
        /// been interacted with during the frame, so you can nicely wrap them in 'if' statements to
        /// react to change!
        ///
        /// Then with the 'ref' parameter, we let you pass in the current state of the UI element. The UI
        /// element will update that value for you based on user interaction, but you can also change it
        /// yourself whenever you want to!
        ///
        UI.Toggle("Show Header", ref showHeader);
        ///
        /// Here's an example slider! We start off with a label element, and tell the UI to
        /// keep the next item on the same line. The slider clamps to the range [0,1], and
        /// will step at intervals of 0.2. If you want it to slide continuously, you can just set
        /// the `step` value to 0!
        ///
        UI.Label("Slide");
        UI.SameLine();
        UI.HSlider("slider", ref slider, 0, 1, 0.2f, 72 * Units.mm2m);
        ///
        /// Here's how you use a simple button! Just check it with an 'if'. Any UI method
        /// will return true on the frame when their value or state has changed.
        ///
        if (UI.ButtonRound("Exit", powerSprite))
        {
            StereoKitApp.Quit();
        }
        ///
        /// And for every begin, there must also be an end! StereoKit will log errors when this
        /// occurs, so keep your eyes peeled for that!
        ///
        UI.WindowEnd();
        ///
        /// ## Custom Windows
        ///
        /// ![Simple UI]({{site.url}}/img/screenshots/GuideUserInterfaceCustom.jpg)
        ///
        /// Mixed Reality also provides us with the opportunity to turn objects into interfaces!
        /// Instead of using the old 'window' paradigm, we can create 3D models and apply UI
        /// elements to their surface! StereoKit uses 'affordances' to accomplish this, a grabbable
        /// area that behaves much like a window, but with a few more options for customizing
        /// layout and size.
        ///
        /// We'll load up a clipboard, so we can attach an interface to that!
        ///
        /// ```csharp
        /// Model clipboard = Model.FromFile("Clipboard.glb");
        /// ```
        ///
        /// And, similar to the window previously, here's how you would turn it into a grabbable
        /// interface! This behaves the same, except we're defining where the grabbable region is
        /// specifically, and then drawing our own model instead of a plain bar. You'll also notice
        /// we're drawing using an identity matrix. This takes advantage of how AffordanceBegin
        /// pushes the affordance's pose onto the Hierarchy transform stack!
        ///
        UI.AffordanceBegin("Clip", ref clipboardPose, clipboard.Bounds);
        Renderer.Add(clipboard, Matrix.Identity);
        ///
        /// Once we've done that, we also need to define the layout area of the model, where UI
        /// elements will go. This is different for each model, so you'll need to plan this around
        /// the size of your object!
        ///
        UI.LayoutArea(new Vec3(12, 13, 0) * Units.cm2m, new Vec2(24, 30) * Units.cm2m);
        ///
        /// Then after that? We can just add UI elements like normal!
        ///
        UI.Image(logoSprite, new Vec2(22, 0) * Units.cm2m);

        UI.Toggle("Toggle", ref clipToggle);
        UI.HSlider("Slide", ref clipSlider, 0, 1, 0, 22 * Units.cm2m);
        ///
        /// And while we're at it, here's a quick example of doing a radio button group! Not much
        /// 'radio' actually happening, but it's still pretty simple. Pair it with an enum, or an
        /// integer, and have fun!
        ///
        if (UI.Radio("Radio 1", clipOption == 1))
        {
            clipOption = 1;
        }
        UI.SameLine();
        if (UI.Radio("Radio 2", clipOption == 2))
        {
            clipOption = 2;
        }
        UI.SameLine();
        if (UI.Radio("Radio 3", clipOption == 3))
        {
            clipOption = 3;
        }
        ///
        /// As with windows, Affordances need an End call.
        ///
        UI.AffordanceEnd();
        ///
        /// And there you go! That's how UI works in StereoKit, pretty simple, huh?
        /// For further reference, and more UI methods, check out the
        /// [UI class documentation]({{site.url}}/Pages/Reference/UI.html).
        ///
        /// If you'd like to see the complete code for this sample,
        /// [check it out on Github](https://github.com/maluoi/StereoKit/blob/master/Examples/StereoKitTest/DemoUI.cs)!
        /// :End:
    }
Esempio n. 9
0
    public void Update()
    {
        if (Demos.TestMode)
        {
            Renderer.Screenshot(new Vec3(-0.325f, -0.025f, .075f), new Vec3(-.4f, -0.075f, 0), 600, 400, "../../../docs/img/screenshots/GuideUserInterface.jpg");
        }

        /// :CodeDoc: Guides User Interface
        /// Then we'll move over to the application step where we'll do the rest of the UI code!
        ///
        /// We'll start with a window titled "Window" that's 20cm wide, and auto-resizes on the
        /// y-axis. The Units class is pretty helpful here, as it allows us to reason more visually
        /// about the units we're using! StereoKit uses meters as its base unit, which look a little
        /// awkward, especially in the millimeter range.
        ///
        /// We'll also use a toggle to turn the window's header on and off! The value from that toggle
        /// is passed in here via the showHeader field.
        UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * Units.cm2m, showHeader);

        /// Here's that toggle button! You'll also notice our use of 'ref' values in a lot of the UI
        /// code. UI functions typically follow the pattern of returning true/false to indicate they've
        /// been interacted with during the frame, so you can nicely wrap them in 'if' statements to
        /// react to change!
        ///
        /// Then with the 'ref' parameter, we let you pass in the current state of the UI element. The UI
        /// element will update that value for you based on user interaction, but you can also change it
        /// yourself whenever you want to!
        UI.Toggle("Show Header", ref showHeader);

        /// Here's an example slider! We start off with a label element, and tell the UI to
        /// keep the next item on the same line. The slider clamps to the range [0,1], and
        /// will step at intervals of 0.2. If you want it to slide continuously, you can just set
        /// the `step` value to 0!
        UI.Label("Slide");
        UI.SameLine();
        UI.HSlider("slider", ref slider, 0, 1, 0.2f, 72 * Units.mm2m);

        /// Here's how you use a simple button! Just check it with an 'if'. Any UI method
        /// will return true on the frame when their value or state has changed.
        if (UI.ButtonRound("Exit"))
        {
            StereoKitApp.Quit();
        }

        /// And for every begin, there must also be an end! StereoKit will log errors when this
        /// occurs, so keep your eyes peeled for that!
        UI.WindowEnd();

        /// And there you go! That's how UI works in StereoKit, pretty simple, huh?
        /// For further reference, and more UI methods, check out the
        /// [UI class documentation]({{site.url}}/Pages/Reference/UI.html).
        ///
        /// If you'd like to see the complete code for this sample,
        /// [check it out on Github](https://github.com/maluoi/StereoKit/blob/master/Examples/StereoKitTest/DemoUI.cs)!
        /// :End:

        UI.AffordanceBegin("Clip", ref clipboardPose, new Vec3(-15, 20, 0) * Units.cm2m, new Vec3(30, 40, 5) * Units.cm2m, false);
        UI.LayoutArea(new Vec3(-12, 15, 0) * Units.cm2m, new Vec2(24, 30) * Units.cm2m);
        UI.Label("Application 'Settings'");
        UI.Toggle("Subtitles", ref subtitles); UI.SameLine();
        UI.Toggle("Butts", ref clipButts);
        UI.HSlider("Slide", ref clipSlider, 0, 1, 0, 22 * Units.cm2m);
        UI.ButtonRound("Press");
        UI.Button("Squeeze");
        UI.AffordanceEnd();
        clipboard.Draw(clipboardPose.ToMatrix());
    }
Esempio n. 10
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();
        }