Пример #1
0
        public void Generate()
        {
            float apothem = 0.5f * unit / Mathf.Tan(Mathf.PI / nSides);

            apex     = GeoObjConstruction.iPoint(spawnPoint.position + unit * Vector3.up);
            basePoly = GeoObjConstruction.rPoly(nSides, apothem, spawnPoint.position);
            dPyramid = GeoObjConstruction.dPyramid(basePoly, apex);

            if (prism)
            {
                dPyramid.sides.ForEach(p => p.LeapInteraction = false);
                dPyramid.sides.ForEach(p => p.transform.GetChild(0).gameObject.SetActive(false));

                iPrism = GeoObjConstruction.iPrism(basePoly, spawnPoint.position + unit * Vector3.up);
                iPrism.LeapInteraction = false;

                iPrism.sides.ForEach(p => GeoObjConstruction.dPyramid(p, apex).sides.ForEach(q => q.LeapInteraction = false));
                iPrism.sides.ForEach(p => p.LeapInteraction = false);

                iPrism.bases.ForEach(p => p.pointList.ForEach(q => q.LeapInteraction = false));
                iPrism.bases.ForEach(p => p.pointList.ForEach(q => q.GetComponent <MeshRenderer>().enabled = false));

                HW_GeoSolver.ins.AddDependence(basePoly2, apex);

                apex.GetComponent <InteractionBehaviour>().OnGraspedMovement += updateFigure;
            }
            else
            {
                HW_GeoSolver.ins.removeComponent(basePoly2);
                //iPrism.geoManager.removeComponent(iPrism.transform);
            }
            thisAS.clip = successClip;
            thisAS.Play();
        }
Пример #2
0
        public static DependentPyramid dPyramid(AbstractPolygon basePoly, AbstractPoint apex)
        {
            DependentPyramid pyramid = DependentPyramid.Constructor();

            pyramid.basePolygon = basePoly;
            pyramid.apex        = apex;

            List <AbstractPolygon> sideList = new List <AbstractPolygon>();

            foreach (AbstractLineSegment baseLine in basePoly.lineList)
            {
                if (baseLine.GetComponent <InteractableLineSegment>() != null)
                {
                    List <AbstractPoint>       vertexList = new List <AbstractPoint>();
                    List <AbstractLineSegment> lineList   = new List <AbstractLineSegment>();

                    vertexList.Add(apex);
                    vertexList.Add(baseLine.GetComponent <InteractableLineSegment>().point1);
                    vertexList.Add(baseLine.GetComponent <InteractableLineSegment>().point2);

                    lineList.Add(baseLine);
                    lineList.Add(iLineSegment(apex, baseLine.GetComponent <InteractableLineSegment>().point1));
                    lineList.Add(iLineSegment(apex, baseLine.GetComponent <InteractableLineSegment>().point2));

                    sideList.Add(dPolygon(lineList, vertexList));
                }
                else
                {
                    List <AbstractPoint>       vertexList = new List <AbstractPoint>();
                    List <AbstractLineSegment> lineList   = new List <AbstractLineSegment>();

                    vertexList.Add(apex);
                    vertexList.Add(baseLine.GetComponent <DependentLineSegment>().point1);
                    vertexList.Add(baseLine.GetComponent <DependentLineSegment>().point2);

                    lineList.Add(baseLine);
                    lineList.Add(iLineSegment(apex, baseLine.GetComponent <DependentLineSegment>().point1));
                    lineList.Add(iLineSegment(apex, baseLine.GetComponent <DependentLineSegment>().point2));

                    sideList.Add(dPolygon(lineList, vertexList));
                }
            }

            pyramid.sides = sideList;

            HW_GeoSolver.ins.AddDependence(pyramid, basePoly);//This dependency must be first on the list for XMLManager Loading to operate correctly

            foreach (AbstractPolygon poly in sideList)
            {
                HW_GeoSolver.ins.AddDependence(pyramid, poly);
            }

            return(pyramid);
        }
Пример #3
0
 private void prevLine(AbstractPoint value)
 {
     if (value == null)
     {
         thisLR.enabled = false;
         updateLine     = false;
     }
     else
     {
         thisLR.enabled = true;
         thisLR.SetPosition(0, value.transform.position);
         updateLine = true;
         thisLR.SetPosition(1, endofPin.position);
     }
 }
Пример #4
0
        public static DependentLineSegment dLineSegment(AbstractPoint point1, AbstractPoint point2)
        {
            DependentLineSegment line = DependentLineSegment.Constructor();

            line.transform.GetComponent <DependentLineSegment>().point1 = point1.transform.GetComponent <AbstractPoint>();
            line.transform.GetComponent <DependentLineSegment>().point2 = point2.transform.GetComponent <AbstractPoint>();
            line.vertex0 = point1.Position3;
            line.vertex1 = point2.Position3;
            line.transform.GetComponent <DependentLineSegment>().InitializeFigure();

            HW_GeoSolver.ins.AddDependence(line, point1);
            HW_GeoSolver.ins.AddDependence(line, point2);

            return(line);
        }
Пример #5
0
        public static DependentSphere dSphere(AbstractPoint center, AbstractPoint edge)
        {
            DependentSphere thisSphere = DependentSphere.Constructor();

            thisSphere.center         = center;
            thisSphere.centerPosition = center.Position3;
            thisSphere.edge           = edge;
            thisSphere.edgePosition   = edge.Position3;
            thisSphere.Position3      = center.Position3;

            HW_GeoSolver.ins.AddDependence(thisSphere, center);
            HW_GeoSolver.ins.AddDependence(thisSphere, edge);

            thisSphere.InitializeFigure();
            return(thisSphere);
        }
Пример #6
0
        public static InteractableLineSegment iLineSegment(AbstractPoint point1, AbstractPoint point2)
        {
            InteractableLineSegment line = InteractableLineSegment.Constructor();

            line.point1  = point1;
            line.point2  = point2;
            line.vertex0 = point1.Position3;
            line.vertex1 = point2.Position3;
            line.transform.GetComponent <InteractableLineSegment>().InitializeFigure();

            HW_GeoSolver.ins.addComponent(line);
            HW_GeoSolver.ins.AddDependence(line, point1);
            HW_GeoSolver.ins.AddDependence(line, point2);

            return(line);
        }
Пример #7
0
        public static DependentCircle dCircle(AbstractPoint center, AbstractPoint edge, Vector3 normDir)
        {
            DependentCircle dc = DependentCircle.Constructor();

            dc.transform.parent = center.transform.parent;

            dc.center    = center;
            dc.centerPos = center.Position3;
            dc.edge      = edge;
            dc.edgePos   = edge.Position3;
            dc.normalDir = normDir;

            HW_GeoSolver.ins.AddDependence(dc, center);
            HW_GeoSolver.ins.AddDependence(dc, edge);

            dc.InitializeFigure();

            return(dc);
        }
Пример #8
0
 private void OnTriggerEnter(Collider other)
 {
     if (!madePyramid && other.GetComponent <AbstractPolygon>() != null)
     {
         apexOfPyramid = GeoObjConstruction.iPoint(transform.position);
         apexFollow    = true;
         StartCoroutine(Hold());
         GeoObjConstruction.dPyramid(other.GetComponent <AbstractPolygon>(), apexOfPyramid);
         madePyramid = true;
     }
     else if (!madePyramid && other.GetComponent <InteractableLineSegment>() != null)
     {
         apexOfPyramid = GeoObjConstruction.iPoint(transform.position);
         apexFollow    = true;
         StartCoroutine(Hold());
         GeoObjConstruction.iTriangle(other.GetComponent <InteractableLineSegment>(), apexOfPyramid);
         madePyramid = true;
     }
 }
Пример #9
0
        public static DependentRevolvedSurface dRevSurface(AbstractPoint center, AbstractLineSegment attachedLineSegment, Vector3 normDir)
        {
            DependentRevolvedSurface drs = DependentRevolvedSurface.Constructor();

            drs.transform.parent = attachedLineSegment.transform.parent;

            drs.attachedLine    = attachedLineSegment;
            drs.endpoint1       = attachedLineSegment.vertex0;
            drs.endpoint2       = attachedLineSegment.vertex1;
            drs.normalDirection = normDir;
            drs.centerPoint     = center.Position3;
            drs.center          = center;

            HW_GeoSolver.ins.AddDependence(drs, center);
            HW_GeoSolver.ins.AddDependence(drs, attachedLineSegment);

            drs.InitializeFigure();

            return(drs);
        }
        public override void Stretch(InteractionController iControll)
        {
            if (stretchEnabled && thisIBehave.graspingControllers.Count > 1)
            {
                iControll.ReleaseGrasp();
                AbstractPoint newPoint1 = GeoObjConstruction.iPoint(point1.Position3);
                AbstractPoint newPoint2 = GeoObjConstruction.iPoint(point2.Position3);

                GeoObjConstruction.iPolygon(new List <AbstractLineSegment>()
                {
                    this, GeoObjConstruction.iLineSegment(point1, newPoint1),
                    GeoObjConstruction.iLineSegment(newPoint1, newPoint2), GeoObjConstruction.iLineSegment(newPoint2, point2)
                },
                                            new List <AbstractPoint>()
                {
                    point1, newPoint1, newPoint2, point2
                });

                StartCoroutine(waitForStretch);
            }
        }
Пример #11
0
        internal static InteractablePrism iPrism(AbstractPolygon polygon)
        {
            List <AbstractLineSegment> lineList0  = polygon.transform.GetComponent <AbstractPolygon>().lineList;
            List <AbstractPoint>       pointList0 = polygon.transform.GetComponent <AbstractPolygon>().pointList;

            //make new lists for the points and lines in the new plane
            List <AbstractLineSegment> lineList1  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList1 = new List <AbstractPoint>();

            //create new points for the new plane.
            foreach (AbstractPoint point in pointList0)
            {
                AbstractPoint newPoint = iPoint(point.Position3);
                pointList1.Add(newPoint);
            }

            //create new lines for the new plane.
            foreach (AbstractLineSegment line in lineList0)
            {
                if (line.GetComponent <InteractableLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index], pointList1[point2Index]);
                    lineList1.Add(newLine);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
                else if (line.GetComponent <DependentLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index], pointList1[point2Index]);
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
            }

            AbstractPolygon plane1 = iPolygon(lineList1, pointList1);


            plane1.InitializeFigure();
            List <AbstractPolygon> sideList = new List <AbstractPolygon>();

            foreach (AbstractLineSegment l in lineList0)
            {
                int lineIndex = lineList0.IndexOf(l);

                sideList.Add(makePlaneWall(lineIndex, lineList0, lineList1));
            }

            InteractablePrism      prism    = InteractablePrism.Constructor();
            List <AbstractPolygon> baseList = new List <AbstractPolygon>();

            baseList.Add(polygon);
            baseList.Add(plane1);

            prism.bases = baseList;
            prism.sides = sideList;

            prism.vertexPoints.ForEach(p => HW_GeoSolver.ins.AddDependence(prism, p));
            prism.lineSegments.ForEach(l => HW_GeoSolver.ins.AddDependence(prism, l));
            prism.bases.ForEach(b => HW_GeoSolver.ins.AddDependence(prism, b));
            prism.sides.ForEach(b => HW_GeoSolver.ins.AddDependence(prism, b));
            prism.InitializeFigure();

            return(prism);
        }
Пример #12
0
        internal static InteractablePrism dPrism(AbstractPolygon polygon, Vector3 base2Pos)
        {
            List <AbstractLineSegment> lineList0  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList0 = new List <AbstractPoint>();

            lineList0  = polygon.transform.GetComponent <AbstractPolygon>().lineList;
            pointList0 = polygon.transform.GetComponent <AbstractPolygon>().pointList;

            //make new lists for the points and lines in the new plane
            List <AbstractLineSegment> lineList1  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList1 = new List <AbstractPoint>();

            //create new points for the new plane.
            foreach (AbstractPoint point in pointList0)
            {
                AbstractPoint newPoint = dPoint(point.Position3 - polygon.Position3 + base2Pos);
                pointList1.Add(newPoint);
            }

            //create new lines for the new plane.
            foreach (AbstractLineSegment line in lineList0)
            {
                if (line.GetComponent <InteractableLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index].GetComponent <AbstractPoint>(), pointList1[point2Index].GetComponent <AbstractPoint>());
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
                else if (line.GetComponent <DependentLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index].GetComponent <AbstractPoint>(), pointList1[point2Index].GetComponent <AbstractPoint>());
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
            }

            AbstractPolygon plane1 = dPolygon(lineList1, pointList1);

            plane1.AddToRManager();

            foreach (AbstractLineSegment line in lineList1)
            {
                HW_GeoSolver.ins.AddDependence(plane1, line);
            }

            plane1.transform.GetComponent <AbstractPolygon>().InitializeFigure();
            List <AbstractPolygon> sideList = new List <AbstractPolygon>();

            foreach (AbstractLineSegment line0 in lineList0)
            {
                int lineIndex = lineList0.IndexOf(line0);


                AbstractLineSegment lineTest = lineList0[lineIndex];

                sideList.Add(makePlaneWall(lineIndex, lineList0, lineList1));
            }

            InteractablePrism      prism    = InteractablePrism.Constructor();
            List <AbstractPolygon> baseList = new List <AbstractPolygon>
            {
                polygon,
                plane1
            };

            prism.bases = baseList;
            prism.sides = sideList;

            foreach (AbstractPolygon poly in baseList)
            {
                HW_GeoSolver.ins.AddDependence(prism, poly);
            }
            foreach (AbstractPolygon poly in sideList)
            {
                HW_GeoSolver.ins.AddDependence(prism, poly);
            }

            prism.vertexPoints.ForEach(p => HW_GeoSolver.ins.AddDependence(prism, p));

            prism.InitializeFigure();

            return(prism);
        }
Пример #13
0
        internal static InteractablePolygon iTriangle(InteractableLineSegment lineSegment, AbstractPoint point)
        {
            List <AbstractPoint> pointList = new List <AbstractPoint>()
            {
                point, lineSegment.point1, lineSegment.point2
            };
            List <AbstractLineSegment> lineList = new List <AbstractLineSegment>()
            {
                lineSegment, dLineSegment(point, lineSegment.point1), dLineSegment(point, lineSegment.point2)
            };

            return(iPolygon(lineList, pointList));
        }
Пример #14
0
        public static DependentPolygon dTriangle(InteractableLineSegment lineSegment, AbstractPoint point)
        {
            List <AbstractPoint> pointList = new List <AbstractPoint>()
            {
                point, lineSegment.point1, lineSegment.point2
            };
            List <AbstractLineSegment> lineList = new List <AbstractLineSegment>()
            {
                lineSegment, dLineSegment(point, lineSegment.point1), dLineSegment(point, lineSegment.point2)
            };

            return(dPolygon(lineList, pointList));
        }
Пример #15
0
        public void hoist()
        {
            #region Hoist
            MasterGeoObj[] selObj = FindObjectsOfType <MasterGeoObj>().Where(o => ((o.figType != GeoObjType.point) && o.IsSelected)).ToArray();
            foreach (MasterGeoObj currObj in selObj)
            {
                switch (currObj.figType)
                {
                case GeoObjType.point:
                    break;

                case GeoObjType.line:
                    AbstractPoint newPoint  = GeoObjConstruction.iPoint(currObj.GetComponent <InteractableLineSegment>().point1.transform.position);
                    AbstractPoint newPoint2 = GeoObjConstruction.iPoint(currObj.GetComponent <InteractableLineSegment>().point2.transform.position);

                    GeoObjConstruction.iLineSegment(newPoint, newPoint2);

                    currObj.GetComponent <InteractableLineSegment>().point2.transform.RotateAround(parentSE.center, parentSE.normalDir, deltaRotate);
                    currObj.GetComponent <InteractableLineSegment>().point1.transform.RotateAround(parentSE.center, parentSE.normalDir, deltaRotate);
                    break;

                case GeoObjType.polygon:
                    break;

                case GeoObjType.prism:
                    break;

                case GeoObjType.pyramid:
                    break;

                case GeoObjType.circle:
                    break;

                case GeoObjType.sphere:
                    break;

                case GeoObjType.revolvedsurface:
                    break;

                case GeoObjType.torus:
                    break;

                case GeoObjType.flatface:
                    break;

                case GeoObjType.straightedge:
                    break;

                default:
                    break;
                }
            }

            //These need to be developed.

            //foreach (GameObject planeObj in GameObject.FindGameObjectsWithTag("SelPlane"))
            //{
            //    foreach (Transform point in planeObj.GetComponent<PlaneBehave>().pointList)
            //    {
            //        point.transform.RotateAround(parentSE.center(), parentSE.normalDir(), deltaRotate);
            //    }
            //}

            //foreach (GameObject arc in GameObject.FindGameObjectsWithTag("SelArc"))
            //{
            //    attachedGeoObjs.Add(arc.transform);
            //    attachedGeoObjs.Add(arc.GetComponent<ArcBehave>().attachedPoint.transform);
            //}

            //foreach (GameObject circle in GameObject.FindGameObjectsWithTag("SelCircle"))
            //{
            //    attachedGeoObjs.Add(circle.transform);
            //    attachedGeoObjs.Add(circle.GetComponent<CircleBehave>().attachedLine.GetComponent<LineBehave>().point1);
            //    attachedGeoObjs.Add(circle.GetComponent<CircleBehave>().attachedLine.GetComponent<LineBehave>().point2);
            //}
            #endregion
        }
Пример #16
0
 public void makeCircle(Vector3 revPoint, AbstractPoint attachedPoint, Vector3 normDir)
 {
     #region intialize an arc or circle
     /*DependentCircle dc = */ GeoObjConstruction.dCircle(GeoObjConstruction.dPoint(revPoint), attachedPoint, normDir);
     #endregion
 }