Beispiel #1
0
 // Update
 //--------------------------------------
 public void Update(float tDelta, bool isBoneIKMatrix, bool isBoneIKRigging)
 {
     if (_childMeshGroup == null)
     {
         return;
     }
     _childMeshGroup.SetBoneIKEnabled(isBoneIKMatrix, isBoneIKRigging);
     _childMeshGroup.UpdateRenderUnits(tDelta, false);
     _childMeshGroup.SetBoneIKEnabled(false, false);
 }
        /// <summary>
        /// [Editor] 업데이트를 한다.
        /// FPS에 맞게 프레임을 증가시킨다.
        /// MeshGroup은 자동으로 재생시킨다.
        /// (재생중이 아닐때는 MeshGroup 자체의 FPS에 맞추어 업데이트를 한다.)
        /// </summary>
        /// <param name="tDelta"></param>
        /// <param name="isUpdateVertsAlways">단순 재생에는 False, 작업시에는 True로 설정</param>
        public void Update_Editor(float tDelta, bool isUpdateVertsAlways, bool isBoneIKMatrix, bool isBoneIKRigging)
        {
#if UNITY_EDITOR
            //시간을 따로 계산하자
            float multiply = 1.0f;
            if (_tDelta_Editor < 0)
            {
                _stopWatch_Editor.Start();
                _tDelta_Editor  = tDelta;
                _sampleDateTime = DateTime.Now;
            }
            else
            {
                _stopWatch_Editor.Stop();
                _tDelta_Editor = (float)(_stopWatch_Editor.ElapsedMilliseconds / 1000.0);

                if (_tDelta_Editor > 0)
                {
                    float dateTimeMillSec = (float)(DateTime.Now.Subtract(_sampleDateTime).TotalMilliseconds / 1000.0);
                    multiply = dateTimeMillSec / _tDelta_Editor;
                    //UnityEngine.Debug.Log("Update Anim / StopWatch : " + _tDelta_Editor + " / DateTime Span : " + dateTimeMillSec + " / Mul : " + multiply);
                }
                _sampleDateTime = DateTime.Now;

                _stopWatch_Editor.Reset();
                _stopWatch_Editor.Start();
            }
            tDelta = _tDelta_Editor * multiply;
#endif

            if (!_isPlaying)
            {
                if (_targetMeshGroup != null)
                {
                    _targetMeshGroup.SetBoneIKEnabled(isBoneIKMatrix, isBoneIKRigging);
                }
                UpdateMeshGroup_Editor(false, tDelta, isUpdateVertsAlways);                //<<강제로 업데이트 하지 않는다.

                if (_targetMeshGroup != null)
                {
                    _targetMeshGroup.SetBoneIKEnabled(false, false);
                }
                return;
            }


            _tUpdate += tDelta;
            if (_tUpdate >= TimePerFrame)
            {
                _curFrame++;
                //_tUpdate -= TimePerFrame;

                if (_curFrame >= _endFrame)
                {
                    if (_isLoop)
                    {
                        //루프가 되었당
                        //루프는 endframe을 찍지 않고, 바로 startFrame으로 가야한다.
                        _curFrame = _startFrame;
                    }
                    else
                    {
                        //endframe에서 정지
                        _curFrame  = _endFrame;
                        _isPlaying = false;
                        //Debug.Log("Stop In Last Frame");
                    }
                }


                //Debug.Log("Update AnimClip : " + _name);

                //1. Control Param을 먼저 업데이트를 하고 [Control Param]
                UpdateControlParam(true);


                //2. Mesh를 업데이트한다. [Animated Modifier + Bone]
                //UpdateMeshGroup_Editor(true, _tUpdate, isUpdateVertsAlways);//강제로 업데이트하자
                //UpdateMeshGroup_Editor(false, tDelta, isUpdateVertsAlways);//일반 업데이트

                //Debug.Log("Anim Update : " + (int)(1.0f / _tUpdate) + "FPS");

                _tUpdate -= TimePerFrame;
            }

            if (_targetMeshGroup != null)
            {
                _targetMeshGroup.SetBoneIKEnabled(isBoneIKMatrix, isBoneIKRigging);
            }

            UpdateMeshGroup_Editor(true, tDelta, isUpdateVertsAlways);

            if (_targetMeshGroup != null)
            {
                _targetMeshGroup.SetBoneIKEnabled(false, false);
            }
        }