/// <summary> /// Checks if there is an intersection between any figures in the scene that isnt currently attached to any anchor. /// </summary> public void checkIntersectAny() { AbstractGeoObj[] geoObjList = GameObject.FindObjectsOfType <AbstractGeoObj>().Where(g => g.GetComponent <AbstractPoint>() == null).ToArray(); for (int i = 0; i < geoObjList.Length; i++) { AbstractGeoObj obj1 = geoObjList[i]; if (obj1.GetComponent <AnchorableBehaviour>() != null && (obj1.GetComponent <AnchorableBehaviour>().isAttached)) { continue; } if (true) { for (int j = i + 1; j < geoObjList.Length; j++) { AbstractGeoObj obj2 = geoObjList[j]; if (obj2.GetComponent <AnchorableBehaviour>() != null && (obj2.GetComponent <AnchorableBehaviour>().isAttached)) { continue; } if (obj1 != obj2) { checkIntersection(obj1, obj2); } } } } }
private AbstractGeoObj[] checkSphereFlatface(AbstractSphere abstractSphere, flatfaceBehave flatfaceBehave) { intersectionFigData data = IntersectionMath.SpherePlaneIntersection(abstractSphere, flatfaceBehave); AbstractGeoObj[] mgoResult = null; if (data.figtype == GeoObjType.circle) { DependentPoint centerPoint = GeoObjConstruction.dPoint(data.vectordata[0]); Vector3 radiusDirection = Vector3.up; if (Vector3.Cross(radiusDirection, data.vectordata[1]).magnitude == 0) { radiusDirection = Vector3.right; } radiusDirection = Vector3.Cross(data.vectordata[1], radiusDirection).normalized; DependentPoint edgePoint = GeoObjConstruction.dPoint(data.vectordata[0] + data.floatdata[0] * radiusDirection); DependentCircle newCircle = GeoObjConstruction.dCircle(centerPoint, edgePoint, data.vectordata[1]); mgoResult = new AbstractGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(1), newCircle.setIntersectionFigure(2) }; } else if (data.figtype == GeoObjType.point) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) }; } return(mgoResult); }
private void updateSphereLine(AbstractGeoObj mgo, AbstractGeoObj AbstractGeoObj1, AbstractGeoObj AbstractGeoObj2) { intersectionFigData data = IntersectionMath.SphereLineIntersection(AbstractGeoObj1.GetComponent <AbstractSphere>(), AbstractGeoObj2.GetComponent <straightEdgeBehave>()); if (data.figtype == mgo.figType) { //point or points; if (data.vectordata.Length > 1) { mgo.Position3 = data.vectordata[mgo.intersectionMultipleIDX]; } else { mgo.Position3 = data.vectordata[0]; } } else if (data.figtype == GeoObjType.none) { mgo.DeleteGeoObj(); } else { Debug.LogWarning("TYPE MISMATCH"); } }
private AbstractGeoObj[] checkSphereSphere(AbstractSphere abstractSphere1, AbstractSphere abstractSphere2) { intersectionFigData data = IntersectionMath.SphereSphereIntersection(abstractSphere1, abstractSphere2); Debug.Log("Data produces " + data.figtype.ToString()); Debug.Log("Point Value " + data.vectordata[0].ToString()); AbstractGeoObj[] mgoResult = null; if (data.figtype == GeoObjType.circle) { DependentPoint centerPoint = GeoObjConstruction.dPoint(data.vectordata[0]); Vector3 radiusDirection = Vector3.up; if (Vector3.Cross(radiusDirection, data.vectordata[1]).magnitude == 0) { radiusDirection = Vector3.right; } radiusDirection = Vector3.Cross(data.vectordata[1], radiusDirection).normalized; DependentPoint edgePoint = GeoObjConstruction.dPoint(data.vectordata[2]); DependentCircle newCircle = GeoObjConstruction.dCircle(centerPoint, edgePoint, data.vectordata[1]); mgoResult = new AbstractGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(0), newCircle.setIntersectionFigure(0) }; } else if (data.figtype == GeoObjType.point) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) }; } return(mgoResult); }
internal void removeComponent(AbstractGeoObj geoComp) { Debug.Log(geoComp.figName + " is being removed from the graph. Refer to trace for reason."); if (blockDelete == false) { if (geoComp.GetComponent <AnchorableBehaviour>() != null) { geoComp.GetComponent <AnchorableBehaviour>().Detach(); } if (geoComp.GetComponent <straightEdgeBehave>() != null || geoComp.GetComponent <flatfaceBehave>() != null) { Node <string> meNode = geoComp.FindGraphNode(); if (rManList.Contains(meNode)) { rManList.Remove(meNode); } geomanager.Remove(meNode.Value); Destroy(geoComp.gameObject); } else { string meNAME = geoComp.figName; Node <string> meNode = geomanager.findGraphNode(meNAME); if (rManList.Contains(meNode)) { rManList.Remove(meNode); } geomanager.Remove(meNAME); Destroy(geoComp.gameObject); } } }
public bool foundMGO(Hand hand) { float shortestDist = Mathf.Infinity; closestObj = null; foreach (StaticPoint mgo in FindObjectsOfType <StaticPoint>().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; } } } if (shortestDist < maximumRangeToSelect) { currPoint = closestObj.GetComponent <AbstractPoint>(); } return(shortestDist < maximumRangeToSelect); }
private void setEmission(AbstractGeoObj face, float value) { Material mat = face.GetComponent <MeshRenderer>().materials[0]; float emission = value; Color baseColor = mat.color; Color finalColor = baseColor * Mathf.LinearToGammaSpace(emission); mat.SetColor("_EmissionColor", finalColor); }
private AbstractGeoObj[] checkFlatfaceStraightedge(flatfaceBehave flatfaceBehave, straightEdgeBehave straightEdgeBehave) { intersectionFigData data = IntersectionMath.LinePlaneIntersection(flatfaceBehave, straightEdgeBehave); AbstractGeoObj[] mgoResult = null; if (data.figtype == GeoObjType.point) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) }; } return(mgoResult); }
///// <summary> ///// Adds a dependence in the lifemanager and updatemanager and reactionmanager system ///// </summary> internal void AddDependence(AbstractGeoObj fromMGO, AbstractGeoObj toMGO) { //Debug.Log("adding directed edge from " + fromMGO.GetComponent<AbstractGeoObj>().figName + " to " + toMGO.GetComponent<AbstractGeoObj>().figName); if (string.IsNullOrEmpty(fromMGO.figName)) { fromMGO.InitializeFigure(); } if (string.IsNullOrEmpty(toMGO.figName)) { toMGO.InitializeFigure(); } geomanager.AddDirectedEdge(fromMGO.figName, toMGO.figName, 1); }
internal void addComponent(AbstractGeoObj geoComp) { //set index GeoObjType type = geoComp.figType; geoComp.figIndex = currentIndex; string newmyNAME = type.ToString() + _currentIndex.ToString("000");//changed to include padding for ordering the objects nicely geoComp.figName = newmyNAME; geoComp.gameObject.name = newmyNAME; geomanager.AddNode(newmyNAME); // set transform reference for graph node to make reactionManager more efficient. geomanager.SetTransformRef(geomanager.findGraphNode(newmyNAME), geoComp.transform); }
private AbstractGeoObj[] CheckCircleCircle(AbstractCircle abstractCircle1, AbstractCircle abstractCircle2) { intersectionFigData data = IntersectionMath.CircleCircleIntersection(abstractCircle1, abstractCircle2); AbstractGeoObj[] mgoResult = null; if (data.figtype == GeoObjType.point) { if (data.vectordata.Length == 1) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) }; } else if (data.vectordata.Length == 2) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0), GeoObjConstruction.dPoint(data.vectordata[1]).setIntersectionFigure(1) }; } } return(mgoResult); }
private AbstractGeoObj[] checkSphereStraightEdge(AbstractSphere abstractSphere, straightEdgeBehave straightEdgeBehave) { intersectionFigData data = IntersectionMath.SphereLineIntersection(abstractSphere, straightEdgeBehave); AbstractGeoObj[] mgoResult = null; if (data.figtype == GeoObjType.point) { if (data.vectordata.Length == 1) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) }; } else if (data.vectordata.Length == 2) { mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0), GeoObjConstruction.dPoint(data.vectordata[1]).setIntersectionFigure(1) }; } } return(mgoResult); }
/// <summary> /// Sets the value for emission brightness /// </summary> /// <param name="obj">object to change emission</param> /// <param name="value">Between 0 and 1, percent brightness</param> private void setEmission(AbstractGeoObj obj, float value) { if (value > 1 || value < 0) { return; } Material mat = obj.GetComponent <MeshRenderer>().materials[0]; if (mat != null) { mat.SetColor("_EmissionColor", Vector4.one * value); } else { Debug.LogError("Tried to set the emission for object " + obj.name + ", but it has no material!"); } }
private void updatePlanePlane(AbstractGeoObj mgo, AbstractGeoObj AbstractGeoObj1, AbstractGeoObj AbstractGeoObj2) { intersectionFigData data = IntersectionMath.PlanePlaneIntersection(AbstractGeoObj1.GetComponent <flatfaceBehave>(), AbstractGeoObj2.GetComponent <flatfaceBehave>()); if (data.figtype == mgo.figType) { //line only option mgo.Position3 = data.vectordata[0]; mgo.AddToRManager(); } else if (data.figtype == GeoObjType.none) { mgo.DeleteGeoObj(); } else { Debug.LogWarning("TYPE MISMATCH"); } }
private void AddToDictionary(AbstractGeoObj obj1, AbstractGeoObj obj2, AbstractGeoObj[] objList) { if (objList != null && objList.Length > 0) { AbstractGeoObj[] inputList = new AbstractGeoObj[2]; inputList[0] = obj1; inputList[1] = obj2; hashIntersectedFigs.Add(obj1.name + obj2.name); foreach (AbstractGeoObj obj in objList) { hashIntersectionProducts.Add(obj.name); pastIntersections.Add(obj, inputList); this.GetComponent <HW_GeoSolver>().AddDependence(obj, obj1); this.GetComponent <HW_GeoSolver>().AddDependence(obj, obj2); } } }
public bool foundMGO(Hand hand) { 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))).Where(g => g.GetComponent <AbstractGeoObj>().figType != GeoObjType.point)) { float distance = mgo.LocalDistanceToClosestPoint(hand.PalmPosition.ToVector3()); if (Mathf.Abs(distance) < shortestDist) { if (distance < shortestDist) { closestObj = mgo; shortestDist = distance; } } } return(shortestDist < maximumRangeToSelect); }
private void updateCircleLine(AbstractGeoObj mgo, AbstractGeoObj AbstractGeoObj1, AbstractGeoObj AbstractGeoObj2) { intersectionFigData data = IntersectionMath.CircleLineIntersection(AbstractGeoObj1.GetComponent <AbstractCircle>(), AbstractGeoObj2.GetComponent <straightEdgeBehave>()); if (data.figtype == mgo.figType) { switch (data.figtype) { case GeoObjType.point: mgo.Position3 = data.vectordata[0]; mgo.AddToRManager(); break; case GeoObjType.circle: DependentCircle circle = mgo.GetComponent <DependentCircle>(); circle.centerPos = data.vectordata[0]; circle.normalDir = data.vectordata[1]; circle.center.Position3 = data.vectordata[0]; circle.edgePos = data.vectordata[2]; circle.edge.Position3 = data.vectordata[2]; circle.AddToRManager(); circle.edge.AddToRManager(); circle.center.AddToRManager(); break; default: break; } } else if (data.figtype == GeoObjType.none) { mgo.DeleteGeoObj(); } else { Debug.LogWarning("TYPE MISMATCH"); } }
private void updateCirclePlane(AbstractGeoObj mgo, AbstractGeoObj AbstractGeoObj1, AbstractGeoObj AbstractGeoObj2) { intersectionFigData data = IntersectionMath.CirclePlaneIntersection(AbstractGeoObj1.GetComponent <AbstractCircle>(), AbstractGeoObj2.GetComponent <flatfaceBehave>()); if (data.figtype == mgo.figType) { if (data.vectordata.Length > 1) { mgo.Position3 = data.vectordata[mgo.intersectionMultipleIDX]; } else { mgo.Position3 = data.vectordata[0]; } } else if (data.figtype == GeoObjType.none) { mgo.DeleteGeoObj(); } else { Debug.LogWarning("TYPE MISMATCH"); } }
internal void checkLifeRequirements(AbstractGeoObj geoComp) { //add case for clones. bool killorder = false; NodeList <string> neighborList = geoComp.FindGraphNode().Neighbors; GeoObjType type = geoComp.figType; int pointCount = 0; switch (type) { case GeoObjType.point: //degree == 0 killorder = false; break; case GeoObjType.line: pointCount = neighborTypeCount(neighborList, GeoObjType.point); //Debug.Log(geoComp.gameObject.name+" has "+pointCount+" points."); if (pointCount < 2) { killorder = true; } else { killorder = false; } break; case GeoObjType.polygon: pointCount = neighborTypeCount(neighborList, GeoObjType.point); //TOFIX: add cycle check if (pointCount < 3) { killorder = true; } else { killorder = false; } break; case GeoObjType.circle: pointCount = neighborTypeCount(neighborList, GeoObjType.point); if (pointCount < 1) //|| geoComp.GetComponent<DependentCircle>().Radius <= 0.00000000001f) { killorder = true; } else { killorder = false; } break; case GeoObjType.revolvedsurface: //pointCount = neighborTypeCount (neighborList, "Point"); //arcCount = neighborTypeCount (neighborList, "Arc"); pointCount = neighborTypeCount(neighborList, GeoObjType.point); if (pointCount < 2) { killorder = true; } else { killorder = false; } break; case GeoObjType.sphere: pointCount = neighborTypeCount(neighborList, GeoObjType.point); if (pointCount < 2 || geoComp.GetComponent <DependentSphere>().radius <= 0.00000001f) { killorder = true; } else { killorder = false; } break; default: break; } if (killorder) { removeComponent(geoComp); } }
private GeoObjDef determineDef(AbstractGeoObj obj, GeoObjType figType) { switch (figType) { case GeoObjType.point: if (obj.GetComponent <InteractablePoint>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentPoint>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticPoint>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.line: if (obj.GetComponent <InteractableLineSegment>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentLineSegment>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticLineSegment>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.polygon: if (obj.GetComponent <InteractablePolygon>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentPolygon>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticPolygon>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.prism: if (obj.GetComponent <InteractablePrism>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentPrism>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticSolid>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.pyramid: if (obj.GetComponent <DependentPyramid>() != null) //Case doesn't exist yet //{ // return GeoObjDef.Interactable; //} //else if (obj.GetComponent<DependentPyramid>() != null) { return(GeoObjDef.Dependent); } //else if (obj.GetComponent<staticPyramid>() != null) //Case doesn't exist yet //{ // return GeoObjDef.Static; //} else { return(GeoObjDef.none); } case GeoObjType.circle: if (obj.GetComponent <InteractableCircle>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentCircle>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticCircle>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.sphere: //if (obj.GetComponent<AbstractSphere>() != null) //{ // return GeoObjDef.Interactable; //Case doesn't exist yet //} if (obj.GetComponent <DependentSphere>() != null) { return(GeoObjDef.Dependent); } //else if (obj.GetComponent<StaticSphere>() != null) //{ // return GeoObjDef.Static; //Case doesn't exist yet //} else { return(GeoObjDef.Abstract); } case GeoObjType.revolvedsurface: if (obj.GetComponent <InteractableRevolvedSurface>() != null) { return(GeoObjDef.Interactable); } else if (obj.GetComponent <DependentRevolvedSurface>() != null) { return(GeoObjDef.Dependent); } else if (obj.GetComponent <StaticRevolvedSurface>() != null) { return(GeoObjDef.Static); } else { return(GeoObjDef.Abstract); } case GeoObjType.torus: //if (obj.GetComponent<InteractableTorus>() != null) //{ // return GeoObjDef.Interactable; //} //else if (obj.GetComponent<DependentTorus>() != null) //{ // return GeoObjDef.Dependent; //Cases do not exist yet //} //else if (obj.GetComponent<StaticTorus>() != null) //{ // return GeoObjDef.Static; //} //else //{ // return GeoObjDef.Abstract; //} return(GeoObjDef.none); case GeoObjType.flatface: return(GeoObjDef.none); case GeoObjType.straightedge: return(GeoObjDef.none); default: Debug.Log("Object type not supported within XMLManager! " + obj.figType + " was attempted and failed to serialize."); return(GeoObjDef.none); } }
//[ContextMenu("Load from Save")] for debugging make public and uncomment private void xmlToMGO() { Dictionary <string, AbstractGeoObj> spawnedObjects = new Dictionary <string, AbstractGeoObj>(); foreach (GeoObj geo in GeoObjDB.list) { switch (geo.type) { case GeoObjType.point: AbstractGeoObj spawnedPoint = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedPoint = GeoObjConstruction.dPoint(geo.position); break; case GeoObjDef.Interactable: spawnedPoint = GeoObjConstruction.iPoint(geo.position); break; case GeoObjDef.Static: spawnedPoint = GeoObjConstruction.sPoint(geo.position); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedPoint != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedPoint, geo.label); } spawnedObjects.Add(geo.figName, spawnedPoint); } break; case GeoObjType.line: AbstractGeoObj spawnedLine = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedLine = GeoObjConstruction.dLineSegment(spawnedObjects[geo.dependencies[0]] as AbstractPoint, spawnedObjects[geo.dependencies[1]] as AbstractPoint); break; case GeoObjDef.Interactable: spawnedLine = GeoObjConstruction.iLineSegment(spawnedObjects[geo.dependencies[0]] as AbstractPoint, spawnedObjects[geo.dependencies[1]] as AbstractPoint); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedLine != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedLine, geo.label); } spawnedObjects.Add(geo.figName, spawnedLine); } break; case GeoObjType.polygon: AbstractGeoObj spawnedPoly = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. List <AbstractLineSegment> lineList; List <AbstractPoint> pointList; switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: lineList = new List <AbstractLineSegment>(); geo.dependencies.Where(d => spawnedObjects[d].figType == GeoObjType.line).ToList().ForEach(l => lineList.Add(spawnedObjects[l] as AbstractLineSegment)); pointList = new List <AbstractPoint>(); geo.dependencies.Where(d => spawnedObjects[d].figType == GeoObjType.point).ToList().ForEach(p => pointList.Add(spawnedObjects[p] as AbstractPoint)); spawnedPoly = GeoObjConstruction.dPolygon(lineList, pointList); break; case GeoObjDef.Interactable: lineList = new List <AbstractLineSegment>(); geo.dependencies.Where(d => spawnedObjects[d].figType == GeoObjType.line).ToList().ForEach(l => lineList.Add(spawnedObjects[l] as AbstractLineSegment)); pointList = new List <AbstractPoint>(); geo.dependencies.Where(d => spawnedObjects[d].figType == GeoObjType.point).ToList().ForEach(p => pointList.Add(spawnedObjects[p] as AbstractPoint)); spawnedPoly = GeoObjConstruction.iPolygon(lineList, pointList); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedPoly != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedPoly, geo.label); } spawnedObjects.Add(geo.figName, spawnedPoly); } break; case GeoObjType.prism: AbstractGeoObj spawnedPrism = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Interactable: if (!(geo.prismData.bases.Count < 2 || geo.prismData.sides.Count < spawnedObjects[geo.prismData.bases[0]].GetComponent <AbstractPolygon>().pointList.Count)) { List <AbstractPolygon> bases = new List <AbstractPolygon>(); List <AbstractPolygon> sides = new List <AbstractPolygon>(); geo.prismData.bases.ForEach(b => bases.Add(spawnedObjects[b] as AbstractPolygon)); geo.prismData.sides.ForEach(s => sides.Add(spawnedObjects[s] as AbstractPolygon)); spawnedPrism = GeoObjConstruction.iPrism(bases, sides); } else { List <AbstractLineSegment> edges = new List <AbstractLineSegment>(); geo.prismData.edges.ForEach(e => edges.Add(spawnedObjects[e] as AbstractLineSegment)); spawnedPrism = GeoObjConstruction.iPrism(edges); } break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedPrism != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedPrism, geo.label); } spawnedObjects.Add(geo.figName, spawnedPrism); } break; case GeoObjType.pyramid: AbstractGeoObj spawnedPyramid = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedPyramid = GeoObjConstruction.dPyramid(spawnedObjects[geo.dependencies[0]] as AbstractPolygon, spawnedObjects[geo.pyramidData.apexName] as AbstractPoint); break; case GeoObjDef.Interactable: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedPyramid != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedPyramid, geo.label); } spawnedObjects.Add(geo.figName, spawnedPyramid); } break; case GeoObjType.circle: AbstractGeoObj spawnedCircle = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedCircle = GeoObjConstruction.dCircle(spawnedObjects[geo.dependencies[0]] as AbstractPoint, spawnedObjects[geo.dependencies[1]] as AbstractPoint, geo.circleData.normDir); break; case GeoObjDef.Interactable: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedCircle != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedCircle, geo.label); } spawnedObjects.Add(geo.figName, spawnedCircle); } break; case GeoObjType.sphere: AbstractGeoObj spawnedSphere = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedSphere = GeoObjConstruction.dSphere(spawnedObjects[geo.dependencies[0]] as AbstractPoint, spawnedObjects[geo.dependencies[1]] as AbstractPoint); break; case GeoObjDef.Interactable: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedSphere != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedSphere, geo.label); } spawnedObjects.Add(geo.figName, spawnedSphere); } break; case GeoObjType.revolvedsurface: AbstractGeoObj spawnedrevSurf = null; //initialzed as null so that cases that do not spawn still have it initialized but still fails a null check. switch (geo.definition) { case GeoObjDef.Abstract: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Dependent: spawnedrevSurf = GeoObjConstruction.dRevSurface(spawnedObjects[geo.dependencies[0]] as AbstractPoint, spawnedObjects[geo.dependencies[1]] as AbstractLineSegment, geo.revSurfData.normDir); spawnedrevSurf.transform.position = geo.position; spawnedrevSurf.transform.rotation = geo.rotation; break; case GeoObjDef.Interactable: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.Static: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; case GeoObjDef.none: Debug.Log(geo.figName + " was attempted to spawn but is not supported yet within XMLManager script! Add construction function in place of this log."); break; default: break; } if (spawnedrevSurf != null) { if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(spawnedrevSurf, geo.label); } spawnedObjects.Add(geo.figName, spawnedrevSurf); } break; case GeoObjType.torus: break; case GeoObjType.flatface: Transform flatface = flatfaceBehave.Constructor().transform; flatface.transform.position = geo.position; flatface.transform.rotation = geo.rotation; if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(flatface.GetComponent <flatfaceBehave>(), geo.label); } spawnedObjects.Add(geo.figName, flatface.GetComponent <AbstractGeoObj>()); break; case GeoObjType.straightedge: Transform straightEdge = straightEdgeBehave.Constructor().transform; straightEdge.transform.position = geo.position; straightEdge.transform.rotation = geo.rotation; if (!String.IsNullOrEmpty(geo.label)) { GeoObjConstruction.label(straightEdge.GetComponent <straightEdgeBehave>(), geo.label); } spawnedObjects.Add(geo.figName, straightEdge.GetComponent <AbstractGeoObj>()); break; default: break; } } }
public void updateIntersectionProduct(AbstractGeoObj mgo) { AbstractGeoObj[] parents = pastIntersections[mgo]; switch (parents[0].figType) { case GeoObjType.circle: switch (parents[1].figType) { case GeoObjType.circle: updateCircleCircle(mgo, parents[0], parents[1]); break; case GeoObjType.sphere: updateSphereCircle(mgo, parents[1], parents[0]); break; case GeoObjType.flatface: updateCirclePlane(mgo, parents[0], parents[1]); break; case GeoObjType.straightedge: updateCircleLine(mgo, parents[0], parents[1]); break; default: Debug.LogWarning("ParentTypeMisMatch"); break; } break; case GeoObjType.sphere: switch (parents[1].figType) { case GeoObjType.circle: updateSphereCircle(mgo, parents[0], parents[1]); break; case GeoObjType.sphere: updateSphereSphere(mgo, parents[0], parents[1]); break; case GeoObjType.flatface: updateSpherePlane(mgo, parents[0], parents[1]); break; case GeoObjType.straightedge: updateSphereLine(mgo, parents[0], parents[1]); break; default: Debug.LogWarning("ParentTypeMisMatch"); break; } break; case GeoObjType.flatface: switch (parents[1].figType) { case GeoObjType.circle: updateCirclePlane(mgo, parents[1], parents[0]); break; case GeoObjType.sphere: updateSpherePlane(mgo, parents[0], parents[1]); break; case GeoObjType.flatface: updatePlanePlane(mgo, parents[0], parents[1]); break; case GeoObjType.straightedge: updatePlaneLine(mgo, parents[0], parents[1]); break; default: Debug.LogWarning("ParentTypeMisMatch"); break; } break; case GeoObjType.straightedge: switch (parents[1].figType) { case GeoObjType.circle: updateCircleLine(mgo, parents[1], parents[0]); break; case GeoObjType.sphere: updateSphereLine(mgo, parents[1], parents[0]); break; case GeoObjType.flatface: updatePlaneLine(mgo, parents[1], parents[0]); break; case GeoObjType.straightedge: updateLineLine(mgo, parents[0], parents[1]); break; default: Debug.LogWarning("ParentTypeMisMatch"); break; } break; default: Debug.LogWarning("ParentTypeMisMatch"); break; } }
private bool checkInDictionary(AbstractGeoObj obj1, AbstractGeoObj obj2) { return(hashIntersectedFigs.Contains(obj1.name + obj2.name) || hashIntersectedFigs.Contains(obj1.name + obj2.name)); //return (pastIntersections.ContainsKey(inputList) || pastIntersections.ContainsKey(inputList2)); }
/// <summary> /// Given a pair of AbstractGeoObjs, check to see if they intersect. /// </summary> internal void checkIntersection(AbstractGeoObj obj1, AbstractGeoObj obj2) { if (!checkInDictionary(obj1, obj2)) { //Debug.Log(obj1.figName + " " + obj2.figName); switch (obj1.figType) { case GeoObjType.sphere: switch (obj2.figType) { case GeoObjType.sphere: AddToDictionary(obj1, obj2, checkSphereSphere(obj1.GetComponent <AbstractSphere>(), obj2.GetComponent <AbstractSphere>())); break; case GeoObjType.straightedge: AddToDictionary(obj1, obj2, checkSphereStraightEdge(obj1.GetComponent <AbstractSphere>(), obj2.GetComponent <straightEdgeBehave>())); break; case GeoObjType.flatface: AddToDictionary(obj1, obj2, checkSphereFlatface(obj1.GetComponent <AbstractSphere>(), obj2.GetComponent <flatfaceBehave>())); break; } break; case GeoObjType.circle: switch (obj2.figType) { case GeoObjType.sphere: AddToDictionary(obj1, obj2, checkSpherecircle(obj2.GetComponent <AbstractSphere>(), obj1.GetComponent <AbstractCircle>())); break; case GeoObjType.circle: AddToDictionary(obj1, obj2, CheckCircleCircle(obj1.GetComponent <AbstractCircle>(), obj2.GetComponent <AbstractCircle>())); break; case GeoObjType.straightedge: AddToDictionary(obj1, obj2, checkCircleStraightEdge(obj1.GetComponent <AbstractCircle>(), obj2.GetComponent <straightEdgeBehave>())); break; case GeoObjType.flatface: AddToDictionary(obj1, obj2, checkCircleFlatface(obj1.GetComponent <AbstractCircle>(), obj2.GetComponent <flatfaceBehave>())); break; } break; case GeoObjType.flatface: switch (obj2.figType) { case GeoObjType.sphere: AddToDictionary(obj1, obj2, checkSphereFlatface(obj2.GetComponent <AbstractSphere>(), obj1.GetComponent <flatfaceBehave>())); break; case GeoObjType.circle: AddToDictionary(obj1, obj2, checkCircleFlatface(obj2.GetComponent <AbstractCircle>(), obj1.GetComponent <flatfaceBehave>())); break; case GeoObjType.straightedge: AddToDictionary(obj1, obj2, checkFlatfaceStraightedge(obj1.GetComponent <flatfaceBehave>(), obj2.GetComponent <straightEdgeBehave>())); break; case GeoObjType.flatface: AddToDictionary(obj1, obj2, checkFlatfaceFlatface(obj1.GetComponent <flatfaceBehave>(), obj2.GetComponent <flatfaceBehave>())); break; } break; case GeoObjType.straightedge: switch (obj2.figType) { case GeoObjType.sphere: AddToDictionary(obj1, obj2, checkSphereStraightEdge(obj2.GetComponent <AbstractSphere>(), obj1.GetComponent <straightEdgeBehave>())); break; case GeoObjType.circle: AddToDictionary(obj1, obj2, checkCircleStraightEdge(obj2.GetComponent <AbstractCircle>(), obj1.GetComponent <straightEdgeBehave>())); break; case GeoObjType.straightedge: AddToDictionary(obj1, obj2, checkStraightedgeStraightedge(obj1.GetComponent <straightEdgeBehave>(), obj2.GetComponent <straightEdgeBehave>())); break; case GeoObjType.flatface: AddToDictionary(obj1, obj2, checkFlatfaceStraightedge(obj2.GetComponent <flatfaceBehave>(), obj1.GetComponent <straightEdgeBehave>())); break; } break; } } }