private CubeProductionScope SelectionScaleAndShift(SelectProduction selector, Quaternion rotation, Vector3 octant, ProductionAxis axis) { var s = rotation * Bounds.size; s[(int)axis] = selector.IsAbsolute ? selector.FaceBreadth : s[(int)axis] * selector.FaceBreadth; // after applying the rotation, we could have rotated into a negative space. so just abs it! s[0] = Mathf.Abs(s[0]); s[1] = Mathf.Abs(s[1]); s[2] = Mathf.Abs(s[2]); var offset = (Math.Abs((rotation * Bounds.size)[(int)axis]) - s[(int)axis]) / 2f; var c = Bounds.center - offset * (rotation * octant); if (s.x < 0f || s.y < 0f || s.z < 0f) { Debug.Log("Selecting to a negative size..."); } return(new CubeProductionScope(new Bounds(c, s), rotation)); }
/// <summary> /// /// </summary> /// <param name="selector"></param> /// <returns></returns> public override ProductionScope[] Select(SelectProduction selector) { var selectandScopes = new List <ProductionScope>(); if (selector.Faces.Contains(ScopeFace.Front)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation * Quaternion.identity, new Vector3(1, 0, 0), ProductionAxis.X)); } if (selector.Faces.Contains(ScopeFace.Back)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation * Quaternion.AngleAxis(180, Vector3.up), new Vector3(1, 0, 0), ProductionAxis.X)); } if (selector.Faces.Contains(ScopeFace.Left)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation * Quaternion.AngleAxis(90, Vector3.up), new Vector3(1, 0, 0), ProductionAxis.X)); } if (selector.Faces.Contains(ScopeFace.Right)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation * Quaternion.AngleAxis(-90, Vector3.up), new Vector3(1, 0, 0), ProductionAxis.X)); } if (selector.Faces.Contains(ScopeFace.Top)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation * Quaternion.identity, new Vector3(0, -1, 0), ProductionAxis.Y)); } if (selector.Faces.Contains(ScopeFace.Bottom)) { selectandScopes.Add(SelectionScaleAndShift(selector, Rotation, new Vector3(0, 1, 0), ProductionAxis.Y)); } return(selectandScopes.ToArray()); }
public override ProductionScope[] Select(SelectProduction selector) { throw new NotImplementedException(); }
public abstract ProductionScope[] Select(SelectProduction selector);