Defines the arguments for frame events. A FrameEventArgs instance is only valid for the duration of the relevant event; do not store references to FrameEventArgs outside this event.
Наследование: System.EventArgs
Пример #1
0
        public void Render(FrameEventArgs e)
        {
            UpdateControl();

            int x = 100;
            int y = 110;

            GL.Disable(EnableCap.Texture2D);
            Draw.FilledRectangle(x, y, game.Width - x * 2, game.Height - y * 2, new Color4(32, 32, 32, 255));
            Draw.Rectangle(x, y, game.Width - x * 2, game.Height - y * 2, new Color4(96, 96, 96, 255));

            font.Options.Colour = Color4.LightGray;
            font.Print(@"On the other hand, we denounce with righteous indignation and
            dislike men who are so beguiled and demoralized by the
            charms of pleasure of the moment, so blinded by desire,
            that they cannot foresee the pain and trouble that are
            bound to ensue; and equal blame belongs to those who fail
            in their duty through weakness of will, which is the same as saying
            through shrinking from toil and pain. These cases are perfectly
            simple and easy to distinguish. In a free hour, when our
            power of choice isuntrammelled and when nothing prevents our
            being able to do what we like best, every pleasure is to be
            welcomed and every pain avoided. But in certain circumstances
            and owing to the claims of duty or the obligations of business
            it will frequently occur that pleasures have to be repudiated
            and annoyances accepted. The wise man therefore always holds in
            these matters to this principle of selection: he rejects
            pleasures to secure other greater pleasures, or else he
            endures pains to avoid worse pains.", new Vector2(x + 10, y + 10));

            font.Options.Colour = Color4.Orange;
            font.Print("<< Back", new Vector2(x + 10, 450));
        }
Пример #2
0
        public override void Update(OpenTK.FrameEventArgs e)
        {
            base.Update(e);

            if (_spriteTimer > 0)
            {
                _spriteTimer -= (float)e.Time;
            }

            KeyboardState keyState = Keyboard.GetState();

            bool running = false;

            if (keyState.IsKeyDown(Key.LShift) && _mapPlayer.GetPlayerPacket().Data.Stamina > 0)
            {
                running = true;
            }

            if (!Moving())
            {
                SetXFrame(0);
            }
            else
            {
                if (_spriteTimer <= 0)
                {
                    _spriteTimer = _spriteTimerMax;
                    if (running)
                    {
                        _spriteTimer /= 3.0f;
                    }
                    IncrementXFrame();
                }
            }
        }
Пример #3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            physics.Update((float)e.Time);

            if (Keyboard[OpenTK.Input.Key.Escape] || Keyboard[OpenTK.Input.Key.Q])
                Exit();
        }
Пример #4
0
        private void OnRenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            // set up viewport
            GL.Viewport(0, 0, Width, Height);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            SetupPerspective();

            // determinate object view rotation vectors and apply them
            _objectView = _baseView;
            var rotation = _rotateVectors[_rotateIndex];

            if (rotation != Vector3.Zero)
            {
                _objectView *= Matrix4.CreateFromAxisAngle(_rotateVectors[_rotateIndex], (float)(_stopwatch.Elapsed.TotalSeconds * 1.0));
            }

            // set transformation matrix
            _textureProgram.Use();
            _textureProgram.ModelViewProjectionMatrix.Set(_objectView * ModelView * Projection);

            // render cube with texture
            _cubeVao.Bind();
            _cubeVao.DrawArrays(_cube.DefaultMode, 0, _cube.VertexBuffer.ElementCount);

            // swap buffers
            SwapBuffers();
        }
Пример #5
0
        protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            Title = $"Forge {versionNum} FPS: {1f / e.Time:0} Map: {currentMap}";

            //Clear screen
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //TODO move to seperate file
            //Tell OpenGL to use our shaders
            if (_useShaded)
            {
                GL.UseProgram(_shadedShaderProgram);
            }
            else
            {
                GL.UseProgram(_defaultShaderProgram);
            }


            //Send projection matrix to shader
            GL.UniformMatrix4(
                20,                                    //Match location in shader
                false,                                 //don't transpose
                ref cam.projectionMatrix               //use projection matrix
                );

            //Send view matrix to shader
            GL.UniformMatrix4(21, false, ref cam.viewMatrix);

            //Send model matrix to shader
            GL.UniformMatrix4(22, false, ref cam.modelMatrix);

            //Render Grid
            if (drawGrid)
            {
                grid.Bind();
                grid.Render(PrimitiveType.Lines);
            }

            //Render each object in object array
            foreach (RenderObject renderObject in renderObjects)
            {
                renderObject.Bind();
                renderObject.Render(PrimitiveType.TriangleFan);
            }

            ////Depth color pass
            //foreach (RenderObject renderObject in renderObjects)
            //{
            //	GL.UseProgram(_lineShaderProgram);
            //	renderObject.Bind();
            //	renderObject.Render(PrimitiveType.LineStrip);
            //}

            //Render ImGUI gui
            //RenderGui();

            //Display new frame
            SwapBuffers();
        }
Пример #6
0
        /*public void SetBallPositions (ZertzBallRenderer[] balls) {
         *      float z1 = HALF_WIDTH-2.0f*ZertzBallRenderer.RADIUS, x = HALF_WIDTH+0.5f*THICKNESS, y = this.ballheight, dz = 3.0f*ZertzBallRenderer.RADIUS;
         *      float z2 = -z1, z3 = z1;
         *      Vector3 v;
         *      foreach(ZertzBallRenderer zbr in balls) {
         *              switch(zbr.Type) {
         *                      case ZertzBallType.White :
         *                              v = new Vector3(-x,y,z1);
         *                              z1 -= dz;
         *                              break;
         *                      case ZertzBallType.Gray :
         *                              v = new Vector3(-x,y,z2);
         *                              z2 += dz;
         *                              break;
         *                      case ZertzBallType.Black :
         *                              v = new Vector3(x,y,z3);
         *                              z3 -= dz;
         *                              break;
         *                      default :
         *                              v = Vector3.Zero;
         *                              break;
         *              }
         *              zbr.RenderMover = RenderMoveManager.GenerateStaticMover(v);
         *      }
         * }*/
        /*public void SetRingPositions (ZertzRingRenderer[] rings) {
         *      int mask = ~0x01;
         *      float r = HALF_WIDTH+0.5f*THICKNESS, y0 = ZertzRingRenderer.THICKNESS+BORDER_HEIGHT+CORNER_HEIGHT;
         *      float moveHeight = BORDER_HEIGHT+CORNER_HEIGHT+ZertzTileRenderer.TILE_HEIGHT;
         *      for(int i = 0x00; i < rings.Length; i++) {
         *              rings[i].TileLocation = new Vector3(r,2.0f*ZertzRingRenderer.THICKNESS*(i&mask)+y0,r);
         *              rings[i].MoveHeight = moveHeight;
         *              r = -r;
         *      }
         * }*/
        public void Render(OpenTK.FrameEventArgs e)
        {
            GL.Color3(0.4f, 0.2f, 0.0f);
            this.ztra.Render(e);
            this.ztrb.Render(e);
            GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.NormalArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.BindBuffer(BufferTarget.ArrayBuffer, cupBuff);
            int stride = sizeof(float) << 0x03;

            GL.VertexPointer(0x03, VertexPointerType.Float, stride, 0x00);
            GL.NormalPointer(NormalPointerType.Float, stride, 0x03 * sizeof(float));
            GL.TexCoordPointer(0x02, TexCoordPointerType.Float, stride, 0x06 * sizeof(float));
            GL.DrawArrays(BeginMode.Quads, 0x00, cupN);

            /*GL.PushAttrib(AttribMask.EnableBit);
             * GL.Color3(1.0f,1.0f,1.0f);
             * GL.Enable(EnableCap.Texture2D);
             * GL.BindTexture(TextureTarget.Texture2D,glT);
             * GL.BindBuffer(BufferTarget.ArrayBuffer,glBuff);
             * GL.BindBuffer(BufferTarget.ElementArrayBuffer,glIdBuff);
             * GL.VertexPointer(0x03,VertexPointerType.Float,stride,0x00);
             * GL.NormalPointer(NormalPointerType.Float,stride,0x03*sizeof(float));
             * GL.TexCoordPointer(0x02,TexCoordPointerType.Float,stride,0x06*sizeof(float));
             * GL.DrawElements(BeginMode.QuadStrip,glN,DrawElementsType.UnsignedInt,0x00);
             * GL.PopAttrib();//*/

            GL.PopClientAttrib();
            GL.Color3(0.09f, 0.275f, 0.17f);
            //ws.Render(e);
        }
Пример #7
0
 protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
 {
     if (Keyboard[Key.Escape] || Keyboard[Key.Q])
     {
         Exit();
     }
 }
 public override void OnUpdateFrame(FrameEventArgs e)
 {
     base.OnUpdateFrame(e);
     count++;
     if (count >= maxCount)
         TestSuccess();
 }
Пример #9
0
        /// <summary>
        /// Called when the frame is updated.
        /// </summary>
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            Hue1024++;

            float h = Hue1024 / 1024f;
            var   c = OpenTK.Graphics.Color4.FromHsv(new Vector4(h, Sat, Value, 1));

            GL.ClearColor(c);



            // バッファの初期化
            int sampleCount  = 256;
            int bufferLength = sampleCount * 2;

            wavebuffer = new int[sampleCount];

            // バッファのコピー (1024byte = 512sample)
            this.AudioCapture.ReadSamples(wavebuffer, bufferLength);


            // Rotation Right On
            if (this.RotationRight == true)
            {
                //GL.Rotate(-1, 0, 0, 1);
            }
        }
Пример #10
0
        public override void Update(OpenTK.FrameEventArgs e)
        {
            base.Update(e);
            if (!_mapEvent.Enabled)
            {
                return;
            }

            if (_mapEvent.UpdateMovement((float)e.Time))
            {
                SetRealPosition();
            }

            SetYFrame((int)_mapEvent.EventDirection);

            if (_spriteTimer > 0)
            {
                _spriteTimer -= (float)e.Time;
            }

            if (!_mapEvent.Moving())
            {
                SetXFrame(0);
            }
            else
            {
                if (_spriteTimer <= 0)
                {
                    _spriteTimer = _spriteTimerMax;
                    IncrementXFrame();
                }
            }
        }
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (_synchronizeCameras)
            {
                _lodCamera.Position = _camera.Position;
                _lodCamera.Target   = _camera.Target;
                _lodCamera.Up       = _camera.Up;
                _lodCamera.Width    = _camera.Width;
                _lodCamera.Height   = _camera.Height;
            }

            _frameTimeCounter.UpdateFrameTime(e.Time);

            GL.Clear(ClearBufferMask.DepthBufferBit);

            foreach (var system in _systems)
            {
                system.Update(ElapsedTime.TotalSeconds, _entityManager);
            }

            _terrain.Render(_camera, _lodCamera, _entityManager.GetComponent <PositionalLightComponent>(_entityManager.GetEntitiesWithComponent <PositionalLightComponent>().Single()).Position);
            _cube.Render(_camera, _entityManager.GetComponent <PositionalLightComponent>(_entityManager.GetEntitiesWithComponent <PositionalLightComponent>().Single()).Position);

            SwapBuffers();
        }
Пример #12
0
        private void GWindow_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            GL.ClearColor(1, 0, 0, 1);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.Clear(ClearBufferMask.DepthBufferBit);

            GL.LoadIdentity();

            double xtrans    = -xpos;
            double ztrans    = -zpos;
            double sceneroty = 360.0f - yrot;

            GL.Rotate(lookupdown, 1.0f, 0.0, 0.0);
            GL.Rotate(sceneroty, 0, 1.0f, 0);

            GL.Translate(xtrans, 0.25f, ztrans);

            foreach (var renderable in renderables)
            {
                renderable.Render();
            }

            GL.Flush();

            gWindow.SwapBuffers();
        }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     //our loaded vertex sets now represent on-screen objects that can be drawn
     foreach (VertexSet v in loadedVertexSets) {
         v.Draw();
     }
 }
Пример #14
0
 public void Draw(FrameEventArgs e)
 {
     if (Visible)
       {
     foreach(GameComponent g in this.Components)
       g.Draw(e);
     DoDraw(e);
       }
 }
Пример #15
0
        private void OnInternalUpdate(object sender, OpenTK.FrameEventArgs e)
        {
            UpdateFrameEventArgs args = new UpdateFrameEventArgs(e.Time * 1000D);

            Time = args.Time;

            OnUpdateFrame(this, args);
            UpdateFrame?.Invoke(this, args);
        }
Пример #16
0
        public override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            myCamera.UpdateViewMatrix();

            myShader.StartBatch();
            myCell.Render(myShader, RenderLayer.Base);
            myCell.Render(myShader, RenderLayer.Alpha1);
            myCell.Render(myShader, RenderLayer.Alpha2);
            myShader.EndBatch();
        }
Пример #17
0
        private void onRenderFrame(object sender, OpenTK.FrameEventArgs args)
        {
            _renderFrameArgs.Time = args.Time;
            var renderFrame = RenderFrame;

            if (renderFrame != null)
            {
                renderFrame(sender, _renderFrameArgs);
            }
        }
Пример #18
0
        private void onUpdateFrame(object sender, OpenTK.FrameEventArgs args)
        {
            _updateFrameArgs.Time = args.Time;
            var updateFrame = UpdateFrame;

            if (updateFrame != null)
            {
                updateFrame(sender, _updateFrameArgs);
            }
        }
Пример #19
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            physics.Update((float)e.Time);

            KeyboardState state = OpenTK.Input.Keyboard.GetState();
            if (state.IsKeyDown(Key.Escape) || state.IsKeyDown(Key.Q))
            {
                Exit();
            }
        }
Пример #20
0
        internal override void Render(FrameEventArgs e)
        {
            base.Render(e);

            GL.PushMatrix();
            GL.Translate(Coords.Xf, Coords.Yf, Coords.Zf);
            GL.Rotate(WorldHost.RotationCounter, -Vector3.UnitY);
            DisplayList.RenderDisplayList(DisplayList.BlockQuarterId, Block.FaceTexture(BlockType, Face.Top));
            GL.PopMatrix();
        }
Пример #21
0
 public void Render(OpenTK.FrameEventArgs e)
 {
     lock (objects) {
         foreach (KeyValuePair <int, IRenderable> ir in this.objects)
         {
             GL.LoadName(ir.Key);
             ir.Value.Render(e);
         }
         GL.LoadName(-0x01);
     }
 }
Пример #22
0
 private void BasicGameWindow_UpdateFrame(object sender, OpenTK.FrameEventArgs e)
 {
     if (States.CurrentState == null)
     {
         Exit();
     }
     else
     {
         States.Update(TimeSpan.FromSeconds(e.Time));
     }
 }
Пример #23
0
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            OpenTK.Input.KeyboardState input = OpenTK.Input.Keyboard.GetState();

            if (input.IsKeyDown(OpenTK.Input.Key.Escape))
            {
                Exit();
            }

            base.OnUpdateFrame(e);
        }
Пример #24
0
        /// <summary>
        /// Aktualizace herního okna.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateFrame(object sender, FrameEventArgs e)
        {
            frames++;

            if (ElapsedMilliseconds > 1000)
            {
                fps = frames * 1000 / ElapsedMilliseconds;
                frames = 0;
                Restart();
            }
        }
Пример #25
0
 public void Render(OpenTK.FrameEventArgs e)
 {
     GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
     GL.EnableClientState(ArrayCap.VertexArray);
     GL.EnableClientState(ArrayCap.NormalArray);
     GL.BindBuffer(BufferTarget.ArrayBuffer, this.glRef);
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, this.glInd);
     GL.VertexPointer(0x03, VertexPointerType.Float, Vector3.SizeInBytes, 0x00);
     GL.NormalPointer(NormalPointerType.Float, Vector3.SizeInBytes, m * n * Vector3.SizeInBytes);
     GL.DrawElements(BeginMode.QuadStrip, this.glN, DrawElementsType.UnsignedShort, 0x00);
     GL.PopClientAttrib();
 }
Пример #26
0
        private void _window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            GL.LoadIdentity();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            for (int i = 0; i < _drawingList.Count; i++)
            {
                _drawingList[i].Draw();
            }

            _window.SwapBuffers();
        }
 private static void Gw_RenderFrame(object sender, OpenTK.FrameEventArgs e)
 {
     GL.ClearColor(Color4.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.BindBuffer(BufferTarget.ArrayBuffer, lineVertexBuffer);
     GL.UseProgram(shaderProgram);
     GL.BindVertexArray(vertexInfo);
     GL.DrawArrays(PrimitiveType.LineStrip, 0, vertexCount);
     GL.BindVertexArray(0);
     GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
     GL.UseProgram(0);
     gw.SwapBuffers();
 }
Пример #28
0
 public override void OnRenderFrame(OpenTK.FrameEventArgs e)
 {
     GL.ClearColor(Color.Green);
     GL.Clear(ClearBufferMask.ColorBufferBit);
     the3d.OrthoMode(window.Width, window.Height);
     for (int i = 0; i < 7; i++)
     {
         the3d.Draw2dText("Hello!", 50, 100 + i * 50, 8 + i * 6, colors[i]);
     }
     for (int i = 0; i < 16; i++)
     {
         the3d.Draw2dText(colorCodes[i] + "Color" + "&f & " + colorCodes[i][1], 300, 100 + i * 30, 14, null);
     }
 }
Пример #29
0
        /// <summary>
        /// Called when the frame is updated.
        /// </summary>
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            Console.WriteLine("On Update");

            count++;
            //image[count] = count / (float)(N*N);

            if (count > N * N)
            {
                count = 0;
            }
            image[count] = 1f;
        }
Пример #30
0
        private void DoorBehaviour_Updated(object sender, OpenTK.FrameEventArgs e)
        {
            float dt = (float)e.Time;

            this.initialRotation = this.initialRotation ?? this.Detail.Rotation;

            float targetRotation = (this.isOpen ? 1.0f : 0.0f);

            float delta = targetRotation - this.fOpen;

            this.fOpen += Math.Sign(delta) * Math.Min(Math.Abs(delta), dt);

            this.Detail.Rotation = this.initialRotation.Value * Quaternion.FromAxisAngle(Vector3.UnitY, 0.7f * MathHelper.Pi * this.fOpen);
        }
Пример #31
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            frameTime += (float)e.Time;
            fps++;
            if (frameTime >= 1)
            {
                frameTime = 0;
                Title = "BulletSharp OpenTK Demo, FPS = " + fps.ToString();
                fps = 0;
            }

            GL.Viewport(0, 0, Width, Height);

            float aspect_ratio = Width / (float)Height;
            Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 0.1f, 100);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref perspective);

            Matrix4 lookat = Matrix4.LookAt(new Vector3(10, 20, 30), Vector3.Zero, Vector3.UnitY);
            GL.MatrixMode(MatrixMode.Modelview);

            GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
            angle += (float)e.Time*100;

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            InitCube();

            foreach (RigidBody body in physics.World.CollisionObjectArray)
            {
                Matrix4 modelLookAt = Convert(body.MotionState.WorldTransform) * lookat;
                GL.LoadMatrix(ref modelLookAt);

                if ("Ground".Equals(body.UserObject))
                {
                    DrawCube(Color.Green, 50.0f);
                    continue;
                }

                if (body.ActivationState == ActivationState.ActiveTag)
                    DrawCube2(Color.Orange, 1);
                else
                    DrawCube2(Color.Red, 1);
            }

            UninitCube();

            SwapBuffers();
        }
Пример #32
0
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            animator.Update(e.Time);

            if (isPlotUpdated)
            {
                isPlotUpdated = false;
                plotSurface.RedrawPlotSurface();
            }

            if (isStatusTextChanged)
            {
                isStatusTextChanged = false;
                PositionStatusText();
            }
        }
Пример #33
0
        private void OnRenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            // Rotate the position of the camera around to make sure I'm not
            // running into any weird orientation issues.
            sininput += .01f;
            motionZ   = (float)Math.Sin((double)sininput) * 10;
            motionX   = (float)Math.Cos((double)sininput) * 10;
            camera.SetPosition(new Vector3(motionX, 3, motionZ));
            // For monitoring:
            Debug.WriteLine("current motion x:{0}, y:3, z:{1}", motionX, motionZ);

            GL.Clear(ClearBufferMask.ColorBufferBit);
            // Raise the draw event
            Draw?.Invoke(this, EventArgs.Empty);
            GL.Flush();
            Program.window.SwapBuffers();
        }
Пример #34
0
        private void RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            this.Renderer.Prepare();

            switch (this.Mode)
            {
            case 1:
                this.Render3D();
                break;

            case 2:
                this.Render2D();
                break;
            }

            this.Display.Update();
        }
Пример #35
0
        public void Render(OpenTK.FrameEventArgs e)
        {
            //GL.PushAttrib
            GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
            GL.PushMatrix();
            GL.Translate(v);
            GL.BindBuffer(BufferTarget.ArrayBuffer, dataBuff);
            int stride = sizeof(float) << 0x03;

            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.NormalArray);
            GL.VertexPointer(0x03, VertexPointerType.Float, stride, 0x00);
            GL.NormalPointer(NormalPointerType.Float, stride, 0x03 * sizeof(float));
            GL.DrawArrays(BeginMode.QuadStrip, 0x00, dataN);
            GL.PopMatrix();
            GL.PopClientAttrib();
        }
Пример #36
0
        private void OnInternalRender(object sender, OpenTK.FrameEventArgs e)
        {
            if (!_fpsTimer.IsRunning)
            {
                _fpsTimer.Start();
            }

            RenderFrameEventArgs args = new RenderFrameEventArgs(e.Time * 1000D);

            OnRenderFrame(this, args);
            RenderFrame?.Invoke(this, args);

            if (!_isEventPolled && _isStarted)
            {
                _fps++;
                CheckWindowFPS();
            }
        }
Пример #37
0
        //Updates every frame
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            //Get keyboard inputs
            PollKeyboard();

            //Get horizontal and vertical angles TODO move to own function?
            if (camActive)
            {
                cam.HorizontalAngle += (Mouse.X - (Width / 2)) * e.Time * cam.mouseSensitivity;
                cam.VerticalAngle   += -(Mouse.Y - (Height / 2)) * e.Time * cam.mouseSensitivity;

                CenterMouse();
            }

            //Calculate the front facing vector
            cam.CalcFront();

            cam.viewMatrix = Matrix4.LookAt(cam.Position, cam.Position + Vector3.Normalize(cam.front), cam.up).Normalized();
        }
Пример #38
0
 //int xi = 0;
 //int yi = 0;
 protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
 {
     //Console.WriteLine($"xi:{xi}, yi:{yi}, c:{count}");
     GL.Begin(PrimitiveType.Points);
     {
         for (int i = 0; i < N * N; i++)
         {
             int x = (int)((float)i % N);
             int y = (int)((float)i / N);
             //float c = image[i];
             float c = 1f;
             GL.Color3(c, 0f, 0f);
             GL.Vertex2(x, y);
             //Console.WriteLine($"xi:{x}, yi:{y}, c:{c}");
         }
     }
     GL.End();
     this.SwapBuffers();
     base.OnRenderFrame(e);
 }
Пример #39
0
        private void _window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            //exit window if escape pressed
            KeyboardState input = Keyboard.GetState();

            if (input.IsKeyDown(Key.Escape))
            {
                _window.Exit();
            }

            GL.LoadIdentity();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            for (int i = 0; i < _drawingList.Count; i++)
            {
                _drawingList[i].Draw();
            }

            _window.SwapBuffers();
        }
Пример #40
0
        /// <summary>Projectile explodes on decay.</summary>
        internal void OnItemDecay(FrameEventArgs e)
        {
            if (Config.IsServer || Config.IsSinglePlayer)
            {
                var positions = Coords.AdjacentPositions;
                var removeBlocks = new List<RemoveBlock>();
                var addBlockItems = new List<AddBlockItem>();
                Settings.ChunkUpdatesDisabled = true;
                foreach (var position in positions)
                {
                    var block = position.GetBlock();
                    if (block.Type != Block.BlockType.Air && block.Type != Block.BlockType.Water)
                    {
                        WorldData.PlaceBlock(position, Block.BlockType.Air);
                        var tempPosition = position; //copy to pass by ref
                        removeBlocks.Add(new RemoveBlock(ref tempPosition));

                        if (!block.IsTransparent && position.IsValidItemLocation)
                        {
                            var tempCoords = position.ToCoords(); //copy to pass by ref
                            var newBlockItem = new BlockItem(ref tempCoords, block.Type);
                            addBlockItems.Add(new AddBlockItem(ref newBlockItem.Coords, ref newBlockItem.Velocity, newBlockItem.BlockType, newBlockItem.Id));
                        }
                    }
                }
                Settings.ChunkUpdatesDisabled = false;

                if (Config.IsServer && removeBlocks.Count > 0)
                {
                    foreach (var player in Server.Controller.Players.Values)
                    {
                        var removeBlockMulti = new RemoveBlockMulti {ConnectedPlayer = player};
                        removeBlockMulti.Blocks.AddRange(removeBlocks);
                        removeBlockMulti.BlockItems.AddRange(addBlockItems);
                        removeBlockMulti.Send();
                    }
                }
            }
        }
Пример #41
0
 protected override void DoDraw(FrameEventArgs e)
 {
 }
Пример #42
0
 public virtual void Draw(FrameEventArgs e)
 {
 }
Пример #43
0
 private void RotationBehaviour_Updated(object sender, FrameEventArgs e)
 {
     this.Detail.Rotation *= Quaternion.FromAxisAngle(Vector3.UnitY, (float)e.Time);
 }
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (_synchronizeCameras)
            {
                _lodCamera.Position = _camera.Position;
                _lodCamera.Target = _camera.Target;
                _lodCamera.Up = _camera.Up;
                _lodCamera.Width = _camera.Width;
                _lodCamera.Height = _camera.Height;
            }

            _frameTimeCounter.UpdateFrameTime(e.Time);

            GL.Clear(ClearBufferMask.DepthBufferBit);

            foreach (var system in _systems)
            {
                system.Update(ElapsedTime.TotalSeconds, _entityManager);
            }

            _terrain.Render(_camera, _lodCamera, _entityManager.GetComponent<PositionalLightComponent>(_entityManager.GetEntitiesWithComponent<PositionalLightComponent>().Single()).Position);
            _cube.Render(_camera, _entityManager.GetComponent<PositionalLightComponent>(_entityManager.GetEntitiesWithComponent<PositionalLightComponent>().Single()).Position);

            SwapBuffers();
        }
Пример #45
0
        private void Game_RenderFrame(object sender, FrameEventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.LoadIdentity();
            GL.Ortho(0, Width, Height, 0, -1, 1);

            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture2D);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            GL.ClearColor(OpenTK.Graphics.Color4.CornflowerBlue);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            Camera.Begin();

            _map.Draw();

            _ui.Draw();

            Camera.End();

            SwapBuffers();
        }
Пример #46
0
 void OnRender(object sender, FrameEventArgs e)
 {
     switch (gameState)
     {
         case GameState.LEVEL:
             stars.Render();
             level.Render();
             player.Render();
             break;
     }
 }
Пример #47
0
        public void OnUpdateFrame(FrameEventArgs args)
        {
            foreach (var chunk in _chunks)
            {
                chunk.OnUpdateFrame(args);
            }

            foreach (var entity in _entities)
            {
                entity.OnUpdateFrame(args);
            }

            _self.OnUpdateFrame(args);
        }
Пример #48
0
 internal static void Update(FrameEventArgs e)
 {
     if (OnUpdate != null) {
         OnUpdate();
     }
 }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     count++;
 }
Пример #50
0
        public override void Update(FrameEventArgs e)
        {
            base.Update(e);
            if (!focused) return;
            time += e.Time;
            if (time > toggleCursorTime)
            {
                time = 0;
                if (textAppearence.AppendText == "|")
                    textAppearence.AppendText = "";
                else
                    textAppearence.AppendText = "|";

                Singleton<GUI>.INSTANCE.Dirty = true;
            }
        }
 protected override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     Draw();
 }
Пример #52
0
 protected abstract void DoDraw(FrameEventArgs e);
Пример #53
0
        internal static void OnUpdateFrame(FrameEventArgs e)
        {
            //Check Animation
            Rotation.Update((float)e.Time);

            //Keyboard movement
            Camera.CameraKeyboardMove((float)e.Time);
        }
Пример #54
0
 protected abstract void DoUpdate(FrameEventArgs e);
Пример #55
0
        private void Game_UpdateFrame(object sender, FrameEventArgs e)
        {
            PreviousMouseState = MouseState;
            PreviousKeyboardState = KeyboardState;

            MouseState = OpenTK.Input.Mouse.GetState();
            KeyboardState = OpenTK.Input.Keyboard.GetState();

            PreviousMousePosition = MousePosition;

            #if GRAPHMAKER
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            int x = Camera.X + MousePosition.X;
            int y = Camera.Y + MousePosition.Y;

            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released && MousePosition.X > 40) {
               doc.Element("Waypoints").Add(new XElement("Waypoint", new XAttribute("X", x), new XAttribute("Y", y)));
               minID++;
               Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/BlueMinion.png" }), new Sprite(new List<string>() { "Images/BlueMinion0.png", "Images/BlueMinion1.png" }) }, minID);
                markerMinion.Pos.X = x;
                markerMinion.Pos.Y = y;
                _player1.AddMinion(markerMinion);
              // doc.Save("TestWaypoint.xml");
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            }

            if (MouseState.RightButton == ButtonState.Pressed && PreviousMouseState.RightButton == ButtonState.Released && MousePosition.X > 40)
            {
                switch (rightClicks)
                {
                    case 0: clicks[0] = x;
                        clicks[1] = y;
                        break;

                    case 1:
                        clicks[2] = x;
                        clicks[3] = y;
                         minID++;
                         Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/square.png" }), new Sprite(new List<string>() { "Images/square.png", "Images/square.png" }) }, minID);
                         WaypointNode waypoint1 = graph.GetClosestWaypoint(clicks[0], clicks[1]);
                         WaypointNode waypoint2 = graph.GetClosestWaypoint(clicks[2], clicks[3]);
                         markerMinion.Pos.X = waypoint1.X + (waypoint2.X - waypoint1.X) / 2;
                         markerMinion.Pos.Y = waypoint1.Y + (waypoint2.Y - waypoint1.Y) / 2;
                _player1.AddMinion(markerMinion);
                graph.ConnectNodes(waypoint1, waypoint2);
                        Console.Write("Added neighbor");
                        break;
                }
                rightClicks++;
                rightClicks = rightClicks % 2;
                graph.WriteGraph("TestWaypointNeighbors.xml");
            }

            _scrollBar.Update(e.Time);
            #else

            _map.Update(e.Time);

            _ui.Update(e.Time);

            #endif
            }

            private void Mouse_Move(object sender, MouseMoveEventArgs e)
            {
            MousePosition = e.Position;
            }
            }
        }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     sprites.Draw();
 }
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            ProcessMouseInput();

            ProcessKeyboardInput();
        }
Пример #58
0
 public void Update(FrameEventArgs e)
 {
     if (Enabled)
       {
     foreach(GameComponent g in this.Components)
       g.Update(e);
     DoUpdate(e);
       }
 }
Пример #59
0
 protected override void DoUpdate(FrameEventArgs e)
 {
 }
Пример #60
0
 public virtual void Update(FrameEventArgs e)
 {
 }