Пример #1
0
			public void MovePrimitives(IEnumerable<IEditorPrimitive> primitives, Vector2 move2d, Camera camera, TransformToolMode mode)
			{
				Vector2 v1proj = camera.ProjectPoint(V1);
				Vector2 v2proj = camera.ProjectPoint(V1 + AxisVector[axis]);

				Vector2 dir = (v2proj - v1proj);

				float l = dir.Normalize();
				float amount = (dir.Dot(move2d)) / l;
				
				Vector3 translation = new Vector3();
				Vector3 scale = new Vector3(1,1,1);
				Vector3 euler = new Vector3();

				if (mode == TransformToolMode.Move)
					translation = amount * AxisVector[axis];
				else if (mode == TransformToolMode.Rotate)
					euler = AxisVector[axis] * (amount * 0.1f);
				else if (mode == TransformToolMode.Scale)
					scale += AxisVector[axis] * amount * 0.1f;

				Transformer transformer = new Transformer()
					{ euler =euler, translation = translation, scale = scale };

				// Get vertices
				foreach (ISceneEditor se in Program.SceneManager.SceneEditors)
					se.TransformSelection (primitives, transformer);
			}