From 60e38e67718890d4a64cf4009cf66597abd3f4d1 Mon Sep 17 00:00:00 2001 From: Dabinn Date: Thu, 12 Mar 2020 10:44:37 +0800 Subject: [PATCH] Keep Model Upright when Rotating --- open3mod/OrbitCameraController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/open3mod/OrbitCameraController.cs b/open3mod/OrbitCameraController.cs index f083acc..2e500b5 100644 --- a/open3mod/OrbitCameraController.cs +++ b/open3mod/OrbitCameraController.cs @@ -96,7 +96,11 @@ public void MouseMove(int x, int y) if (x != 0) { - _view *= Matrix4.CreateFromAxisAngle(_up, (float)(x * RotationSpeed * Math.PI / 180.0)); + // Free Orbit + //_view *= Matrix4.CreateFromAxisAngle(_up, (float)(x * RotationSpeed * Math.PI / 180.0)); + + // Constrained Orbit: Keep Model Upright when Rotating + _view *= Matrix4.CreateFromAxisAngle(Matrix4.Invert(_view).Column1.Xyz, (float)(x * RotationSpeed * Math.PI / 180.0)); } if (y != 0)