Esempio n. 1
0
        public override void Load()
        {
            AddButton("Exit", () => Engine.CreateYesNoPrompt("Exit Program?", () => Environment.Exit(0)).Center((Engine.Window.WindowSize / 2)));
            AddButton("Stop", RealSenseCamera.Stop);
            AddButton("Start", RealSenseCamera.Start);

            Engine.Camera3D.SetPerspective(Engine.Window.WindowSize, (90.0f).ToRad(), NearClip, 100);

            LegShader = new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/leg.vert"),
                                          new ShaderStage(ShaderType.FragmentShader, "content/shaders/leg.frag"));

            VertsMesh = new Mesh3D();
            VertsMesh.PrimitiveType = PrimitiveType.Points;
            VertsMesh.SetVertices(new Vertex3());

            // Variables
            Sparse        = ConVar.Register(nameof(Sparse).ToLower(), 0);         // 3
            LegLength     = ConVar.Register(nameof(LegLength).ToLower(), 100.0f); // 1.0f
            LegWidth      = ConVar.Register(nameof(LegWidth).ToLower(), 100.0f);  // 0.5f
            PickDistance  = ConVar.Register(nameof(PickDistance).ToLower(), 1.0f);
            PickSize      = ConVar.Register(nameof(PickSize).ToLower(), 0.01f);   // 0.025f
            PickSampleNum = ConVar.Register(nameof(PickSampleNum).ToLower(), 10); // 10

            ConCmd.Register("list", (Argv) => {
                GConsole.WriteLine(Sparse);
                GConsole.WriteLine(LegLength);
                GConsole.WriteLine(LegWidth);
                GConsole.WriteLine(PickDistance);
                GConsole.WriteLine(PickSize);
                GConsole.WriteLine(PickSampleNum);
            });

            Thread PollingThread = new Thread(() => {
                while (true)
                {
                    RealSenseCamera.PollForFrames(OnPointCloud: OnPointCloud);
                    Thread.Sleep(0);
                }
            });

            PollingThread.IsBackground = true;
            PollingThread.Start();

            Engine.Camera3D.Position = new Vector3(0, 0, -1);
            Engine.Camera3D.LookAt(Vector3.Zero);
            Engine.Camera3D.Position = new Vector3(0, 0, -NearClip);
        }