public FormElement VertexForm(GeoVertex vertex) { string s = geometry.VertexSign(vertex.Id); FormElement formElement = new FormElement(1, new string[] { s }); return(formElement); }
public override void InitWithGeometry(Geometry geometry) { VertexUnit unit1 = geometry.VertexUnit(vertex.id); int count = face.ids.Length; VertexUnit[] faceUnits = new VertexUnit[count]; for (int i = 0; i < count; i++) { faceUnits[i] = geometry.VertexUnit(face.ids[i]); } VertexPlaneVertical unit2 = new VertexPlaneVertical(unit1, faceUnits); unit2.preferredSign = sign; geometry.VertexUnitSetId(unit2, 0); units = new VertexUnit[] { unit2 }; GizmoRight gizmoRight = new GizmoRight(vertex.id, unit2.id, faceUnits[0].id); gizmos = new Gizmo[] { gizmoRight }; GeoVertex geoVertex = new GeoVertex(unit2); GeoEdge geoEdge = new GeoEdge(unit1, unit2); elements = new GeoElement[] { geoVertex, geoEdge }; dependencies.AddRange(faceUnits); dependencies.Add(unit1); }
public override void InitWithGeometry(Geometry geometry) { VertexUnit unit1 = geometry.VertexUnit(vertex.id); VertexUnit unit2 = geometry.VertexUnit(edge.id1); VertexUnit unit3 = geometry.VertexUnit(edge.id2); VertexLineVertical unit4 = new VertexLineVertical(unit1, unit2, unit3); unit4.preferredSign = sign; geometry.VertexUnitSetId(unit4, 0); units = new VertexUnit[] { unit4 }; GizmoRight gizmoRight = new GizmoRight(vertex.id, unit4.id, edge.id2); gizmos = new Gizmo[] { gizmoRight }; GeoVertex geoVertex = new GeoVertex(unit4); GeoEdge geoEdge = new GeoEdge(unit1, unit4); elements = new GeoElement[] { geoVertex, geoEdge }; dependencies.Add(unit1); dependencies.Add(unit2); dependencies.Add(unit3); }
public void SetVertex(GeoVertex vertex) { element = vertex; ButtonBoard buttonBoard = InitRootButtonBoard(); List <ButtonAtRoot> buttonAtRoot = new List <ButtonAtRoot>(); buttonAtRoot.Add(ColorButton); buttonAtRoot.Add(StyleButton); buttonAtRoot.Add(DisplayButton); buttonAtRoot.Add(SignButton); if (!vertex.isBased) { buttonAtRoot.Add(DeleteButton); } if (vertex.isSpace) { buttonAtRoot.Add(CoordinateButton); } buttonBoard.CountOfButtons = () => buttonAtRoot.Count; buttonBoard.ButtonAtIndex = (button, i) => buttonAtRoot[i](button); buttonBoard.InitButtons(); overlay.SetActive(true); }
private void RemoveVertex(GeoVertex geoVertex) { VertexBehaviour vertexBehaviour = vertexMap[geoVertex]; Destroy(vertexBehaviour.gameObject); vertexMap.Remove(geoVertex); }
public Vector3 VertexCenterDirection(GeoVertex vertex) { Vector3 v = UnitVector(vertex.Id); v = v - center; return(v.normalized); }
public override void InitWithGeometry(Geometry geometry) { VertexUnit unit1 = geometry.VertexUnit(edge.id1); VertexUnit unit2 = geometry.VertexUnit(edge.id2); VertexLine unit3 = new VertexLine(unit1, unit2, ratio); unit3.preferredSign = sign; geometry.VertexUnitSetId(unit3, 0); units = new VertexUnit[] { unit3 }; List <GeoElement> elementList = new List <GeoElement>(); GeoVertex geoVertex = new GeoVertex(unit3); elementList.Add(geoVertex); // if (!geometry.IsEdge(id, id1)) // elementList.Add(new GeoEdge(id, id1)); // if (!geometry.IsEdge(id, id2)) // elementList.Add(new GeoEdge(id, id2)); elements = elementList.ToArray(); dependencies.Add(unit1); dependencies.Add(unit2); }
public DeleteVertexOperation(GeoController geoController, Geometry geometry, GeoVertex geoVertex) { CanRotateCamera = true; CanActiveElement = false; this.geoController = geoController; this.geometry = geometry; this.geoVertex = geoVertex; }
public override void Init() { base.Init(); Name = "Triangular Pyramid"; Type = GeometryType.TriPyd; float sqrt3 = Mathf.Sqrt(3); Vector3 faceNormal = Vector3.up; VertexFace u0 = new VertexFace(-1, 0, -sqrt3 / 3, faceNormal); VertexFace u1 = new VertexFace(1, 0, -sqrt3 / 3, faceNormal); VertexFace u2 = new VertexFace(0, 0, sqrt3 * 2 / 3, faceNormal); VertexSpace u3 = new VertexSpace(0, sqrt3, 0); AddBaseVertex(u0); AddBaseVertex(u1); AddBaseVertex(u2); AddBaseVertex(u3); GeoVertex v0 = new GeoVertex(u0, true); GeoVertex v1 = new GeoVertex(u1, true); GeoVertex v2 = new GeoVertex(u2, true); GeoVertex v3 = new GeoVertex(u3, true); AddGeoVertex(v0); AddGeoVertex(v1); AddGeoVertex(v2); AddGeoVertex(v3); GeoEdge e0 = new GeoEdge(u0, u1, true); GeoEdge e1 = new GeoEdge(u0, u2, true); GeoEdge e2 = new GeoEdge(u1, u2, true); GeoEdge e3 = new GeoEdge(u0, u3, true); GeoEdge e4 = new GeoEdge(u1, u3, true); GeoEdge e5 = new GeoEdge(u2, u3, true); AddGeoEdge(e0); AddGeoEdge(e1); AddGeoEdge(e2); AddGeoEdge(e3); AddGeoEdge(e4); AddGeoEdge(e5); GeoFace f0 = new GeoFace(new VertexUnit[] { u0, u1, u2 }, true); GeoFace f1 = new GeoFace(new VertexUnit[] { u1, u0, u3 }, true); GeoFace f2 = new GeoFace(new VertexUnit[] { u0, u2, u3 }, true); GeoFace f3 = new GeoFace(new VertexUnit[] { u2, u1, u3 }, true); AddGeoFace(f0); AddGeoFace(f1); AddGeoFace(f2); AddGeoFace(f3); InitDatas(); }
public void SetRectangle(Vector3[] positions) { if (positions.Length != 4) { return; } Vector3 faceNormal = Vector3.right; VertexResolvedBody u0 = new VertexResolvedBody(positions[0].x, positions[0].y, positions[0].z, faceNormal); // u0.isFixed = true; VertexResolvedBody u1 = new VertexResolvedBody(positions[1].x, positions[1].y, positions[1].z, faceNormal); // u1.isFixed = true; VertexResolvedBody u2 = new VertexResolvedBody(positions[2].x, positions[2].y, positions[2].z, faceNormal); // u2.isFixed = true; VertexResolvedBody u3 = new VertexResolvedBody(positions[3].x, positions[3].y, positions[3].z, faceNormal); // u3.isFixed = true; AddBaseVertex(u0); AddBaseVertex(u1); AddBaseVertex(u2); AddBaseVertex(u3); vertexResolvedBodies = new VertexResolvedBody[] { u0, u1, u2, u3 }; GeoVertex v0 = new GeoVertex(u0, true); GeoVertex v1 = new GeoVertex(u1, true); GeoVertex v2 = new GeoVertex(u2, true); GeoVertex v3 = new GeoVertex(u3, true); AddGeoVertex(v0); AddGeoVertex(v1); AddGeoVertex(v2); AddGeoVertex(v3); GeoEdge e0 = new GeoEdge(u0, u1, true); GeoEdge e1 = new GeoEdge(u1, u2, true); GeoEdge e2 = new GeoEdge(u2, u3, true); GeoEdge e3 = new GeoEdge(u0, u3, true); AddGeoEdge(e0); AddGeoEdge(e1); AddGeoEdge(e2); AddGeoEdge(e3); GeoFace f0 = new GeoFace(new VertexUnit[] { u0, u1, u2, u3 }, true); AddGeoFace(f0); InitDatas(); NavAxisBehaviour axis = GameObject.Find("X").GetComponent <NavAxisBehaviour>(); PointerEventData data = new PointerEventData(EventSystem.current); axis.OnPointerClick(data); shapeSetted = true; }
public void ClickVertex(GeoVertex vertex) { if (currentOperation == null) { EditVertexOperation(vertex); } else { currentOperation.OnClickElement(vertex); } }
public void DeleteVertexOperation(GeoVertex geoVertex) { if (state != GeoState.Normal) { return; } SetState(GeoState.EditVertex); currentOperation = new DeleteVertexOperation(this, geometry, geoVertex); currentOperation.Start(); }
public void EditVertexOperation(GeoVertex geoVertex) { if (state != GeoState.Normal) { return; } SetState(GeoState.EditVertex); currentOperation = new EditVertexOperation(this, stateController, geoCamera, geometry, geometryBehaviour, geoUI, geoVertex); currentOperation.Start(); }
public void VertexCoordinateOperation(GeoVertex geoVertex) { if (state != GeoState.Normal) { return; } SetState(GeoState.EditVertex); VertexUnit vertexUnit = geometry.VertexUnit(geoVertex.Id); currentOperation = new VertexCoordinateOperation(this, stateController, geometry, geometryBehaviour, geoUI, vertexUnit); currentOperation.Start(); }
public void MoveVertexOperation(GeoVertex geoVertex, VertexBehaviour vertexBehaviour) { if (state != GeoState.Normal) { return; } SetState(GeoState.MoveVertex); VertexUnit unit = geometry.VertexUnit(geoVertex.Id); currentOperation = new MoveVertexOperation(stateController, geoCamera, geometry, geometryBehaviour, geoUI, unit, vertexBehaviour, isSnapToGrid); currentOperation.Start(); }
public override void InitWithGeometry(Geometry geometry) { VertexSpace unit = new VertexSpace(x, y, z); unit.preferredSign = sign; geometry.VertexUnitSetId(unit, 0); units = new VertexUnit[] { unit }; GeoVertex geoVertex = new GeoVertex(unit); elements = new GeoElement[] { geoVertex }; }
public EditVertexOperation(GeoController geoController, StateController stateController, GeoCamera geoCamera, Geometry geometry, GeometryBehaviour geometryBehaviour, GeoUI geoUI, GeoVertex geoVertex) { CanRotateCamera = false; CanActiveElement = false; this.geoController = geoController; this.stateController = stateController; this.geoCamera = geoCamera; this.geometry = geometry; this.geometryBehaviour = geometryBehaviour; this.activePanel = geoUI.activePanel; this.elementPanel = geoUI.elementPanel; this.geoVertex = geoVertex; }
private void AddVertex(GeoVertex geoVertex) { GameObject vertexObject = new GameObject(geoVertex.ToString()); vertexObject.transform.SetParent(vertexWrapper.transform); VertexBehaviour vertexBehaviour = vertexObject.AddComponent <VertexBehaviour>(); vertexBehaviour.Init(geoVertex, geoCamera); vertexBehaviour.SetData(geometry.Vertex(geoVertex)); vertexMap.Add(geoVertex, vertexBehaviour); elementMap.Add(geoVertex, vertexBehaviour); }
public void HoverVertex(GeoVertex vertex, bool isHover) { if (isCameraRotate) { return; } if (currentOperation != null && !currentOperation.CanActiveElement) { return; } if (isHover) { FormElement formElement = VertexForm(vertex); geoUI.activePanel.SetVertex(formElement); } else { geoUI.activePanel.Clear(); } geometryBehaviour.HighlightVertex(vertex, isHover); }
public override void InitWithGeometry(Geometry geometry) { int count = face.ids.Length; VertexUnit[] vertexUnits = new VertexUnit[count]; for (int i = 0; i < count; i++) { vertexUnits[i] = geometry.VertexUnit(face.ids[i]); } VertexPlaneCenter unit = new VertexPlaneCenter(vertexUnits); unit.preferredSign = sign; geometry.VertexUnitSetId(unit, 0); units = new VertexUnit[] { unit }; GeoVertex geoVertex = new GeoVertex(unit); elements = new GeoElement[] { geoVertex }; dependencies.AddRange(vertexUnits); }
public void Init(GeoVertex geoVertex, GeoCamera camera) { geoCamera = camera; geoCamera.OnRotate += OnCameraRotate; geoController = GameObject.Find("/GeoController").GetComponent <GeoController>(); this.geoVertex = geoVertex; if (mesh == null) { mesh = PointMesh(); } MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>(); meshRenderer = gameObject.AddComponent <MeshRenderer>(); BoxCollider meshCollider = gameObject.AddComponent <BoxCollider>(); meshCollider.size = new Vector3(POINT_COLLIDER_SIZE, POINT_COLLIDER_SIZE, POINT_COLLIDER_SIZE); meshFilter.sharedMesh = mesh; meshRenderer.sharedMaterial = ConfigManager.VertexStyle[0].Material; SetSize(geoVertex.isFixed ? FIXED_SIZE : UNFIXED_SIZE); SetColorIndex(0); SetStyleIndex(0); StyleManager.OnStyleChange += () => { SetColorIndex(0); SetStyleIndex(0); }; visiable = true; }
public Vector3 VertexNormal(GeoVertex vertex) { return(normals[vertex.Id]); }
public void HighlightVertex(GeoVertex geoVertex, bool highlight) { vertexMap[geoVertex].SetHighlight(highlight); }
private void UpdateVertex(GeoVertex geoVertex) { VertexBehaviour vertexBehaviour = vertexMap[geoVertex]; vertexBehaviour.SetData(geometry.Vertex(geoVertex)); }
public void RemoveGeoVertex(GeoVertex vertex) { geoVertices.Remove(vertex); vertex.RemoveObserveElements(); }
public Vertex Vertex(GeoVertex vertex) { return(vertex.Vertex()); }
public override void Init() { base.Init(); Name = "Cuboid"; Type = GeometryType.Cubio; VertexCuboid u0 = new VertexCuboid(1, -1, 1); VertexCuboid u1 = new VertexCuboid(-1, -1, 1); VertexCuboid u2 = new VertexCuboid(-1, -1, -1); VertexCuboid u3 = new VertexCuboid(1, -1, -1); VertexCuboid u4 = new VertexCuboid(1, 1, 1); VertexCuboid u5 = new VertexCuboid(-1, 1, 1); VertexCuboid u6 = new VertexCuboid(-1, 1, -1); VertexCuboid u7 = new VertexCuboid(1, 1, -1); AddBaseVertex(u0); AddBaseVertex(u1); AddBaseVertex(u2); AddBaseVertex(u3); AddBaseVertex(u4); AddBaseVertex(u5); AddBaseVertex(u6); AddBaseVertex(u7); vertexCuboids = new VertexCuboid[] { u0, u1, u2, u3, u4, u5, u6, u7 }; GeoVertex v0 = new GeoVertex(u0, true); GeoVertex v1 = new GeoVertex(u1, true); GeoVertex v2 = new GeoVertex(u2, true); GeoVertex v3 = new GeoVertex(u3, true); GeoVertex v4 = new GeoVertex(u4, true); GeoVertex v5 = new GeoVertex(u5, true); GeoVertex v6 = new GeoVertex(u6, true); GeoVertex v7 = new GeoVertex(u7, true); AddGeoVertex(v0); AddGeoVertex(v1); AddGeoVertex(v2); AddGeoVertex(v3); AddGeoVertex(v4); AddGeoVertex(v5); AddGeoVertex(v6); AddGeoVertex(v7); GeoEdge e0 = new GeoEdge(u0, u1, true); GeoEdge e1 = new GeoEdge(u1, u2, true); GeoEdge e2 = new GeoEdge(u2, u3, true); GeoEdge e3 = new GeoEdge(u3, u0, true); GeoEdge e4 = new GeoEdge(u4, u5, true); GeoEdge e5 = new GeoEdge(u5, u6, true); GeoEdge e6 = new GeoEdge(u6, u7, true); GeoEdge e7 = new GeoEdge(u7, u4, true); GeoEdge e8 = new GeoEdge(u0, u4, true); GeoEdge e9 = new GeoEdge(u1, u5, true); GeoEdge e10 = new GeoEdge(u2, u6, true); GeoEdge e11 = new GeoEdge(u3, u7, true); AddGeoEdge(e0); AddGeoEdge(e1); AddGeoEdge(e2); AddGeoEdge(e3); AddGeoEdge(e4); AddGeoEdge(e5); AddGeoEdge(e6); AddGeoEdge(e7); AddGeoEdge(e8); AddGeoEdge(e9); AddGeoEdge(e10); AddGeoEdge(e11); GeoFace f0 = new GeoFace(new VertexUnit[] { u0, u1, u2, u3 }, true); GeoFace f1 = new GeoFace(new VertexUnit[] { u0, u4, u5, u1 }, true); GeoFace f2 = new GeoFace(new VertexUnit[] { u1, u5, u6, u2 }, true); GeoFace f3 = new GeoFace(new VertexUnit[] { u2, u6, u7, u3 }, true); GeoFace f4 = new GeoFace(new VertexUnit[] { u3, u7, u4, u0 }, true); GeoFace f5 = new GeoFace(new VertexUnit[] { u7, u6, u5, u4 }, true); AddGeoFace(f0); AddGeoFace(f1); AddGeoFace(f2); AddGeoFace(f3); AddGeoFace(f4); AddGeoFace(f5); InitDatas(); GameObject geo = GameObject.Find("/3D/Geometry/Vertex"); Debug.Log(geo.transform.childCount); }
public void AddGeoVertex(GeoVertex vertex) { geoVertices.Add(vertex); vertex.AddObserveElements(); }