예제 #1
0
    // Update is called once per frame
    void Update()
    {
        Vector3 tipPos = _tip.transform.position;

        if (Physics.Raycast(tipPos, transform.up, out touch, drawThresHold))
        {
            if (touch.collider.tag == "Whiteboard")
            {
                // Debug.Log("Poop");
                this._whiteboard = touch.collider.gameObject.GetComponent <Whiteboard>();

                _whiteboard.SetColour(penColor);
                _whiteboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                _whiteboard.ToggleTouch(true);



                if (!lastTouch)
                {
                    lastTouch = true;
                    lastAngle = this.transform.rotation;
                }
            }
            else
            {
                _whiteboard.ToggleTouch(false);
                lastTouch = false;
            }
        }
        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        float   tipHeight = transform.Find("Tip").transform.localScale.y;
        Vector3 tip       = transform.Find("Tip/TouchPoint").transform.position;

        Debug.Log(tip);

        if (lastTouch)
        {
            tipHeight *= 1.1f;
        }

        // Check for a Raycast from the tip of the pen
        if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
        {
            if (!(touch.collider.tag == "Whiteboard"))
            {
                return;
            }

            // Give haptic feedback when touching the whiteboard
            controllerActions.TriggerHapticPulse(0.05f);

            // Set whiteboard parameters
            whiteboard.SetColor(Color.blue);
            whiteboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
            whiteboard.ToggleTouch(true);

            // If we started touching, get the current angle of the pen
            if (lastTouch == false)
            {
                lastTouch = true;
                lastAngle = transform.rotation;
            }
        }
        else
        {
            whiteboard.ToggleTouch(false);
            lastTouch = false;
        }

        // Lock the rotation of the pen if "touching"
        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }
예제 #3
0
    void Update()
    {
        float   tipHeight = transform.Find("Tip").transform.localScale.y;
        Vector3 tip       = transform.Find("Tip/TouchPoint").transform.position;

        whiteboard.SetPenSize(100);
        //Debug.Log(tip);

        if (lastTouch)
        {
            tipHeight *= 1.1f;
        }

        if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
        {
            if (touch.collider.tag == "Whiteboard")
            {
                this.whiteboard = touch.collider.GetComponent <Whiteboard>();

                whiteboard.SetColor(myColor);
                whiteboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                whiteboard.ToggleTouch(true);


                if (lastTouch == false)
                {
                    lastTouch = true;
                    lastAngle = transform.rotation;
                }
            }
            else if (touch.collider.tag == "Wallboard")
            {
                this.wallboard = touch.collider.GetComponent <WallBoard>();

                wallboard.SetColor(myColor);
                wallboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                wallboard.ToggleTouch(true);


                if (lastTouch == false)
                {
                    lastTouch = true;
                    lastAngle = transform.rotation;
                }
            }
        }
        else
        {
            whiteboard.ToggleTouch(false);
            lastTouch = false;
        }


        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }
예제 #4
0
파일: testDrawLine.cs 프로젝트: cule1/CLUE
    // Update is called once per frame
    void Update()
    {
        LineRenderer lineRenderer = GetComponent <LineRenderer>();

        lineRenderer.positionCount = 2;

        if (Input.GetKeyDown(KeyCode.Space) && !m_bIsDraw)
        {
            m_bIsDraw            = true;
            lineRenderer.enabled = true;
        }
        else if (Input.GetKeyDown(KeyCode.Space) && m_bIsDraw)
        {
            m_bIsDraw            = false;
            lineRenderer.enabled = false;
        }

        if (m_bIsDraw)
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit) &&
                hit.collider.gameObject.name == "Whiteboard")
            {
                this.whiteboard = hit.collider.GetComponent <Whiteboard>();

                whiteboard.SetColor(Color.black);
                whiteboard.SetTouchPosition(hit.textureCoord.x, hit.textureCoord.y);
                whiteboard.ToggleTouch(true);

                if (lastTouch == false)
                {
                    lastTouch = true;
                    lastAngle = transform.rotation;
                }


                lineRenderer.startColor = Color.blue;
                lineRenderer.endColor   = Color.blue;
                lineRenderer.SetPosition(0, transform.position);
                lineRenderer.SetPosition(1, hit.point);

                ////if (Input.GetKeyDown(KeyCode.A) && !m_bIsDrawing)
                //if (Input.GetKeyDown(KeyCode.A) && !m_bIsDrawing)
                //{
                //    m_bIsDrawing = true;

                //    GameObject.Find("Board").GetComponent<testBoard>().m_HitPos = hit.point;
                //}
                //else if (Input.GetKeyDown(KeyCode.A) && m_bIsDrawing)
                //{
                //    m_bIsDrawing = false;
                //}
            }
            else
            {
                whiteboard.ToggleTouch(false);
                lastTouch = false;

                lineRenderer.startColor = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                lineRenderer.endColor   = new Color(1.0f, 1.0f, 1.0f, 0.0f);
            }

            if (lastTouch)
            {
                transform.rotation = lastAngle;
            }
        }
    }