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); }
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); } }
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; }
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; }
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; }
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); }
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; } }
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; } }
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; }
public void RemoveTouch(Tuio.Touch t) { removeJoint(t.TouchId); removeDragger(t); }
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); }
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; }
void updateTouchIcon(Tuio.Touch t) { if (!touchIcons.ContainsKey(t.TouchId)) return; GUITexture go = touchIcons[t.TouchId]; setTouchIconPos(go, t.TouchPoint); }
void addTouch(Tuio.Touch t) { addTouchIcon(t); }
void updateTouchIcon(Vector3 hitPoint, Tuio.Touch t, bool visible) { GameObject go = touchIcons[t.TouchId]; go.transform.position = hitPoint; go.renderer.enabled = visible; }
void removeTouchIcon(Tuio.Touch t) { GameObject go = touchIcons[t.TouchId]; touchIcons.Remove(t.TouchId); Destroy(go); }
void removeTouch(Tuio.Touch t) { removeTouchIcon(t); }
void removeTouchIcon(Tuio.Touch t) { if (!touchIcons.ContainsKey(t.TouchId)) return; GUITexture go = touchIcons[t.TouchId]; touchIcons.Remove(t.TouchId); Destroy(go.gameObject); }
public void UpdateTouch(Tuio.Touch t) { }
Ray getRay(Tuio.Touch t) { Vector3 touchPoint = new Vector3(t.TouchPoint.x, t.TouchPoint.y, 0f); Ray targetRay = _targetCamera.ScreenPointToRay(touchPoint); return targetRay; }
void removeDragger(Tuio.Touch t) { GameObject go = draggers[t.TouchId]; draggers.Remove(t.TouchId); Destroy(go); }
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; }
void updateTouch(Tuio.Touch t) { updateTouchIcon(t); }