public static alphabetLabel label(AbstractGeoObj obj, string labelText) { alphabetLabel label = alphabetLabel.Constructor(); label.spawnOnMGO(obj, labelText); return(label); }
private void OnTriggerExit(Collider other) { if (other.gameObject.GetComponent <AbstractGeoObj>() != null && other.gameObject.GetComponent <AbstractGeoObj>() == recentHit) { recentHit = null; } }
internal override void GlueToFigure(AbstractGeoObj toObj) { if ((toObj.gameObject.tag.Contains("Point") && (toObj.figIndex > this.figIndex)) && ((this.GetComponent <InteractionBehaviour>().isGrasped) || (toObj.transform.GetComponent <InteractionBehaviour>().isGrasped))) { foreach (Node <string> node in HW_GeoSolver.ins.geomanager.Nodes) { GraphNode <string> thisGraphNode = HW_GeoSolver.ins.geomanager.findGraphNode(this.figName); if (HW_GeoSolver.ins.geomanager.neighborsOfNode(node.Value).Contains(thisGraphNode)) { NodeList <string> newNeighborList = HW_GeoSolver.ins.geomanager.neighborsOfNode(node.Value); GraphNode <string> otherGraphNode = HW_GeoSolver.ins.geomanager.findGraphNode(toObj.figName); if (newNeighborList.Contains(otherGraphNode) == false) { HW_GeoSolver.ins.AddDependence(GameObject.Find(node.Value).GetComponent <AbstractGeoObj>(), toObj); HW_GeoSolver.ins.replaceDepentVar(GameObject.Find(node.Value).transform, this.transform, toObj.transform); } else { //deletes redundancy instances between two points HW_GeoSolver.ins.removeComponentS(node.Value); } } } HW_GeoSolver.ins.removeComponent(this); //check for cycle in geoObjMan graph if (HW_GeoSolver.ins.checkIfPath(this.transform, toObj.transform)) { //a cycle is being created. //make a polygon Debug.Log("NEED TO MAKE A POLYGON"); } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.GetComponent <AbstractGeoObj>() != null) { recentHit = other.gameObject.GetComponent <AbstractGeoObj>(); } }
internal static SnappablePoint snapPoint(AbstractGeoObj activeMGO, Vector3 position) { SnappablePoint snap = SnappablePoint.Constructor(); snap.Position3 = position; snap.attachedObject = activeMGO; return(snap); }
private IEnumerator transformFollow(AbstractGeoObj followMGO) { while (followMGO.isActiveAndEnabled) { transform.position = followMGO.transform.position; transform.rotation = Quaternion.LookRotation(transform.position - Camera.main.transform.position); yield return(new WaitForEndOfFrame()); } Destroy(gameObject); //if attached object doesnt exist anymore }
public void spawnOnMGO(AbstractGeoObj MGO, string label) { _thisCount = (int)(label.ToCharArray()[label.ToCharArray().Length - 1] - 65); if (_thisCount > totalCount) { totalCount = _thisCount + 1; } recentHit = MGO; this.Label = label; attachToMGO(); }
private void setupRelativePosition(AbstractGeoObj value) { switch (value.figType) { //case GeoObjType.point: // break; case GeoObjType.line: AbstractLineSegment line = value.GetComponent <AbstractLineSegment>(); relativeWeights.Add(Vector3.Magnitude(Position3 - line.vertex0) / Vector3.Magnitude(line.vertex0 - line.vertex1)); relativeWeights.Add(Vector3.Magnitude(Position3 - line.vertex1) / Vector3.Magnitude(line.vertex0 - line.vertex1)); break; case GeoObjType.polygon: Debug.LogWarning("Polygonsn not yet supported for Relative Movement"); break; //case GeoObjType.prism: // break; //case GeoObjType.pyramid: // break; case GeoObjType.circle: AbstractCircle circle = value.GetComponent <AbstractCircle>(); relativeWeights.Add(Vector3.SignedAngle(circle.edgePos - circle.centerPos, this.Position3 - circle.centerPos, circle.normalDir)); break; case GeoObjType.sphere: Vector3 direction = Vector3.Normalize(this.Position3 - value.GetComponent <AbstractSphere>().centerPosition); relativeWeights.Add(direction.x); relativeWeights.Add(direction.y); relativeWeights.Add(direction.z); break; //case GeoObjType.revolvedsurface: // break; //case GeoObjType.torus: // break; case GeoObjType.flatface: Debug.LogWarning("Flatface not yet supported for Relative Movement"); break; case GeoObjType.straightedge: Debug.LogWarning("Straightedge not yet supported for Relative Movement"); break; default: Debug.LogWarning(value.figType.ToString() + " not supported for relative movement"); break; } }
private void nextActive() { activeMGO.thisSelectStatus = AbstractGeoObj.SelectionStatus.canidate; canidateIDX++; if (canidateIDX > mgoCanidates.Count) { canidateIDX = 0; } else if (canidateIDX < 0) { canidateIDX = mgoCanidates.Count; } activeMGO = mgoCanidates[canidateIDX]; activeMGO.thisSelectStatus = AbstractGeoObj.SelectionStatus.active; }
internal override void GlueToFigure(AbstractGeoObj toObj) { //do nothing. }
internal override bool RMotion(NodeList <string> inputNodeList) { bool tempValue = false; foreach (AbstractPoint point in pointList) { if (point.GetComponent <StaticPoint>()) { tempValue = true; } } if (tempValue) { return(false); } if (thisIBehave.isGrasped) { Vector3 center = this.Position3; int pointNum = pointList.Count; MeshFilter mf = GetComponent <MeshFilter>(); Mesh mesh = mf.mesh; int i = 0; foreach (AbstractPoint point in pointList) { point.Position3 = this.transform.localPosition + vertices[i]; vertices[i] = point.Position3 - center; i++; } return(true); } else if (inputNodeList.checkForMGOmatch(pointListMGO)) { int pointNum = pointList.Count; MeshFilter mf = GetComponent <MeshFilter>(); Mesh mesh = mf.mesh; Quaternion angle = Quaternion.identity; if (!skewable && CheckSkewPolygon()) { Debug.LogWarning("This polygon " + figName + " is a skew polygon."); AbstractGeoObj firstHit = inputNodeList.findMGOmatch(pointList.Cast <AbstractGeoObj>().ToList()); switch (firstHit.figType) { case GeoObjType.point: //need to rotate every other point based ont the angle from the old point position and the center. angle = angleAroundCenter(firstHit.Position3, vertices[pointList.FindIndex(x => x == firstHit.GetComponent <AbstractPoint>())]); break; case GeoObjType.line: //need to rotate every other point based on the angle from the midpoint of the line segment and the center. //need to address this case in the future. break; default: break; } } int i = 0; this.Position3 = center; foreach (AbstractPoint point in pointList) { //move points with a rotation around the center. if (inputNodeList.checkForMGOmatch(point)) { vertices[i] = angle * (point.Position3 - center); } else { vertices[i] = (point.Position3 - center); //don't rotate the point around the angle that has already moved. } i++; } bool isTrue = mesh.vertices == vertices; mesh.vertices = vertices; return(isTrue); } return(false); }
private Vector3 vectorMap(Vector3 input) { return(new Vector3(input.x + AbstractGeoObj.LocalPosition(myPoly.Position3).x, functionMap(input), input.z + AbstractGeoObj.LocalPosition(myPoly.Position3).z) + Vector3.up); }
internal bool checkForMGOmatch(AbstractGeoObj mgo) { return(checkForMGOmatch(new List <AbstractGeoObj> { mgo })); }
private void interactionEnd() { mgoCanidates = new List <AbstractGeoObj>(); if (this.GetComponent <AnchorableBehaviour>().isAttached == false) { foreach (AbstractGeoObj mgo in FindObjectsOfType <AbstractGeoObj>().Where(g => (g.GetComponent <AnchorableBehaviour>() == null || (g.GetComponent <AnchorableBehaviour>() != null && !g.GetComponent <AnchorableBehaviour>().isAttached)))) { float distance = 15; switch (mgo.figType) { case GeoObjType.point: distance = Vector3.Magnitude(this.transform.position - mgo.transform.position); break; case GeoObjType.line: distance = Vector3.Magnitude(Vector3.Project(transform.position - mgo.transform.position, mgo.GetComponent <AbstractLineSegment>().vertex0 - mgo.GetComponent <AbstractLineSegment>().vertex1) + mgo.transform.position - this.transform.position); break; case GeoObjType.polygon: Vector3 positionOnPlane = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <AbstractPolygon>().normDir) + mgo.transform.position; distance = Vector3.Magnitude(positionOnPlane - this.transform.position); Debug.LogWarning("Polygon doesn't check boundariers"); break; case GeoObjType.prism: distance = Vector3.Magnitude(mgo.transform.position - this.transform.position); break; case GeoObjType.pyramid: Debug.LogWarning("Pyramids not yet supported"); break; case GeoObjType.circle: Vector3 positionOnPlane2 = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <AbstractCircle>().normalDir) + mgo.transform.position; Vector3 positionOnCircle = Vector3.Normalize(positionOnPlane2 - mgo.GetComponent <AbstractCircle>().centerPos) * mgo.GetComponent <AbstractCircle>().Radius + mgo.GetComponent <AbstractCircle>().centerPos; distance = Vector3.Magnitude(this.transform.position - positionOnCircle); break; case GeoObjType.sphere: Vector3 lineDir = Vector3.Normalize(transform.position - mgo.transform.position); Vector3 positionOnSphere1 = mgo.GetComponent <AbstractSphere>().radius *lineDir + mgo.transform.position; distance = Vector3.Magnitude(positionOnSphere1 - this.transform.position); break; case GeoObjType.revolvedsurface: Debug.LogWarning("RevoledSurface not yet supported"); break; case GeoObjType.torus: Debug.LogWarning("Torus not yet supported"); break; case GeoObjType.flatface: Vector3 positionOnPlane3 = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <flatfaceBehave>().normalDir) + mgo.transform.position; distance = Vector3.Magnitude(positionOnPlane3 - this.transform.position); break; case GeoObjType.straightedge: Vector3 positionOnStraightedge = Vector3.Project(transform.position - mgo.transform.position, mgo.GetComponent <straightEdgeBehave>().normalDir) + mgo.transform.position; distance = Vector3.Magnitude(positionOnStraightedge - this.transform.position); break; default: Debug.LogWarning("Something went wrong in the selectionmanager.... :("); break; } if (Mathf.Abs(distance) < selectionRadius && mgo.thisSelectStatus != AbstractGeoObj.SelectionStatus.selected) { mgo.thisSelectStatus = AbstractGeoObj.SelectionStatus.canidate; mgoCanidates.Add(mgo); } else if (Mathf.Abs(distance) < selectionRadius) { mgoCanidates.Add(mgo); } else if (mgo.thisSelectStatus == AbstractGeoObj.SelectionStatus.canidate || mgo.thisSelectStatus == AbstractGeoObj.SelectionStatus.active) { mgo.thisSelectStatus = AbstractGeoObj.SelectionStatus.none; } } } if (mgoCanidates.Count >= 1) { activeMGO = mgoCanidates[0]; canidateIDX = 0; } setbuttonState(mgoCanidates.Count >= 1); }
/// <summary> /// Called each frame the gesture is active /// </summary> /// <param name="hand">The hand completing the gesture</param> protected override void WhileGestureActive(Hand hand) { //sethandtomodeSelect float shortestDist = Mathf.Infinity; closestObj = null; foreach (AbstractGeoObj mgo in FindObjectsOfType <AbstractGeoObj>().Where(g => (g.GetComponent <AnchorableBehaviour>() == null || (g.GetComponent <AnchorableBehaviour>() != null && !g.GetComponent <AnchorableBehaviour>().isAttached)))) { float distance = mgo.LocalDistanceToClosestPoint(hand.Fingers[1].TipPosition.ToVector3()); float angle = mgo.PointingAngleDiff(hand.Fingers[1].TipPosition.ToVector3(), hand.Fingers[1].Direction.ToVector3()); if (Mathf.Abs(distance) < shortestDist) { if (distance < shortestDist && angle < angleTolerance) { closestObj = mgo; shortestDist = distance; } } else { //check to see if any higher priority objectes lie within epsilon bool v = (Mathf.Abs(distance) - shortestDist <= maximumRangeToSelect) && ( ((closestObj.figType == GeoObjType.line || closestObj.figType == GeoObjType.polygon) && mgo.figType == GeoObjType.point) || (closestObj.figType == GeoObjType.polygon && mgo.figType == GeoObjType.point) ); if (v) { closestObj = mgo; shortestDist = distance; } } } handColourManager.setHandColorMode(whichHand, handColourManager.handModes.select); if (closestObj != null && shortestDist <= maximumRangeToSelect) { if (debugSelect) { Debug.Log(closestObj + " is the object toggling selection state."); } //switch on mode: // Select // Colour if (closestObj.IsSelected) { closestObj.thisSelectStatus = AbstractGeoObj.SelectionStatus.none; } else { closestObj.thisSelectStatus = AbstractGeoObj.SelectionStatus.selected; } playSuccessSound(); //This determines if you have to cancel the gesture to select another object completeBool = true; } }
internal override void GlueToFigure(AbstractGeoObj toObj) { throw new NotImplementedException(); }
internal override void SnapToFigure(AbstractGeoObj toObj) { //do nothing }
internal override void SnapToFigure(AbstractGeoObj toObj) { Debug.Log(name + " is attempting to snap to " + toObj.name + "."); //if object and child objects are not being grasped if (!(this.GetComponent <InteractionBehaviour>().isGrasped)) { ///this object is being grasped switch (toObj.figType) { case GeoObjType.point: Position3 = toObj.Position3; break; case GeoObjType.line: Position3 = Vector3.Project(Position3 - toObj.Position3, toObj.GetComponent <AbstractLineSegment>().vertex0 - toObj.GetComponent <AbstractLineSegment>().vertex1) + toObj.Position3; break; case GeoObjType.polygon: Vector3 positionOnPlane = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <AbstractPolygon>().normDir) + toObj.Position3; if (toObj.GetComponent <AbstractPolygon>().checkInPolygon(positionOnPlane)) { Position3 = positionOnPlane; } break; //case GeoObjType.prism: // break; //case GeoObjType.pyramid: // break; case GeoObjType.circle: Vector3 positionOnPlane2 = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <AbstractCircle>().normalDir) + toObj.Position3; if (Vector3.Magnitude(positionOnPlane2 - toObj.Position3) == toObj.GetComponent <AbstractCircle>().Radius) { Position3 = positionOnPlane2; } break; case GeoObjType.sphere: Vector3 lineDir = Vector3.Normalize(Position3 - toObj.Position3); Position3 = toObj.GetComponent <AbstractSphere>().radius *lineDir + toObj.Position3; break; //case GeoObjType.revolvedsurface: // break; //case GeoObjType.torus: // break; case GeoObjType.flatface: Position3 = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <flatfaceBehave>().normalDir) + toObj.Position3; break; case GeoObjType.straightedge: Position3 = Vector3.Project(Position3 - toObj.Position3, toObj.GetComponent <straightEdgeBehave>().normalDir) + toObj.Position3; break; default: break; } setupRelativePosition(toObj); } else { switch (toObj.figType) { case GeoObjType.point: this.Position3 = toObj.Position3; break; case GeoObjType.line: AbstractLineSegment line = toObj.GetComponent <AbstractLineSegment>(); this.Position3 = line.vertex0 * relativeWeights[0] + line.vertex1 * relativeWeights[1]; break; case GeoObjType.polygon: Debug.LogWarning("Polygon not yet supported for Relative Movement"); break; //case GeoObjType.prism: // break; //case GeoObjType.pyramid: // break; case GeoObjType.circle: AbstractCircle circle = toObj.GetComponent <AbstractCircle>(); Vector3 basis1 = circle.edgePos - circle.centerPos; Vector3 basis2 = Vector3.Cross(basis1, circle.normalDir); Vector3.OrthoNormalize(ref basis1, ref basis2); this.Position3 = circle.Radius * (basis1 * Mathf.Sin(relativeWeights[0]) + basis2 * Mathf.Cos(relativeWeights[0])) + circle.centerPos; break; case GeoObjType.sphere: Vector3 direction = relativeWeights[0] * Vector3.right + relativeWeights[1] * Vector3.up + relativeWeights[2] * Vector3.forward; this.Position3 = toObj.GetComponent <AbstractSphere>().radius *direction; break; //case GeoObjType.revolvedsurface: // break; //case GeoObjType.torus: // break; case GeoObjType.flatface: Debug.LogWarning("Straightedge not yet supported for Relative Movement"); break; case GeoObjType.straightedge: Debug.LogWarning("Straightedge not yet supported for Relative Movement"); break; default: Debug.LogWarning(toObj.figType.ToString() + " not supported for relative movement"); break; } } }