//----------------------------------------------------------------------------- // Name: FrameMove() // Desc: //----------------------------------------------------------------------------- public Matrix FrameMove(float fElapsedTime, Input input) { m_fElapsedTime = fElapsedTime; input.Mouse.GetMouseButtons(); const float DIVIDE = 700.0f; byte[] keys = input.Mouse.GetMouseButtons(); bool leftDown = keys[0] == 128; bool rightDown = keys[1] == 128; if (leftDown && rightDown) { Vector3 matTrans = new Vector3(); matTrans.Y = ( -(float)input.Mouse.Y / DIVIDE ) * fElapsedTime * DIVIDE * 10.0f; m_From += matTrans; m_To += matTrans; Vector3 vCross; Vector3 vViewVector = m_To - m_From; vCross.X = ( ( m_Up.Y * vViewVector.Z ) - ( m_Up.Z * vViewVector.Y ) ); vCross.Y = ( ( m_Up.Z * vViewVector.X ) - ( m_Up.X * vViewVector.Z ) ); vCross.Z = ( ( m_Up.X * vViewVector.Y ) - ( m_Up.Y * vViewVector.X ) ); m_From.X += vCross.X * ( (float)input.Mouse.X / DIVIDE ) * fElapsedTime * DIVIDE * 0.15f; m_From.Z += vCross.Z * ((float)input.Mouse.X / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; m_To.X += vCross.X * ((float)input.Mouse.X / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; m_To.Z += vCross.Z * ((float)input.Mouse.X / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; } else if (rightDown) { RotateView(0.0f, -((float)input.Mouse.X / DIVIDE) * fElapsedTime * DIVIDE * 0.15f, 0.0f); m_To.Y += (-(float)input.Mouse.Y / DIVIDE) * fElapsedTime * (DIVIDE * 2.0f) * 10; } else if (leftDown) { Vector3 vVector; RotateView(0.0f, -((float)input.Mouse.X / DIVIDE) * fElapsedTime * DIVIDE * 0.15f, 0.0f); vVector = m_To - m_From; m_From.X += vVector.X * (-(float)input.Mouse.Y / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; m_From.Z += vVector.Z * (-(float)input.Mouse.Y / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; m_To.X += vVector.X * (-(float)input.Mouse.Y / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; m_To.Z += vVector.Z * (-input.Mouse.Y / DIVIDE) * fElapsedTime * DIVIDE * 0.15f; } return Matrix.LookAtLH(m_From, m_To, m_Up); }
public Form1() { //this.Size = new System.Drawing.Size(1280, 1024); this.Text = "GalaxySmash"; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); this.WindowState = FormWindowState.Maximized; _presentParams = new PresentParameters(); _presentParams.Windowed = true; _presentParams.SwapEffect = SwapEffect.Discard; _device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, _presentParams); _input = new Input(); _input.Init(this); _universalRemote = new UniversalRemote(); // _universalRemote.Show(); }