public void UpdateLine2(Vector3 position) { _smoothedPosition.Update(position, Time.deltaTime); bool shouldAdd = false; shouldAdd |= _vertices.Count == 0; shouldAdd |= Vector3.Distance(_prevRing0, _smoothedPosition.value) >= _parent._minSegmentLength; if (shouldAdd) { addRing(position); updateMesh(); } }
void AlignArmHUD(HandModel handModel) { ArmHUDgeom.SetActive(true); if (targetHandID != handModel.GetInstanceID()) { // Reinitialize ArmHUD alignment //Debug.Log ("Reinitialize ArmHUD alignment Time.time = " + Time.time); smoothedPosition.reset = true; smoothedRotation.reset = true; targetHandID = handModel.GetInstanceID(); } float sqrCos = handModel.GetArmDirection().y; sqrCos *= sqrCos; float delay = sqrCos * verticalFilterTime + (1f - sqrCos) * horizontalFilterTime; //Debug.Log ("delay(sqrCos = " + sqrCos + ", Time.deltaTime = " + Time.deltaTime + ") = " + delay); smoothedPosition.delay = delay; smoothedRotation.delay = delay; Vector3 localArmCenter = transform.parent.InverseTransformPoint(handModel.GetArmCenter()); Quaternion localArmRotation = Quaternion.Inverse(transform.parent.rotation) * handModel.GetArmRotation(); transform.localPosition = smoothedPosition.Update(localArmCenter, Time.deltaTime); transform.localRotation = smoothedRotation.Update(localArmRotation, Time.deltaTime); if (ArmHUDisOpen == false) //Change this to state transition from ARMHUDSTATE_NOLEFTHAND -> ARMHUDSTATE_STATUS_ETC { if (Activate()) { ArmHUDAnimator.Play("Take 001_Opening"); ArmHUDeventsAnimator.Play("WristGraphicsEvents"); ArmHUDisOpen = true; } else { ArmHUDState.Change(ARMHUDSTATE_STATUS_ETC); return; } } // ArmHUDbaseLookAtGRP.LookAt(LookTarget); Vector3 localEulerAngles = ArmHUDbaseLookAtGRP.localEulerAngles; if (ArmHUDisOpen == true) { if (localEulerAngles.x < 340.0f && localEulerAngles.x > 280.0f) { ArmHUDState.Change(ARMHUDSTATE_STATUS_ETC); } else if (localEulerAngles.x > 26.0f && localEulerAngles.x < 80.0f && ArmHUDState.state != ARMHUDSTATE_PANELVISIBLE) { ArmHUDState.Change(ARMHUDSTATE_SETTINGS_ONLY); } } // localEulerAngles.y = 90f; // localEulerAngles.z = 0f; // ArmHUDbaseLookAtGRP.localEulerAngles = localEulerAngles; }
public void UpdateLine(Vector3 position) { if (!canDraw) { if (Vector3.Distance(position, _prevRing0) > 0.05f) { return; } else { BeginNewLine(); } } _parent.mParticles.SetActive(false); _smoothedPosition.Update(position, Time.deltaTime); LastTime += Time.deltaTime; if (LastTime <= 0.035f) { return; } _parent.upDateColor(); LastTime = 0; if (length == 0) { firstPosition = position; length = 0.01f; //trending = Vector3 (0f, 0f, 0f); } else { _smoothedPosition.value = _smoothedPosition.value + trending / 2; trending = _smoothedPosition.value - _prevRing0; length += Vector3.Distance(_prevRing0, _smoothedPosition.value); } bool shouldAdd = false; shouldAdd |= _vertices.Count == 0; shouldAdd |= Vector3.Distance(_prevRing0, _smoothedPosition.value) >= _parent._minSegmentLength; if (shouldAdd) { addRing(_smoothedPosition.value); //Add to the path also. _parent.scriptC.addPath(_smoothedPosition.value); updateMesh(); canDraw = true; } }
public void UpdateLine(Vector3 position) { _smoothedPosition.Update(position, Time.deltaTime); bool shouldAdd = false; shouldAdd |= _vertices.Count == 0; shouldAdd |= Vector3.Distance(_prevRing0, _smoothedPosition.value) >= _parent._minSegmentLength; // 平滑程度 /* * float dis = Vector3.Distance(_prevRing0, _smoothedPosition.value); * float ratio = dis / _parent._minSegmentLength; * print(1/ratio); */ if (shouldAdd) { addRing(_smoothedPosition.value); updateMesh(); } }