Exemplo n.º 1
0
        private MasterGeoObj[] 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());

            MasterGeoObj[] 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 MasterGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(0), newCircle.setIntersectionFigure(0) };
            }
            else if (data.figtype == GeoObjType.point)
            {
                mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) };
            }
            return(mgoResult);
        }
Exemplo n.º 2
0
        private MasterGeoObj[] checkSphereFlatface(AbstractSphere abstractSphere, flatfaceBehave flatfaceBehave)
        {
            intersectionFigData data = IntersectionMath.SpherePlaneIntersection(abstractSphere, flatfaceBehave);

            MasterGeoObj[] 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 MasterGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(1), newCircle.setIntersectionFigure(2) };
            }
            else if (data.figtype == GeoObjType.point)
            {
                mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) };
            }
            return(mgoResult);
        }
Exemplo n.º 3
0
        private void updateSphereLine(MasterGeoObj mgo, MasterGeoObj masterGeoObj1, MasterGeoObj masterGeoObj2)
        {
            intersectionFigData data = IntersectionMath.SphereLineIntersection(masterGeoObj1.GetComponent <AbstractSphere>(), masterGeoObj2.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");
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        internal void removeComponent(MasterGeoObj 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);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks if there is an intersection between any figures in the scene that isnt currently attached to any anchor.
        /// </summary>
        public void checkIntersectAny()
        {
            MasterGeoObj[] geoObjList = GameObject.FindObjectsOfType <MasterGeoObj>().Where(g => g.GetComponent <AbstractPoint>() == null).ToArray();

            for (int i = 0; i < geoObjList.Length; i++)
            {
                MasterGeoObj obj1 = geoObjList[i];
                if (obj1.GetComponent <AnchorableBehaviour>() != null && (obj1.GetComponent <AnchorableBehaviour>().isAttached))
                {
                    continue;
                }
                if (true)
                {
                    for (int j = i + 1; j < geoObjList.Length; j++)
                    {
                        MasterGeoObj obj2 = geoObjList[j];
                        if (obj2.GetComponent <AnchorableBehaviour>() != null && (obj2.GetComponent <AnchorableBehaviour>().isAttached))
                        {
                            continue;
                        }
                        if (obj1 != obj2)
                        {
                            checkIntersection(obj1, obj2);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private MasterGeoObj[] checkFlatfaceStraightedge(flatfaceBehave flatfaceBehave, straightEdgeBehave straightEdgeBehave)
        {
            intersectionFigData data = IntersectionMath.LinePlaneIntersection(flatfaceBehave, straightEdgeBehave);

            MasterGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.point)
            {
                mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) };
            }
            return(mgoResult);
        }
Exemplo n.º 8
0
 ///// <summary>
 ///// Adds a dependence in the lifemanager and updatemanager and reactionmanager system
 ///// </summary>
 internal void AddDependence(MasterGeoObj fromMGO, MasterGeoObj toMGO)
 {
     //Debug.Log("adding directed edge from " + fromMGO.GetComponent<MasterGeoObj>().figName + " to " + toMGO.GetComponent<MasterGeoObj>().figName);
     if (string.IsNullOrEmpty(fromMGO.figName))
     {
         fromMGO.InitializeFigure();
     }
     if (string.IsNullOrEmpty(toMGO.figName))
     {
         toMGO.InitializeFigure();
     }
     geomanager.AddDirectedEdge(fromMGO.figName, toMGO.figName, 1);
 }
Exemplo n.º 9
0
        internal void addComponent(MasterGeoObj 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);
        }
        /// <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(MasterGeoObj 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!");
            }
        }
Exemplo n.º 11
0
        private MasterGeoObj[] CheckCircleCircle(AbstractCircle abstractCircle1, AbstractCircle abstractCircle2)
        {
            intersectionFigData data = IntersectionMath.CircleCircleIntersection(abstractCircle1, abstractCircle2);

            MasterGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.point)
            {
                if (data.vectordata.Length == 1)
                {
                    mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) };
                }
                else if (data.vectordata.Length == 2)
                {
                    mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0), GeoObjConstruction.dPoint(data.vectordata[1]).setIntersectionFigure(1) };
                }
            }
            return(mgoResult);
        }
Exemplo n.º 12
0
        private MasterGeoObj[] checkSphereStraightEdge(AbstractSphere abstractSphere, straightEdgeBehave straightEdgeBehave)
        {
            intersectionFigData data = IntersectionMath.SphereLineIntersection(abstractSphere, straightEdgeBehave);

            MasterGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.point)
            {
                if (data.vectordata.Length == 1)
                {
                    mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) };
                }
                else if (data.vectordata.Length == 2)
                {
                    mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0), GeoObjConstruction.dPoint(data.vectordata[1]).setIntersectionFigure(1) };
                }
            }
            return(mgoResult);
        }
Exemplo n.º 13
0
        private void updatePlanePlane(MasterGeoObj mgo, MasterGeoObj masterGeoObj1, MasterGeoObj masterGeoObj2)
        {
            intersectionFigData data = IntersectionMath.PlanePlaneIntersection(masterGeoObj1.GetComponent <flatfaceBehave>(), masterGeoObj2.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");
            }
        }
Exemplo n.º 14
0
        private void AddToDictionary(MasterGeoObj obj1, MasterGeoObj obj2, MasterGeoObj[] objList)
        {
            if (objList != null && objList.Length > 0)
            {
                MasterGeoObj[] inputList = new MasterGeoObj[2];
                inputList[0] = obj1;
                inputList[1] = obj2;

                hashIntersectedFigs.Add(obj1.name + obj2.name);

                foreach (MasterGeoObj 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);
                }
            }
        }
Exemplo n.º 15
0
        public bool foundMGO(Hand hand)
        {
            float shortestDist = Mathf.Infinity;

            closestObj = null;

            foreach (MasterGeoObj mgo in FindObjectsOfType <MasterGeoObj>().Where(g => (g.GetComponent <AnchorableBehaviour>() == null || (g.GetComponent <AnchorableBehaviour>() != null && !g.GetComponent <AnchorableBehaviour>().isAttached))).Where(g => g.GetComponent <MasterGeoObj>().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);
        }
Exemplo n.º 16
0
        private void updateCircleLine(MasterGeoObj mgo, MasterGeoObj masterGeoObj1, MasterGeoObj masterGeoObj2)
        {
            intersectionFigData data = IntersectionMath.CircleLineIntersection(masterGeoObj1.GetComponent <AbstractCircle>(), masterGeoObj2.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");
            }
        }
Exemplo n.º 17
0
        private void updateCirclePlane(MasterGeoObj mgo, MasterGeoObj masterGeoObj1, MasterGeoObj masterGeoObj2)
        {
            intersectionFigData data = IntersectionMath.CirclePlaneIntersection(masterGeoObj1.GetComponent <AbstractCircle>(), masterGeoObj2.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");
            }
        }
Exemplo n.º 18
0
        internal void checkLifeRequirements(MasterGeoObj 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);
            }
        }
Exemplo n.º 19
0
        private GeoObjDef determineDef(MasterGeoObj 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);
            }
        }
Exemplo n.º 20
0
        public void updateIntersectionProduct(MasterGeoObj mgo)
        {
            MasterGeoObj[] 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;
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Given a pair of MasterGeoObjs, check to see if they intersect.
        /// </summary>
        internal void checkIntersection(MasterGeoObj obj1, MasterGeoObj 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;
                }
            }
        }
Exemplo n.º 22
0
        //[ContextMenu("Load from Save")] for debugging make public and uncomment
        private void xmlToMGO()
        {
            Dictionary <string, MasterGeoObj> spawnedObjects = new Dictionary <string, MasterGeoObj>();

            foreach (GeoObj geo in GeoObjDB.list)
            {
                switch (geo.type)
                {
                case GeoObjType.point:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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:
                    MasterGeoObj 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 <MasterGeoObj>());
                    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 <MasterGeoObj>());
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 23
0
        private bool checkInDictionary(MasterGeoObj obj1, MasterGeoObj obj2)
        {
            return(hashIntersectedFigs.Contains(obj1.name + obj2.name) || hashIntersectedFigs.Contains(obj1.name + obj2.name));

            //return (pastIntersections.ContainsKey(inputList) || pastIntersections.ContainsKey(inputList2));
        }