コード例 #1
0
        private void PlayMotions()
        {
            // Stop playing when reached the end of the list
            if (this.playingTransformIndex >= this.playingTransformList.Count)
            {
                this.StopPlaying();
                return;
            }

            UpdatingTransformList updatingTransformList = null;

            // Increase the list index until the elapsed time of the list reaches the actual elapsed time
            while (this.elapsedTime >= this.playingTransformList[this.playingTransformIndex].ElapsedTime)
            {
                updatingTransformList = this.playingTransformList[this.playingTransformIndex];

                this.playingTransformIndex++;

                if (this.playingTransformIndex >= this.playingTransformList.Count)
                {
                    break;
                }
            }

            if (updatingTransformList == null)
            {
                return;
            }

            // Play
            foreach (UpdatingTransformData updatingTransformData in updatingTransformList.GetUpdatingTransformList())
            {
                updatingTransformData.UpdateTransform();
            }
        }
コード例 #2
0
        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);
                }
            }
        }