Example #1
0
	bool MayaCamera::MouseDrag(int button, int x, int y, const ModifierKeys& mods)
	{
		if (mods.alt)
		{
			int dx = x - prevx;
			int dy = y - prevy;

			if (button == MOUSE_LEFT_BUTTON)
			{
				OrbitLeft(-dx * orbitSpeed);
				OrbitUp(dy * orbitSpeed);
			}
			else if (button == MOUSE_MIDDLE_BUTTON)
			{
				DollyLeft(dx * dollySpeed);
				DollyUp(dy * dollySpeed);
			}
			else if (button == MOUSE_RIGHT_BUTTON)
			{
				int val = (abs(dx) > abs(dy) ? dx : dy);
				Zoom(val * zoomSpeed);
			}

			prevx = x;
			prevy = y;
			return true;
		}
		return false;
	}
void ArcBallCameraController::RotateTargetUp(float angle_)
{
	m_bRecomputeViewMatrix = true;

	Quaternion rot;
	rot.FromAxisAngle(Right(), angle_);
	Vector3F dir = Direction() * m_fDistance;
	Vector3F vec;
	rot.Transform(dir, vec);
	//Vector3F::Transform(dir, rot, vec);
	m_Target += vec - dir;

	OrbitUp(-angle_);
}