Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
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);
                        }
                    }
                }
            }
        }
Esempio 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");
            }
        }
Esempio 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);
        }
        /// <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!");
            }
        }
Esempio n. 6
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");
            }
        }
Esempio n. 7
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");
            }
        }
Esempio n. 8
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");
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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;
                }
            }
        }
Esempio n. 11
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);
            }
        }