예제 #1
0
    public void Init(GeoCircular geoCircular, GeoCamera camera)
    {
        geoController       = GameObject.Find("/GeoController").GetComponent <GeoController>();
        geometryBehaviour   = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        this.geoCircular = geoCircular;

        mesh         = new Mesh();
        colliderMesh = new Mesh();

        MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>();

        meshRenderer            = gameObject.AddComponent <MeshRenderer>();
        meshCollider            = gameObject.AddComponent <MeshCollider>();
        meshFilter.sharedMesh   = mesh;
        meshCollider.sharedMesh = colliderMesh;

        meshFilter.sharedMesh = mesh;

        SetColorIndex(0);
        SetStyleIndex(0);

        StyleManager.OnStyleChange += () =>
        {
            SetColorIndex(0);
            SetStyleIndex(0);
        };

        visiable = true;
    }
예제 #2
0
    void Start()
    {
        geometryBehaviour   = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();
        navigationBehaviour = GameObject.Find("/3D/Navigation").GetComponent <NavigationBehaviour>();
        gridBehaviour       = GameObject.Find("/3D/Grid").GetComponent <GridBehaviour>();
        coordinateBehaviour = GameObject.Find("/3D/Coordinate").GetComponent <CoordinateBehaviour>();

        geoCamera = GameObject.Find("/3D/GeoCamera").GetComponent <GeoCamera>();
        navCamera = GameObject.Find("/3D/NavCamera").GetComponent <NavCamera>();

        InitTouchSystem();
        InitView();
        InitUI();

        geoCamera.InitDefault();

        stateController = GetComponent <StateController>();
        stateController.Init(geoUI.statePanel);

        toolController = GetComponent <ToolController>();
        toolController.Init(geoUI.toolPanel);

        recognizeController = GetComponent <RecognizeController>();
        recognizeController.Init(geoUI.writingPanel);

        ClearGeometry();
    }
예제 #3
0
    public void Init(GeoCamera camera)
    {
        geoCamera = camera;

        CreatCenter();
        CreateNavAxis();
        transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
    }
예제 #4
0
    public virtual void Init(GeoCamera camera, int size)
    {
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        if (size <= 0)
        {
            size = 2;
        }
        if (size % 2 == 1)
        {
            size += 1;
        }

        if (lineMesh == null)
        {
            lineMesh = LineMesh();
        }

        count = size + 1;
        int offset = size / 2;

        lines = new GameObject[count * 2];

        // x
        for (int i = 0; i < count; i++)
        {
            MeshRenderer mr;
            GameObject   line = InitLine(i, out mr);
            lines[i] = line;
            line.transform.position   = new Vector3(i - offset, 0, 0);
            line.transform.localScale = new Vector3(count, 1, 1);
        }
        // z
        for (int i = 0; i < count; i++)
        {
            MeshRenderer mr;
            GameObject   line = InitLine(i, out mr);
            lines[count + i]          = line;
            line.transform.position   = new Vector3(0, 0, i - offset);
            line.transform.localScale = new Vector3(count, 1, 1);
        }

        foreach (GameObject line in lines)
        {
            MeshRenderer mr = line.GetComponent <MeshRenderer>();
            StyleManager.SetGridMaterial(mr, count);
        }

        StyleManager.OnStyleChange += () =>
        {
            foreach (GameObject line in lines)
            {
                MeshRenderer mr = line.GetComponent <MeshRenderer>();
                StyleManager.SetGridMaterial(mr, count);
            }
        };
    }
예제 #5
0
    public virtual void Init(GeoCamera camera)
    {
        geoCamera = camera;

        if (lineMesh == null)
        {
            lineMesh = LineMesh();
        }
    }
예제 #6
0
파일: NavCamera.cs 프로젝트: Y-dc/GeoSpace
    // Use this for initialization
    public void Init(GeoCamera camera)
    {
        _camera = GetComponent <Camera>();

        InitViewport();

        geoCamera           = camera;
        geoCamera.OnRotate += SetCameraTransform;
    }
예제 #7
0
    // test
    // LineRenderer lineRenderer;

    public void Init(int i, GeoCamera camera)
    {
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        id = i;

        if (mesh == null)
        {
            mesh = SignMesh();
        }

        textMesh     = gameObject.AddComponent <TextMesh>();
        textRenderer = textMesh.GetComponent <MeshRenderer>();

        textMesh.anchor    = TextAnchor.MiddleCenter;
        textMesh.alignment = TextAlignment.Center;

        StyleManager.SetSignAttr(textMesh);
        StyleManager.SetSignMaterial(textRenderer);

        StyleManager.OnStyleChange += () =>
        {
            StyleManager.SetSignAttr(textMesh);
            StyleManager.SetSignMaterial(textRenderer);

            SetText();
        };

        backgroundObject = new GameObject("background");
        backgroundObject.transform.SetParent(transform);
        backgroundObject.transform.position = Vector3.zero;

        MeshFilter meshFilter = backgroundObject.AddComponent <MeshFilter>();

        backgroundRenderer = backgroundObject.AddComponent <MeshRenderer>();

        meshFilter.sharedMesh = mesh;

        SetState(SignState.Normal);

        SetTintColor();
        StyleManager.OnStyleChange += () =>
        {
            SetTintColor();
        };

        //test
        // GameObject lineObject = new GameObject();
        // lineRenderer = lineObject.AddComponent<LineRenderer>();
        // lineObject.transform.position = Vector3.zero;
        // lineRenderer.alignment = LineAlignment.View;
        // lineRenderer.useWorldSpace = true;
        // lineRenderer.startWidth = 0.02f;
        // lineRenderer.endWidth = 0.02f;
    }
예제 #8
0
    public EditEdgeOperation(GeoController geoController, GeoCamera geoCamera, Geometry geometry, GeometryBehaviour geometryBehaviour, GeoUI geoUI, GeoEdge geoEdge)
    {
        CanRotateCamera  = false;
        CanActiveElement = false;

        this.geoController     = geoController;
        this.geoCamera         = geoCamera;
        this.geometry          = geometry;
        this.geometryBehaviour = geometryBehaviour;
        this.activePanel       = geoUI.activePanel;
        this.elementPanel      = geoUI.elementPanel;
        this.geoEdge           = geoEdge;
    }
예제 #9
0
    public void Init(GeoLine geoLine, GeoCamera geoCamera)
    {
        lineRenderer            = gameObject.AddComponent <LineRenderer>();
        lineRenderer.material   = new Material(Shader.Find("Sprites/Default"));
        lineRenderer.startWidth = LINE_WIDTH;
        lineRenderer.endWidth   = LINE_WIDTH;
        Color color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), 1f);

        lineRenderer.startColor = new Color(0.5f, 0.5f, 0.5f, 1);
        lineRenderer.endColor   = new Color(0.5f, 0.5f, 0.5f, 1);
        positions = geoLine.Position();
        lineRenderer.positionCount = positions.Length;
        lineRenderer.SetPositions(positions);
    }
예제 #10
0
    public EditVertexOperation(GeoController geoController, StateController stateController, GeoCamera geoCamera, Geometry geometry, GeometryBehaviour geometryBehaviour, GeoUI geoUI, GeoVertex geoVertex)
    {
        CanRotateCamera  = false;
        CanActiveElement = false;

        this.geoController     = geoController;
        this.stateController   = stateController;
        this.geoCamera         = geoCamera;
        this.geometry          = geometry;
        this.geometryBehaviour = geometryBehaviour;
        this.activePanel       = geoUI.activePanel;
        this.elementPanel      = geoUI.elementPanel;
        this.geoVertex         = geoVertex;
    }
예제 #11
0
    public MoveVertexOperation(StateController stateController, GeoCamera geoCamera, Geometry geometry, GeometryBehaviour geometryBehaviour, GeoUI geoUI, VertexUnit vertex, VertexBehaviour vertexBehaviour, bool snap)
    {
        CanRotateCamera = false;
        CanActiveElement = false;

        this.stateController = stateController;

        this.geoCamera = geoCamera;
        this.geometry = geometry;
        this.geometryBehaviour = geometryBehaviour;
        this.inputPanel = geoUI.inputPanel;

        this.vertex = vertex;
        this.vertexBehaviour = vertexBehaviour;

        this.snap = snap;
    }
예제 #12
0
    // Mesh mesh;

    // MeshFilter meshFilter;
    // MeshRenderer meshRenderer;

    public void Init(GeoCamera camera)
    {
        geoCamera = camera;

        vertexWrapper = InitWrapper("Vertex");
        edgeWrapper   = InitWrapper("Edge");
        faceWrapper   = InitWrapper("Face");
        signWrapper   = InitWrapper("Sign");
        gizmoWrapper  = InitWrapper("Gizmo");

        elementMap   = new Dictionary <GeoElement, ElementBehaviour>();
        hideElements = new List <GeoElement>();

        vertexMap = new Dictionary <GeoVertex, VertexBehaviour>();
        edgeMap   = new Dictionary <GeoEdge, EdgeBehaviour>();
        faceMap   = new Dictionary <GeoFace, FaceBehaviour>();
        signMap   = new Dictionary <int, SignBehaviour>();
        gizmoMap  = new Dictionary <Gizmo, GizmoBehaviour>();
    }
예제 #13
0
    public override void Init(GeoCamera camera)
    {
        base.Init(camera);

        geoCamera.OnRotate += OnCameraRotate;

        MeshRenderer mr1, mr2;

        line1 = InitLine(1, out mr1);
        line2 = InitLine(2, out mr2);

        StyleManager.SetGizmosLineMaterial(mr1);
        StyleManager.SetGizmosLineMaterial(mr2);
        StyleManager.OnStyleChange += () =>
        {
            StyleManager.SetGizmosLineMaterial(mr1);
            StyleManager.SetGizmosLineMaterial(mr2);
        };
    }
예제 #14
0
    public override void Init(GeoCamera camera)
    {
        base.Init(camera);

        geoCamera.OnRotate += OnCameraRotate;

        textMesh     = gameObject.AddComponent <TextMesh>();
        textRenderer = textMesh.GetComponent <MeshRenderer>();

        textMesh.anchor    = TextAnchor.MiddleCenter;
        textMesh.alignment = TextAlignment.Center;

        StyleManager.SetGizmoTextAttr(textMesh);
        StyleManager.SetGizmoTextMaterial(textRenderer);

        StyleManager.OnStyleChange += () =>
        {
            StyleManager.SetGizmoTextAttr(textMesh);
            StyleManager.SetGizmoTextMaterial(textRenderer);
        };
    }
예제 #15
0
    // test
    // LineRenderer lineRenderer;

    public void Init(GeoEdge geoEdge, GeoCamera camera)
    {
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        geoController = GameObject.Find("/GeoController").GetComponent <GeoController>();

        this.geoEdge = geoEdge;

        mesh = LineMesh();

        MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>();

        meshRenderer      = gameObject.AddComponent <MeshRenderer>();
        meshCollider      = gameObject.AddComponent <BoxCollider>();
        meshCollider.size = new Vector3(1 - LINE_COLLIDER_OFFSET, LINE_COLLIDER_SIZE, LINE_COLLIDER_SIZE);

        meshFilter.sharedMesh = mesh;

        SetColorIndex(0);
        SetStyleIndex(0);

        StyleManager.OnStyleChange += () =>
        {
            SetColorIndex(0);
            SetStyleIndex(0);
        };

        visiable = true;

        // test
        // GameObject lineObject = new GameObject();
        // lineRenderer = lineObject.AddComponent<LineRenderer>();
        // lineObject.transform.position = Vector3.zero;
        // lineRenderer.alignment = LineAlignment.View;
        // lineRenderer.useWorldSpace = false;
        // lineRenderer.startWidth = 0.02f;
        // lineRenderer.endWidth = 0.02f;
    }
예제 #16
0
    public AddAuxiliaryOperation(GeoController geoController, GeoCamera geoCamera, StateController stateController, Geometry geometry, GeometryBehaviour geometryBehaviour, GeoUI geoUI, Tool tool)
    {
        CanRotateCamera  = true;
        CanActiveElement = true;

        this.geoController = geoController;

        this.geoCamera = geoCamera;

        this.stateController   = stateController;
        this.geometry          = geometry;
        this.geometryBehaviour = geometryBehaviour;
        this.inputPanel        = geoUI.inputPanel;
        this.tool  = tool;
        this.geoUI = geoUI;
        Type type = Type.GetType(tool.Name + "AuxiliaryTool");

        if (type != null)
        {
            auxiliaryTool = (AuxiliaryTool)Activator.CreateInstance(type);
        }
    }
예제 #17
0
    public override void Init(GeoCamera camera)
    {
        base.Init(camera);

        geoCamera.OnRotate += OnCameraRotate;

        lines = new GameObject[COUNT];
        dirs  = new Vector3[COUNT];

        for (int i = 0; i < COUNT; i++)
        {
            MeshRenderer mr;
            GameObject   line = InitLine(i, out mr);
            lines[i] = line;

            StyleManager.SetGizmosLineMaterial(mr);

            StyleManager.OnStyleChange += () =>
            {
                StyleManager.SetGizmosLineMaterial(mr);
            };
        }
    }
예제 #18
0
    public void Init(GeoVertex geoVertex, GeoCamera camera)
    {
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        geoController = GameObject.Find("/GeoController").GetComponent <GeoController>();

        this.geoVertex = geoVertex;

        if (mesh == null)
        {
            mesh = PointMesh();
        }

        MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>();

        meshRenderer = gameObject.AddComponent <MeshRenderer>();
        BoxCollider meshCollider = gameObject.AddComponent <BoxCollider>();

        meshCollider.size = new Vector3(POINT_COLLIDER_SIZE, POINT_COLLIDER_SIZE, POINT_COLLIDER_SIZE);

        meshFilter.sharedMesh       = mesh;
        meshRenderer.sharedMaterial = ConfigManager.VertexStyle[0].Material;

        SetSize(geoVertex.isFixed ? FIXED_SIZE : UNFIXED_SIZE);

        SetColorIndex(0);
        SetStyleIndex(0);

        StyleManager.OnStyleChange += () =>
        {
            SetColorIndex(0);
            SetStyleIndex(0);
        };

        visiable = true;
    }
예제 #19
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);
    }
예제 #20
0
    public void Init(GeoCamera camera, int size)
    {
        geoCamera           = camera;
        geoCamera.OnRotate += OnCameraRotate;

        if (size <= 0)
        {
            size = 2;
        }
        if (size % 2 == 1)
        {
            size += 1;
        }


        if (lineMesh == null)
        {
            lineMesh = LineMesh();
        }

        count = size + 1;
        int offset = size / 2;


        axisWrapper  = InitWrapper("Axis");
        arrowWrapper = InitWrapper("Arrow");
        pointWrapper = InitWrapper("Point");
        signWrapper  = InitWrapper("Sign");

        // Axis
        MeshRenderer xAxisRender, yAxisRender, zAxisRender;

        xAxis = InitAxis("x", out xAxisRender);
        yAxis = InitAxis("y", out yAxisRender);
        zAxis = InitAxis("z", out zAxisRender);

        StyleManager.SetAxisXMaterial(xAxisRender);
        StyleManager.SetAxisYMaterial(yAxisRender);
        StyleManager.SetAxisZMaterial(zAxisRender);


        // Arrow
        MeshRenderer xArrowRender, yArrowRender, zArrowRender;

        xArrow = InitArrow("x", new Vector3(offset, 0, 0), new Vector3(0, 0, -90), out xArrowRender);
        yArrow = InitArrow("y", new Vector3(0, offset, 0), new Vector3(0, 0, 0), out yArrowRender);
        zArrow = InitArrow("z", new Vector3(0, 0, offset), new Vector3(90, 0, 0), out zArrowRender);

        StyleManager.SetArrowXMaterial(xArrowRender);
        StyleManager.SetArrowYMaterial(yArrowRender);
        StyleManager.SetArrowZMaterial(zArrowRender);


        MeshRenderer xSignRender, ySignRender, zSignRender;

        xSign = InitSign("x", "x", new Vector3(offset, 0, 0), out xSignRender);
        ySign = InitSign("y", "y", new Vector3(0, offset, 0), out ySignRender);
        zSign = InitSign("z", "z", new Vector3(0, 0, offset), out zSignRender);

        StyleManager.SetAxisSignAttr(xSign);
        StyleManager.SetAxisSignAttr(ySign);
        StyleManager.SetAxisSignAttr(zSign);

        StyleManager.SetAxisSignXMaterial(xSignRender);
        StyleManager.SetAxisSignYMaterial(ySignRender);
        StyleManager.SetAxisSignZMaterial(zSignRender);

        // Point
        xPoints = new GameObject[size];
        yPoints = new GameObject[size];
        zPoints = new GameObject[size];

        xSigns = new TextMesh[size];
        ySigns = new TextMesh[size];
        zSigns = new TextMesh[size];

        xPos = new Vector3[size];
        yPos = new Vector3[size];
        zPos = new Vector3[size];

        InitPointsSigns("x", ref xPos, ref xPoints, ref xSigns, Vector3.right, size, StyleManager.SetAxisXMaterial, StyleManager.SetAxisSignXMaterial);
        InitPointsSigns("y", ref yPos, ref yPoints, ref ySigns, Vector3.up, size, StyleManager.SetAxisYMaterial, StyleManager.SetAxisSignYMaterial);
        InitPointsSigns("z", ref zPos, ref zPoints, ref zSigns, Vector3.forward, size, StyleManager.SetAxisZMaterial, StyleManager.SetAxisSignZMaterial);


        StyleManager.OnStyleChange += () =>
        {
            StyleManager.SetAxisXMaterial(xAxisRender);
            StyleManager.SetAxisYMaterial(yAxisRender);
            StyleManager.SetAxisZMaterial(zAxisRender);

            StyleManager.SetArrowXMaterial(xArrowRender);
            StyleManager.SetArrowYMaterial(yArrowRender);
            StyleManager.SetArrowZMaterial(zArrowRender);

            StyleManager.SetAxisSignAttr(xSign);
            StyleManager.SetAxisSignAttr(ySign);
            StyleManager.SetAxisSignAttr(zSign);

            StyleManager.SetAxisSignXMaterial(xSignRender);
            StyleManager.SetAxisSignYMaterial(ySignRender);
            StyleManager.SetAxisSignZMaterial(zSignRender);

            for (int i = 0; i < size; i++)
            {
                MeshRenderer pointMRX = xPoints[i].GetComponent <MeshRenderer>();
                StyleManager.SetAxisXMaterial(pointMRX);

                MeshRenderer pointMRY = yPoints[i].GetComponent <MeshRenderer>();
                StyleManager.SetAxisYMaterial(pointMRY);

                MeshRenderer pointMRZ = zPoints[i].GetComponent <MeshRenderer>();
                StyleManager.SetAxisXMaterial(pointMRZ);

                MeshRenderer signMRX = xSigns[i].GetComponent <MeshRenderer>();
                StyleManager.SetPointSignAttr(xSigns[i]);
                StyleManager.SetAxisSignXMaterial(signMRX);

                MeshRenderer signMRY = ySigns[i].GetComponent <MeshRenderer>();
                StyleManager.SetPointSignAttr(ySigns[i]);
                StyleManager.SetAxisSignYMaterial(signMRY);

                MeshRenderer signMRZ = zSigns[i].GetComponent <MeshRenderer>();
                StyleManager.SetPointSignAttr(zSigns[i]);
                StyleManager.SetAxisSignZMaterial(signMRZ);
            }
        };
    }
예제 #21
0
 public SpreadAuxiliary() : base()
 {
     geometryBehaviour = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();
     geoCamera         = GameObject.Find("/3D/GeoCamera").GetComponent <GeoCamera>();
 }