public void AddGestureToTimeline(TimelineItemData sample) { GameObject button = GameObject.Instantiate<GameObject>(timelineButtonPrefab) as GameObject; TimelineButtonInformation info = new TimelineButtonInformation(nrButtons, sample, button); buttons[nrButtons] = info; Button btn = button.GetComponent<Button>(); btn.onClick.AddListener(delegate { OnButtonSelected(btn); }); button.GetComponentInChildren<Text>().text = (nrButtons++).ToString(); button.GetComponent<RectTransform>().SetParent(rectTransform); }
public void Play(TimelineItemData rec) { gestureController.SwitchFaceExpression(gestureController.sFaceExp[rec.FacialExpression]); gestureController.SwitchGesture(gestureController.sGestures_L[rec.LeftHand.Gesture], GestureAnimationController.Hand.left); gestureController.SwitchGesture(gestureController.sGestures_R[rec.RightHand.Gesture], GestureAnimationController.Hand.right); IKCtrl.Instance.SetRotation(AvatarIKGoal.LeftHand, rec.LeftHand.rotation); IKCtrl.Instance.SetRotation(AvatarIKGoal.RightHand, rec.RightHand.rotation); StartCoroutine(PlayTimed(rec.LeftHand, leftHand)); StartCoroutine(PlayTimed(rec.RightHand, rightHand)); }
public void SetRotation(AvatarIKGoal hand, TimelineItemData.Hand.Rotation rot) { switch (hand) { case AvatarIKGoal.LeftHand: desiredRotationLeft = rot; break; case AvatarIKGoal.RightHand: desiredRotationLeft = rot; break; default: break; } }
public TimelineButtonInformation(uint id, TimelineItemData sample, GameObject button) { this.id = id; this.sample = sample; this.button = button; }
public TimelineItemDataMeta(List<TimelineItemData> data, TimelineItemData.Meta meta) { Data = data; MetaData = meta; }
static TimelineItemData Deserialize(JSONNode item) { TimelineItemData data = new TimelineItemData() { Number = int.Parse(item["number"]), FacialExpression = int.Parse(item["facialExpression"]), Timestamp = float.Parse(item["timestamp"]), Duration = float.Parse(item["duration"]), LeftHand = new Hand() { Gesture = int.Parse(item["leftHand"]["gesture"]), rotation = new Hand.Rotation(float.Parse(item["leftHand"]["rotation"]["ik"]), float.Parse(item["leftHand"]["rotation"]["blend"])) }, RightHand = new Hand() { Gesture = int.Parse(item["rightHand"]["gesture"]), rotation = new Hand.Rotation(float.Parse(item["rightHand"]["rotation"]["ik"]), float.Parse(item["rightHand"]["rotation"]["blend"])) } }; AddKeyframesTo(item["leftHand"]["keyFrames"], data.LeftHand.KeyFrames); AddKeyframesTo(item["rightHand"]["keyFrames"], data.RightHand.KeyFrames); return data; }
public IEnumerator Record() { isRecording = true; TimelineItemData item = new TimelineItemData(); float startTime = Time.realtimeSinceStartup; while (isRecording) { var leftKeyframe = new TimelineItemData.Hand.KeyFrame(); var rightKeyframe = new TimelineItemData.Hand.KeyFrame(); leftKeyframe.Position = leftHand.transform.position; rightKeyframe.Position = rightHand.transform.position; leftKeyframe.Timestamp = rightKeyframe.Timestamp = item.Duration = Time.realtimeSinceStartup - startTime; item.LeftHand.KeyFrames.Add(leftKeyframe); item.RightHand.KeyFrames.Add(rightKeyframe); yield return new WaitForSeconds(0.01f); } yield return null; if (TimelineController.Instance != null) TimelineController.Instance.AddGestureToTimeline(item); }
IEnumerator PlayTimed(TimelineItemData.Hand hand, HandClickHandle ikHandle) { playerCount++; while (ikHandle.IsMoving) { yield return null; } ikHandle.IsMoving = true; for (int i = 0; i < hand.KeyFrames.Count - 1; i++) { float duration = hand.KeyFrames[i + 1].Timestamp - hand.KeyFrames[i].Timestamp; Vector3 from = hand.KeyFrames[i].Position; Vector3 to = hand.KeyFrames[i + 1].Position; StartCoroutine(MoveTimed(from, to, duration, ikHandle.transform)); yield return new WaitForSeconds(duration); } ikHandle.IsMoving = false; yield return null; playerCount--; }
public void AddGestureToTimeline(TimelineItemData sample) { if (TimelineButtonPrefab != null && ScrollableLabel != null) { GameObject buttonObj = Instantiate(TimelineButtonPrefab) as GameObject; TimelineButtonInformation buttonInfo = new TimelineButtonInformation((uint)timelineButtonList.Count, sample, buttonObj); timelineButtonList.Add(buttonInfo); Button uiButton = buttonObj.GetComponent<Button>(); // Setup EventTriggers uiButton.onClick.AddListener(delegate { TimelineElementClicked(buttonInfo.id); }); uiButton.GetComponentInChildren<Text>().text = timelineButtonList.Count.ToString(); uiButton.GetComponent<RectTransform>().SetParent(ScrollableLabel); uiButton.GetComponent<RectTransform>().localScale = Vector3.one; StartCoroutine(DelayedButtonClick(uiButton)); } }