public void Moving(MouseEventArgs e) { if (!enable) { return; } Camera camera = RayTracer.GetInstance().GetScene().GetActiveCamera(); if (m_isMouseHandleMoving) { int deltaX = e.X - m_mousePosX; int deltaY = e.Y - m_mousePosY; Vector3 right = camera.right; Vector3 up = camera.up; Vector3 pos = camera.position; pos = pos + up * kMouseMoveSpeed * deltaY - right * kMouseMoveSpeed * deltaX; camera.position = pos; m_mousePosX = e.X; m_mousePosY = e.Y; } else if (m_isMouseHandleRotating) { int deltaX = e.X - m_mousePosX; int deltaY = e.Y - m_mousePosY; Vector3 euler = camera.euler; euler.x -= kMouseRotateSpeed * deltaY; euler.y += kMouseRotateSpeed * deltaX; camera.euler = euler; m_mousePosX = e.X; m_mousePosY = e.Y; } }
private void OpenToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.Filter = "场景文件|*.scene"; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) { RayTracer.GetInstance().GetScene().CreateFromFile(openFileDialog.FileName); } }
public void Scalling(MouseEventArgs e) { if (!enable) { return; } if (e.Button == MouseButtons.None) { Camera camera = RayTracer.GetInstance().GetScene().GetActiveCamera(); Vector3 forward = camera.forward; Vector3 pos = camera.position; pos += forward * kMouseScallingSpeed * e.Delta; camera.position = pos; } }
private void NewToolStripMenuItem_Click(object sender, EventArgs e) { RayTracer.GetInstance().GetScene().Create(); }