void Update() { // look at if (LookAt != null && LeftEyeBone != null && RightEyeBone != null) { LeftEyeBone.LookAt(LookAt.position, HeadBone.up); LeftEyeBone.localEulerAngles += LookAtRotationOffset; RightEyeBone.LookAt(LookAt.position, HeadBone.up); RightEyeBone.localEulerAngles += LookAtRotationOffset; } // look at from tracker if (LookAt == null && LeftEyeBone != null && RightEyeBone != null) { float horizontal = Mathf.Clamp(Tracker.GazeDirection.x * HorizontalLookAtScale, -HorizontalLookAtLimit, HorizontalLookAtLimit); float vertical = Mathf.Clamp(Tracker.GazeDirection.y * VerticalLookAtScale, -VerticalLookAtLimit, VerticalLookAtLimit); LeftEyeBone.localRotation = Quaternion.AngleAxis(-horizontal, Vector3.up) * Quaternion.AngleAxis(vertical, Vector3.right); LeftEyeBone.localEulerAngles += LookAtRotationOffset; RightEyeBone.localRotation = Quaternion.AngleAxis(-horizontal, Vector3.up) * Quaternion.AngleAxis(vertical, Vector3.right); RightEyeBone.localEulerAngles += LookAtRotationOffset; } // update blink if (AutoBlinking) { float blink1 = BlinkMeshRenderer.GetBlendShapeWeight(BlinkBlendshapeIndexes[0]); float blink2 = BlinkMeshRenderer.GetBlendShapeWeight(BlinkBlendshapeIndexes[1]); blink1 = Mathf.Lerp(blink1, blinkDesiredValue[0], 0.7f); blink2 = Mathf.Lerp(blink2, blinkDesiredValue[1], 0.7f); BlinkMeshRenderer.SetBlendShapeWeight(BlinkBlendshapeIndexes[0], blink1); BlinkMeshRenderer.SetBlendShapeWeight(BlinkBlendshapeIndexes[1], blink2); } }
private void Update() { float grip = 0; float pinch = 0; if (interactable.attachedToHand) { grip = gripSqueeze.GetAxis(interactable.attachedToHand.handType); pinch = pinchSqueeze.GetAxis(interactable.attachedToHand.handType); } renderer.SetBlendShapeWeight(0, Mathf.Lerp(renderer.GetBlendShapeWeight(0), grip * 150, Time.deltaTime * 10)); if (renderer.sharedMesh.blendShapeCount > 1) // make sure there's a pinch blend shape { renderer.SetBlendShapeWeight(1, Mathf.Lerp(renderer.GetBlendShapeWeight(1), pinch * 200, Time.deltaTime * 10)); } if (affectMaterial) { renderer.material.SetFloat("_Deform", Mathf.Pow(grip * 1.5f, 0.5f)); if (renderer.material.HasProperty("_PinchDeform")) { renderer.material.SetFloat("_PinchDeform", Mathf.Pow(pinch * 2.0f, 0.5f)); } } }
// Update is called once per frame void Update() { for (int i = 0; i < 20; i++) { if (skinnedMeshRenderer.GetBlendShapeWeight(i) < blendshapes[i]) { skinnedMeshRenderer.SetBlendShapeWeight(i, skinnedMeshRenderer.GetBlendShapeWeight(i) + 1); } if (skinnedMeshRenderer.GetBlendShapeWeight(i) > blendshapes[i]) { skinnedMeshRenderer.SetBlendShapeWeight(i, skinnedMeshRenderer.GetBlendShapeWeight(i) - 1); } } if (timer < time) { timer = timer + 33; //Debug.Log (timer); } else { //Debug.Log ("fetching next snippet"); //Debug.Log (snippetCount); if (snippetCount < num_action) { timer = 0; string s = snippetArray [snippetCount]; snippetCount++; StartCoroutine(handler(s, metadata)); } } }
public void GetBlendshapes() { for (int i = 0; i < 52; i++) { syncListFloat[i] = possesableMesh.GetBlendShapeWeight(i); } }
void Update() { deviceLeft = SteamVR_Controller.Input((int)trackedObjLeft.index); deviceRight = SteamVR_Controller.Input((int)trackedObjRight.index); unstretchedPos = controllerLeft.GetComponent <Picker>().unstretchedPos; stretchedPos = controllerLeft.GetComponent <Picker>().stretchedPos; if ((unstretchedPos && !stretchedPos) && (!controllerLeft.GetComponent <Picker>().inHand) && (!stretched) && (controllerLeft.GetComponent <Picker>().onSlider)) { stretch = Vector3.Distance(controllerLeft.transform.Find("Detector").position, start.transform.position); blendShape.SetBlendShapeWeight(0, stretch * 500); deviceLeft.TriggerHapticPulse((ushort)(blendShape.GetBlendShapeWeight(0) * vibration)); deviceRight.TriggerHapticPulse((ushort)(blendShape.GetBlendShapeWeight(0) * vibration)); } else if ((unstretchedPos && stretchedPos) && (!controllerLeft.GetComponent <Picker>().inHand) && (!stretched)) { controllerLeft.GetComponent <Picker>().unstretchedPos = false; controllerLeft.GetComponent <Picker>().stretchedPos = false; blendShape.SetBlendShapeWeight(0, 100f); stretched = true; } if ((!controllerLeft.GetComponent <Picker>().onSlider) && (!stretched)) { blendShape.SetBlendShapeWeight(0, 0f); } }
IEnumerator EyeBlink() { float accelerate = 1; bool IsClosingEyes = FaceMesh.GetBlendShapeWeight(4) == 0; //100 = eyes closed; float targetWeight = IsClosingEyes ? 100 : 0; while (enabled && (IsClosingEyes ? (FaceMesh.GetBlendShapeWeight(4) < targetWeight - 5) : (FaceMesh.GetBlendShapeWeight(4) > targetWeight + 5))) { float closeSpd = 500f, openSpd = -700f; float eyeWeight = FaceMesh.GetBlendShapeWeight(4) + (IsClosingEyes ? closeSpd : openSpd) * accelerate * Time.deltaTime; FaceMesh.SetBlendShapeWeight(4, eyeWeight); FaceMesh.SetBlendShapeWeight(5, eyeWeight); accelerate += 1; yield return(new WaitForEndOfFrame()); } FaceMesh.SetBlendShapeWeight(4, targetWeight); FaceMesh.SetBlendShapeWeight(5, targetWeight); if (!IsClosingEyes) { while (blinkFrequencyIndex == OldFrequencyIndex) { blinkFrequencyIndex = Random.Range(0, 3); } OldFrequencyIndex = blinkFrequencyIndex; } yield return(new WaitForSeconds(IsClosingEyes ? 0.1f : BlinkFrequencies[blinkFrequencyIndex])); StartCoroutine(EyeBlink()); }
//QUANDO O BOTAO É ATIVADO, ESSA FUNCAO EH CHAMADA. AQUI VOCE DEVE PROGRAMAR O SEU CODIGO PARA O SEU BOTAO... public override void OnInteractionTrigger(InteractionModes modes) { switch (modes) { case InteractionModes.Over: break; case InteractionModes.Out: countDownToTurnOff = 0; skinnedMeshRenderer.SetBlendShapeWeight(blendShapeIndex, 0); break; case InteractionModes.Click: countDownToTurnOff = totalLerpDuration; lerpA = skinnedMeshRenderer.GetBlendShapeWeight(blendShapeIndex); lerpB = 100; break; case InteractionModes.DoubleClick: break; case InteractionModes.Up: countDownToTurnOff = totalLerpDuration; lerpA = skinnedMeshRenderer.GetBlendShapeWeight(blendShapeIndex); lerpB = 0; break; case InteractionModes.Grab: break; default: break; } }
void Start() { BlendShapes = this.GetComponent <SkinnedMeshRenderer> (); //Get the current weight of the B shapes and set them to the variables BSW1 = BlendShapes.GetBlendShapeWeight(0); BSW2 = BlendShapes.GetBlendShapeWeight(1); BSW3 = BlendShapes.GetBlendShapeWeight(2); }
void Update() { float smoothVol = Mathf.SmoothDamp(blendshapesRenderer.GetBlendShapeWeight(volumeShapeIndex), volumeScale * rmsValue, ref volVel, 0.025f); float smoothPit = Mathf.SmoothDamp(blendshapesRenderer.GetBlendShapeWeight(pitchShapeIndex), pitchScale * pitchValue, ref pitVet, 0.025f); blendshapesRenderer.SetBlendShapeWeight(volumeShapeIndex, smoothVol); blendshapesRenderer.SetBlendShapeWeight(pitchShapeIndex, smoothPit); }
void FixedUpdate() { if (blendshape == null) { return; } blendshape.SetValue(Small, dummyBlendShape.GetBlendShapeWeight(0) / 100f); blendshape.SetValue(Medium, dummyBlendShape.GetBlendShapeWeight(1) / 100f); blendshape.SetValue(Large, dummyBlendShape.GetBlendShapeWeight(2) / 100f); }
public void MouseOver() { if (!mouseOver) { mouseOver = true; mouseOverAnimationWeightStartValue = skinnedMeshRenderer.GetBlendShapeWeight(0); mouseOverAnimationWeightEndValue = 100; mouseOverAnimationCurrentTime = 0.0f; currentMouseOverCoroutine = StartCoroutine(MouseOverAnimation()); } }
IEnumerator ShowSecondaryButton() { // Don't perform additional animated visuals if already in a fully revealed state if (Mathf.Approximately(m_CloseButtonContainerCanvasGroup.alpha, 1f)) { m_SecondaryButtonVisibilityCoroutine = null; yield break; } const float kSecondaryButtonFrameVisibleBlendShapeWeight = 16f; // The extra amount of the frame to show on hover-before the full reveal of the secondary button const float kTargetDuration = 1f; const int kIntroDurationMultiplier = 10; var currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); var currentDuration = 0f; while (currentDuration < kTargetDuration) { var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kIntroDurationMultiplier); m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kSecondaryButtonFrameVisibleBlendShapeWeight, shapedAmount)); yield return(null); } const float kDelayBeforeSecondaryButtonReveal = 0.25f; currentDuration = 0f; // Reset current duration while (currentDuration < kDelayBeforeSecondaryButtonReveal) { currentDuration += Time.unscaledDeltaTime; yield return(null); } const float kFrameSecondaryButtonVisibleBlendShapeWeight = 61f; const float kSecondaryButtonVisibleBlendShapeWeight = 46f; const int kDurationMultiplier = 25; this.StopCoroutine(ref m_HighlightCoroutine); var currentSecondaryButtonVisibilityAmount = m_CloseInsetMeshRenderer.GetBlendShapeWeight(0); var currentSecondaryCanvasGroupAlpha = m_CloseButtonContainerCanvasGroup.alpha; currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); currentDuration = 0f; while (currentDuration < 1f) { var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kDurationMultiplier); m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kFrameSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); m_CloseButtonContainerCanvasGroup.alpha = Mathf.Lerp(currentSecondaryCanvasGroupAlpha, 1f, shapedAmount); yield return(null); } m_SecondaryButtonVisibilityCoroutine = null; }
IEnumerator DeployLeaf() { float lerpBlend; while (ParachuteLeaf.GetBlendShapeWeight(0) < 99) { lerpBlend = Mathf.Lerp(ParachuteLeaf.GetBlendShapeWeight(0), 100, 0.3f); ParachuteLeaf.SetBlendShapeWeight(0, lerpBlend); yield return(new WaitForSeconds(0.05f)); } }
private bool AreAllBlendShapesZeroed() { for (int i = 0; i < sharedMesh.blendShapeCount; i++) { if (skinnedMeshRenderer.GetBlendShapeWeight(i) != 0) { return(false); } } return(true); }
// Update is called once per frame void Update() { if (mesh.GetBlendShapeWeight(15) > 30) { moo.gameObject.SetActive(true); moo.text = "Mouth open " + (int)mesh.GetBlendShapeWeight(15) + "%"; } else { moo.gameObject.SetActive(false); } }
void Update() { if (Win.enabled) { Vector3 pos = water.transform.position; water.transform.position = new Vector3(pos.x, pos.y + .01f, pos.z); if (ToiletWater.GetBlendShapeWeight(0) > 1) { ToiletWater.SetBlendShapeWeight(0, ToiletWater.GetBlendShapeWeight(0) - .5f); } } }
private void Timer() { //wait 3 seconds before confirming that he is balanced/equal timerForEquality += Time.deltaTime; if (timerForEquality >= 3f) { targetFormAchieved = true; } if (blendshapes.GetBlendShapeWeight(3) > 0 || Mathf.Ceil(enkidu.transform.localScale.magnitude) != Mathf.Ceil(targetScale.magnitude)) { timerForEquality = 0f; } }
// Update is called once per frame //母音のブレンドシェイプの値を設定。別アプリケーションで動いてるキャラにlipSyncを反映させるために手動でつける必要がある void Update() { skinnedMeshRenderer.SetBlendShapeWeight(A_mouth, A); skinnedMeshRenderer.SetBlendShapeWeight(I_mouth, I); skinnedMeshRenderer.SetBlendShapeWeight(U_mouth, U); skinnedMeshRenderer.SetBlendShapeWeight(E_mouth, E); skinnedMeshRenderer.SetBlendShapeWeight(O_mouth, O); A = skinnedMeshRenderer.GetBlendShapeWeight(A_mouth); I = skinnedMeshRenderer.GetBlendShapeWeight(I_mouth); U = skinnedMeshRenderer.GetBlendShapeWeight(U_mouth); E = skinnedMeshRenderer.GetBlendShapeWeight(E_mouth); O = skinnedMeshRenderer.GetBlendShapeWeight(O_mouth); }
// Update is called once per frame void Update() { skinnedMeshRenderer.SetBlendShapeWeight(A_mouth, A2); skinnedMeshRenderer.SetBlendShapeWeight(I_mouth, I2); skinnedMeshRenderer.SetBlendShapeWeight(U_mouth, U2); skinnedMeshRenderer.SetBlendShapeWeight(E_mouth, E2); skinnedMeshRenderer.SetBlendShapeWeight(O_mouth, O2); A2 = skinnedMeshRenderer.GetBlendShapeWeight(A_mouth); I2 = skinnedMeshRenderer.GetBlendShapeWeight(I_mouth); U2 = skinnedMeshRenderer.GetBlendShapeWeight(U_mouth); E2 = skinnedMeshRenderer.GetBlendShapeWeight(E_mouth); O2 = skinnedMeshRenderer.GetBlendShapeWeight(O_mouth); }
private void Update() { float grip = 0; float pinch = 0; if (interactable.attachedToHand) { grip = gripSqueeze.GetAxis(interactable.attachedToHand.handType); pinch = pinchSqueeze.GetAxis(interactable.attachedToHand.handType); } rend.SetBlendShapeWeight(0, Mathf.Lerp(rend.GetBlendShapeWeight(0), grip * 150, Time.deltaTime * 10)); rend.SetBlendShapeWeight(1, Mathf.Lerp(rend.GetBlendShapeWeight(1), pinch * 200, Time.deltaTime * 10)); }
/// <summary>Returns the current Blend Shapes Values</summary> public virtual float[] GetBlendShapeValues() { if (HasBlendShapes) { float[] BS = new float[mesh.sharedMesh.blendShapeCount]; for (int i = 0; i < BS.Length; i++) { BS[i] = mesh.GetBlendShapeWeight(i); } return(BS); } return(null); }
void modifyBlendShape(int index) { if (rend.GetBlendShapeWeight(index) < 100) { rend.SetBlendShapeWeight(index, rend.GetBlendShapeWeight(index) + increaseSpeed); } if (optionalMeshRenderer != null) { if (optionalMeshRenderer.GetBlendShapeWeight(index) < 100) { optionalMeshRenderer.SetBlendShapeWeight(index, rend.GetBlendShapeWeight(index) + increaseSpeed); } } }
private void modifyValue(ref SkinnedMeshRenderer renderer, string blendShapenames, float speed) { string[] blendshapes = blendShapenames.Split(','); foreach (string blendShapename in blendshapes) { if (renderer.sharedMesh.GetBlendShapeIndex(blendShapename) > -1) { int blendShape = renderer.sharedMesh.GetBlendShapeIndex(blendShapename); if (renderer.GetBlendShapeWeight(blendShape) < 100) { renderer.SetBlendShapeWeight(blendShape, renderer.GetBlendShapeWeight(blendShape) + Time.deltaTime * speed); } } } }
private void Set() { var shape = new TargetShape(); shape.name = setTargetShape; shape.parameters = new float[sourceShape.Length]; for (int i = 0; i < shape.parameters.Length; i++) { shape.parameters[i] = source.GetBlendShapeWeight(source.sharedMesh.GetBlendShapeIndex(sourceShape[i])); } targetShape.Add(shape); }
private void UpdateMeterDisplay() { if (CurrentMeter > HigherLimit) { MeterPercentage.text = "Suspicion: 100%"; MeterPercentage.GraphicUpdateComplete(); DeathScript.IsDead = true; meter.enabled = false; MeterPercentage.enabled = false; meterBackground.enabled = false; return; } else if (CurrentMeter < LowerLimit) { CurrentMeter = LowerLimit + 1; } float percentage = CurrentMeter / HigherLimit; meter.rectTransform.localScale = new Vector3(percentage, 1, 1); percentage = (float)System.Math.Round(percentage, 2); MeterPercentage.text = "Suspicion: " + percentage * 100 + "%"; if (percentage > .5f) { if (person.GetBlendShapeWeight(0) < 99) { person.SetBlendShapeWeight(0, person.GetBlendShapeWeight(0) + 5); if (!ShowerCurtain.isPlaying) { ShowerCurtain.Play(); } } } else { if (person.GetBlendShapeWeight(0) > 1) { person.SetBlendShapeWeight(0, person.GetBlendShapeWeight(0) - 5); if (!ShowerCurtain.isPlaying) { ShowerCurtain.Play(); } } } }
private IEnumerator AnimateVisuals(bool focus) { if (m_RotationVisualsCoroutine != null) { yield break; } Vector3 targetBorderLocalScale = focus ? m_BorderOutlineOriginalLocalScale * kBorderScaleMultiplier : m_BorderOutlineOriginalLocalScale; Vector3 currentBorderLocalScale = m_BorderOutlineTransform.localScale; float currentBlendShapeWeight = m_TitleIcon.GetBlendShapeWeight(0); float targetWeight = focus ? 100f : 0f; float smoothTime = focus ? 0.25f : 0.5f; const float kLerpEmphasisWeight = 0.2f; float smoothVelocity = 0f; while (!Mathf.Approximately(currentBlendShapeWeight, targetWeight)) { currentBlendShapeWeight = Mathf.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.unscaledDeltaTime); currentBorderLocalScale = Vector3.Lerp(currentBorderLocalScale, targetBorderLocalScale, currentBlendShapeWeight * kLerpEmphasisWeight); m_BorderOutlineTransform.localScale = currentBorderLocalScale; m_TitleIcon.SetBlendShapeWeight(0, currentBlendShapeWeight); yield return(null); } m_TitleIcon.SetBlendShapeWeight(0, targetWeight); m_BorderOutlineTransform.localScale = targetBorderLocalScale; m_RotationVisualsCoroutine = null; }
public void SetBlendshapeWeights(SkinnedMeshRenderer smr) { Mesh mesh = null; if (smr != null) { mesh = smr.sharedMesh; } if (mesh != null) { int nbs = mesh.blendShapeCount; if (nbs > 0) { var weights = new float[nbs]; for (int bsi = 0; bsi < nbs; ++bsi) { weights[bsi] = smr.GetBlendShapeWeight(bsi); } SetBlendshapeWeights(weights); } } else { rthsMeshInstanceSetBlendshapeWeights(self, null, 0); } }
public static void ApplyMouthOffset(int charIndex, FBSCtrlMouth mouthControl) { if (charIndex >= characterOffsets.Length || mouthOffsets[charIndex] <= 0 || mouthControl == null || mouthControl.FBSTarget.Length == 0) { return; } foreach (FBSTargetInfo fbstargetInfo in mouthControl.FBSTarget) { SkinnedMeshRenderer skinnedMeshRenderer = fbstargetInfo.GetSkinnedMeshRenderer(); if (skinnedMeshRenderer.name != "o_head") { continue; } var mouthShape = skinnedMeshRenderer.GetBlendShapeWeight(46); if (mouthShape <= 0) { continue; } if (mouthOffsets[charIndex] > 0) { skinnedMeshRenderer.SetBlendShapeWeight(53, mouthShape * mouthOffsets[charIndex]); } else { skinnedMeshRenderer.SetBlendShapeWeight(46, mouthShape * (mouthOffsets[charIndex] + 1)); } } }
public override string[] GetBlendables() { if (!isReady || characterMesh == null) { return(null); } bool setInternal = false; string[] blendShapes = new string[characterMesh.sharedMesh.blendShapeCount]; if (blendableCount == 0) { setInternal = true; } for (int a = 0; a < blendShapes.Length; a++) { blendShapes[a] = characterMesh.sharedMesh.GetBlendShapeName(a) + " (" + a.ToString() + ")"; if (setInternal) { AddBlendable(a, characterMesh.GetBlendShapeWeight(a)); } } return(blendShapes); }
private void UpdateFace(float interpolatePoint = 1f) { if (AllowFacialAnim) { /*for (int i = 0; i < Mathf.Min(1, FacialJoints.Count); i++) * { * if (FacialJoints[i] != null) * { * Quaternion goalRotation = Quaternion.Lerp(FacialInitRotations[i], FacialFullRotations[i], frameData.facialParams[i]); * FacialJoints[i].localRotation = Quaternion.Lerp(FacialJoints[i].localRotation, goalRotation, interpolatePoint); * } * } * for (int i = 1; i < FacialJoints.Count; i++) * { * if (FacialJoints[i] != null) * { * * Quaternion goalRotation = Quaternion.Lerp(FacialInitRotations[i], FacialFullRotations[i], 1f - frameData.facialParams[i]); * FacialJoints[i].localRotation = Quaternion.Lerp(FacialJoints[i].localRotation, goalRotation, interpolatePoint); * } * }*/ if (blendMesh != null) { for (int i = 0; i < frameData.facialParams.Count; i++) { float currentWeight = blendMesh.GetBlendShapeWeight(i); float interpolatedWeight = Mathf.Lerp(currentWeight, frameData.facialParams[i] * 100f / facialParamMultiplier, interpolatePoint); blendMesh.SetBlendShapeWeight(i, interpolatedWeight); } } } }