예제 #1
0
    public void Clear(int dimension)
    {
        geometry = null;
        StatusButton lockButton = GameObject.Find("LockButton").GetComponent <StatusButton>();

        if (dimension == 2)
        {
            geoCamera.Trigger2DRAnimation();
            lockButton.SetStatus(1);
        }
        else
        {
            geoCamera.TriggerCenterRAnimation();
            lockButton.SetStatus(0);
        }

        // Clear Element
        clearElements();

        // Clear Gizmos
        foreach (KeyValuePair <Gizmo, GizmoBehaviour> pair in gizmoMap)
        {
            Destroy(pair.Value.gameObject);
        }
        gizmoMap.Clear();
    }
예제 #2
0
    public void Clear()
    {
        geometry = null;
        geoCamera.TriggerCenterRAnimation();

        // Clear Element
        clearElements();

        // Clear Gizmos
        foreach (KeyValuePair <Gizmo, GizmoBehaviour> pair in gizmoMap)
        {
            Destroy(pair.Value.gameObject);
        }
        gizmoMap.Clear();
    }
예제 #3
0
    private void CreatCenter()
    {
        int layer = LayerMask.NameToLayer(LAYER);

        GameObject centerObject = new GameObject("center");

        centerObject.layer = layer;
        centerObject.transform.SetParent(transform);
        centerObject.transform.position = Vector3.zero;

        NavCenterBehaviour center = centerObject.AddComponent <NavCenterBehaviour>();

        center.mesh = CenterMesh;
        center.Init();
        center.OnClick = () => geoCamera.TriggerCenterRAnimation();
    }
예제 #4
0
 private void transformCamera()
 {
     geoCamera.TriggerCenterRAnimation();
 }
예제 #5
0
    public void SpinCartoon(VertexUnit[] vertexUnits, Geometry geometry)
    {
        ResolvedBody resolvedBody;

        if (geometry is ResolvedBody)
        {
            resolvedBody = (ResolvedBody)geometry;
        }
        else
        {
            return;
        }

        if (resolvedBody.isSpinned)
        {
            return;
        }
        resolvedBody.isSpinned = true;
        GeoCamera geoCamera = GameObject.Find("/3D/GeoCamera").GetComponent <GeoCamera>();

        geoCamera.TriggerCenterRAnimation();

        VertexUnit vertex1 = vertexUnits[0];
        VertexUnit vertex2 = vertexUnits[1];
        VertexUnit vertex3 = vertexUnits[2];

        GameObject   rectangle    = new GameObject("CartoonFace");
        MeshFilter   filter       = rectangle.AddComponent <MeshFilter>();
        MeshCollider meshCollider = rectangle.AddComponent <MeshCollider>();
        Mesh         mesh         = new Mesh();
        Mesh         colliderMesh = new Mesh();

        meshCollider.sharedMesh = colliderMesh;
        filter.sharedMesh       = mesh;
        // triangle
        if (vertexUnits.Length == 3)
        {
            mesh.vertices = new Vector3[3] {
                vertex1.Position(), vertex2.Position(), vertex3.Position()
            };
            mesh.triangles = new int[3] {
                0, 1, 2
            };
        }
        // rectangle
        else if (vertexUnits.Length == 4)
        {
            VertexUnit vertex4 = vertexUnits[3];
            mesh.vertices = new Vector3[6] {
                vertex1.Position(), vertex2.Position(), vertex3.Position(), vertex1.Position(), vertex3.Position(), vertex4.Position()
            };
            mesh.triangles = new int[6] {
                0, 1, 2, 3, 4, 5
            };
        }
        mesh.RecalculateNormals();
        mesh.RecalculateBounds();

        // uv
        Vector3 y = mesh.normals[0].normalized;
        Vector3 x = (mesh.vertices[1] - mesh.vertices[0]).normalized;
        Vector3 z = Vector3.Cross(x, y);

        Matrix4x4 matrix = new Matrix4x4(
            new Vector4(x.x, y.x, z.x, 0),
            new Vector4(x.y, y.y, z.y, 0),
            new Vector4(x.z, y.z, z.z, 0),
            new Vector4(0, 0, 0, 1));

        Vector2[] uvs = new Vector2[mesh.vertices.Length];
        for (int i = 0; i < mesh.vertices.Length; i++)
        {
            Vector3 position = matrix.MultiplyPoint(mesh.vertices[i]);
            uvs[i] = new Vector2(position.x, position.z);
        }
        mesh.uv = uvs;

        MeshRenderer render = rectangle.AddComponent <MeshRenderer>();

        StyleManager.SetPlaneProperty(render, 0);
        render.sharedMaterial = ConfigManager.FaceStyle[0].Material;

        rectangle.AddComponent <ObjectSpin>().GetData(geometry);
    }