private void ShowBoundaryElement(BoundarySettings element) { EditorGUILayout.BeginVertical("box"); { BoundaryType saveKind = element.Type; element.Type = (BoundaryType)EditorGUILayout.EnumPopup("Type Boundary:", element.Type); if (GUI.changed && saveKind != element.Type) { if (UsingType.Contains("bt_" + saveKind.ToString())) { UsingType.Remove("bt_" + saveKind.ToString()); } UsingType.Add("bt_" + element.Type.ToString()); } element.Material = (Material)EditorGUILayout.ObjectField("Material", element.Material, typeof(Material)); if (element.Material == null) { DisplayErrorMEssage("Not setting material"); } element.Width = EditorGUILayout.FloatField("Boundary Width", element.Width); } EditorGUILayout.EndVertical(); }
public BoundaryFactorySettings() { DefaultBoundary = new BoundarySettings() { Material = null, Type = BoundaryType.Unknown }; SettingsBoundary = new List <BoundarySettings>(); }
protected BoundarySettings createBoundarySettings(BoundaryType type, int width, string material) { var bs = new BoundarySettings(); bs.Type = type; bs.Material = (Material)Resources.Load(material, typeof(Material)); bs.Width = width; return(bs); }
private void CreateMesh(List <Vector3> list, BoundarySettings settings, MeshData md) { var vertsStartCount = md.Vertices.Count; Vector3 lastPos = Vector3.zero; var norm = Vector3.zero; for (int i = 1; i < list.Count; i++) { var p1 = list[i - 1]; var p2 = list[i]; var p3 = p2; if (i + 1 < list.Count) { p3 = list[i + 1]; } if (lastPos == Vector3.zero) { lastPos = Vector3.Lerp(p1, p2, 0f); norm = GetNormal(p1, lastPos, p2) * settings.Width; md.Vertices.Add(lastPos + norm); md.Vertices.Add(lastPos - norm); } lastPos = Vector3.Lerp(p1, p2, 1f); norm = GetNormal(p1, lastPos, p3) * settings.Width; md.Vertices.Add(lastPos + norm); md.Vertices.Add(lastPos - norm); } for (int j = vertsStartCount; j <= md.Vertices.Count - 3; j += 2) { var clock = Vector3.Cross(md.Vertices[j + 1] - md.Vertices[j], md.Vertices[j + 2] - md.Vertices[j + 1]); if (clock.y < 0) { md.Indices.Add(j); md.Indices.Add(j + 2); md.Indices.Add(j + 1); md.Indices.Add(j + 1); md.Indices.Add(j + 2); md.Indices.Add(j + 3); } else { md.Indices.Add(j + 1); md.Indices.Add(j + 2); md.Indices.Add(j); md.Indices.Add(j + 3); md.Indices.Add(j + 2); md.Indices.Add(j + 1); } } }
private static void SetProperties(JSONObject geo, Boundary boundary, BoundarySettings typeSettings) { boundary.name = "boundary " + geo["properties"]["id"].ToString(); if (geo["properties"].HasField("name")) { boundary.Name = geo["properties"]["name"].str; } boundary.Id = geo["properties"]["id"].ToString(); boundary.Type = geo["type"].str; boundary.SortKey = (int)geo["properties"]["sort_key"].f; boundary.Kind = geo["properties"]["kind"].str; boundary.GetComponent <MeshRenderer>().material = typeSettings.Material; }