Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (cam.pixelRect.Contains(Input.mousePosition))
        {
            if (Input.GetMouseButtonDown(0))
            {
                mouseOld = Input.mousePosition;
            }
            if (Input.GetMouseButton(0))
            {
                Vector3 mouseNew = Input.mousePosition;
                surface.transform.Rotate(Vector3.forward, (mouseNew.x - mouseOld.x) * 2);
                Vector3 xCam = cam.transform.TransformDirection(Vector3.right);
                surface.transform.Rotate(xCam, (mouseNew.y - mouseOld.y) * 2, Space.World);
                mouseOld = mouseNew;
            }
        }


        l.Clear();
        l.currentColor = Color.blue;
        l.AddGrid(surface.position, surface.nbControlU, surface.nbControlV);
        l.currentColor = Color.red;
        l.AddGrid(DrawSurface(50, 50), 50, 50);
    }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     if (cam.pixelRect.Contains(Input.mousePosition))
     {
         if (Input.GetMouseButtonDown(0))
         {
             Vector3 p = mouseToLocal();
             curve.Add(p, 1.0f);
         }
         if (Input.GetMouseButtonDown(1))
         {
             Vector3 p = mouseToLocal();
             selected = Closest(p, 0.1f);
             if (selected != -1)
             {
                 move = true;
             }
         }
         if (Input.GetMouseButton(1))
         {
             if (move && selected != -1)
             {
                 Vector3 p = mouseToLocal();
                 curve.position [selected] = p;
             }
         }
         if (Input.GetKeyDown(KeyCode.X))
         {
             curve.position.Clear();
         }
         if (Input.GetAxis("Mouse ScrollWheel") < 0)
         {
             Vector3 p      = mouseToLocal();
             int     change = Closest(p, 0.1f);
             if (change != -1)
             {
                 curve.weight [change] *= 0.9f;
             }
         }
         if (Input.GetAxis("Mouse ScrollWheel") > 0)
         {
             Vector3 p      = mouseToLocal();
             int     change = Closest(p, 0.1f);
             if (change != -1)
             {
                 curve.weight [change] *= 1.1f;
             }
         }
     }
     l.Clear();
     l.currentColor = Color.blue;
     l.AddLine(curve.position);
     l.currentColor = Color.red;
     l.AddLine(curve.DrawNurbs());
 }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (cam.pixelRect.Contains(Input.mousePosition))
        {
            if (Input.GetMouseButtonDown(0))
            {
                firstClick = Input.mousePosition.x;
                move       = true;
                firstMove  = true;
            }
            if (Input.GetMouseButton(0))
            {
                if (move)
                {
                    if (firstMove)
                    {
                        selected = ClosestKnot(firstClick, Input.mousePosition.x);
                        if (selected != -1 && selected != b.knot.Count - 1 && selected != 0)
                        {
                            firstMove          = false;
                            directionMoveRight = (firstClick - Input.mousePosition.x < 0);
                        }
                    }
                    else
                    {
                        MoveSelectedKnot(Input.mousePosition);
                    }
                }
            }
            if (Input.GetMouseButton(1))
            {
                Vector3 mouse = cam.ScreenToWorldPoint(Input.mousePosition);
                mouse = b.transform.InverseTransformPoint(mouse);
                if (mouse.x < 0)
                {
                    b.currentT = 0.0;
                }
                else if (mouse.x >= 1)
                {
                    b.currentT = 0.9999999;
                }
                else
                {
                    b.currentT = mouse.x;
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                move = false;
            }
            if (Input.GetKeyDown(KeyCode.F1))
            {
                if (b.degree >= 1)
                {
                    b.degree--;
                }
            }
            if (Input.GetKeyDown(KeyCode.F2))
            {
                b.degree++;
            }
        }


        l.Clear();
        BasisDrawCompute();
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (cam.pixelRect.Contains(Input.mousePosition))
        {
            if (Input.GetMouseButtonDown(0))
            {
                mouseOld = Input.mousePosition;
            }
            if (Input.GetMouseButton(0))
            {
                Vector3 mouseNew = Input.mousePosition;
                surface.transform.Rotate(Vector3.forward, (mouseNew.x - mouseOld.x) * 2);
                Vector3 xCam = cam.transform.TransformDirection(Vector3.right);
                surface.transform.Rotate(xCam, (mouseNew.y - mouseOld.y) * 2, Space.World);
                mouseOld = mouseNew;
            }
        }


        l.Clear();
        l.currentColor = Color.blue;
        l.AddGrid(surface.position, surface.nbControlU, surface.nbControlV);
        l.currentColor = Color.red;
        l.AddGrid(DrawSurface(50, 50), 50, 50);

        if (Input.GetMouseButtonDown(1))
        {
            Ray p = mouseLocal();
            selected = Closest(p, 0.1f);
            if (selected != -1)
            {
                distance = Vector3.Distance(p.origin, surface.transform.TransformPoint(surface.position [selected]));
                move     = true;
            }
        }
        if (Input.GetMouseButton(1))
        {
            if (move && selected != -1)
            {
                Ray p = mouseLocal();
                Debug.Log(distance);
                surface.position [selected] = surface.transform.InverseTransformPoint(p.GetPoint(distance));
            }
        }
        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            Ray p      = mouseLocal();
            int change = Closest(p, 0.1f);
            if (change != -1)
            {
                surface.weight [change] *= 0.9f;
            }
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            Ray p      = mouseLocal();
            int change = Closest(p, 0.1f);
            if (change != -1)
            {
                surface.weight [change] *= 1.1f;
            }
        }
    }