private void UpdateHeadLookTarget() { if (this.IsApplyHeadLooking) { lock (locker) { if (this.isUpdatedFaceTracking) { this.destinationFaceRotation = FaceTrackingUtils.ExtractRotationFromMatrix(ref transformationM); this.destinationFaceRotation.eulerAngles = new Vector3(-this.destinationFaceRotation.eulerAngles.x, -this.destinationFaceRotation.eulerAngles.y, this.destinationFaceRotation.eulerAngles.z); // 鏡写しに回転するよう補正 this.isUpdatedFaceTracking = false; } } // ワールド座標中心に回す this.HeadLookTargetRotationCenter.rotation = this.destinationFaceRotation; // 回転対象のローカル座標に中心位置を戻す this.HeadLookTargetRotationCenter.position = this.HeadModel.position; // モデル全体(Root)の回転値を反映 this.HeadLookTargetRotationCenter.rotation *= this.HeadModel.root.rotation; this.isInitialFiltering = false; } else { // Target に値を反映しない場合は、頭部モデルに追従 this.HeadLookTargetRotationCenter.position = this.HeadModel.position; this.HeadLookTargetRotationCenter.rotation = this.HeadModel.rotation; } }
private void UpdateTargetModel() { lock (locker) { if (this.isUpdatedFaceTracking) { this.destinationFaceRotation = FaceTrackingUtils.ExtractRotationFromMatrix(ref transformationM); this.destinationFaceRotation.eulerAngles = new Vector3(-this.destinationFaceRotation.eulerAngles.x, -this.destinationFaceRotation.eulerAngles.y, this.destinationFaceRotation.eulerAngles.z); // 鏡写しに回転するよう補正 if (this.isLocal) { this.destinationFaceRotation = Quaternion.Euler(this.targetFaceObject.transform.parent.TransformVector(this.destinationFaceRotation.eulerAngles)); } this.isUpdatedFaceTracking = false; } } if (!this.isLocal) { this.destinationFaceRotation = this.destinationFaceRotation * this.initialModelHeadRotation; } else { this.destinationFaceRotation = this.initialModelHeadRotation * this.destinationFaceRotation; } // 毎フレーム頭部の回転値に対してLowPassFilteringして補間 if (!isLocal) { this.targetFaceObject.transform.rotation = LowpassFilterQuaternion(this.targetFaceObject.transform.rotation, this.destinationFaceRotation, this.lowPassFactor, this.isInitialFiltering); } else { this.targetFaceObject.transform.localRotation = LowpassFilterQuaternion(this.targetFaceObject.transform.localRotation, this.destinationFaceRotation, this.lowPassFactor, this.isInitialFiltering); } this.isInitialFiltering = false; }