/// <summary> /// Copies all settings to another token. /// </summary> protected PersistentSettings(PersistentSettings other) : base(other) { BrushSize = other.BrushSize; BrushName = other.BrushName; BrushRotation = other.BrushRotation; BrushAlpha = other.BrushAlpha; BrushColor = other.BrushColor; RandMaxAlpha = other.RandMaxAlpha; RandMinAlpha = other.RandMinAlpha; RandMaxSize = other.RandMaxSize; RandMinSize = other.RandMinSize; RandRotLeft = other.RandRotLeft; RandRotRight = other.RandRotRight; RandHorzShift = other.RandHorzShift; RandVertShift = other.RandVertShift; DoRotateWithMouse = other.DoRotateWithMouse; DoColorizeBrush = other.DoColorizeBrush; DoLockAlpha = other.DoLockAlpha; MinDrawDistance = other.MinDrawDistance; RandMaxR = other.RandMaxR; RandMaxG = other.RandMaxG; RandMaxB = other.RandMaxB; RandMinR = other.RandMinR; RandMinG = other.RandMinG; RandMinB = other.RandMinB; SizeChange = other.SizeChange; RotChange = other.RotChange; AlphaChange = other.AlphaChange; Symmetry = other.Symmetry; CustomBrushLocations = new HashSet <string>( other.CustomBrushLocations, other.CustomBrushLocations.Comparer); }
/// <summary> /// Creates a new settings token. /// </summary> public PersistentSettings() { BrushSize = 20; BrushName = string.Empty; BrushRotation = 0; BrushAlpha = 0; BrushColor = UserSettings.userPrimaryColor; RandMaxAlpha = 0; RandMinAlpha = 0; RandMaxSize = 0; RandMinSize = 0; RandRotLeft = 0; RandRotRight = 0; RandHorzShift = 0; RandVertShift = 0; DoRotateWithMouse = false; DoColorizeBrush = true; DoLockAlpha = false; MinDrawDistance = 0; RandMaxR = 0; RandMaxG = 0; RandMaxB = 0; RandMinR = 0; RandMinG = 0; RandMinB = 0; SizeChange = 0; RotChange = 0; AlphaChange = 0; Symmetry = SymmetryMode.None; CustomBrushLocations = new HashSet <string>(); }
// symmetry mode is used by code to determine axis of symmetry public void ToggleSymmetryMode() { symmetryMode = (SymmetryMode)((int)++symmetryMode % System.Enum.GetNames(typeof(SymmetryMode)).Length); if (symmetryButtonText) { symmetryButtonText.text = "SYMMETRY MODE: " + symmetryMode.ToString().ToUpper(); } }
public void SetSymmetryMode(SymmetryMode mode, bool recordCommand = true) { int active = m_NumActivePointers; switch (mode) { case SymmetryMode.None: active = 1; break; case SymmetryMode.SinglePlane: active = 2; break; case SymmetryMode.FourAroundY: active = 4; break; case SymmetryMode.DebugMultiple: active = DEBUG_MULTIPLE_NUM_POINTERS; break; } int maxUserPointers = m_Pointers.Length; if (active > maxUserPointers) { throw new System.ArgumentException("Not enough pointers for mode"); } m_CurrentSymmetryMode = mode; m_NumActivePointers = active; m_SymmetryWidgetScript.SetMode(m_CurrentSymmetryMode); m_SymmetryWidgetScript.Show(m_UseSymmetryWidget && SymmetryModeEnabled); if (recordCommand) { SketchMemoryScript.m_Instance.RecordCommand( new SymmetryWidgetVisibleCommand(m_SymmetryWidgetScript)); } for (int i = 1; i < m_Pointers.Length; ++i) { var pointer = m_Pointers[i]; bool enabled = i < m_NumActivePointers; pointer.m_UiEnabled = enabled; pointer.m_Script.gameObject.SetActive(enabled); pointer.m_Script.EnableRendering(m_PointersRenderingActive && enabled); if (enabled) { pointer.m_Script.CopyInternals(m_Pointers[0].m_Script); } } App.Switchboard.TriggerMirrorVisibilityChanged(); }
// flips the x/y value of the passed vector based on passed symmetry mode private Vector2 GetSymmetrizedVector(Vector2 vec, SymmetryMode mode) { switch (mode) { case SymmetryMode.X: return(new Vector2(-vec.x, vec.y)); case SymmetryMode.Y: return(new Vector2(vec.x, -vec.y)); default: return(vec); } }
public void updateVariables() { if (m_toggleRandom.isOn) m_eSymmetryMode = (SymmetryMode)Random.Range(0, (int)SymmetryMode.COUNT); else if (m_toggleAny.isOn) m_eSymmetryMode = (SymmetryMode)Random.Range(1, (int)SymmetryMode.COUNT); else if (m_toggleNo.isOn) m_eSymmetryMode = SymmetryMode.no; else if (m_toggleHorizontal.isOn) m_eSymmetryMode = SymmetryMode.horizontal; else if (m_toggleVertical.isOn) m_eSymmetryMode = SymmetryMode.vertical; else if (m_toggleCenter.isOn) m_eSymmetryMode = SymmetryMode.center; else if (m_togglePoint.isOn) m_eSymmetryMode = SymmetryMode.point; Debug.Log(m_eSymmetryMode); }
private static WireframeData Parse(string file) { // Initialize variables List <IShape> shapes = new List <IShape>(); SymmetryMode sm = SymmetryMode.None; // Read data StreamReader sr = new StreamReader(file); int lineNr = 0; string line; while ((line = sr.ReadLine()) != null) { string l = line.Trim().ToLower(); lineNr++; try { if (string.IsNullOrEmpty(l) || l[0] == '#') { continue; } else if (l[0] == '@' && char.IsLetter(l[1])) { // Directive string directive = l.Substring(1, l.IndexOf(' ') - 1); string[] values = l.Substring(l.IndexOf(' ') + 1).Split(','); switch (directive) { case "sym": if (values.Length > 0) { if (values[0] == "x") { sm = SymmetryMode.X; } else if (values[0] == "y") { sm = SymmetryMode.Y; } else if (values[0] == "xy") { sm = SymmetryMode.XY; } else if (values[0] == "yx") { sm = SymmetryMode.XY; } else { throw new Exception("Unknown parameter type for Sym"); } } else { throw new Exception("Directive Sym requires one parameter!"); } break; } } else if (l[0] == 'r' && l[1] == ' ') { // Rectangle string[] tokens = l.Substring(2).Split(','); if (tokens.Length >= 4) { Color color = Color.Black; if (tokens.Length == 5) { color = GetColor(line); } string[] p1 = tokens[0].Trim().Split(' '); string[] p2 = tokens[1].Trim().Split(' '); string[] p3 = tokens[2].Trim().Split(' '); string[] p4 = tokens[3].Trim().Split(' '); if (p1.Length != 2 || p2.Length != 2 || p3.Length != 2 || p4.Length != 2) { throw new System.Exception("r: String must contain a pair of real values!"); } float p1x = float.Parse(p1[0].Replace('.', ',')); float p2x = float.Parse(p2[0].Replace('.', ',')); float p3x = float.Parse(p3[0].Replace('.', ',')); float p4x = float.Parse(p4[0].Replace('.', ',')); float p1y = float.Parse(p1[1].Replace('.', ',')); float p2y = float.Parse(p2[1].Replace('.', ',')); float p3y = float.Parse(p3[1].Replace('.', ',')); float p4y = float.Parse(p4[1].Replace('.', ',')); Line l1 = new Line(p1x, p1y, p2x, p2y, color); Line l2 = new Line(p2x, p2y, p3x, p3y, color); Line l3 = new Line(p3x, p3y, p4x, p4y, color); Line l4 = new Line(p4x, p4y, p1x, p1y, color); shapes.Add(new Rectangle(l1, l2, l3, l4)); } else { throw new Exception($"Not a valid rectangle. Format: r [x1] [y1], [x2] [y2], [x3] [y3], [x4] [y4] (, [color])"); } } else if (l[0] == 't' && l[1] == ' ') { // Triangle string[] tokens = l.Substring(2).Split(','); if (tokens.Length >= 3) { Color color = Color.Black; if (tokens.Length == 4) { color = GetColor(line); } string[] p1 = tokens[0].Trim().Split(' '); string[] p2 = tokens[1].Trim().Split(' '); string[] p3 = tokens[2].Trim().Split(' '); if (p1.Length != 2 || p2.Length != 2 || p3.Length != 2) { throw new Exception("t: String must contain a pair of real values!"); } float p1x = float.Parse(p1[0].Replace('.', ',')); float p2x = float.Parse(p2[0].Replace('.', ',')); float p3x = float.Parse(p3[0].Replace('.', ',')); float p1y = float.Parse(p1[1].Replace('.', ',')); float p2y = float.Parse(p2[1].Replace('.', ',')); float p3y = float.Parse(p3[1].Replace('.', ',')); Line l1 = new Line(p1x, p1y, p2x, p2y, color); Line l2 = new Line(p2x, p2y, p3x, p3y, color); Line l3 = new Line(p3x, p3y, p1x, p1y, color); shapes.Add(new Triangle(l1, l2, l3)); } else { throw new Exception($"Not a valid triangle. Format: t [x1] [y1], [x2] [y2], [x3] [y3] (, [color])"); } } else if (l[0] == 'l' && l[1] == ' ') { // Line string[] tokens = l.Substring(2).Split(','); if (tokens.Length >= 2) { Color color = Color.Black; if (tokens.Length == 3) { color = GetColor(line); } string[] p1 = tokens[0].Trim().Split(' '); string[] p2 = tokens[1].Trim().Split(' '); if (p1.Length != 2 || p2.Length != 2) { throw new Exception("l: String must contain a pair of real values!"); } float p1x = float.Parse(p1[0].Replace('.', ',')); float p2x = float.Parse(p2[0].Replace('.', ',')); float p1y = float.Parse(p1[1].Replace('.', ',')); float p2y = float.Parse(p2[1].Replace('.', ',')); shapes.Add(new Line(p1x, p1y, p2x, p2y, color)); } else { throw new Exception($"Not a valid line. Format: l [x1] [y1], [x2] [y2] (, [color])"); } } else { throw new Exception($"Unknown token: " + l); } } catch (Exception e) { Console.WriteLine($"[{lineNr}] {e.Message}"); } } return(new WireframeData(shapes.ToArray(), sm)); }
public WireframeData(IShape[] shapes, SymmetryMode symmetryMode) { Shapes = shapes; SymmetryMode = symmetryMode; }
public override void OnSymmetry(SymmetryMode mode, IPartScript originalPart, bool created) { UpdateTank(); }
public void Symmetry(Point orgin, SymmetryMode mode) { throw new NotImplementedException(); }