Browse Source

Rotate handle arcs are now properly positioned

Marko Pintera 11 years ago
parent
commit
450b8a27a4

+ 4 - 9
BansheeEditor/Source/BsHandleSliderDisc.cpp

@@ -121,15 +121,9 @@ namespace BansheeEngine
 
 
 	Degree HandleSliderDisc::pointOnCircleToAngle(Vector3 up, Vector3 point)
 	Degree HandleSliderDisc::pointOnCircleToAngle(Vector3 up, Vector3 point)
 	{
 	{
-		Vector3 arcBasis[3];
-		arcBasis[1] = up;
-		arcBasis[1].orthogonalComplement(arcBasis[2], arcBasis[0]);
-
-		Matrix4 worldToPlane = Matrix4::IDENTITY;
-		worldToPlane.setColumn(0, (Vector4)arcBasis[0]);
-		worldToPlane.setColumn(1, (Vector4)arcBasis[1]);
-		worldToPlane.setColumn(2, (Vector4)arcBasis[2]);
+		Quaternion rot = Quaternion::getRotationFromTo(up, Vector3::UNIT_Y);
 
 
+		Matrix4 worldToPlane = Matrix4::TRS(Vector3::ZERO, rot, Vector3::ONE);
 		point = worldToPlane.multiplyAffine(point);
 		point = worldToPlane.multiplyAffine(point);
 
 
 		return Radian(Math::atan2(-point.z, -point.x) + Math::PI);
 		return Radian(Math::atan2(-point.z, -point.x) + Math::PI);
@@ -144,7 +138,8 @@ namespace BansheeEngine
 		mStartAngle = pointOnCircleToAngle(mNormal, mStartPosition);
 		mStartAngle = pointOnCircleToAngle(mNormal, mStartPosition);
 		mStartPosition = getTransform().multiplyAffine(mStartPosition);
 		mStartPosition = getTransform().multiplyAffine(mStartPosition);
 
 
-		mDirection = mNormal.cross(mStartPosition - getPosition());
+		Vector3 toStart = mStartPosition - getPosition();
+		mDirection = toStart.cross(mNormal);
 		mDirection.normalize();
 		mDirection.normalize();
 	}
 	}
 
 

+ 4 - 10
BansheeEngine/Source/BsShapeMeshes3D.cpp

@@ -967,22 +967,16 @@ namespace BansheeEngine
 	{
 	{
 		assert(numVertices >= 2);
 		assert(numVertices >= 2);
 
 
-		Vector3 normalizedUp = Vector3::normalize(up);
-		Vector3 right;
-
-		if (Math::abs(normalizedUp.dot(Vector3::UNIT_Z)) <= 0.95f)
-			right = Vector3::UNIT_Z.cross(normalizedUp);
-		else
-			right = Vector3::UNIT_Y.cross(normalizedUp);
+		Quaternion alignWithStart = Quaternion(-Vector3::UNIT_Y, startAngle);
+		Quaternion alignWithUp = Quaternion::getRotationFromTo(Vector3::UNIT_Y, up);
 
 
+		Vector3 right = alignWithUp.rotate(alignWithStart.rotate(Vector3::UNIT_X));
 		right.normalize();
 		right.normalize();
-		Quaternion moveToStart(-up, startAngle);
-		Vector3 start = moveToStart.rotate(right);
 
 
 		Quaternion increment(-up, angleAmount / (float)(numVertices - 1));
 		Quaternion increment(-up, angleAmount / (float)(numVertices - 1));
 
 
 		outVertices += vertexOffset * vertexStride;
 		outVertices += vertexOffset * vertexStride;
-		Vector3 curDirection = start * radius;
+		Vector3 curDirection = right * radius;
 		for (UINT32 i = 0; i < numVertices; i++)
 		for (UINT32 i = 0; i < numVertices; i++)
 		{
 		{
 			outVertices = writeVector3(outVertices, vertexStride, center + curDirection);
 			outVertices = writeVector3(outVertices, vertexStride, center + curDirection);

+ 2 - 2
MBansheeEditor/DebugCameraHandle.cs

@@ -31,9 +31,9 @@ namespace BansheeEditor
             Vector3 end = target.sceneObject.Position + Vector3.xAxis * 5;
             Vector3 end = target.sceneObject.Position + Vector3.xAxis * 5;
 
 
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else
             else
-                HandleDrawing.SetColor(Color.green);
+                HandleDrawing.SetColor(Color.Green);
 
 
             HandleDrawing.DrawLine(target.sceneObject.Position, end);
             HandleDrawing.DrawLine(target.sceneObject.Position, end);
         }
         }

+ 21 - 21
MBansheeEditor/Scene/MoveHandle.cs

@@ -103,33 +103,33 @@ namespace BansheeEditor
             Color axisHover = new Color(0.8f, 0.8f, 0.8f, 1.0f);
             Color axisHover = new Color(0.8f, 0.8f, 0.8f, 1.0f);
 
 
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if(xAxis.State == HandleSlider.StateType.Hover)
             else if(xAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.red * axisHover);
+                HandleDrawing.SetColor(Color.Red * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.red);
+                HandleDrawing.SetColor(Color.Red);
 
 
             Vector3 xConeStart = Vector3.xAxis*(1.0f - CONE_HEIGHT);
             Vector3 xConeStart = Vector3.xAxis*(1.0f - CONE_HEIGHT);
             HandleDrawing.DrawLine(Vector3.zero, xConeStart, handleSize);
             HandleDrawing.DrawLine(Vector3.zero, xConeStart, handleSize);
             HandleDrawing.DrawCone(xConeStart, Vector3.xAxis, CONE_HEIGHT, CONE_RADIUS, handleSize);
             HandleDrawing.DrawCone(xConeStart, Vector3.xAxis, CONE_HEIGHT, CONE_RADIUS, handleSize);
 
 
             if (yAxis.State == HandleSlider.StateType.Active)
             if (yAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if (yAxis.State == HandleSlider.StateType.Hover)
             else if (yAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.green * axisHover);
+                HandleDrawing.SetColor(Color.Green * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.green);
+                HandleDrawing.SetColor(Color.Green);
 
 
             Vector3 yConeStart = Vector3.yAxis * (1.0f - CONE_HEIGHT);
             Vector3 yConeStart = Vector3.yAxis * (1.0f - CONE_HEIGHT);
             HandleDrawing.DrawLine(Vector3.zero, yConeStart, handleSize);
             HandleDrawing.DrawLine(Vector3.zero, yConeStart, handleSize);
             HandleDrawing.DrawCone(yConeStart, Vector3.yAxis, CONE_HEIGHT, CONE_RADIUS, handleSize);
             HandleDrawing.DrawCone(yConeStart, Vector3.yAxis, CONE_HEIGHT, CONE_RADIUS, handleSize);
 
 
             if (zAxis.State == HandleSlider.StateType.Active)
             if (zAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if (zAxis.State == HandleSlider.StateType.Hover)
             else if (zAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.blue * axisHover);
+                HandleDrawing.SetColor(Color.Blue * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.blue);
+                HandleDrawing.SetColor(Color.Blue);
 
 
             Vector3 zConeStart = Vector3.zAxis * (1.0f - CONE_HEIGHT);
             Vector3 zConeStart = Vector3.zAxis * (1.0f - CONE_HEIGHT);
             HandleDrawing.DrawLine(Vector3.zero, zConeStart, handleSize);
             HandleDrawing.DrawLine(Vector3.zero, zConeStart, handleSize);
@@ -145,17 +145,17 @@ namespace BansheeEditor
             Vector3 planeZOffset = Vector3.zAxis * 0.3f;
             Vector3 planeZOffset = Vector3.zAxis * 0.3f;
 
 
             //// XY plane
             //// XY plane
-            HandleDrawing.SetColor(Color.blue);
+            HandleDrawing.SetColor(Color.Blue);
 
 
             HandleDrawing.DrawLine(planeXOffset, planeXOffset + planeYOffset, handleSize);
             HandleDrawing.DrawLine(planeXOffset, planeXOffset + planeYOffset, handleSize);
             HandleDrawing.DrawLine(planeYOffset, planeYOffset + planeXOffset, handleSize);
             HandleDrawing.DrawLine(planeYOffset, planeYOffset + planeXOffset, handleSize);
 
 
             if (xyPlane.State == HandleSlider.StateType.Active)
             if (xyPlane.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.blue * planeActive);
+                HandleDrawing.SetColor(Color.Blue * planeActive);
             else if (xyPlane.State == HandleSlider.StateType.Hover)
             else if (xyPlane.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.blue * planeHover);
+                HandleDrawing.SetColor(Color.Blue * planeHover);
             else
             else
-                HandleDrawing.SetColor(Color.blue * planeNormal);
+                HandleDrawing.SetColor(Color.Blue * planeNormal);
 
 
             Rect3 xyPlaneArea = new Rect3(
             Rect3 xyPlaneArea = new Rect3(
                 (planeXOffset + planeYOffset) * 0.5f,
                 (planeXOffset + planeYOffset) * 0.5f,
@@ -164,17 +164,17 @@ namespace BansheeEditor
             HandleDrawing.DrawRect(xyPlaneArea, handleSize);
             HandleDrawing.DrawRect(xyPlaneArea, handleSize);
 
 
             //// YZ plane
             //// YZ plane
-            HandleDrawing.SetColor(Color.red);
+            HandleDrawing.SetColor(Color.Red);
 
 
             HandleDrawing.DrawLine(planeYOffset, planeYOffset + planeZOffset, handleSize);
             HandleDrawing.DrawLine(planeYOffset, planeYOffset + planeZOffset, handleSize);
             HandleDrawing.DrawLine(planeZOffset, planeZOffset + planeYOffset, handleSize);
             HandleDrawing.DrawLine(planeZOffset, planeZOffset + planeYOffset, handleSize);
 
 
             if (yzPlane.State == HandleSlider.StateType.Active)
             if (yzPlane.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.red * planeActive);
+                HandleDrawing.SetColor(Color.Red * planeActive);
             else if (yzPlane.State == HandleSlider.StateType.Hover)
             else if (yzPlane.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.red * planeHover);
+                HandleDrawing.SetColor(Color.Red * planeHover);
             else
             else
-                HandleDrawing.SetColor(Color.red * planeNormal);
+                HandleDrawing.SetColor(Color.Red * planeNormal);
 
 
             Rect3 yzPlaneArea = new Rect3(
             Rect3 yzPlaneArea = new Rect3(
                 (planeYOffset + planeZOffset) * 0.5f,
                 (planeYOffset + planeZOffset) * 0.5f,
@@ -184,17 +184,17 @@ namespace BansheeEditor
             HandleDrawing.DrawRect(yzPlaneArea, handleSize);
             HandleDrawing.DrawRect(yzPlaneArea, handleSize);
 
 
             //// ZX plane
             //// ZX plane
-            HandleDrawing.SetColor(Color.green);
+            HandleDrawing.SetColor(Color.Green);
 
 
             HandleDrawing.DrawLine(planeZOffset, planeZOffset + planeXOffset, handleSize);
             HandleDrawing.DrawLine(planeZOffset, planeZOffset + planeXOffset, handleSize);
             HandleDrawing.DrawLine(planeXOffset, planeXOffset + planeZOffset, handleSize);
             HandleDrawing.DrawLine(planeXOffset, planeXOffset + planeZOffset, handleSize);
 
 
             if (zxPlane.State == HandleSlider.StateType.Active)
             if (zxPlane.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.green * planeActive);
+                HandleDrawing.SetColor(Color.Green * planeActive);
             else if (zxPlane.State == HandleSlider.StateType.Hover)
             else if (zxPlane.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.green * planeHover);
+                HandleDrawing.SetColor(Color.Green * planeHover);
             else
             else
-                HandleDrawing.SetColor(Color.green * planeNormal);
+                HandleDrawing.SetColor(Color.Green * planeNormal);
 
 
             Rect3 zxPlaneArea = new Rect3(
             Rect3 zxPlaneArea = new Rect3(
                 (planeZOffset + planeXOffset) * 0.5f,
                 (planeZOffset + planeXOffset) * 0.5f,

+ 45 - 60
MBansheeEditor/Scene/RotateHandle.cs

@@ -17,28 +17,23 @@ namespace BansheeEditor
 
 
         internal override bool IsDragged()
         internal override bool IsDragged()
         {
         {
-            return xAxis.State == HandleSlider.StateType.Active;
-            //return xAxis.State == HandleSlider.StateType.Active ||
-            //        yAxis.State == HandleSlider.StateType.Active ||
-            //        zAxis.State == HandleSlider.StateType.Active;
+            return xAxis.State == HandleSlider.StateType.Active ||
+                    yAxis.State == HandleSlider.StateType.Active ||
+                    zAxis.State == HandleSlider.StateType.Active;
         }
         }
 
 
         public RotateHandle()
         public RotateHandle()
         {
         {
             xAxis = new HandleSliderDisc(this, Vector3.xAxis, 1.0f);
             xAxis = new HandleSliderDisc(this, Vector3.xAxis, 1.0f);
-            //yAxis = new HandleSliderDisc(this, Vector3.yAxis, 1.0f);
-            //zAxis = new HandleSliderDisc(this, Vector3.zAxis, 1.0f);
+            yAxis = new HandleSliderDisc(this, Vector3.yAxis, 1.0f);
+            zAxis = new HandleSliderDisc(this, Vector3.zAxis, 1.0f);
         }
         }
 
 
         protected override void PreInput()
         protected override void PreInput()
         {
         {
             xAxis.Position = position;
             xAxis.Position = position;
-           // yAxis.Position = position;
-            //zAxis.Position = position;
-
-            xAxis.Rotation = rotation;
-            //yAxis.Rotation = rotation;
-            //zAxis.Rotation = rotation;
+            yAxis.Position = position;
+            zAxis.Position = position;
         }
         }
 
 
         protected override void PostInput()
         protected override void PostInput()
@@ -52,66 +47,62 @@ namespace BansheeEditor
             if (Handles.RotateHandleSnapActive)
             if (Handles.RotateHandleSnapActive)
             {
             {
                 xValue = Handles.SnapValue(xAxis.Delta, Handles.RotateSnapAmount);
                 xValue = Handles.SnapValue(xAxis.Delta, Handles.RotateSnapAmount);
-                //yValue = Handles.SnapValue(yAxis.Delta, Handles.RotateSnapAmount);
-                //zValue = Handles.SnapValue(zAxis.Delta, Handles.RotateSnapAmount);
+                yValue = Handles.SnapValue(yAxis.Delta, Handles.RotateSnapAmount);
+                zValue = Handles.SnapValue(zAxis.Delta, Handles.RotateSnapAmount);
             }
             }
             else
             else
             {
             {
                 xValue = xAxis.Delta;
                 xValue = xAxis.Delta;
-                //yValue = yAxis.Delta;
-               // zValue = zAxis.Delta;
+                yValue = yAxis.Delta;
+                zValue = zAxis.Delta;
             }
             }
 
 
             delta = Quaternion.FromAxisAngle(GetXDir(), xValue) * delta;
             delta = Quaternion.FromAxisAngle(GetXDir(), xValue) * delta;
-           // delta = Quaternion.FromAxisAngle(GetYDir(), yValue) * delta;
-           // delta = Quaternion.FromAxisAngle(GetZDir(), zValue) * delta;
+            delta = Quaternion.FromAxisAngle(GetYDir(), yValue) * delta;
+            delta = Quaternion.FromAxisAngle(GetZDir(), zValue) * delta;
         }
         }
 
 
         protected override void Draw()
         protected override void Draw()
         {
         {
-            HandleDrawing.SetTransform(Matrix4.TRS(Position, Rotation, Vector3.one));
+            HandleDrawing.SetTransform(Matrix4.TRS(Position, Quaternion.identity, Vector3.one));
             float handleSize = Handles.GetHandleSize(EditorApplication.SceneViewCamera, position);
             float handleSize = Handles.GetHandleSize(EditorApplication.SceneViewCamera, position);
 
 
             // Draw arcs
             // Draw arcs
-            Color axisHover = new Color(0.8f, 0.8f, 0.8f, 1.0f);
-
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if(xAxis.State == HandleSlider.StateType.Hover)
             else if(xAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.red * axisHover);
+                HandleDrawing.SetColor(Color.BansheeOrange);
             else
             else
-                HandleDrawing.SetColor(Color.red);
+                HandleDrawing.SetColor(Color.Red);
 
 
             Vector3 xStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetXDir());
             Vector3 xStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetXDir());
             Degree xStartAngle = PointOnCircleToAngle(GetXDir(), xStartDir);
             Degree xStartAngle = PointOnCircleToAngle(GetXDir(), xStartDir);
 
 
-            Debug.Log("START ARC: " + xStartDir + " -- " + xStartAngle);
-
             HandleDrawing.DrawWireArc(Vector3.zero, GetXDir(), 1.0f, xStartAngle, 180.0f, handleSize);
             HandleDrawing.DrawWireArc(Vector3.zero, GetXDir(), 1.0f, xStartAngle, 180.0f, handleSize);
 
 
-            //if (yAxis.State == HandleSlider.StateType.Active)
-            //    HandleDrawing.SetColor(Color.white);
-            //else if (yAxis.State == HandleSlider.StateType.Hover)
-            //    HandleDrawing.SetColor(Color.green * axisHover);
-            //else
-            //    HandleDrawing.SetColor(Color.green);
+            if (yAxis.State == HandleSlider.StateType.Active)
+                HandleDrawing.SetColor(Color.White);
+            else if (yAxis.State == HandleSlider.StateType.Hover)
+                HandleDrawing.SetColor(Color.BansheeOrange);
+            else
+                HandleDrawing.SetColor(Color.Green);
 
 
-            //Vector3 yStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetYDir());
-            //Degree yStartAngle = PointOnCircleToAngle(GetYDir(), yStartDir);
+            Vector3 yStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetYDir());
+            Degree yStartAngle = PointOnCircleToAngle(GetYDir(), yStartDir);
 
 
-            //HandleDrawing.DrawWireArc(Vector3.zero, GetYDir(), 1.0f, yStartAngle, 180.0f, handleSize);
+            HandleDrawing.DrawWireArc(Vector3.zero, GetYDir(), 1.0f, yStartAngle, 180.0f, handleSize);
 
 
-            //if (zAxis.State == HandleSlider.StateType.Active)
-            //    HandleDrawing.SetColor(Color.white);
-            //else if (zAxis.State == HandleSlider.StateType.Hover)
-            //    HandleDrawing.SetColor(Color.blue * axisHover);
-            //else
-            //    HandleDrawing.SetColor(Color.blue);
+            if (zAxis.State == HandleSlider.StateType.Active)
+                HandleDrawing.SetColor(Color.White);
+            else if (zAxis.State == HandleSlider.StateType.Hover)
+                HandleDrawing.SetColor(Color.BansheeOrange);
+            else
+                HandleDrawing.SetColor(Color.Blue);
 
 
-            //Vector3 zStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, -GetZDir());
-            //Degree zStartAngle = PointOnCircleToAngle(-GetZDir(), zStartDir);
+            Vector3 zStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetZDir());
+            Degree zStartAngle = PointOnCircleToAngle(GetZDir(), zStartDir);
 
 
-            //HandleDrawing.DrawWireArc(Vector3.zero, -GetZDir(), 1.0f, zStartAngle, 180.0f, handleSize);
+            HandleDrawing.DrawWireArc(Vector3.zero, GetZDir(), 1.0f, zStartAngle, 180.0f, handleSize);
 
 
             // Draw active rotation pie
             // Draw active rotation pie
             Color gray = new Color(1.0f, 1.0f, 1.0f, 0.3f);
             Color gray = new Color(1.0f, 1.0f, 1.0f, 0.3f);
@@ -119,41 +110,35 @@ namespace BansheeEditor
 
 
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
                 HandleDrawing.DrawArc(Vector3.zero, GetXDir(), 1.0f, xAxis.StartAngle, xAxis.Delta, handleSize);
                 HandleDrawing.DrawArc(Vector3.zero, GetXDir(), 1.0f, xAxis.StartAngle, xAxis.Delta, handleSize);
-            //else if (yAxis.State == HandleSlider.StateType.Active)
-            //    HandleDrawing.DrawArc(Vector3.zero, GetYDir(), 1.0f, yAxis.StartAngle, yAxis.Delta, handleSize);
-            //else if (zAxis.State == HandleSlider.StateType.Active)
-            //    HandleDrawing.DrawArc(Vector3.zero, -GetZDir(), 1.0f, zAxis.StartAngle, zAxis.Delta, handleSize);
+            else if (yAxis.State == HandleSlider.StateType.Active)
+                HandleDrawing.DrawArc(Vector3.zero, GetYDir(), 1.0f, yAxis.StartAngle, yAxis.Delta, handleSize);
+            else if (zAxis.State == HandleSlider.StateType.Active)
+                HandleDrawing.DrawArc(Vector3.zero, GetZDir(), 1.0f, zAxis.StartAngle, zAxis.Delta, handleSize);
 
 
             // TODO - Free rotate handle
             // TODO - Free rotate handle
         }
         }
 
 
         private Vector3 GetXDir()
         private Vector3 GetXDir()
         {
         {
-             return rotation.Rotate(Vector3.xAxis);
+             return Vector3.xAxis;
         }
         }
 
 
         private Vector3 GetYDir()
         private Vector3 GetYDir()
         {
         {
-            return rotation.Rotate(Vector3.yAxis);
+            return Vector3.yAxis;
         }
         }
 
 
         private Vector3 GetZDir()
         private Vector3 GetZDir()
         {
         {
-            return rotation.Rotate(Vector3.zAxis);
+            return Vector3.zAxis;
         }
         }
 
 
         private Degree PointOnCircleToAngle(Vector3 up, Vector3 point)
         private Degree PointOnCircleToAngle(Vector3 up, Vector3 point)
         {
         {
-            Vector3[] arcBasis = new Vector3[3];
-            arcBasis[1] = up;
-            Vector3.OrthogonalComplement(arcBasis[1], out arcBasis[2], out arcBasis[0]);
-
-            Matrix4 worldToPlane = Matrix4.identity;
-            worldToPlane.SetColumn(0, (Vector4)arcBasis[0]);
-            worldToPlane.SetColumn(1, (Vector4)arcBasis[1]);
-            worldToPlane.SetColumn(2, (Vector4)arcBasis[2]);
+            Quaternion rot = Quaternion.FromToRotation(up, Vector3.yAxis);
 
 
-            point = worldToPlane.Multiply(point);
+            Matrix4 worldToPlane = Matrix4.TRS(Vector3.zero, rot, Vector3.one);
+            point = worldToPlane.MultiplyAffine(point);
 
 
             return (MathEx.Atan2(-point.z, -point.x) + MathEx.Pi) * MathEx.Rad2Deg;
             return (MathEx.Atan2(-point.z, -point.x) + MathEx.Pi) * MathEx.Rad2Deg;
         }
         }

+ 9 - 9
MBansheeEditor/Scene/ScaleHandle.cs

@@ -62,11 +62,11 @@ namespace BansheeEditor
             Color axisHover = new Color(0.8f, 0.8f, 0.8f, 1.0f);
             Color axisHover = new Color(0.8f, 0.8f, 0.8f, 1.0f);
 
 
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if (xAxis.State == HandleSlider.StateType.Hover)
             else if (xAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.red * axisHover);
+                HandleDrawing.SetColor(Color.Red * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.red);
+                HandleDrawing.SetColor(Color.Red);
 
 
             Vector3 xCubeOffset = Vector3.xAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 xCubeOffset = Vector3.xAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 xCubeStart = Vector3.xAxis - xCubeOffset;
             Vector3 xCubeStart = Vector3.xAxis - xCubeOffset;
@@ -75,11 +75,11 @@ namespace BansheeEditor
             HandleDrawing.DrawCube(xCubeStart + xCubeOffset, smallCubeExtents, handleSize);
             HandleDrawing.DrawCube(xCubeStart + xCubeOffset, smallCubeExtents, handleSize);
 
 
             if (yAxis.State == HandleSlider.StateType.Active)
             if (yAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if (yAxis.State == HandleSlider.StateType.Hover)
             else if (yAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.green * axisHover);
+                HandleDrawing.SetColor(Color.Green * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.green);
+                HandleDrawing.SetColor(Color.Green);
 
 
             Vector3 yCubeOffset = Vector3.yAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 yCubeOffset = Vector3.yAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 yCubeStart = Vector3.yAxis - yCubeOffset;
             Vector3 yCubeStart = Vector3.yAxis - yCubeOffset;
@@ -88,11 +88,11 @@ namespace BansheeEditor
             HandleDrawing.DrawCube(yCubeStart + yCubeOffset, smallCubeExtents, handleSize);
             HandleDrawing.DrawCube(yCubeStart + yCubeOffset, smallCubeExtents, handleSize);
 
 
             if (zAxis.State == HandleSlider.StateType.Active)
             if (zAxis.State == HandleSlider.StateType.Active)
-                HandleDrawing.SetColor(Color.white);
+                HandleDrawing.SetColor(Color.White);
             else if (zAxis.State == HandleSlider.StateType.Hover)
             else if (zAxis.State == HandleSlider.StateType.Hover)
-                HandleDrawing.SetColor(Color.blue * axisHover);
+                HandleDrawing.SetColor(Color.Blue * axisHover);
             else
             else
-                HandleDrawing.SetColor(Color.blue);
+                HandleDrawing.SetColor(Color.Blue);
 
 
             Vector3 zCubeOffset = Vector3.zAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 zCubeOffset = Vector3.zAxis * SMALL_CUBE_SIZE * 0.5f;
             Vector3 zCubeStart = Vector3.zAxis - zCubeOffset;
             Vector3 zCubeStart = Vector3.zAxis - zCubeOffset;

+ 10 - 39
MBansheeEngine/Color.cs

@@ -11,45 +11,16 @@ namespace BansheeEngine
         public float b;
         public float b;
         public float a;
         public float a;
 
 
-        public static Color red
-        {
-            get
-            {
-                return new Color(1.0f, 0.0f, 0.0f, 1.0f);
-            }
-        }
-
-        public static Color green
-        {
-            get
-            {
-                return new Color(0.0f, 1.0f, 0.0f, 1.0f);
-            }
-        }
-
-        public static Color blue
-        {
-            get
-            {
-                return new Color(0.0f, 0.0f, 1.0f, 1.0f);
-            }
-        }
-
-        public static Color white
-        {
-            get
-            {
-                return new Color(1.0f, 1.0f, 1.0f, 1.0f);
-            }
-        }
-
-        public static Color black
-        {
-            get
-            {
-                return new Color(0.0f, 0.0f, 0.0f, 1.0f);
-            }
-        }
+        public static Color Red { get { return new Color(1.0f, 0.0f, 0.0f, 1.0f); } }
+        public static Color Green { get { return new Color(0.0f, 1.0f, 0.0f, 1.0f); } }
+        public static Color Blue { get { return new Color(0.0f, 0.0f, 1.0f, 1.0f); } }
+        public static Color Yellow { get { return new Color(1.0f, 1.0f, 0.0f, 1.0f); } }
+        public static Color Cyan { get { return new Color(0.0f, 1.0f, 1.0f, 1.0f); } }
+        public static Color Magenta { get { return new Color(1.0f, 0.0f, 1.0f, 1.0f); } }
+        public static Color White { get { return new Color(1.0f, 1.0f, 1.0f, 1.0f); } }
+        public static Color Black { get { return new Color(0.0f, 0.0f, 0.0f, 1.0f); } }
+
+        public static Color BansheeOrange { get { return new Color(1.0f, (168.0f/255.0f), 0.0f, 1.0f); } }
 
 
         public float this[int index]
         public float this[int index]
         {
         {

+ 3 - 6
TODO.txt

@@ -16,17 +16,14 @@ Add free scale handle
 
 
 Rotate handle:
 Rotate handle:
  - Transparent angle start is at the wrong position
  - Transparent angle start is at the wrong position
- - Red arc is on the wrong side when viewed from above
+ - Selecting the top right quadrant of the blue disc doesn't seem to work
  - Missing two free rotate arcs
  - Missing two free rotate arcs
+ - How to handle local/global with rotate handle?
+
 
 
 Cursor wrap only works when cursor moves really slowly over the border, and even then it's spotty
 Cursor wrap only works when cursor moves really slowly over the border, and even then it's spotty
 When changing handle types they do not refresh until you click on the scene view
 When changing handle types they do not refresh until you click on the scene view
 
 
-The first time I mouse over a GUI button it flashes for a frame as if it has no texture
- - It seems that the ParamBlockBuffer for the vertex shader gets updated one frame too late
- - First frame it is set to all zeroes, but fragment data seems valid (both the param block and texture/sampler)
- - Then syncToCore() happens next frame and data is updated.
-
 <<<<Multi-resource saving>>>>:
 <<<<Multi-resource saving>>>>:
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Register it in its meta file
  - Register it in its meta file