Пример #1
0
        // Use this for initialization
        void Start()
        {
            InteractablePolygon iPoly = GeoObjConstruction.rPoly(5, .2f, Vector3.up * 1.8f, Vector3.up);
            ProjectedPolygon    pPoly = iPoly.gameObject.AddComponent <ProjectedPolygon>();

            pPoly.Initialize();
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        private void checkTwoPoints()
        {
            if (prevSet && currSet && _prevPoint != _currPoint)
            {
                currPoint.tag = "Untagged";
                prevPoint.tag = "Untagged";
                switch (thisPinType)
                {
                case pinType.polymaker:
                    lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                    //if (_currPoint == pointList[0] && lineList.Count > 1 && pointsAreCoPlanar(pointList,lineList))
                    if (_currPoint == pointList[0] && lineList.Count > 1)
                    {
                        GeoObjConstruction.iPolygon(lineList, pointList);
                        endInteraction();
                    }
                    successfullyMade = true;
                    break;

                case pinType.wireframe:
                    lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                    successfullyMade = true;
                    polyCut();
                    break;

                case pinType.solidmaker:
                    Debug.Log("This isn't setup yet do not use! Object: " + gameObject.name);
                    Destroy(gameObject, Time.fixedDeltaTime);
                    break;

                default:
                    break;
                }
            }
        }
        private void Start()
        {
            sidesForPyramids = new List <AbstractPolygon>();
            myPyramids       = new List <DependentPyramid>();

            myPrism = GeoObjConstruction.iPrism(GeoObjConstruction.rPoly(nSides, apothem, Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1), Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2);
            myPrism.LeapInteraction = false;
            foreach (AbstractLineSegment mgo in myPrism.allEdges)
            {
                mgo.LeapInteraction = false;
            }
            foreach (AbstractPolygon mgo in myPrism.allfaces)
            {
                mgo.LeapInteraction = false;
                foreach (AbstractPoint mgol2 in mgo.pointList)
                {
                    mgol2.LeapInteraction = false;
                }
            }
            foreach (AbstractPolygon side in myPrism.sides)
            {
                sidesForPyramids.Add(side);
            }
            sidesForPyramids.Add(myPrism.bases[0]);

            myApex = GeoObjConstruction.iPoint(Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2);

            //restrict the movement of myApex.
            flatface1 = flatlandSurface.Constructor();
            flatface1.GetComponent <MeshRenderer>().materials[0].color = Color.clear;
            flatface1.attachedObjs.Add(myApex);

            foreach (AbstractPolygon side in sidesForPyramids)
            {
                myPyramids.Add(GeoObjConstruction.dPyramid(side, myApex));
            }

            for (int i = 0; i < myPyramids.Count; i++)
            {
                foreach (AbstractPolygon face in myPyramids[i].allfaces)
                {
                    face.figColor        = mgoColor[i];
                    face.LeapInteraction = false;
                }
                foreach (AbstractLineSegment line in myPyramids[i].allEdges)
                {
                    line.LeapInteraction = false;
                }
                foreach (AbstractPoint point in myPyramids[i].basePolygon.pointList)
                {
                    point.LeapInteraction = false;
                }
            }
            foreach (DependentPyramid pyramid in myPyramids)
            {
                pyramid.GetComponent <InteractionBehaviour>().OnHoverBegin += updateGlow;
                pyramid.GetComponent <InteractionBehaviour>().OnHoverEnd   += updateGlow;
            }
        }
Пример #6
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);
        }
Пример #7
0
        private AbstractGeoObj[] checkStraightedgeStraightedge(straightEdgeBehave straightEdgeBehave1, straightEdgeBehave straightEdgeBehave2)
        {
            intersectionFigData data = IntersectionMath.LineLineIntersection(straightEdgeBehave1, straightEdgeBehave2);

            AbstractGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.point)
            {
                mgoResult = new AbstractGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]).setIntersectionFigure(0) };
            }
            return(mgoResult);
        }
Пример #8
0
        /// <summary>
        /// On Gesture end
        /// </summary>
        /// <param name="maybeNullHand">Hand reference that ended the gesture</param>
        /// <param name="reason">reason the gesture was ended</param>
        protected override void WhenGestureDeactivated(Hand maybeNullHand, DeactivationReason reason)
        {
            this.thisLR.enabled = false;
            if (maybeNullHand != null)
            {
                switch (reason)
                {
                case DeactivationReason.FinishedGesture:
                    playSuccessSound();

                    if (maybeNullHand.Fingers[0].IsExtended)
                    {
                        //thumb up is draw polygon
                        if (prevSet && currSet && _prevPoint != _currPoint)
                        {
                            lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                            int idx  = pointList.LastIndexOf(_currPoint);
                            int idx2 = pointList.IndexOf(_currPoint);

                            if (idx > idx2 && lineList.Count > 1)
                            {
                                List <AbstractPoint>       p1 = pointList.GetRange(idx2, (idx) - idx2);
                                List <AbstractLineSegment> l1 = lineList.Where(l => p1.Contains(l.GetComponent <DependentLineSegment>().point1) || p1.Contains(l.GetComponent <DependentLineSegment>().point2)).ToList();
                                //TODO: Point list is overpopulated. CodyCodyCodyCodyCodyCody
                                GeoObjConstruction.iPolygon(l1, p1);
                                endInteraction();
                            }
                        }
                    }
                    else
                    {
                        //thumb down is draw wireframe
                        if (prevSet && currSet && _prevPoint != _currPoint)
                        {
                            lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                        }
                    }
                    break;

                default:
                    break;
                }

                Chirality chirality = Chirality.Right;
                if (maybeNullHand.IsLeft)
                {
                    chirality = Chirality.Left;
                }
                handColourManager.setHandColorMode(chirality, handColourManager.handModes.none);
            }
        }
Пример #9
0
        public void constructLatticeLand()
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    for (int k = 0; k < size; k++)
                    {
                        StaticPoint curr = GeoObjConstruction.sPoint(scaleFactor * ((i - (size / 2)) * basisSystem[0] + j * basisSystem[1] + (k - (size / 2)) * basisSystem[2]) + translation);
                        curr.transform.SetParent(transform);
                        //curr.GetComponent<InteractionBehaviour>().enabled = false;

                        curr.GetComponent <MasterGeoObj>().allowDelete = false;
                    }
                }
            }
        }
Пример #10
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);
        }
Пример #11
0
        private AbstractGeoObj[] checkSpherecircle(AbstractSphere abstractSphere, AbstractCircle abstractCircle)
        {
            intersectionFigData data = IntersectionMath.SphereCircleIntersection(abstractSphere, abstractCircle);

            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);
        }
Пример #12
0
        private AbstractGeoObj[] checkCircleFlatface(AbstractCircle abstractCircle, flatfaceBehave flatfaceBehave)
        {
            intersectionFigData data = IntersectionMath.CirclePlaneIntersection(abstractCircle, flatfaceBehave);

            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);
        }
Пример #13
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);
        }
        private void Start()
        {
            myPrism = GeoObjConstruction.iPrism(GeoObjConstruction.rPoly(nSides, Mathf.Abs(height1 - height2) / 2f, Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1), Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2);
            myPrism.LeapInteraction = false;
            foreach (AbstractLineSegment mgo in myPrism.allEdges)
            {
                mgo.LeapInteraction = false;
            }
            foreach (AbstractPolygon mgo in myPrism.bases)
            {
                mgo.LeapInteraction = false;
                foreach (AbstractPoint mgol2 in mgo.pointList)
                {
                    mgol2.LeapInteraction = false;
                }
            }

            foreach (AbstractPolygon face in myPrism.allfaces)
            {
                face.figColor = mgoColor;
            }

            //pyramid 1 - base ABC - apex D
            myPyramids.Add(GeoObjConstruction.dPyramid(myPrism.bases[0], myPrism.bases[1].pointList[0]));

            //pyramid 2 - base DEF - apex C
            myPyramids.Add(GeoObjConstruction.dPyramid(myPrism.bases[1], myPrism.bases[0].pointList[2]));

            //pyramid 3 - base CBD - apex E
            myPyramids.Add(GeoObjConstruction.dPyramid(myPyramids[0].sides[1], myPrism.bases[1].pointList[1]));

            foreach (DependentPyramid pyramid in myPyramids)
            {
                pyramid.GetComponent <InteractionBehaviour>().OnHoverBegin += updateGlow;
                pyramid.GetComponent <InteractionBehaviour>().OnHoverEnd   += updateGlow;
            }
        }
Пример #15
0
        internal void Start()
        {
            shearingLabManager labMan = FindObjectOfType <shearingLabManager>();

            labMan.measurementDisplays.Add(areaModel.transform);
            labMan.measurementDisplays.Add(perimeterModel.transform);
            //labMan.measurementDisplays.Add(crossSectionModel.transform);
            labMan.disableDisplays();

            areaModel.GetComponent <MeshRenderer>().materials[0].color         = mgoColor;
            perimeterModel.GetComponent <LineRenderer>().materials[0].color    = mgoColor;
            crossSectionModel.GetComponent <LineRenderer>().materials[0].color = mgoColor;


            line1 = parallelLines.Constructor();
            parallelLines line2 = parallelLines.Constructor();

            line1.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2;
            line2.Position3 = Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1;

            line1.otherLine = line2;
            line2.otherLine = line1;

            AbstractPoint p1 = GeoObjConstruction.iPoint(line1.Position3);
            AbstractPoint p2 = GeoObjConstruction.iPoint(line2.Position3);
            AbstractPoint p3 = GeoObjConstruction.iPoint(line2.Position3 + line2.normalDir * 0.3f);

            p1.GetComponent <InteractionBehaviour>().OnGraspedMovement += checkOutOfRange;
            p1.GetComponent <InteractionBehaviour>().OnGraspEnd        += constantVelOutOfRange;

            labMan.addApexToList(p1);
            //line not on Parallel
            l1 = GeoObjConstruction.dLineSegment(p1, p2);
            //line not on parallel
            l2 = GeoObjConstruction.dLineSegment(p1, p3);
            //line on parallel
            AbstractLineSegment l3 = GeoObjConstruction.dLineSegment(p3, p2);

            line1.attachedObjs.Add(p1);
            line2.attachedObjs.Add(p2);
            line2.attachedObjs.Add(p3);

            points.Add(p1);
            points.Add(p2);
            points.Add(p3);

            lines.Add(l1);
            lines.Add(l2);
            lines.Add(l3);

            triangle = GeoObjConstruction.dPolygon(lines, points);

            foreach (AbstractLineSegment line in lines)
            {
                line.GetComponent <InteractionBehaviour>().enabled = false;
            }

            triangle.GetComponent <InteractionBehaviour>().enabled = false;

            myLR = GetComponent <LineRenderer>();

            palmDetectors = GetComponentsInChildren <PalmDirectionDetector>();

            for (int i = 0; i < palmDetectors.Length; i++)
            {
                PalmDirectionDetector palm = palmDetectors[i];
                palm.OnActivate.AddListener(startUpdateMesh);
                palm.OnDeactivate.AddListener(endUpdateMesh);

                ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>();
                finger.OnDeactivate.AddListener(endUpdateMesh);

                switch (i)
                {
                case 0:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    break;

                case 1:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.RHand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged;
                    break;

                default:
                    break;
                }
                //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors.
            }

            updateLR = updateLR_Routine();

            if (overridePalmDetector)
            {
                startUpdateMesh();
            }

            triangle.figColor = mgoColor;

            movePointOnLine = animatePoint(points[0]);
        }
Пример #16
0
        //[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;
                }
            }
        }
        internal void Start()
        {
            shearingLabManager labMan = FindObjectOfType <shearingLabManager>();

            labMan.measurementDisplays.Add(surfaceAreaModel.transform);
            labMan.measurementDisplays.Add(volumeModel.transform);
            //labMan.measurementDisplays.Add(crossSectionModel.transform);
            labMan.disableDisplays();

            surfaceAreaModel.GetComponent <MeshRenderer>().materials[0].color  = mgoColor;
            volumeModel.GetComponent <MeshRenderer>().materials[0].color       = mgoColor;
            crossSectionModel.GetComponent <MeshRenderer>().materials[0].color = mgoColor;
            //copy into base scene on Load.
            //this.transform.parent = SceneManager.GetSceneByName("HandWaverBase").GetRootGameObjects()[0].transform.parent;

            //construct parallel planes

            flatface1 = flatlandSurface.Constructor();
            flatface2 = flatlandSurface.Constructor();

            flatface1.otherFlatlandSurface = flatface2;
            flatface2.otherFlatlandSurface = flatface1;

            flatface1.transform.localScale = new Vector3(3f, .0001f, 3f);
            flatface2.transform.localScale = new Vector3(3f, .0001f, 3f);

            AbstractPoint   apexPoint = GeoObjConstruction.iPoint(Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height2);
            AbstractPolygon basePoly  = GeoObjConstruction.rPoly(nSides, .3f, Vector3.ProjectOnPlane(this.transform.position, Vector3.up) + Vector3.up * height1);

            myPyramid = GeoObjConstruction.dPyramid(basePoly, apexPoint);

            foreach (AbstractLineSegment line in myPyramid.allEdges)
            {
                line.LeapInteraction = false;
            }
            foreach (AbstractPoint point in basePoly.pointList)
            {
                point.LeapInteraction = false;
                flatface1.attachedObjs.Add(point);
            }
            foreach (AbstractPolygon face in myPyramid.allfaces)
            {
                face.LeapInteraction = false;
            }
            flatface2.attachedObjs.Add(apexPoint);
            flatface2.attachedObjs.Add(basePoly);

            myPyramid.GetComponent <InteractionBehaviour>().enabled = false;

            mf.transform.position   = Vector3.zero;
            mf.transform.localScale = Vector3.one;
            mf.transform.rotation   = Quaternion.identity;

            palmDetectors = GetComponentsInChildren <PalmDirectionDetector>();

            //NATHAN HELP ME HERE
            for (int i = 0; i < palmDetectors.Length; i++)
            {
                PalmDirectionDetector palm = palmDetectors[i];

                palm.OnActivate.AddListener(startUpdateMesh);
                palm.OnDeactivate.AddListener(endUpdateMesh);

                ExtendedFingerDetector finger = palm.GetComponent <ExtendedFingerDetector>();

                finger.OnDeactivate.AddListener(endUpdateMesh);
                //the extended finger detectors are set to enable/disable the respective PalmDirectionDetectors.

                switch (i)
                {
                case 0:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.Lhand_rigged;
                    break;

                case 1:
                    palm.HandModel   = leapHandDataLogger.ins.currHands.RHand_rigged;
                    finger.HandModel = leapHandDataLogger.ins.currHands.RHand_rigged;
                    break;

                default:
                    break;
                }
            }

            updateMesh = updateMeshRoutine();
            if (overrideHandInput)
            {
                startUpdateMesh();
            }

            foreach (AbstractPolygon face in myPyramid.allfaces)
            {
                face.figColor = mgoColor;
            }

            myPyramid.apex.GetComponent <InteractionBehaviour>().OnGraspEnd += constantVelOutOfRange;
            labMan.addApexToList(myPyramid.apex);
        }
        // Use this for initialization
        private void Start()
        {
            volumeLineRenderer = GetComponentInChildren <LineRenderer>();
            TMPro         = GetComponentInChildren <TextMeshPro>();
            myAudioSource = GetComponent <AudioSource>();

            xLen          = .1f;
            controllPoint = GeoObjConstruction.iPoint(this.transform.position);
            prismBase.Add(controllPoint);
            prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.right * (sideLength1 - 2 * xLen)));
            prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.right * (sideLength1 - 2 * xLen) + Vector3.forward * (sideLength2 - 2 * xLen)));
            prismBase.Add(GeoObjConstruction.dPoint(controllPoint.Position3 + Vector3.forward * (sideLength2 - 2 * xLen)));

            List <AbstractLineSegment> prismBaseLines = new List <AbstractLineSegment>();

            for (int i = 0; i < 3; i++)
            {
                prismBaseLines.Add(GeoObjConstruction.dLineSegment(prismBase[i], prismBase[i + 1]));
            }
            prismBaseLines.Add(GeoObjConstruction.dLineSegment(prismBase[prismBase.Count - 1], prismBase[0]));

            prismBasePoly = GeoObjConstruction.dPolygon(prismBaseLines, prismBase);
            prism         = GeoObjConstruction.dPrism(prismBasePoly, prismBasePoly.center + Vector3.up * xLen);
            prismTopPoly  = prism.bases[1];

            cutoutRectangle.Add(prismBase[0]);
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[0].Position3 + Vector3.back * xLen));
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[1].Position3 + Vector3.back * xLen));
            cutoutRectangle.Add(prismBase[1]);
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[1].Position3 + Vector3.right * xLen));
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[2].Position3 + Vector3.right * xLen));
            cutoutRectangle.Add(prismBase[2]);
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[2].Position3 + Vector3.forward * xLen));
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[3].Position3 + Vector3.forward * xLen));
            cutoutRectangle.Add(prismBase[3]);
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[3].Position3 + Vector3.left * xLen));
            cutoutRectangle.Add(GeoObjConstruction.dPoint(prismBase[0].Position3 + Vector3.left * xLen));

            List <AbstractLineSegment> cutoutLines = new List <AbstractLineSegment>();

            for (int i = 0; i < cutoutRectangle.Count - 1; i++)
            {
                cutoutLines.Add(GeoObjConstruction.dLineSegment(cutoutRectangle[i], cutoutRectangle[i + 1]));
            }
            cutoutLines.Add(GeoObjConstruction.dLineSegment(cutoutRectangle[0], cutoutRectangle[cutoutRectangle.Count - 1]));

            cutoutRectanglePoly = GeoObjConstruction.dPolygon(cutoutLines, cutoutRectangle);

            foreach (MasterGeoObj mgo in prism.transform.parent.GetComponentsInChildren <MasterGeoObj>())
            {
                if (mgo != controllPoint)
                {
                    mgo.LeapInteraction = false;
                }
            }

            controllPoint.GetComponent <Leap.Unity.Interaction.InteractionBehaviour>().OnGraspedMovement += updateDiagram;
            controllPoint.GetComponent <Leap.Unity.Interaction.InteractionBehaviour>().OnGraspEnd        += updateDiagram;
            volumeLineRenderer.useWorldSpace = false;

            Color tmp = Color.blue;

            tmp.a = .5f;

            cutoutRectanglePoly.figColor = tmp;
            foreach (AbstractPolygon poly in prism.allfaces)
            {
                tmp           = Color.red;
                tmp.a         = .5f;
                poly.figColor = tmp;
            }
            prism.bases[0].figColor = Color.clear;
        }
Пример #19
0
        private void polyCut()
        {
            List <AbstractPolygon> prevPointPolygons = new List <AbstractPolygon>();
            List <AbstractPolygon> currPointPolygons = new List <AbstractPolygon>();

            HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(_prevPoint.figName)                                                           //all bidirectional neighbors
            .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>() != null).ToList()          // list of all abstractpolygons in prev list
            .ForEach(d => prevPointPolygons.Add(HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>())); //foreach adds the polygon to final list
            HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(_currPoint.figName)                                                           //same as above but with other point
            .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>() != null).ToList()
            .ForEach(d => currPointPolygons.Add(HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>()));
            //prevPointPolygons.ForEach(p => Debug.Log(_prevPoint.figName + " is in the following: " + p.figName));
            //Debug.Log("_____+_____");
            //currPointPolygons.ForEach(p => Debug.Log(_currPoint.figName + " is in the following: " + p.figName));
            //Debug.Log("_____=_____");
            List <AbstractPolygon> sharedPolygons;

            if (prevPointPolygons.Count > currPointPolygons.Count)
            {
                sharedPolygons = prevPointPolygons.Intersect(currPointPolygons).Where(poly => poly.lineList.Count > 3).ToList();
            }
            else
            {
                sharedPolygons = currPointPolygons.Intersect(prevPointPolygons).Where(poly => poly.lineList.Count > 3).ToList();
            }
            //sharedPolygons.ForEach(p => Debug.Log("Both are in the following: " + p.figName));
            //list created from any duplicates from two prev lists that have more than 3 sides
            //Debug.Log(_prevPoint.figName + " and " + _currPoint.figName + " are both on " + sharedPolygons.Count + " together.");
            if (sharedPolygons.Count > 0)
            {
                DependentLineSegment cutLine = GeoObjConstruction.dLineSegment(_prevPoint, _currPoint);
                foreach (AbstractPolygon p in sharedPolygons)
                {
                    List <AbstractPoint>       currPointList = p.pointList;
                    List <AbstractLineSegment> currLineList  = p.lineList;
                    if (Mathf.Abs(currPointList.IndexOf(_prevPoint) - currPointList.IndexOf(_currPoint)) > 1)
                    {
                        List <AbstractPoint> newPointList1 = newPointListGen(currPointList, currPointList.IndexOf(_prevPoint), currPointList.IndexOf(_currPoint));
                        List <AbstractPoint> newPointList2 = newPointListGen(currPointList, currPointList.IndexOf(_currPoint), currPointList.IndexOf(_prevPoint));

                        List <AbstractLineSegment> newLineList1 = new List <AbstractLineSegment>()
                        {
                            cutLine
                        };                                                                                                           //creates list and adds the line created by the cut
                        List <AbstractLineSegment> newLineList2 = new List <AbstractLineSegment>()
                        {
                            cutLine
                        };                                                                                                   //creates list and adds the line created by the cut
                        foreach (AbstractLineSegment currLine in currLineList                                                //newLineList1 Generator
                                 .Where(cL => ((cL.GetComponent <InteractableLineSegment>() != null &&                       //is interactable line segment and point1 or point2 is found in newPointList1
                                                newPointList1.Any(point => point == cL.GetComponent <InteractableLineSegment>().point1 || point == cL.GetComponent <InteractableLineSegment>().point2)) ||
                                               ((cL.GetComponent <DependentLineSegment>() != null &&                         //is dependent line segment and point1 or point2 is found in newPointList1
                                                 newPointList1.Any(point => point == cL.GetComponent <DependentLineSegment>().point1 || point == cL.GetComponent <DependentLineSegment>().point2))))))
                        {
                            newLineList1.Add(currLine);
                        }
                        foreach (AbstractLineSegment currLine in currLineList                                                   //newLineList2 Generator
                                 .Where(cL => ((cL.GetComponent <InteractableLineSegment>() != null &&                          //is interactable line segment and point1 or point2 is found in newPointList1
                                                newPointList2.Any(point => point == cL.GetComponent <InteractableLineSegment>().point1 || point == cL.GetComponent <InteractableLineSegment>().point2)) ||
                                               ((cL.GetComponent <DependentLineSegment>() != null &&                            //is dependent line segment and point1 or point2 is found in newPointList1
                                                 newPointList2.Any(point => point == cL.GetComponent <DependentLineSegment>().point1 || point == cL.GetComponent <DependentLineSegment>().point2))))))
                        {
                            newLineList2.Add(currLine);
                        }
                        AbstractPolygon          newPoly1      = GeoObjConstruction.iPolygon(newLineList1, newPointList1);
                        AbstractPolygon          newPoly2      = GeoObjConstruction.iPolygon(newLineList2, newPointList2);
                        List <InteractablePrism> currPrismList = new List <InteractablePrism>();
                        HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(p.figName)                        //all bidirectional neighbors
                        .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <InteractablePrism>() != null).ToList().ForEach(prism => currPrismList.Add(prism.mytransform.GetComponent <InteractablePrism>()));
                        foreach (InteractablePrism cPrism in currPrismList)
                        {
                            HW_GeoSolver.ins.AddDependence(newPoly1, cPrism);
                            HW_GeoSolver.ins.AddDependence(newPoly2, cPrism);
                        }
                        HW_GeoSolver.ins.removeComponent(p);
                    }
                }
            }
        }