示例#1
0
    void addTouch(Tuio.Touch t)
    {
        RaycastHit h = new RaycastHit();
        bool hasHit = (Physics.Raycast(getRay(t), out h, 100f, GetLayerMask(hitOnlyLayers)));

        addTouchIcon(h.point, t, hasHit);
    }
示例#2
0
    public void RemoveTouch(Tuio.Touch t)
    {
        // Not most recent touch?
        if (curTouch.TouchId != t.TouchId) return;

        // Check it's not expired
        //if (Time.time - t.TimeAdded > maxHeldTime) return;

        // Over the movement threshold?
        Vector2 curTouchPos = new Vector2(
                t.TouchPoint.x / (float)_screenWidth,
                t.TouchPoint.y / (float)_screenHeight);
        if (Vector2.Distance(curTouchPos, originalPos) > 0.003f) return;

        // Check if the touch still hits the same collider
        RaycastHit h = new RaycastHit();
        bool hit = origCollider.Raycast(getRay(t), out h, Mathf.Infinity);
        if (!hit) return;

        // Do the click
        gameObject.SendMessage("Click", h, SendMessageOptions.DontRequireReceiver);
        foreach (GameObject g in NotifyObjects)
        {
            g.SendMessage("Click", h, SendMessageOptions.DontRequireReceiver);
        }
    }
示例#3
0
    GameObject addTouchIcon(Vector3 hitPoint, Tuio.Touch t, bool visible)
    {
        GameObject go = (GameObject)Instantiate(TouchIcon);
        go.transform.position = new Vector3(hitPoint.x, hitPoint.y, hitPoint.z);
        //go.renderer.enabled = visible;

        touchIcons.Add(t.TouchId, go);
        return go;
    }
示例#4
0
 public void AddTouch(Tuio.Touch t, RaycastHit hit)
 {
     // This will always keep the most recent touch
     curTouch = t;
     originalPos = new Vector2(
             t.TouchPoint.x / (float)_screenWidth,
             t.TouchPoint.y / (float)_screenHeight);
     origCollider = hit.collider;
 }
示例#5
0
    GUITexture addTouchIcon(Tuio.Touch t)
    {
        GameObject touchIcon = (GameObject)Instantiate(GUITouchIcon);
        GUITexture texture = touchIcon.GetComponent<GUITexture>();

        setTouchIconPos(texture, t.TouchPoint);

        touchIcons.Add(t.TouchId, texture);
        return texture;
    }
示例#6
0
文件: GestureDrag.cs 项目: shu1/dfu
    public void UpdateTouch(Tuio.Touch t)
    {
        if (t.Status != TouchStatus.Moved) return;

        RaycastHit h = new RaycastHit();
        bool hasHit = (Physics.Raycast(getRay(t), out h, 100f, GetLayerMask(hitOnlyLayers)));

        Vector3 hitPoint = h.point;
        if (h.collider.gameObject == gameObject)
                hitPoint = new Vector3(hitPoint.x, transform.position.y, hitPoint.z);

        updateDragger(hitPoint, t, hasHit);
    }
示例#7
0
 void HandleTouches(Tuio.Touch t)
 {
     switch (t.Status)
     {
     case TouchStatus.Began:
         addTouch(t);
         break;
     case TouchStatus.Ended:
         removeTouch(t);
         break;
     case TouchStatus.Moved:
         updateTouch(t);
         break;
     case TouchStatus.Stationary:
     default:
         break;
     }
 }
示例#8
0
 void HandleTouches(Tuio.Touch t)
 {
     switch (t.Status)
     {
     case TouchStatus.Began:
         linker.AddTouch(t, getRay(t, new RaycastHit()));
         break;
     case TouchStatus.Ended:
         linker.RemoveTouch(t);
         break;
     case TouchStatus.Moved:
         linker.UpdateTouch(t);
         break;
     case TouchStatus.Stationary:
         linker.UpdateTouch(t);
         break;
     default:
         break;
     }
 }
示例#9
0
文件: GestureDrag.cs 项目: shu1/dfu
    GameObject addDragger(Vector3 hitPoint, Tuio.Touch t, bool visible)
    {
        GameObject go = (GameObject)Instantiate(dragger);
        float y = fixedDraggerHeight == 0 ? hitPoint.y : fixedDraggerHeight;
        go.transform.position = new Vector3(hitPoint.x, y, hitPoint.z);

        if (go.renderer != null) go.renderer.enabled = visible && showDraggers;

        draggers.Add(t.TouchId, go);
        return go;
    }
示例#10
0
文件: GestureDrag.cs 项目: shu1/dfu
 public void RemoveTouch(Tuio.Touch t)
 {
     removeJoint(t.TouchId);
     removeDragger(t);
 }
示例#11
0
文件: GestureDrag.cs 项目: shu1/dfu
 public void AddTouch(Tuio.Touch t, RaycastHit hit)
 {
     GameObject go = addDragger(hit.point, t, true);
     Rigidbody bod = attachToParent ? transform.parent.rigidbody : rigidbody;
     addJoint(bod, go, hit.point, t);
 }
示例#12
0
文件: GestureDrag.cs 项目: shu1/dfu
    void updateDragger(Vector3 hitPoint, Tuio.Touch t, bool visible)
    {
        GameObject go = draggers[t.TouchId];
        float y = fixedDraggerHeight == 0 ? hitPoint.y : fixedDraggerHeight;
        go.transform.position = new Vector3(hitPoint.x, y, hitPoint.z);

        if (go.renderer != null) go.renderer.enabled = visible && showDraggers;
    }
示例#13
0
 void updateTouchIcon(Tuio.Touch t)
 {
     if (!touchIcons.ContainsKey(t.TouchId)) return;
     GUITexture go = touchIcons[t.TouchId];
     setTouchIconPos(go, t.TouchPoint);
 }
示例#14
0
 void addTouch(Tuio.Touch t)
 {
     addTouchIcon(t);
 }
示例#15
0
 void updateTouchIcon(Vector3 hitPoint, Tuio.Touch t, bool visible)
 {
     GameObject go = touchIcons[t.TouchId];
     go.transform.position = hitPoint;
     go.renderer.enabled = visible;
 }
示例#16
0
 void removeTouchIcon(Tuio.Touch t)
 {
     GameObject go = touchIcons[t.TouchId];
     touchIcons.Remove(t.TouchId);
     Destroy(go);
 }
示例#17
0
 void removeTouch(Tuio.Touch t)
 {
     removeTouchIcon(t);
 }
示例#18
0
 void removeTouchIcon(Tuio.Touch t)
 {
     if (!touchIcons.ContainsKey(t.TouchId)) return;
     GUITexture go = touchIcons[t.TouchId];
     touchIcons.Remove(t.TouchId);
     Destroy(go.gameObject);
 }
示例#19
0
 public void UpdateTouch(Tuio.Touch t)
 {
 }
示例#20
0
 Ray getRay(Tuio.Touch t)
 {
     Vector3 touchPoint = new Vector3(t.TouchPoint.x, t.TouchPoint.y, 0f);
     Ray targetRay = _targetCamera.ScreenPointToRay(touchPoint);
     return targetRay;
 }
示例#21
0
文件: GestureDrag.cs 项目: shu1/dfu
 void removeDragger(Tuio.Touch t)
 {
     GameObject go = draggers[t.TouchId];
     draggers.Remove(t.TouchId);
     Destroy(go);
 }
示例#22
0
文件: GestureDrag.cs 项目: shu1/dfu
    Joint addJoint(Rigidbody attachTo, GameObject go, Vector3 hitPoint, Tuio.Touch t)
    {
        Joint j = (Joint)go.GetComponent<Joint>();

        // Initial position of the joint is the centre of the body we pickup or the hook
        // It will move it in the next frame with the Drag
        if (hook != null)
        {
            go.transform.position = hook.transform.position;
        }
        else
        {
            go.transform.position = hitPoint;
        }

        // Deal with centre of mass
        if (attachToCenterOfMass)
        {
            Vector3 anchor = go.transform.InverseTransformPoint(attachTo.worldCenterOfMass);
            j.anchor = anchor;
        }
        else
        {
            j.anchor = Vector3.zero;
        }

        initJoint(j, attachTo);
        joints.Add(t.TouchId, j);
        return j;
    }
示例#23
0
 void updateTouch(Tuio.Touch t)
 {
     updateTouchIcon(t);
 }