Esempio n. 1
0
        public static void ProcessKeyboard()
        {
            float velocity = Math.Abs(.11f * Convert.ToSingle(StateMaschine.GetElapsedTime() - lasttime));

            lasttime = StateMaschine.GetElapsedTime();
            if (StateMaschine.Context.KeyboardState[Keys.W])
            {
                Position += new Vector3(Front.X, 0, Front.Z).Normalized() * velocity;
            }
            if (StateMaschine.Context.KeyboardState[Keys.S])
            {
                Position -= new Vector3(Front.X, 0, Front.Z).Normalized() * velocity;
            }
            if (StateMaschine.Context.KeyboardState[Keys.A])
            {
                Position += new Vector3(Right.X, 0, Right.Z).Normalized() * velocity;
            }
            if (StateMaschine.Context.KeyboardState[Keys.D])
            {
                Position -= new Vector3(Right.X, 0, Right.Z).Normalized() * velocity;
            }
            Position.Y = StateMaschine.Context.MouseState.Scroll.Y * -4;
            if (Position.X < 0)
            {
                Position.X = 0;
            }
            if (Position.Y < 0)
            {
                Position.Y = 0;
            }
            if (Position.Z < 0)
            {
                Position.Z = 0;
            }
        }
Esempio n. 2
0
 public static void StartFrame()
 {
     if (!_frameIsStarted)
     {
         _frameIsStarted = true;
         _timeSlots.Clear();
         _startTime = StateMaschine.GetElapsedTimeTicks();
     }
 }
Esempio n. 3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            var watch = new Util.StopWatchMilliseconds();

            base.OnUpdateFrame(e);
            StateMaschine.Input();
            StateMaschine.Update(e);

            LastFrameUpdateTime = Convert.ToSingle(watch.Result());
        }
Esempio n. 4
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            var watch = new Util.StopWatchMilliseconds();

            GL.Enable(EnableCap.DepthTest);
            GL.DepthMask(true);
            base.OnRenderFrame(e);
            _controller.Update(this, (float)e.Time);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
            StateMaschine.Render();
            _controller.Render();
            SwapBuffers();
            LastFrameRenderTime = Convert.ToSingle(watch.Result());
            GenerateAverageFrameRenderTime();
        }
Esempio n. 5
0
 public static void StopFrame()
 {
     if (_frameIsStarted)
     {
         _frameIsStarted = false;
         _endTime        = StateMaschine.GetElapsedTimeTicks();
         _duration       = _endTime - _startTime;
         if (DebugPrint)
         {
             Console.WriteLine($"Frametime:{_duration}ms");
             foreach (var slot in _timeSlots)
             {
                 Console.WriteLine($"{slot.Name}:{slot.Duration}ms");
             }
             Console.WriteLine("******************************");
         }
     }
 }
Esempio n. 6
0
        public override void OnGui()
        {
            base.OnGui(); // call first for all entities
            ImGui.Begin("Main");
            if (ImGui.Button("Exit"))
            {
                StateMaschine.Exit();
            }

            ImGui.ColorEdit4("ClearColor", ref ClearColor);
            ImGui.Text("Avg Rendertime:" +
                       StateMaschine.Context.AverageLastFrameRenderTime.ToString("0.000") + "ms");

            if (ImGui.Button("Tree"))
            {
                var listof_obj = Directory.GetFiles("Models/", "*.obj");
                for (int f = 0; f < 1000; f++)
                {
                    var item = listof_obj[rnd.Next(0, listof_obj.Length - 1)];
                    var t    = AddEntity(new StaticOBJModel(item.Remove(item.Length - 4).Substring(7), new Vector3(0, 0, 0), false));
                    GetEntity(t).GetComponent <Transform>().SetPosition(new Vector3(rnd.Next(0, 100), 0, rnd.Next(0, 100)));
                }
            }
            ImGui.Checkbox("Camera Gui", ref Camera.ShowGUI);
            ImGui.Checkbox("Wireframe", ref _WireFrame);
            StateMaschine.Context.WireMode(_WireFrame);
            ImGui.Checkbox("Print Profiler", ref Profiler.DebugPrint);
            ImGui.Checkbox("show random lines", ref drawlines);
            ImGui.Checkbox("Gui Demo Window", ref ShowImGUIDemoWindow);
            ImGui.Checkbox("Show Chunk Outlines", ref SpatialManager.ShowChunkOutline);
            ImGui.Checkbox("Show Profiler Window", ref Profiler.RenderProfiler);
            ImGui.Text($"Current Chunk ID {SpatialManager.GetTupelChunkIDAndInChunkPos(SpatialManager.GetIDfromWorldPos(Camera.Position))}");
            ImGui.Text($"Chunks {SpatialManager._Chunks.Count}");
            ImGui.Text($"Visible Chunks {SpatialManager.VisibleChunksAccordFrustum.Count}");
            ImGui.Text($"Mouse Delta:{picker.getIntersectionGround()}");
            if (house1.Draw("Models/house_type01.png", new Vector2(100, 100)))
            {
                build_mode = true;
                GetEntity <StaticOBJModel>(wellmodel).ChangeModel("house_type01");
                current_build = "house_type01";
            }
            if (house2.Draw("Models/house_type02.png", new Vector2(100, 100)))
            {
                build_mode = true;
                GetEntity <StaticOBJModel>(wellmodel).ChangeModel("house_type02");
                current_build = "house_type02";
            }

            if (street1.Draw("Models/road_straight.png", new Vector2(100, 100)))
            {
                build_mode = true;
                GetEntity <StaticOBJModel>(wellmodel).ChangeModel("road_straight");
                current_build = "road_straight";
            }

            pillar.Draw("Models/bridge_pillar.png", new Vector2(100, 100));


            if (build_mode)
            {
                StateMaschine.Context.CursorVisible = false;
            }

            float[] x = StateMaschine.Context.ListLastFrameTimes.ToArray();
            if (ShowImGUIDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }
            ImGui.End();
        }
Esempio n. 7
0
 public override void OnUpdate(FrameEventArgs e)
 {
     Console.WriteLine("Startup created. Will switch to First State now");
     base.OnUpdate(e);
     StateMaschine.SwitchState(_startScene);
 }
Esempio n. 8
0
 public void Stop()
 {
     EndTime  = StateMaschine.GetElapsedTimeTicks();
     Duration = Convert.ToSingle(EndTime - StartTime);
     Active   = false;
 }
Esempio n. 9
0
 public TimeSlot(string name)
 {
     StartTime = StateMaschine.GetElapsedTimeTicks();
     Name      = name;
     Profiler.AddTimeSlot(this);
 }
Esempio n. 10
0
 static void Main(string[] args)
 {
     StateMaschine.Run(new RenderingTest(), 60, 60);
 }