Ejemplo n.º 1
0
        protected void HandleInput(string source)
        {
            switch (source)
            {
            default:
                print("unknown input: " + source);
                break;

            case "Button_pt1Xinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt1"].X);
                break;

            case "Button_pt1Yinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt1"].Y);
                break;

            case "Button_pt1Zinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt1"].Z);
                break;

            case "Button_pt2Xinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt2"].X);
                break;

            case "Button_pt2Yinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt2"].Y);
                break;

            case "Button_pt2Zinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt2"].Z);
                break;

            case "Button_pt3Xinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt3"].X);
                break;

            case "Button_pt3Yinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt3"].Y);
                break;

            case "Button_pt3Zinput":
                ptManager.SetOutput(ptManager.ptSet.ptCoords["pt3"].Z);
                break;

            case "Button_a":
                ptManager.SetOutput(ptManager.eqnSet.eqnCoefs["a"]);
                break;

            case "Button_b":
                ptManager.SetOutput(ptManager.eqnSet.eqnCoefs["b"]);
                break;

            case "Button_c":
                ptManager.SetOutput(ptManager.eqnSet.eqnCoefs["c"]);
                break;

            case "Button_d":
                ptManager.SetOutput(ptManager.eqnSet.eqnCoefs["d"]);
                break;

            case "LockPlane":
                if (grabber.FixedPlane)
                {
                    grabber.FixedPlane = false;
                    lockButton.LockOff();
                }
                else
                {
                    grabber.FixedPlane = true;
                    lockButton.LockOn();
                }
                break;

            case "":
                break;
            }
            ptManager.manageText();
        }
Ejemplo n.º 2
0
        void Update()
        {
            if (!ptSetExist && ptManager != null && ptManager.ptSet != null)
            {
                ptSetExist = true;
                rawPt1     = ptManager.ptSet.ptCoords["pt1"];
                rawPt2     = ptManager.ptSet.ptCoords["pt2"];
                rawPt3     = ptManager.ptSet.ptCoords["pt3"];
            }
            usersPoint = PtCoordToVector(rawPt1);

            plane.LookAt(lookAtPlaneTarget);

            //TURN OFF AND ON POINT VISABILITY
            point1.GetComponent <MeshRenderer>().enabled = false;
            point2.GetComponent <MeshRenderer>().enabled = false;
            point3.GetComponent <MeshRenderer>().enabled = false;

            //HERES YOUR COORD TEXT
            pt1Label.text = "(" + rawPt1.X.Value + "," + rawPt1.Y.Value + "," + rawPt1.Z.Value + ")";
            //pt2Label.text = "(" + rawPt2.X.Value + "," + rawPt2.Y.Value + "," + rawPt2.Z.Value + ")";
            //pt3Label.text = "(" + rawPt3.X.Value + "," + rawPt3.Y.Value + "," + rawPt3.Z.Value + ")";

            scaledPt1            = ScaledPoint(PtCoordToVector(rawPt1));
            point1.localPosition = scaledPt1;
            scaledPt2            = ScaledPoint(PtCoordToVector(rawPt2));
            point2.localPosition = scaledPt2;
            scaledPt3            = ScaledPoint(PtCoordToVector(rawPt3));
            point3.localPosition = scaledPt3;

            xAxis.localPosition = ScaledPoint(center);
            yAxis.localPosition = ScaledPoint(center);
            zAxis.localPosition = ScaledPoint(center);

            //projectionAxis
            lookAtAxisTarget.localPosition = ScaledPoint(PtCoordToVector(rawPt2));
            axisline.localPosition         = ScaledPoint(center);
            axisline.LookAt(lookAtAxisTarget);



            var sharedMaterial2 = forwardAxisLine.GetComponent <MeshRenderer>().sharedMaterial;

            sharedMaterial2.SetInt("_planeClippingEnabled", 1);

            for (int i = 0; i < 6; i++)
            {
                sharedMaterial2.SetVector("_planePos" + i, walls[i].transform.position);
                //plane normal vector is the rotated 'up' vector.
                sharedMaterial2.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up);
            }

            if ((new Vector3(0, 0, 0)) == PtCoordToVector(rawPt2))
            {
                forwardAxisLine.GetComponent <MeshRenderer>().enabled = false;
            }
            //if there is no 3rd component (line)
            else if (new Vector3(0, 0, 0) == PtCoordToVector(rawPt3))
            {
                forwardAxisLine.GetComponent <MeshRenderer>().enabled = true;
                projectedResult = Vector3.Project(PtCoordToVector(rawPt1), PtCoordToVector(rawPt2));
                ptManager.manageText();
            }
            //if there is a 3rd coord (subspace)
            else
            {
                forwardAxisLine.GetComponent <MeshRenderer>().enabled = false;
                projectedResult = Vector3.ProjectOnPlane(PtCoordToVector(rawPt1), normalVector);
                ptManager.manageText();
            }

            var sharedMaterial3 = forwardPlane.GetComponent <MeshRenderer>().sharedMaterial;

            sharedMaterial3.SetInt("_planeClippingEnabled", 1);

            for (int i = 0; i < 6; i++)
            {
                sharedMaterial3.SetVector("_planePos" + i, walls[i].transform.position);
                //plane normal vector is the rotated 'up' vector.
                sharedMaterial3.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up);
            }

            var sharedMaterial = backwardPlane.GetComponent <MeshRenderer>().sharedMaterial;

            sharedMaterial.SetInt("_planeClippingEnabled", 1);

            for (int i = 0; i < 6; i++)
            {
                sharedMaterial.SetVector("_planePos" + i, walls[i].transform.position);
                //plane normal vector is the rotated 'up' vector.
                sharedMaterial.SetVector("_planeNorm" + i, walls[i].transform.rotation * Vector3.up);
            }
        }