Example #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();
        }
        public override void Stretch(InteractionController obj)
        {
            if (stretchEnabled)
            {
                Debug.Log("Can't Stretch To 4D yet...");
                InteractablePrism thisPrism = this;

                List <AbstractLineSegment> lineList  = new List <AbstractLineSegment>();
                List <AbstractPoint>       pointList = new List <AbstractPoint>();

                thisPrism.bases[0].pointList.ForEach(p => pointList.Add(GeoObjConstruction.iPoint(p.Position3)));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[0], pointList[1]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[1], pointList[2]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[3], pointList[4]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[1], pointList[0]));

                InteractablePrism nextPrism = GeoObjConstruction.iPrism(GeoObjConstruction.iPolygon(lineList, pointList));

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < thisPrism.bases.Count; j++)
                    {
                        GeoObjConstruction.makePlaneWall(i, thisPrism.bases[j].lineList, nextPrism.bases[j].lineList);
                    }

                    for (int k = 0; k < thisPrism.sides.Count; k++)
                    {
                        GeoObjConstruction.makePlaneWall(i, thisPrism.sides[k].lineList, nextPrism.sides[k].lineList);
                    }
                }
            }
        }
Example #3
0
        internal virtual void spawnItem(Transform spawnPoint)
        {
            if (prevItem != null)
            {
                prevItem.transform.localScale /= anchorScale;
            }
            Transform newObj;

            if (!pointSpawner)
            {
                newObj = Instantiate(item, transform.position, Quaternion.identity).transform;
            }
            else
            {
                newObj = GeoObjConstruction.iPoint(HW_GeoSolver.ins.systemPosition(transform.position)).transform;
            }
            if (newObj == null)
            {
                Debug.LogError("No object spawning.");
                return;
            }
            newObj.transform.localScale *= anchorScale;
            newObj.GetComponent <AnchorableBehaviour>().anchor = thisAnchor;
            prevItem = newObj.gameObject;
        }
Example #4
0
        private void checkCenterEdge()
        {
            if (centerSet && edgeSet)
            {
                GeoObjConstruction.dSphere(Center, Edge);

                Destroy(edgeHandle.gameObject);
                Destroy(gameObject);
            }
        }
Example #5
0
        public void makeRevolvedSurface(AbstractLineSegment attachedLine, Vector3 revPoint, Vector3 normDir)
        {
            #region intialize a cylinder, cone or conic /etc.
            InteractablePoint newPoint = InteractablePoint.Constructor();
            newPoint.Position3 = revPoint;            //nullreference on this line from shipswheel

            DependentRevolvedSurface drs = GeoObjConstruction.dRevSurface(newPoint.GetComponent <AbstractPoint>(), attachedLine, normDir);
            HW_GeoSolver.ins.AddDependence(drs, newPoint);
            HW_GeoSolver.ins.AddDependence(drs, attachedLine.GetComponent <MasterGeoObj>());
            #endregion
        }
Example #6
0
 public void drawAllLines()
 {
     foreach (AbstractPoint point1 in GameObject.FindObjectsOfType <AbstractPoint>())
     {
         foreach (AbstractPoint point2 in GameObject.FindObjectsOfType <AbstractPoint>())
         {
             if (point1 != point2 && point1.IsSelected && point2.IsSelected)
             {
                 GeoObjConstruction.dLineSegment(point1, point2);
             }
         }
     }
 }
 public override void Stretch(InteractionController iControll)
 {
     if (stretchEnabled && thisIBehave.graspingControllers.Count > 1)
     {
         iControll.ReleaseGrasp();
         InteractablePoint newPoint = GeoObjConstruction.iPoint(this.Position3);
         /*InteractableLineSegment newLineSegment = */ GeoObjConstruction.iLineSegment(this, newPoint);
         if (HW_GeoSolver.ins.thisInteractionMode == HW_GeoSolver.InteractionMode.rigid)
         {
             newPoint.LeapInteraction = false;
             this.LeapInteraction     = false;
         }
         StartCoroutine(waitForStretch);
     }
 }
Example #8
0
        public override void Stretch(InteractionController iControll)
        {
            if (stretchEnabled && thisIBehave.graspingControllers.Count > 1)
            {
                iControll.ReleaseGrasp();

                InteractablePrism prism = GeoObjConstruction.iPrism(this);

                if (HW_GeoSolver.ins.thisInteractionMode == HW_GeoSolver.InteractionMode.rigid)
                {
                    prism.lineSegments.ForEach(p => p.LeapInteraction = false);
                    prism.vertexPoints.ForEach(p => p.LeapInteraction = false);
                }
                StartCoroutine(waitForStretch);
            }
        }
Example #9
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;
     }
 }
        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);
            }
        }
Example #11
0
        public void InitRegPoly(int nSides, float a, Vector3 normDir)
        {
            apothem = a;
            float hyp = (apothem) / (Mathf.Cos(Mathf.PI / nSides));

            n = nSides;
            if (normDir != Vector3.zero)
            {
                Vector3.OrthoNormalize(ref normDir, ref basis1);
                Vector3.OrthoNormalize(ref normDir, ref basis1, ref basis2);
            }
            for (int i = 0; i < n; i++)
            {
                pointList.Add(GeoObjConstruction.iPoint(this.Position3 + hyp * (Mathf.Sin(2f * Mathf.PI * i / n) * basis1 + Mathf.Cos(2f * Mathf.PI * i / n) * basis2)));
                if (i != 0)
                {
                    lineList.Add(GeoObjConstruction.iLineSegment(pointList[i - 1], pointList[i]));
                }
            }

            lineList.Add(GeoObjConstruction.iLineSegment(pointList[0], pointList[n - 1]));

            foreach (AbstractLineSegment line in lineList)
            {
                HW_GeoSolver.ins.AddDependence(this, line);
            }

            foreach (AbstractPoint point in pointList)
            {
                HW_GeoSolver.ins.AddDependence(this, point);
            }

            this.InitializeFigure();

            this.AddToRManager();
        }
Example #12
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)
                    {
                        GeoObjConstruction.iPolygon(lineList, pointList);
                        Destroy(gameObject, Time.fixedDeltaTime);
                    }
                    break;

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

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

                case pinType.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);
                            }
                        }
                        //GameObject currScissors = Instantiate(scissors);
                        //currScissors.transform.position = _prevPoint.transform.position;														Cuts things
                        //currScissors.GetComponent<scissorAnimator>().travel(_prevPoint.transform.position, _currPoint.transform.position);
                        Destroy(gameObject, Time.fixedDeltaTime);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Example #13
0
 private void spawnPOS()
 {
     GeoObjConstruction.snapPoint(activeMGO, this.transform.position);
 }
Example #14
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
        }
Example #15
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
 }