Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            controlKeyPressed = true;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }
        else if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            controlKeyPressed = false;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }


        if (controlKeyPressed)
        {
            p = new Vector2(
                ImpPlugin.LinearInterpolation(Input.mousePosition.x, 0, Screen.width, MinCoords.x, MaxCoords.x),
                ImpPlugin.LinearInterpolation(Input.mousePosition.y, 0, Screen.height, MinCoords.y, MaxCoords.y));

            if (p.x > ImpPlugin.Imp_MinX() && p.x < ImpPlugin.Imp_MaxX() &&
                p.y > ImpPlugin.Imp_MinY() && p.y < ImpPlugin.Imp_MaxY())
            {
                Execute(p);
            }
        }


        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
        {
            Execute(p);
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        //
        // Fixing possible OutOfRange
        //
        levelIndex      = levelIndex % laplaceMeshes.Count;
        meshTargetIndex = meshTargetIndex % laplaceMeshes[levelIndex].MeshList.Length;

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            controlKeyPressed = true;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }
        else if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            controlKeyPressed = false;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }


        if (controlKeyPressed)
        {
            p = new Vector2(
                ImpPlugin.LinearInterpolation(Input.mousePosition.x, 0, Screen.width, MinCoords.x, MaxCoords.x),
                ImpPlugin.LinearInterpolation(Input.mousePosition.y, 0, Screen.height, MinCoords.y, MaxCoords.y));

            if (p.x > ImpPlugin.Imp_MinX() && p.x < ImpPlugin.Imp_MaxX() &&
                p.y > ImpPlugin.Imp_MinY() && p.y < ImpPlugin.Imp_MaxY())
            {
                Execute(p);
            }
        }
        else
        {
            MeshRenderer target = templateMesh.GetComponent <MeshRenderer>();
            int          v      = 0;
            for (var key = KeyCode.Alpha1; key <= KeyCode.Alpha9; ++key)
            {
                if (Input.GetKeyDown(key))
                {
                    p = vertices2d[v % vertices2d.Count];

                    MeshRenderer source = baseMeshes[v % vertices2d.Count].GetComponent <MeshRenderer>();
                    if (target && source)
                    {
                        target.sharedMaterial = source.sharedMaterial;
                    }

                    meshTargetIndex = v % laplaceMeshes.Count;

                    Execute(p);
                }
                ++v;
            }

            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                target.sharedMaterial = wireframe;
            }
        }

        // +1 is because of laplaceMeshes + baseMeshes
        for (var key = KeyCode.Keypad0; key <= KeyCode.Keypad0 + laplaceMeshes.Count + 1; ++key)
        {
            if (Input.GetKeyDown(key))
            {
                ImpPlugin.Imp_SetCurrent(key - KeyCode.Keypad0);
            }
        }



        switch (levelIndex)
        {
        default:
        case 0: laplaceIterations = 0; break;

        case 1: laplaceIterations = 2; break;

        case 2: laplaceIterations = 5; break;

        case 3: laplaceIterations = 10; break;

        case 4: laplaceIterations = 25; break;

        case 5: laplaceIterations = 50; break;

        case 6: laplaceIterations = 100; break;
        }


        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
        {
            Execute(p);
        }

        //Execute(p);
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            controlKeyPressed = true;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }
        else if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            controlKeyPressed = false;
            if (impUI)
            {
                impUI.MouseTarget(controlKeyPressed);
            }
        }


        if (controlKeyPressed)
        {
            p = new Vector2(
                ImpPlugin.LinearInterpolation(Input.mousePosition.x, 0, Screen.width, MinCoords.x, MaxCoords.x),
                ImpPlugin.LinearInterpolation(Input.mousePosition.y, 0, Screen.height, MinCoords.y, MaxCoords.y));

            if (p.x > ImpPlugin.Imp_MinX() && p.x < ImpPlugin.Imp_MaxX() &&
                p.y > ImpPlugin.Imp_MinY() && p.y < ImpPlugin.Imp_MaxY())
            {
                Execute(p);
            }
        }
        else
        {
            MeshRenderer target = templateMesh.GetComponent <MeshRenderer>();
            int          v      = 0;
            for (var key = KeyCode.Alpha1; key <= KeyCode.Alpha9; ++key)
            {
                if (Input.GetKeyDown(key))
                {
                    p = vertices2d[v % vertices2d.Count];

                    MeshRenderer source = baseMeshes[v % vertices2d.Count].GetComponent <MeshRenderer>();
                    if (target && source)
                    {
                        target.sharedMaterial = source.sharedMaterial;
                    }
                }
                ++v;
            }

            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                target.sharedMaterial = wireframe;
            }
        }


        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
        {
            Execute(p);
        }
    }