// Update is called once per frame void Update() { if (CVInterface.AreDatasAvailable()) { Vector3 pos = CVInterface.GetJointPos3D(joint); pos = projCam.WorldToViewportPoint(pos); pos.z = planeToProjectOnto.position.z; pos = projCam.ViewportToWorldPoint(pos); transform.position = pos; } }
// Update is called once per frame void Update() { if (!CVInterface.AreDatasAvailable()) { return; } foreach (KeyValuePair <IRISJoints.Joints, Transform> couples in JointsToTransforms) { if (CVInterface.IsJointTracked(couples.Key)) { Vector3 p = CVInterface.GetJointPos3D(couples.Key); couples.Value.position = Vector3.Lerp(couples.Value.position, p, .5f); } } Vector3 ol = LeftShoulderT.position; Vector3 or = RightShoulderT.position; // shoulders positions hack to straighten the middle mesh x--> <--x LeftShoulderT.position = Vector3.Lerp(ol, or, .15f); RightShoulderT.position = Vector3.Lerp(ol, or, .85f); foreach (Link l in links) { Vector3 delta = l.j2.position - l.j1.position; if (delta == Vector3.zero) { continue; } if (l.tr == null) { continue; } l.tr.position = l.j1.position + (delta) / 2f; l.tr.rotation = Quaternion.LookRotation(delta) * Quaternion.LookRotation(Vector3.up); Vector3 s = l.tr.localScale; l.tr.localScale = new Vector3(s.x, (l.j2.position - l.j1.position).magnitude / 2f, s.z); } DrawMiddle(); }
public void Update() { if (CVInterface.AreDatasAvailable()) { Vector3 pos = CVInterface.GetJointPos3D(Joint, userIndex); if (pos == Vector3.zero) { pos = previousValue; if (ProjectionCamera != null && ProjectToPlane && ProjectionPlane != null) { pos.z = ProjectionPlane.transform.position.z; } transform.position = Vector3.Lerp(transform.position, targetPos, .5f); previousValue = transform.position; return; } if (ProjectionCamera != null && ProjectToPlane && ProjectionPlane != null) { pos = ProjectionCamera.WorldToViewportPoint(pos); pos.z = ProjectionPlane.position.z; pos = ProjectionCamera.ViewportToWorldPoint(pos); } if (bindX) { targetPos.x = pos.x; } else { targetPos.x = transform.position.x; } if (bindY) { targetPos.y = pos.y; } else { targetPos.y = transform.position.y; } if (bindZ) { targetPos.z = pos.z; } else { targetPos.z = transform.position.z; } transform.position = Vector3.Lerp(transform.position, targetPos, .5f); previousValue = transform.position; } else { Vector3 pos = Vector3.zero; if (ProjectionCamera != null && ProjectToPlane && ProjectionPlane != null) { pos.z = ProjectionPlane.transform.position.z; } transform.position = Vector3.Lerp(transform.position, targetPos, .5f); previousValue = transform.position; } }