Exemplo n.º 1
0
        internal override void GlueToFigure(MasterGeoObj toObj)
        {
            if ((toObj.gameObject.tag.Contains("Point") && (toObj.figIndex > this.figIndex)) && ((this.GetComponent <InteractionBehaviour>().isGrasped) || (toObj.transform.GetComponent <InteractionBehaviour>().isGrasped)))
            {
                foreach (Node <string> node in HW_GeoSolver.ins.geomanager.Nodes)
                {
                    GraphNode <string> thisGraphNode = HW_GeoSolver.ins.geomanager.findGraphNode(this.figName);
                    if (HW_GeoSolver.ins.geomanager.neighborsOfNode(node.Value).Contains(thisGraphNode))
                    {
                        NodeList <string>  newNeighborList = HW_GeoSolver.ins.geomanager.neighborsOfNode(node.Value);
                        GraphNode <string> otherGraphNode  = HW_GeoSolver.ins.geomanager.findGraphNode(toObj.figName);
                        if (newNeighborList.Contains(otherGraphNode) == false)
                        {
                            HW_GeoSolver.ins.AddDependence(GameObject.Find(node.Value).GetComponent <MasterGeoObj>(), toObj);
                            HW_GeoSolver.ins.replaceDepentVar(GameObject.Find(node.Value).transform, this.transform, toObj.transform);
                        }
                        else
                        {
                            //deletes redundancy instances between two points
                            HW_GeoSolver.ins.removeComponentS(node.Value);
                        }
                    }
                }
                HW_GeoSolver.ins.removeComponent(this);

                //check for cycle in geoObjMan graph
                if (HW_GeoSolver.ins.checkIfPath(this.transform, toObj.transform))
                {
                    //a cycle is being created.
                    //make a polygon

                    Debug.Log("NEED TO MAKE A POLYGON");
                }
            }
        }
Exemplo n.º 2
0
        public static alphabetLabel label(MasterGeoObj obj, string labelText)
        {
            alphabetLabel label = alphabetLabel.Constructor();

            label.spawnOnMGO(obj, labelText);
            return(label);
        }
Exemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <MasterGeoObj>() != null)
     {
         recentHit = other.gameObject.GetComponent <MasterGeoObj>();
     }
 }
Exemplo n.º 4
0
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.GetComponent <MasterGeoObj>() != null && other.gameObject.GetComponent <MasterGeoObj>() == recentHit)
     {
         recentHit = null;
     }
 }
Exemplo n.º 5
0
        internal static SnappablePoint snapPoint(MasterGeoObj activeMGO, Vector3 position)
        {
            SnappablePoint snap = SnappablePoint.Constructor();

            snap.Position3      = position;
            snap.attachedObject = activeMGO;
            return(snap);
        }
Exemplo n.º 6
0
 private IEnumerator transformFollow(MasterGeoObj followMGO)
 {
     while (followMGO.isActiveAndEnabled)
     {
         transform.position = followMGO.transform.position;
         transform.rotation = Quaternion.LookRotation(transform.position - Camera.main.transform.position);
         yield return(new WaitForEndOfFrame());
     }
     Destroy(gameObject);            //if attached object doesnt exist anymore
 }
Exemplo n.º 7
0
 public void spawnOnMGO(MasterGeoObj MGO, string label)
 {
     _thisCount = (int)(label.ToCharArray()[label.ToCharArray().Length - 1] - 65);
     if (_thisCount > totalCount)
     {
         totalCount = _thisCount + 1;
     }
     recentHit  = MGO;
     this.Label = label;
     attachToMGO();
 }
Exemplo n.º 8
0
        private void setupRelativePosition(MasterGeoObj value)
        {
            switch (value.figType)
            {
            //case GeoObjType.point:
            //    break;
            case GeoObjType.line:
                AbstractLineSegment line = value.GetComponent <AbstractLineSegment>();
                relativeWeights.Add(Vector3.Magnitude(Position3 - line.vertex0) / Vector3.Magnitude(line.vertex0 - line.vertex1));
                relativeWeights.Add(Vector3.Magnitude(Position3 - line.vertex1) / Vector3.Magnitude(line.vertex0 - line.vertex1));
                break;

            case GeoObjType.polygon:
                Debug.LogWarning("Polygonsn not yet supported for Relative Movement");
                break;

            //case GeoObjType.prism:
            //    break;
            //case GeoObjType.pyramid:
            //    break;
            case GeoObjType.circle:
                AbstractCircle circle = value.GetComponent <AbstractCircle>();
                relativeWeights.Add(Vector3.SignedAngle(circle.edgePos - circle.centerPos, this.Position3 - circle.centerPos, circle.normalDir));
                break;

            case GeoObjType.sphere:
                Vector3 direction = Vector3.Normalize(this.Position3 - value.GetComponent <AbstractSphere>().centerPosition);
                relativeWeights.Add(direction.x);
                relativeWeights.Add(direction.y);
                relativeWeights.Add(direction.z);
                break;

            //case GeoObjType.revolvedsurface:
            //    break;
            //case GeoObjType.torus:
            //    break;
            case GeoObjType.flatface:
                Debug.LogWarning("Flatface not yet supported for Relative Movement");
                break;

            case GeoObjType.straightedge:
                Debug.LogWarning("Straightedge not yet supported for Relative Movement");
                break;

            default:
                Debug.LogWarning(value.figType.ToString() + " not supported for relative movement");
                break;
            }
        }
Exemplo n.º 9
0
        private void nextActive()
        {
            activeMGO.thisSelectStatus = MasterGeoObj.SelectionStatus.canidate;
            canidateIDX++;
            if (canidateIDX > mgoCanidates.Count)
            {
                canidateIDX = 0;
            }
            else if (canidateIDX < 0)
            {
                canidateIDX = mgoCanidates.Count;
            }

            activeMGO = mgoCanidates[canidateIDX];
            activeMGO.thisSelectStatus = MasterGeoObj.SelectionStatus.active;
        }
Exemplo n.º 10
0
 private Vector3 vectorMap(Vector3 input)
 {
     return(new Vector3(input.x + MasterGeoObj.LocalPosition(myPoly.Position3).x, functionMap(input), input.z + MasterGeoObj.LocalPosition(myPoly.Position3).z) + Vector3.up);
 }
Exemplo n.º 11
0
        internal override bool RMotion(NodeList <string> inputNodeList)
        {
            if (inputNodeList.checkForMGOmatch(pointListMGO))
            {
                int pointNum = pointList.Count;

                MeshFilter mf   = GetComponent <MeshFilter>();
                Mesh       mesh = mf.mesh;

                int i = 0;

                Quaternion angle = Quaternion.identity;

                if (!skewable && CheckSkewPolygon())
                {
                    Debug.LogWarning("This polygon " + figName + " is a skew polygon.");
                    MasterGeoObj firstHit = inputNodeList.findMGOmatch(pointListMGO);

                    switch (firstHit.figType)
                    {
                    case GeoObjType.point:
                        //need to rotate every other point based ont the angle from the old point position and the center.
                        angle = angleAroundCenter(firstHit.Position3, vertices[pointList.FindIndex(x => x == firstHit.GetComponent <AbstractPoint>())]);
                        break;

                    case GeoObjType.line:
                        //need to rotate every other point based on the angle from the midpoint of the line segment and the center.
                        //need to address this case in the future.
                        break;

                    default:
                        break;
                    }
                }

                this.Position3 = center;

                foreach (AbstractPoint point in pointList)
                {
                    //move points with a rotation around the center.
                    if (inputNodeList.checkForMGOmatch(point))
                    {
                        vertices[i] = angle * (point.Position3 - center);
                    }
                    else
                    {
                        vertices[i] = (point.Position3 - center);
                        //don't rotate the point around the angle that has already moved.
                    }
                    i++;
                }

                bool isTrue = mesh.vertices == vertices;
                mesh.vertices = vertices;
                return(isTrue);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        private void interactionEnd()
        {
            mgoCanidates = new List <MasterGeoObj>();
            if (this.GetComponent <AnchorableBehaviour>().isAttached == false)
            {
                foreach (MasterGeoObj mgo in FindObjectsOfType <MasterGeoObj>().Where(g => (g.GetComponent <AnchorableBehaviour>() == null || (g.GetComponent <AnchorableBehaviour>() != null && !g.GetComponent <AnchorableBehaviour>().isAttached))))
                {
                    float distance = 15;
                    switch (mgo.figType)
                    {
                    case GeoObjType.point:
                        distance = Vector3.Magnitude(this.transform.position - mgo.transform.position);
                        break;

                    case GeoObjType.line:
                        distance = Vector3.Magnitude(Vector3.Project(transform.position - mgo.transform.position, mgo.GetComponent <AbstractLineSegment>().vertex0 - mgo.GetComponent <AbstractLineSegment>().vertex1) + mgo.transform.position - this.transform.position);
                        break;

                    case GeoObjType.polygon:
                        Vector3 positionOnPlane = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <AbstractPolygon>().normDir) + mgo.transform.position;
                        distance = Vector3.Magnitude(positionOnPlane - this.transform.position);
                        Debug.LogWarning("Polygon doesn't check boundariers");
                        break;

                    case GeoObjType.prism:
                        distance = Vector3.Magnitude(mgo.transform.position - this.transform.position);
                        break;

                    case GeoObjType.pyramid:
                        Debug.LogWarning("Pyramids not yet supported");
                        break;

                    case GeoObjType.circle:
                        Vector3 positionOnPlane2 = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <AbstractCircle>().normalDir) + mgo.transform.position;
                        Vector3 positionOnCircle = Vector3.Normalize(positionOnPlane2 - mgo.GetComponent <AbstractCircle>().centerPos) * mgo.GetComponent <AbstractCircle>().Radius + mgo.GetComponent <AbstractCircle>().centerPos;
                        distance = Vector3.Magnitude(this.transform.position - positionOnCircle);
                        break;

                    case GeoObjType.sphere:
                        Vector3 lineDir           = Vector3.Normalize(transform.position - mgo.transform.position);
                        Vector3 positionOnSphere1 = mgo.GetComponent <AbstractSphere>().radius *lineDir + mgo.transform.position;
                        distance = Vector3.Magnitude(positionOnSphere1 - this.transform.position);
                        break;

                    case GeoObjType.revolvedsurface:
                        Debug.LogWarning("RevoledSurface not yet supported");
                        break;

                    case GeoObjType.torus:
                        Debug.LogWarning("Torus not yet supported");
                        break;

                    case GeoObjType.flatface:
                        Vector3 positionOnPlane3 = Vector3.ProjectOnPlane(transform.position - mgo.transform.position, mgo.GetComponent <flatfaceBehave>().normalDir) + mgo.transform.position;
                        distance = Vector3.Magnitude(positionOnPlane3 - this.transform.position);
                        break;

                    case GeoObjType.straightedge:
                        Vector3 positionOnStraightedge = Vector3.Project(transform.position - mgo.transform.position, mgo.GetComponent <straightEdgeBehave>().normalDir) + mgo.transform.position;
                        distance = Vector3.Magnitude(positionOnStraightedge - this.transform.position);
                        break;

                    default:
                        Debug.LogWarning("Something went wrong in the selectionmanager.... :(");
                        break;
                    }
                    if (Mathf.Abs(distance) < selectionRadius && mgo.thisSelectStatus != MasterGeoObj.SelectionStatus.selected)
                    {
                        mgo.thisSelectStatus = MasterGeoObj.SelectionStatus.canidate;
                        mgoCanidates.Add(mgo);
                    }
                    else if (Mathf.Abs(distance) < selectionRadius)
                    {
                        mgoCanidates.Add(mgo);
                    }
                    else if (mgo.thisSelectStatus == MasterGeoObj.SelectionStatus.canidate || mgo.thisSelectStatus == MasterGeoObj.SelectionStatus.active)
                    {
                        mgo.thisSelectStatus = MasterGeoObj.SelectionStatus.none;
                    }
                }
            }
            if (mgoCanidates.Count >= 1)
            {
                activeMGO   = mgoCanidates[0];
                canidateIDX = 0;
            }
            setbuttonState(mgoCanidates.Count >= 1);
        }
Exemplo n.º 13
0
 internal bool checkForMGOmatch(MasterGeoObj mgo)
 {
     return(checkForMGOmatch(new List <MasterGeoObj> {
         mgo
     }));
 }
Exemplo n.º 14
0
        /// <summary>
        /// Called each frame the gesture is active
        /// </summary>
        /// <param name="hand">The hand completing the gesture</param>
        protected override void WhileGestureActive(Hand hand)
        {
            //sethandtomodeSelect
            float shortestDist = Mathf.Infinity;

            closestObj = null;

            foreach (MasterGeoObj mgo in FindObjectsOfType <MasterGeoObj>().Where(g => (g.GetComponent <AnchorableBehaviour>() == null || (g.GetComponent <AnchorableBehaviour>() != null && !g.GetComponent <AnchorableBehaviour>().isAttached))))
            {
                float distance = mgo.LocalDistanceToClosestPoint(hand.Fingers[1].TipPosition.ToVector3());
                float angle    = mgo.PointingAngleDiff(hand.Fingers[1].TipPosition.ToVector3(), hand.Fingers[1].Direction.ToVector3());

                if (Mathf.Abs(distance) < shortestDist)
                {
                    if (distance < shortestDist && angle < angleTolerance)
                    {
                        closestObj   = mgo;
                        shortestDist = distance;
                    }
                }
                else
                {
                    //check to see if any higher priority objectes lie within epsilon
                    bool v = (Mathf.Abs(distance) - shortestDist <= maximumRangeToSelect) && (
                        ((closestObj.figType == GeoObjType.line || closestObj.figType == GeoObjType.polygon) && mgo.figType == GeoObjType.point) ||
                        (closestObj.figType == GeoObjType.polygon && mgo.figType == GeoObjType.point)
                        );
                    if (v)
                    {
                        closestObj   = mgo;
                        shortestDist = distance;
                    }
                }
            }


            handColourManager.setHandColorMode(whichHand, handColourManager.handModes.select);

            if (closestObj != null && shortestDist <= maximumRangeToSelect)
            {
                if (debugSelect)
                {
                    Debug.Log(closestObj + " is the object toggling selection state.");
                }



                //switch on mode:
                //				Select
                //				Colour
                if (closestObj.IsSelected)
                {
                    closestObj.thisSelectStatus = MasterGeoObj.SelectionStatus.none;
                }
                else
                {
                    closestObj.thisSelectStatus = MasterGeoObj.SelectionStatus.selected;
                }


                playSuccessSound();

                //This determines if you have to cancel the gesture to select another object
                completeBool = true;
            }
        }
Exemplo n.º 15
0
        internal override void SnapToFigure(MasterGeoObj toObj)
        {
            Debug.Log(name + " is attempting to snap to " + toObj.name + ".");
            //if object and child objects are not being grasped
            if (!(this.GetComponent <InteractionBehaviour>().isGrasped))
            {            ///this object is being grasped
                switch (toObj.figType)
                {
                case GeoObjType.point:
                    Position3 = toObj.Position3;
                    break;

                case GeoObjType.line:
                    Position3 = Vector3.Project(Position3 - toObj.Position3, toObj.GetComponent <AbstractLineSegment>().vertex0 - toObj.GetComponent <AbstractLineSegment>().vertex1) + toObj.Position3;
                    break;

                case GeoObjType.polygon:
                    Vector3 positionOnPlane = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <AbstractPolygon>().normDir) + toObj.Position3;
                    if (toObj.GetComponent <AbstractPolygon>().checkInPolygon(positionOnPlane))
                    {
                        Position3 = positionOnPlane;
                    }
                    break;

                //case GeoObjType.prism:
                //	break;
                //case GeoObjType.pyramid:
                //	break;
                case GeoObjType.circle:
                    Vector3 positionOnPlane2 = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <AbstractCircle>().normalDir) + toObj.Position3;
                    if (Vector3.Magnitude(positionOnPlane2 - toObj.Position3) == toObj.GetComponent <AbstractCircle>().Radius)
                    {
                        Position3 = positionOnPlane2;
                    }
                    break;

                case GeoObjType.sphere:
                    Vector3 lineDir = Vector3.Normalize(Position3 - toObj.Position3);
                    Position3 = toObj.GetComponent <AbstractSphere>().radius *lineDir + toObj.Position3;
                    break;

                //case GeoObjType.revolvedsurface:
                //	break;
                //case GeoObjType.torus:
                //	break;
                case GeoObjType.flatface:
                    Position3 = Vector3.ProjectOnPlane(Position3 - toObj.Position3, toObj.GetComponent <flatfaceBehave>().normalDir) + toObj.Position3;
                    break;

                case GeoObjType.straightedge:
                    Position3 = Vector3.Project(Position3 - toObj.Position3, toObj.GetComponent <straightEdgeBehave>().normalDir) + toObj.Position3;
                    break;

                default:
                    break;
                }
                setupRelativePosition(toObj);
            }
            else
            {
                switch (toObj.figType)
                {
                case GeoObjType.point:
                    this.Position3 = toObj.Position3;
                    break;

                case GeoObjType.line:
                    AbstractLineSegment line = toObj.GetComponent <AbstractLineSegment>();
                    this.Position3 = line.vertex0 * relativeWeights[0] + line.vertex1 * relativeWeights[1];
                    break;

                case GeoObjType.polygon:
                    Debug.LogWarning("Polygon not yet supported for Relative Movement");
                    break;

                //case GeoObjType.prism:
                //	break;
                //case GeoObjType.pyramid:
                //	break;
                case GeoObjType.circle:
                    AbstractCircle circle = toObj.GetComponent <AbstractCircle>();
                    Vector3        basis1 = circle.edgePos - circle.centerPos;
                    Vector3        basis2 = Vector3.Cross(basis1, circle.normalDir);
                    Vector3.OrthoNormalize(ref basis1, ref basis2);
                    this.Position3 = circle.Radius * (basis1 * Mathf.Sin(relativeWeights[0]) + basis2 * Mathf.Cos(relativeWeights[0])) + circle.centerPos;
                    break;

                case GeoObjType.sphere:
                    Vector3 direction = relativeWeights[0] * Vector3.right + relativeWeights[1] * Vector3.up + relativeWeights[2] * Vector3.forward;
                    this.Position3 = toObj.GetComponent <AbstractSphere>().radius *direction;
                    break;

                //case GeoObjType.revolvedsurface:
                //	break;
                //case GeoObjType.torus:
                //	break;
                case GeoObjType.flatface:
                    Debug.LogWarning("Straightedge not yet supported for Relative Movement");
                    break;

                case GeoObjType.straightedge:
                    Debug.LogWarning("Straightedge not yet supported for Relative Movement");
                    break;

                default:
                    Debug.LogWarning(toObj.figType.ToString() + " not supported for relative movement");
                    break;
                }
            }
        }
Exemplo n.º 16
0
 internal override void GlueToFigure(MasterGeoObj toObj)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 internal override void SnapToFigure(MasterGeoObj toObj)
 {
     //do nothing
 }
Exemplo n.º 18
0
 internal override void GlueToFigure(MasterGeoObj toObj)
 {
     //do nothing.
 }