Exemplo n.º 1
0
        private void RenderTransformPath(TransformCurves transformCurves, float length, float samplingDelta)
        {
            float t = 0;

            int numberSamples = Mathf.RoundToInt(length / samplingDelta) + 1;

            float delta = length / numberSamples;

            Vector3[] pts = new Vector3[numberSamples];

            int index = 0;

            while (index < numberSamples)
            {
                pts[index++] = transformCurves.GetPosition(t);
                t           += delta;
            }

            if (index != pts.Length)
            {
                Debug.LogError("Number of samples doesn't match: " + (index + 1) + " instead of " + pts.Length);
            }

            Handles.DrawPolyLine(pts);
        }
Exemplo n.º 2
0
 public void CreateTransformCurves()
 {
     if (_transformCurves == null)
     {
         _transformCurves = new TransformCurves(_animEvt.Owner, _animEvt._animationClip);
     }
 }
Exemplo n.º 3
0
        private void PreviewAnimationEvent(FAnimationEventEditor animEvtEditor, int frame)
        {
            FPlayAnimationEvent animEvt = (FPlayAnimationEvent)animEvtEditor._evt;

            if (animEvt._animationClip == null)
            {
                return;
            }

            bool isEditable = animEvt.IsAnimationEditable();

            // render path
            if (isEditable)
            {
                TransformCurves transformCurves = new TransformCurves(animEvt.Owner, animEvt._animationClip);

                RenderTransformPath(transformCurves, animEvt.LengthTime, 1f / animEvt.Sequence.FrameRate);

                float t = (float)(frame + animEvt._startOffset - animEvt.Start) / animEvt.Sequence.FrameRate;

                if (animEvt.FrameRange.Contains(frame))
                {
//					float t = (float)(frame + animEvt._startOffset - animEvt.Start) / animEvt.Sequence.FrameRate;
                    RenderTransformAnimation(transformCurves, t);
                }

//				AnimationClipCurveData[] allCurves = AnimationUtility.GetAllCurves( animEvt._animationClip, true );
//				foreach( AnimationClipCurveData curve in allCurves )
//				{
//
//				}
            }
            else if (animEvt.FrameRange.Contains(frame))
            {
                float t = (float)(frame + animEvt._startOffset - animEvt.Start) / animEvt.Sequence.FrameRate;

                bool wasInAnimationMode = AnimationMode.InAnimationMode();

                if (!AnimationMode.InAnimationMode())
                {
                    AnimationMode.StartAnimationMode();
                }
                AnimationMode.BeginSampling();
                AnimationMode.SampleAnimationClip(animEvt.Owner.gameObject, animEvt._animationClip, t);
                AnimationMode.EndSampling();

                if (!wasInAnimationMode)
                {
                    AnimationMode.StopAnimationMode();
                }
            }
        }
Exemplo n.º 4
0
        private void RenderTransformAnimation(TransformCurves transformCurves, float time)
        {
            Vector3    pos   = transformCurves.GetPosition(time);//new Vector3( xPos.Evaluate(t), yPos.Evaluate(t), zPos.Evaluate(t) );
            Quaternion rot   = transformCurves.GetRotation(time);
            Vector3    scale = transformCurves.GetScale(time);

            transformCurves.bone.localScale    = scale;
            transformCurves.bone.localRotation = rot;
            transformCurves.bone.localPosition = pos;

            Handles.RectangleCap(0, pos, rot, 0.1f);
            Handles.RectangleCap(0, pos + rot * Vector3.forward, rot, 0.4f);
        }