Exemplo n.º 1
0
    public void SetRectangle(Vector3[] positions)
    {
        if (positions.Length != 4)
        {
            return;
        }
        Vector3 faceNormal = Vector3.right;

        VertexResolvedBody u0 = new VertexResolvedBody(positions[0].x, positions[0].y, positions[0].z, faceNormal);
        // u0.isFixed = true;
        VertexResolvedBody u1 = new VertexResolvedBody(positions[1].x, positions[1].y, positions[1].z, faceNormal);
        // u1.isFixed = true;
        VertexResolvedBody u2 = new VertexResolvedBody(positions[2].x, positions[2].y, positions[2].z, faceNormal);
        // u2.isFixed = true;
        VertexResolvedBody u3 = new VertexResolvedBody(positions[3].x, positions[3].y, positions[3].z, faceNormal);

        // u3.isFixed = true;
        AddBaseVertex(u0);
        AddBaseVertex(u1);
        AddBaseVertex(u2);
        AddBaseVertex(u3);
        vertexResolvedBodies = new VertexResolvedBody[] { u0, u1, u2, u3 };

        GeoVertex v0 = new GeoVertex(u0, true);
        GeoVertex v1 = new GeoVertex(u1, true);
        GeoVertex v2 = new GeoVertex(u2, true);
        GeoVertex v3 = new GeoVertex(u3, true);

        AddGeoVertex(v0);
        AddGeoVertex(v1);
        AddGeoVertex(v2);
        AddGeoVertex(v3);

        GeoEdge e0 = new GeoEdge(u0, u1, true);
        GeoEdge e1 = new GeoEdge(u1, u2, true);
        GeoEdge e2 = new GeoEdge(u2, u3, true);
        GeoEdge e3 = new GeoEdge(u0, u3, true);

        AddGeoEdge(e0);
        AddGeoEdge(e1);
        AddGeoEdge(e2);
        AddGeoEdge(e3);

        GeoFace f0 = new GeoFace(new VertexUnit[] { u0, u1, u2, u3 }, true);

        AddGeoFace(f0);

        InitDatas();

        NavAxisBehaviour axis = GameObject.Find("X").GetComponent <NavAxisBehaviour>();
        PointerEventData data = new PointerEventData(EventSystem.current);

        axis.OnPointerClick(data);

        shapeSetted = true;
    }
Exemplo n.º 2
0
    public override void RemoveAuxiliary()
    {
        geometryBehaviour.clearElements();
        geometryBehaviour.AddFaces();
        NavAxisBehaviour axis = GameObject.Find("X").GetComponent <NavAxisBehaviour>();
        PointerEventData data = new PointerEventData(EventSystem.current);

        axis.OnPointerClick(data);
        StatusButton lockButton = GameObject.Find("LockButton").GetComponent <StatusButton>();

        lockButton.SetStatus(0);
        resolvedBody.isSpinned = false;
    }
Exemplo n.º 3
0
    public void OpenWritingPanel(Geometry geometry)
    {
        gameObject.SetActive(true);
        StatusButton lockButton = GameObject.Find("LockButton").GetComponent <StatusButton>();

        lockButton.SetStatus(1);
        recognizePanel.showRecognizePanel();
        penBehaviour.SetDrawing(false);
        penBehaviour.SetGeometry(geometry);

        if (geometry is ResolvedBody)
        {
            ResolvedBody resolvedBody = (ResolvedBody)geometry;
            if (!resolvedBody.shapeSetted)
            {
                NavAxisBehaviour axis = GameObject.Find("X").GetComponent <NavAxisBehaviour>();
                PointerEventData data = new PointerEventData(EventSystem.current);
                axis.OnPointerClick(data);
                penBehaviour.SetDrawing(true);
                penBehaviour.SetGeometry(geometry);
                return;
            }
        }
    }
Exemplo n.º 4
0
    private void CreateNavAxis()
    {
        int layer = LayerMask.NameToLayer(LAYER);

        Mesh meshX = (Mesh)Instantiate(AxisMesh);
        Mesh meshY = (Mesh)Instantiate(AxisMesh);
        Mesh meshZ = (Mesh)Instantiate(AxisMesh);
        Mesh meshW = (Mesh)Instantiate(AxisMesh);

        SetMeshUV(meshX, new Vector4(1, 0, 0, 0));
        SetMeshUV(meshY, new Vector4(0, 1, 0, 0));
        SetMeshUV(meshZ, new Vector4(0, 0, 1, 0));
        SetMeshUV(meshW, new Vector4(0, 0, 0, 1));

        string[]  axisNames     = new string[] { "X", "Y", "Z", "-X", "-Y", "-Z" };
        Vector3[] axisPositions =
        {
            new Vector3(1,   0,  0),
            new Vector3(0,   1,  0),
            new Vector3(0,   0,  1),
            new Vector3(-1,  0,  0),
            new Vector3(0,  -1,  0),
            new Vector3(0,   0, -1),
        };
        Vector3[] axisRotations =
        {
            new Vector3(0,   0,  90),
            new Vector3(180, 0,   0),
            new Vector3(-90, 0,   0),
            new Vector3(0,   0, -90),
            new Vector3(0,   0,   0),
            new Vector3(90,  0,   0),
        };
        Vector3 axisScale = Vector3.one;

        Vector2[] axisCamera =
        {
            new Vector2(270,   0),
            new Vector2(270,  90),
            new Vector2(180,   0),
            new Vector2(90,    0),
            new Vector2(270, -90),
            new Vector2(0,     0),
        };

        Mesh[] axisMeshes = new Mesh[] { meshX, meshY, meshZ, meshW, meshW, meshW };

        for (int i = 0; i < axisNames.Length; i++)
        {
            GameObject axisObject = new GameObject(axisNames[i]);
            axisObject.layer = layer;
            axisObject.transform.SetParent(transform);
            axisObject.transform.position    = axisPositions[i] * 0.5f;
            axisObject.transform.eulerAngles = axisRotations[i];
            axisObject.transform.localScale  = axisScale;

            NavAxisBehaviour axis = axisObject.AddComponent <NavAxisBehaviour>();
            axis.mesh = axisMeshes[i];
            axis.Init(axisCamera[i]);
            axis.OnClick = (rotation) => geoCamera.TriggerRotateAnimation(rotation.x, rotation.y);
        }
    }