Ejemplo n.º 1
0
        // timer
        void timer_Tick(object sender, EventArgs e)
        {
            if (glLoaded)
            {
                const float moveSpeed = 0.05f;
                const float runSpeed  = 0.5f;
                const float rotSpeed  = 5.0f;

                bool invalidate = false;

                // Movement.
                Vector3D pos = new Vector3D();

                if (input[Keys.E])
                {
                    pos       += Vector3D.UnitZ;               // forward
                    invalidate = true;
                }

                if (input[Keys.D])
                {
                    pos       -= Vector3D.UnitZ;               // backward
                    invalidate = true;
                }

                if (input[Keys.S])
                {
                    pos       += Vector3D.UnitX;               // left
                    invalidate = true;
                }

                if (input[Keys.F])
                {
                    pos       -= Vector3D.UnitX;               // right
                    invalidate = true;
                }

                camera.pos += AQuaternion.FromEulerAngles(camera.rot * new Vector3D(1.0f, -1.0f, 1.0f) * (float)MathUtility.DegreesToRadians) * pos * (input[Keys.ShiftKey] ? runSpeed : moveSpeed);

                // Look.
                if (input[invertLook ? Keys.Down : Keys.Up])                 // up
                {
                    camera.rot -= Vector3D.UnitX * rotSpeed;
                    invalidate  = true;
                }

                if (input[invertLook ? Keys.Up : Keys.Down])                 // down
                {
                    camera.rot += Vector3D.UnitX * rotSpeed;
                    invalidate  = true;
                }

                if (input[Keys.Left])                 // left
                {
                    camera.rot -= Vector3D.UnitY * rotSpeed;
                    invalidate  = true;
                }

                if (input[Keys.Right])                 // right
                {
                    camera.rot += Vector3D.UnitY * rotSpeed;
                    invalidate  = true;
                }

                if (invalidate)
                {
                    gl_frame.Invalidate();
                }
            }
        }
Ejemplo n.º 2
0
 // Token: 0x06000398 RID: 920 RVA: 0x0000CB84 File Offset: 0x0000AD84
 public static Quaternion FromEulerAngles(Vector3D eulerAngles)
 {
     return(Quaternion.FromEulerAngles(eulerAngles.X, eulerAngles.Y, eulerAngles.Z));
 }