void Awake() { // Save initial transforms of targets foreach (GameObject targetObj in targetObjects) { Transform[] transforms = targetObj.transform.GetComponentsInChildren <Transform>(true); foreach (Transform transform in transforms) { UpdatingTransformData initialTransform = new UpdatingTransformData(); initialTransform.UpdatingTransform = transform; initialTransform.LocalPosition = transform.localPosition; initialTransform.LocalRotation = transform.localEulerAngles; initialTransform.LocalScale = transform.localScale; this.initialTransforms.Add(initialTransform); } Rigidbody[] rigidbodies = targetObj.transform.GetComponentsInChildren <Rigidbody>(true); foreach (Rigidbody rigidbody in rigidbodies) { this.targetRigidbodies.Add(rigidbody); } } this.ChangeModeDropdownValueChanged(this.changeModeDropdown); }
private void CreatePlayingTransformList(List <string> motionsDataList) { List <Transform> transformOrder = new List <Transform>(); foreach (string motionsData in motionsDataList) { string[] columnArray = motionsData.Split(new char[] { '\t' }, 2); if (columnArray.Length < 2) { continue; } string headerStr = columnArray[0]; string dataStr = columnArray[1]; string[] headerArray = headerStr.Split(','); string[] dataArray = dataStr.Split('\t'); // Definition if (int.Parse(headerArray[1]) == PlaybackerCommon.TypeDef) { transformOrder.Clear(); // Debug.Log("data num=" + dataArray.Length); foreach (string transformPath in dataArray) { if (!this.targetObjectsPathMap.ContainsKey(transformPath)) { throw new Exception("Couldn't find the object that path is " + transformPath); } transformOrder.Add(this.targetObjectsPathMap[transformPath]); } } // Value else if (int.Parse(headerArray[1]) == PlaybackerCommon.TypeVal) { if (transformOrder.Count == 0) { continue; } UpdatingTransformList timeSeriesMotionsData = new UpdatingTransformList(); timeSeriesMotionsData.ElapsedTime = float.Parse(headerArray[0]); for (int i = 0; i < dataArray.Length; i++) { string[] transformValues = dataArray[i].Split(','); UpdatingTransformData transformPlayer = new UpdatingTransformData(); transformPlayer.UpdatingTransform = transformOrder[i]; transformPlayer.LocalPosition = new Vector3(float.Parse(transformValues[0]), float.Parse(transformValues[1]), float.Parse(transformValues[2])); transformPlayer.LocalRotation = new Vector3(float.Parse(transformValues[3]), float.Parse(transformValues[4]), float.Parse(transformValues[5])); if (transformValues.Length == 9) { transformPlayer.LocalScale = new Vector3(float.Parse(transformValues[6]), float.Parse(transformValues[7]), float.Parse(transformValues[8])); } timeSeriesMotionsData.AddUpdatingTransform(transformPlayer); } this.playingTransformList.Add(timeSeriesMotionsData); } } }
public void AddUpdatingTransform(UpdatingTransformData updatingTransformData) { this.updatingTransformList.Add(updatingTransformData); }