public void SetMode(FTransformMode mode) { m_mode = mode; switch (mode) { case FTransformMode.Translation: m_deltaRotation = Quaternion.Identity; m_deltaScale = Vector3.One; break; case FTransformMode.Rotation: m_deltaTranslation = Vector3.Zero; m_deltaScale = Vector3.One; break; case FTransformMode.Scale: m_deltaTranslation = Vector3.Zero; m_deltaRotation = Quaternion.Identity; break; } }
private FAABox[] GetAABBBoundsForMode(FTransformMode mode) { switch (mode) { case FTransformMode.Translation: float boxLength = 100f; float boxHalfWidth = 5; var translationAABB = new[] { // X Axis new FAABox(new Vector3(0, -boxHalfWidth, -boxHalfWidth), new Vector3(boxLength, boxHalfWidth, boxHalfWidth)), // Y Axis new FAABox(new Vector3(-boxHalfWidth, 0, -boxHalfWidth), new Vector3(boxHalfWidth, boxLength, boxHalfWidth)), // Z Axis new FAABox(new Vector3(-boxHalfWidth, -boxHalfWidth, 0), new Vector3(boxHalfWidth, boxHalfWidth, boxLength)), // XY Axes new FAABox(new Vector3(0, 0, -2), new Vector3(boxHalfWidth * 6, boxHalfWidth * 6, 2)), // YZ Axes new FAABox(new Vector3(0, -2, 0), new Vector3(boxHalfWidth * 6, 2, boxHalfWidth * 6)), // XZ Axes new FAABox(new Vector3(-2, 0, 0), new Vector3(2, boxHalfWidth * 6, boxHalfWidth * 6)), }; for (int i = 0; i < translationAABB.Length; i++) { translationAABB[i].ScaleBy(m_scale); } return(translationAABB); case FTransformMode.Rotation: float radius = 100f; var rotationAABB = new[] { // X Axis (YZ Plane) new FAABox(new Vector3(-2, 0, 0), new Vector3(2, radius, radius)), // Y Axis (XZ Plane) new FAABox(new Vector3(0, -2, 0), new Vector3(radius, 2, radius)), // Z Axis (XY Plane) new FAABox(new Vector3(0, 0, -2), new Vector3(radius, radius, 2)), }; for (int i = 0; i < rotationAABB.Length; i++) { rotationAABB[i].ScaleBy(m_scale); } return(rotationAABB); case FTransformMode.Scale: float scaleLength = 100f; float scaleHalfWidth = 5; float scaleCornerSize = 38; var scaleAABB = new[] { // X Axis new FAABox(new Vector3(0, -scaleHalfWidth, -scaleHalfWidth), new Vector3(scaleLength, scaleHalfWidth, scaleHalfWidth)), // Y Axis new FAABox(new Vector3(-scaleHalfWidth, 0, -scaleHalfWidth), new Vector3(scaleHalfWidth, scaleLength, scaleHalfWidth)), // Z Axis new FAABox(new Vector3(-scaleHalfWidth, -scaleHalfWidth, 0), new Vector3(scaleHalfWidth, scaleHalfWidth, scaleLength)), // YX Axes new FAABox(new Vector3(0, 0, -2), new Vector3(scaleCornerSize, scaleCornerSize, 2)), // YZ Axes new FAABox(new Vector3(0, -2, 0), new Vector3(scaleCornerSize, 2, scaleCornerSize)), // XZ Axes new FAABox(new Vector3(-2, 0, 0), new Vector3(2, scaleCornerSize, scaleCornerSize)), // Center new FAABox(new Vector3(-7, -7, -7), new Vector3(7, 7, 7)) }; for (int i = 0; i < scaleAABB.Length; i++) { scaleAABB[i].ScaleBy(m_scale); } return(scaleAABB); } return(new FAABox[0]); }