public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime)
        {
            if (this.target == null)
            {
                this.target = GameObject.Find(this.targetName);
                if (this.target == null)
                {
                    Debug.LogWarning(Translation.GetText("Warnings", "objectNotFound"));
                    this.enabled = false;
                    return;
                }
                this.component = null;
            }
            if (this.component == null)
            {
                // Debug.Log("Attempting to reattach " + this.componentTypeName);
                Type type = typeof(UnityEngine.Component).Assembly.GetType(this.componentTypeName);
                this.component = this.target.GetComponent(type);
            }

            for (int i = 0; i < propsToChange.Count; i++)
            {
                List <int> curveIdxes = this.propIdxToCurveIdxes[i];
                float[]    values     = curveIdxes.Select(idx => clip.curves[idx].Evaluate(sampleTime)).ToArray();
                this.propsToChange[i].SetValue(this.component, values);
            }
        }
Exemplo n.º 2
0
        public int InsertClipAtFreePos(MovieCurveClip clip, bool process, bool snapBefore = true)
        {
            int end = clip.frame;

            if (snapBefore)
            {
                end = clip.frame - clip.length;
            }

            int nextOpenFrame = this.NextOpenFrame(clip.length, clip.frame);

            clip.frame = nextOpenFrame;

            int idx;

            if (process)
            {
                idx = this.ProcessAndAddClip(clip);
            }
            else
            {
                idx = this.AddClip(clip);
            }
            return(idx);
        }
Exemplo n.º 3
0
        public void PreviewTime(float time)
        {
            if (!this.enabled)
            {
                return;
            }

            MovieCurveClip currentClip = this.GetClipForTime(time);
            float          sampleTime;

            if (currentClip == null)
            {
                currentClip = this.GetFirstClipBefore(time);
                sampleTime  = 1f;
                if (currentClip == null)
                {
                    currentClip = this.GetFirstClipAfter(time);
                    sampleTime  = 0f;
                    if (currentClip == null)
                    {
                        return;
                    }
                }
            }
            else
            {
                sampleTime = GetClipSampleTime(currentClip, time);
            }

            this.PreviewTimeInternal(currentClip, sampleTime);
        }
Exemplo n.º 4
0
        // private void AddCurveToAll(int faceValIndex)
        // {
        //     foreach(MovieCurveClip clip in this.clips)
        //     {
        //         this.AddCurve(clip, faceValIndex);
        //     }
        //     this.curveIdxToFaceValIdx.Add(faceValIndex);
        // }

        // private void RemoveCurve(int curveIndex)
        // {
        //     foreach(MovieCurveClip clip in this.clips)
        //     {
        //         clip.curves.RemoveAt(curveIndex);
        //     }
        //     this.curveIdxToFaceValIdx.RemoveAt(curveIndex);
        // }

        public override void AddClipInternal(MovieCurveClip clip)
        {
            for (int i = 0; i < faceVals.GetLength(0); i++)
            {
                this.AddCurve(clip, i);
            }
        }
Exemplo n.º 5
0
 public override void AddClipInternal(MovieCurveClip clip)
 {
     for (int i = 0; i < 1; i++)
     {
         this.AddCurves(clip);
     }
 }
Exemplo n.º 6
0
        public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime)
        {
            if (this.maid == null || !this.maid.Visible)
            {
                Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound"));
                this.enabled = false;
                return;
            }

            if (this.targetMorph == null)
            {
                this.targetMorph = maid.body0.Face.morph;
            }

            maid.boMabataki  = false;
            maid.boFaceAnime = false;
            for (int i = 0; i < clip.curves.Count; i++)
            {
                String key = faceVals[i, 0];
                if (targetMorph.Contains(key))
                {
                    // if (bd.key == "nosefook")
                    //     maid.boNoseFook = bd.val > 0f ? true : false;
                    // else if (bd.key == "hitomih")
                    //     morph.BlendValues[(int)morph.hash[bd.key]] = bd.val * 3;
                    // else
                    targetMorph.BlendValues[(int)targetMorph.hash[key]] = clip.curves[i].Evaluate(sampleTime);
                }
            }
            targetMorph.FixBlendValues_Face();
        }
        private void drawClip(ref MovieCurveClip clip, MovieTrack track, int trackIdx, int clipIdx)
        {
            Rect rect = new Rect((clip.frame * pixelsPerFrame) + ControlBase.FixedMargin,
                                 0,
                                 (clip.length * pixelsPerFrame),
                                 this.ControlHeight * 2);

            int pixelDiffToFramePos = (int)((Input.mousePosition.x - this.ScreenPos.x + this.scrollPosition.x - PANEL_WIDTH) / pixelsPerFrame);

            // GUI.Box(new Rect(pixelDiffToFramePos * pixelsPerFrame, 20, 40, 40), "");
            bool draggingBefore = clip.isDragging;

            clip.Draw(rect, this.ScreenPos);

            if (clip.wasPressed)
            {
                this.selectedTrackIndex = trackIdx;
                this.selectedClipIndex  = clipIdx;
            }

            if (clip.isDragging && !this.updated)
            {
                switch (this.dragMode)
                {
                case DragMode.Drag:
                    int newFrame = pixelDiffToFramePos - (clip.length / 2);
                    if (track.CanInsertClip(newFrame, clip.length, clip))
                    {
                        clip.frame = newFrame;
                    }
                    else if (newFrame <= 0)
                    {
                        clip.frame = 0;
                    }
                    break;

                case DragMode.RightResize:
                    int newEnd = pixelDiffToFramePos + (clip.length / 10);
                    if (track.CanInsertClip(clip.frame, newEnd - clip.length))
                    {
                        clip.end = newEnd;
                    }
                    break;

                default:
                    break;
                }

                this.updated = true;
            }
            else if (clip.wasClicked)
            {
                this.updated = true;
            }
            else if (draggingBefore == true && clip.isDragging == false)
            {
                track.ResolveCollision(clipIdx);
            }
        }
Exemplo n.º 8
0
 private void AddCurves(MovieCurveClip clip)
 {
     float[] values = GetWorldValues();
     for (int j = 0; j < values.Length; j++)
     {
         clip.AddCurve(new MovieCurve(clip.length, values[j], NAMES[j]));
     }
 }
        public override void AddClipInternal(MovieCurveClip clip)
        {
            for (int i = 0; i < propsToChange.Count; i++)
            {
                MovieProperty prop   = propsToChange[i];
                float[]       values = prop.GetValues(this.component);

                this.AddCurvesForProp(prop, clip, i);
            }
        }
Exemplo n.º 10
0
        public int AddClip(MovieCurveClip clip)
        {
            if (this.CanInsertClip(clip.frame, clip.length))
            {
                this.clips.Add(clip);
            }
            int idx = this.clips.Count - 1;

            return(idx);
        }
 private void AddCurvesForProp(MovieProperty prop, MovieCurveClip clip, int index)
 {
     float[] values = prop.GetValues(this.component);
     for (int j = 0; j < values.Length; j++)
     {
         int curveIdx = clip.AddCurve(new MovieCurve(clip.length, values[j],
                                                     Translation.TryGetText("Property", prop.Name) + "." + j));
         this.propIdxToCurveIdxes[index].Add(curveIdx);
     }
 }
Exemplo n.º 12
0
        public int CopyClip(int index)
        {
            if (index < 0 || index >= this.clips.Count)
            {
                return(index);
            }

            MovieCurveClip toCopy = this.clips[index];

            return(this.InsertClipAtFreePos(new MovieCurveClip(toCopy), false));
        }
Exemplo n.º 13
0
        internal static XElement SerializeCurveClip(MovieCurveClip clip)
        {
            XElement elem = new XElement("MovieCurveClip",
                                         from curve in clip.curves
                                         select SerializeCurve(curve));

            elem.SetAttributeValue("frame", clip.frame);
            elem.SetAttributeValue("length", clip.length);

            return(elem);
        }
 public override void AddClipInternal(MovieCurveClip clip)
 {
     foreach (string targetName in TARGET_NAMES)
     {
         // float[] values = GetValues(targetName);
         // for (int j = 0; j < values.Length; j++)
         // {
         //     clip.AddCurve(new MovieCurve(clip.length, values[j], targetName + "." + j));
         // }
     }
 }
Exemplo n.º 15
0
        public bool CanInsertClip(int frame, int length, MovieCurveClip ignore = null)
        {
            for (int i = frame; i < frame + length; i++)
            {
                MovieCurveClip at = this.GetClipForTime(i);
                if (at != null && (ignore != null && ignore != at))
                {
                    return(false);
                }
            }

            return(true);
        }
        private void drawTrack(int index)
        {
            Rect rect = new Rect(0, (index) * this.ControlHeight * 2, this.guiScrollWidth, this.ControlHeight * 2);

            GUI.Box(rect, "");
            GUILayout.BeginArea(rect);
            for (int i = 0; i < this.take.tracks[index].clips.Count; i++)
            {
                MovieCurveClip asd = this.take.tracks[index].clips[i];
                this.drawClip(ref asd, this.take.tracks[index], index, i);
            }
            GUILayout.EndArea();
        }
Exemplo n.º 17
0
        public void InsertKeyframesAtTime(float time)
        {
            MovieCurveClip currentClip = this.GetClipForTime(time);

            if (currentClip == null)
            {
                Debug.LogWarning("No clip at current time " + time);
                return;
            }
            float sampleTime = GetClipSampleTime(currentClip, time);

            float[] worldValues = this.GetWorldValues();
            currentClip.InsertKeyframesAtTime(sampleTime, worldValues);
        }
Exemplo n.º 18
0
        internal static MovieCurveClip DeserializeCurveClip(XElement elem)
        {
            MovieCurveClip clip = new MovieCurveClip();

            var curves = from e in elem.Elements()
                         select DeserializeCurve(e);

            clip.curves = curves.ToList();
            clip.frame  = GetIntAttr(elem, "frame");
            clip.length = GetIntAttr(elem, "length");

            clip.RemakeTexture();

            return(clip);
        }
Exemplo n.º 19
0
        public int ResolveCollision(int index)
        {
            if (index < 0 || index >= this.clips.Count)
            {
                return(index);
            }

            MovieCurveClip current  = this.clips[index];
            bool           collides = this.clips.Any(clip => clip != current && current.end >= clip.frame && current.frame <= clip.end);

            if (collides)
            {
                this.DeleteClip(index);
                index = this.InsertClipAtFreePos(current, false);
            }
            return(index);
        }
Exemplo n.º 20
0
        public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime)
        {
            float[] values = clip.curves.Select(c => c.Evaluate(sampleTime)).ToArray();

            Vector3 pos  = new Vector3(values[0], values[1], values[2]);
            Vector2 rot  = new Vector2(values[3], values[4]);
            float   rotZ = values[5];
            float   dist = values[6];
            float   fov  = values[7];

            this.mainCam.SetDistance(dist, true);
            this.mainCam.SetAroundAngle(rot, true);
            this.mainCam.SetTargetPos(pos, true);

            this.camCompo.fieldOfView = fov;
            Vector3 eulerAngles = this.camCompo.transform.eulerAngles;

            eulerAngles.z = rotZ;
            this.camCompo.transform.eulerAngles = eulerAngles;
        }
        public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime)
        {
            if (this.maid == null || !this.maid.Visible)
            {
                Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound"));
                this.enabled = false;
                return;
            }

            if (this.animationTarget == null)
            {
                this.animationTarget = maid.body0.m_Bones.GetComponent <Animation>();
            }

            animationTarget.Play(this.animationName.ToLower());
            float totalLength  = this.animationTarget[this.animationName].length;
            float sampleLength = sampleTime * totalLength;

            animationTarget[animationName.ToLower()].time    = sampleLength;
            animationTarget[animationName.ToLower()].enabled = true;
            animationTarget.Sample();
            animationTarget[animationName.ToLower()].enabled = false;
        }
        public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime)
        {
            if (this.maid == null || !this.maid.Visible)
            {
                Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound"));
                this.enabled = false;
                return;
            }

            int i = 0;

            foreach (string targetName in TARGET_NAMES)
            {
                Transform target = this.targets[targetName];
                float[]   values = clip.curves.Skip(i * 6).Take(6).Select(c => c.Evaluate(sampleTime)).ToArray();

                Vector3 rot = new Vector3(values[0], values[1], values[2]);
                Vector3 pos = new Vector3(values[3], values[4], values[5]);
                target.eulerAngles = rot;
                target.position    = pos;

                i += 1;
            }
        }
 public override void AddClipInternal(MovieCurveClip clip)
 {
     clip.length = this.AnimationFrameLength();
     clip.AddCurve(new MovieCurve(clip.length, 0, "Length"));
 }
Exemplo n.º 24
0
 private static float GetClipSampleTime(MovieCurveClip clip, float overallTime)
 {
     return((overallTime - clip.startSeconds) / clip.lengthSeconds);
 }
Exemplo n.º 25
0
 public abstract void PreviewTimeInternal(MovieCurveClip clip, float sampleTime);
Exemplo n.º 26
0
 public abstract void AddClipInternal(MovieCurveClip clip);
Exemplo n.º 27
0
 private void AddCurve(MovieCurveClip clip, int faceValIndex)
 {
     clip.AddCurve(new MovieCurve(clip.length, 0, faceVals[faceValIndex, 1]));
 }
Exemplo n.º 28
0
 public virtual float[] GetValues(MovieCurveClip clip, float sampleTime)
 => clip.curves.Select(curve => curve.Evaluate(sampleTime)).ToArray();