示例#1
0
 public LocalPhaseFunction(string name, int[] index, PhaseModule module)
 {
     Module     = module;
     Name       = name;
     Index      = index;
     Visiable   = true;
     LocalPhase = new PhaseFunction(module);
 }
示例#2
0
 public PhaseFunction(PhaseModule module)
 {
     Module = module;
     Phase  = new float[module.Data.GetTotalFrames()];
     Keys   = new int[module.Data.GetTotalFrames()];
     ComputeVelocity();
     ComputePosition();
 }
示例#3
0
 public PhaseFunction(PhaseModule module)
 {
     Module          = module;
     Phase           = new float[module.Data.GetTotalFrames()];
     Keys            = new bool[module.Data.GetTotalFrames()];
     Cycle           = new float[module.Data.GetTotalFrames()];
     NormalisedCycle = new float[module.Data.GetTotalFrames()];
     ComputeVelocities();
 }
示例#4
0
 public void GetPhases(int index)
 {
     for (int i = 0; i < Phases.Length; i++)
     {
         if (TModule.SampleFrame[i] < 1 || TModule.SampleFrame[i] > TModule.Data.GetTotalFrames() - 1)
         {
             Phases[i] = 0.0f;
         }
         else
         {
             PhaseModule module = (PhaseModule)TModule.Data.GetModule(Module.ID.Phase);
             Phases[i] = module.Phases[index + 1].LocalPhase.Phase[TModule.SampleFrame[i] - 1];
         }
     }
 }
示例#5
0
    private IEnumerator ExportData()
    {
        Exporting = true;

        StreamWriter input  = CreateFile("Input");
        StreamWriter output = CreateFile("Output");

        for (int e = 0; e < Editors.Length; e++)
        {
            if (Export[e])
            {
                MotionEditor editor = Editors[e];
                int          items  = 0;
                for (int i = 0; i < editor.GetFiles().Length; i++)
                {
                    if (editor.Files[i].Data.Export)
                    {
                        editor.LoadFile(editor.Files[i]);

                        //StyleModule styleModule = editor.GetFile().Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)editor.GetFile().Data.GetModule(Module.TYPE.Style);
                        PhaseModule phaseModule = editor.GetFile().Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)editor.GetFile().Data.GetModule(Module.TYPE.Phase);

                        for (int m = 1; m <= (Mirror ? 2 : 1); m++)
                        {
                            if (m == 1)
                            {
                                editor.SetMirror(false);
                            }
                            if (m == 2)
                            {
                                editor.SetMirror(true);
                            }
                            for (int s = 0; s < editor.GetFile().Data.Sequences.Length; s++)
                            {
                                MotionData.Sequence.Interval[] intervals = editor.GetFile().Data.Sequences[s].GetIntervals();
                                for (int interval = 0; interval < intervals.Length; interval++)
                                {
                                    Generating = 0f;
                                    Writing    = 0f;

                                    List <State> states = new List <State>();
                                    float        start  = editor.GetFile().Data.GetFrame(intervals[interval].Start).Timestamp;
                                    float        end    = editor.GetFile().Data.GetFrame(intervals[interval].End).Timestamp;

                                    for (float t = start; t <= end; t += 1f / Framerate)
                                    {
                                        Generating = (t - start) / (end - start - 1f / Framerate);
                                        editor.LoadFrame(t);
                                        states.Add(editor.GetState());
                                        //Spin
                                        items += 1;
                                        if (items == BatchSize)
                                        {
                                            items = 0;
                                            yield return(new WaitForSeconds(0f));
                                        }
                                    }

                                    for (int state = 0; state < states.Count - 1; state++)
                                    {
                                        Writing = (float)(state) / (float)(states.Count - 2);
                                        State current = states[state];
                                        State next    = states[state + 1];
                                        editor.LoadFrame(current);

                                        //Input
                                        string inputLine = string.Empty;
                                        for (int k = 0; k < 12; k++)
                                        {
                                            Vector3 position  = current.Trajectory.Points[k].GetPosition().GetRelativePositionTo(current.Root);
                                            Vector3 direction = current.Trajectory.Points[k].GetDirection().GetRelativeDirectionTo(current.Root);
                                            Vector3 velocity  = current.Trajectory.Points[k].GetVelocity().GetRelativeDirectionTo(current.Root);
                                            float[] style     = current.Trajectory.Points[k].Styles;
                                            inputLine += FormatValue(position.x);
                                            inputLine += FormatValue(position.z);
                                            inputLine += FormatValue(direction.x);
                                            inputLine += FormatValue(direction.z);
                                            inputLine += FormatValue(velocity.x);
                                            inputLine += FormatValue(velocity.z);
                                            inputLine += FormatArray(style);
                                        }
                                        for (int k = 0; k < current.BoneTransformations.Length; k++)
                                        {
                                            Vector3 position = current.BoneTransformations[k].GetPosition().GetRelativePositionTo(current.Root);
                                            Vector3 forward  = current.BoneTransformations[k].GetForward().GetRelativeDirectionTo(current.Root);
                                            Vector3 up       = current.BoneTransformations[k].GetUp().GetRelativeDirectionTo(current.Root);
                                            Vector3 velocity = current.BoneVelocities[k].GetRelativeDirectionTo(current.Root);
                                            inputLine += FormatVector3(position);
                                            inputLine += FormatVector3(forward);
                                            inputLine += FormatVector3(up);
                                            inputLine += FormatVector3(velocity);
                                        }
                                        if (phaseModule != null)
                                        {
                                            float currentPhase = phaseModule.GetPhase(editor.GetFile().Data.GetFrame(current.Index), editor.ShowMirror);
                                            //inputLine += FormatVector2(Utility.GetCirclePhase(currentPhase));
                                            inputLine += FormatArray(Utility.StylePhase(current.Trajectory.Points[6].Styles, currentPhase));
                                        }

                                        inputLine = inputLine.Remove(inputLine.Length - 1);
                                        inputLine = inputLine.Replace(",", ".");
                                        input.WriteLine(inputLine);

                                        //Output
                                        string outputLine = string.Empty;
                                        for (int k = 6; k < 12; k++)
                                        {
                                            Vector3 position  = next.Trajectory.Points[k].GetPosition().GetRelativePositionTo(current.Root);
                                            Vector3 direction = next.Trajectory.Points[k].GetDirection().GetRelativeDirectionTo(current.Root);
                                            Vector3 velocity  = next.Trajectory.Points[k].GetVelocity().GetRelativeDirectionTo(current.Root);
                                            float[] style     = next.Trajectory.Points[k].Styles;
                                            outputLine += FormatValue(position.x);
                                            outputLine += FormatValue(position.z);
                                            outputLine += FormatValue(direction.x);
                                            outputLine += FormatValue(direction.z);
                                            outputLine += FormatValue(velocity.x);
                                            outputLine += FormatValue(velocity.z);
                                            outputLine += FormatArray(style);
                                        }
                                        for (int k = 0; k < next.BoneTransformations.Length; k++)
                                        {
                                            Vector3 position = next.BoneTransformations[k].GetPosition().GetRelativePositionTo(current.Root);
                                            Vector3 forward  = next.BoneTransformations[k].GetForward().GetRelativeDirectionTo(current.Root);
                                            Vector3 up       = next.BoneTransformations[k].GetUp().GetRelativeDirectionTo(current.Root);
                                            Vector3 velocity = next.BoneVelocities[k].GetRelativeDirectionTo(current.Root);
                                            outputLine += FormatVector3(position);
                                            outputLine += FormatVector3(forward);
                                            outputLine += FormatVector3(up);
                                            outputLine += FormatVector3(velocity);
                                        }
                                        //outputLine += FormatVector3(next.RootMotion);
                                        if (phaseModule != null)
                                        {
                                            float currentPhase = phaseModule.GetPhase(editor.GetFile().Data.GetFrame(current.Index), editor.ShowMirror);
                                            float nextPhase    = phaseModule.GetPhase(editor.GetFile().Data.GetFrame(next.Index), editor.ShowMirror);
                                            outputLine += FormatValue(Utility.GetLinearPhaseUpdate(currentPhase, nextPhase));
                                        }

                                        outputLine = outputLine.Remove(outputLine.Length - 1);
                                        outputLine = outputLine.Replace(",", ".");
                                        output.WriteLine(outputLine);

                                        //Spin
                                        items += 1;
                                        if (items == BatchSize)
                                        {
                                            items = 0;
                                            yield return(new WaitForSeconds(0f));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        input.Close();
        output.Close();

        Exporting = false;
        yield return(new WaitForSeconds(0f));
    }
示例#6
0
    private IEnumerator ExportOutputLabels()
    {
        MotionEditor editor = Editors[0];

        if (editor == null)
        {
            Debug.Log("No editor found.");
        }
        else
        {
            Exporting = true;

            StreamWriter file = CreateFile("OutputLabels");

            StyleModule styleModule = editor.GetFile().Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)editor.GetFile().Data.GetModule(Module.TYPE.Style);
            PhaseModule phaseModule = editor.GetFile().Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)editor.GetFile().Data.GetModule(Module.TYPE.Phase);

            int index = 0;
            for (int i = 7; i <= 12; i++)
            {
                file.WriteLine(index + " " + "TrajectoryPositionX" + i); index  += 1;
                file.WriteLine(index + " " + "TrajectoryPositionZ" + i); index  += 1;
                file.WriteLine(index + " " + "TrajectoryDirectionX" + i); index += 1;
                file.WriteLine(index + " " + "TrajectoryDirectionZ" + i); index += 1;
                file.WriteLine(index + " " + "TrajectoryVelocityX" + i); index  += 1;
                file.WriteLine(index + " " + "TrajectoryVelocityZ" + i); index  += 1;
                for (int j = 0; j < styleModule.Functions.Length; j++)
                {
                    file.WriteLine(index + " " + styleModule.Functions[j].Name + i); index += 1;
                }
            }
            for (int i = 0; i < editor.GetFile().Data.Source.Bones.Length; i++)
            {
                if (editor.GetFile().Data.Source.Bones[i].Active)
                {
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionX" + (i + 1)); index += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionY" + (i + 1)); index += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionZ" + (i + 1)); index += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardX" + (i + 1)); index  += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardY" + (i + 1)); index  += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardZ" + (i + 1)); index  += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpX" + (i + 1)); index       += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpY" + (i + 1)); index       += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpZ" + (i + 1)); index       += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityX" + (i + 1)); index += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityY" + (i + 1)); index += 1;
                    file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityZ" + (i + 1)); index += 1;
                }
            }
            //file.WriteLine(index + " " + "RootMotionX"); index += 1;
            //file.WriteLine(index + " " + "RootMotionY"); index += 1;
            //file.WriteLine(index + " " + "RootMotionZ"); index += 1;

            if (phaseModule != null)
            {
                file.WriteLine(index + " " + "PhaseUpdate"); index += 1;
            }

            yield return(new WaitForSeconds(0f));

            file.Close();

            Exporting = false;
        }
    }
示例#7
0
    private IEnumerator ExportInputLabels()
    {
        MotionEditor editor = Editors[0];

        Exporting = true;

        StreamWriter file = CreateFile("InputLabels");

        StyleModule styleModule = editor.GetFile().Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)editor.GetFile().Data.GetModule(Module.TYPE.Style);
        PhaseModule phaseModule = editor.GetFile().Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)editor.GetFile().Data.GetModule(Module.TYPE.Phase);
        //ContactModule contactModule = editor.GetFile().Data.GetModule(Module.TYPE.Contact) == null ? null : (ContactModule)editor.GetFile().Data.GetModule(Module.TYPE.Contact);

        int index = 0;

        for (int i = 1; i <= 12; i++)
        {
            file.WriteLine(index + " " + "TrajectoryPositionX" + i); index  += 1;
            file.WriteLine(index + " " + "TrajectoryPositionZ" + i); index  += 1;
            file.WriteLine(index + " " + "TrajectoryDirectionX" + i); index += 1;
            file.WriteLine(index + " " + "TrajectoryDirectionZ" + i); index += 1;
            file.WriteLine(index + " " + "TrajectoryVelocityX" + i); index  += 1;
            file.WriteLine(index + " " + "TrajectoryVelocityZ" + i); index  += 1;
            file.WriteLine(index + " " + "TrajectorySpeed" + i); index      += 1;
            //for(int j=1; j<=StyleFilters.Length; j++) {
            //	file.WriteLine(index + " " + StyleFilters[j-1].Name + i); index += 1;
            //}
            if (styleModule != null)
            {
                //for(int j=1; j<=styleModule.Functions.Length; j++) {
                for (int j = 1; j <= 4; j++)
                {
                    if (phaseModule == null)
                    {
                        file.WriteLine(index + " " + styleModule.Functions[j - 1].Name + i); index += 1;
                    }
                    else
                    {
                        file.WriteLine(index + " " + styleModule.Functions[j - 1].Name + "X" + i); index += 1;
                        file.WriteLine(index + " " + styleModule.Functions[j - 1].Name + "Y" + i); index += 1;
                    }
                }
            }
        }
        for (int i = 0; i < editor.GetFile().Data.Source.Bones.Length; i++)
        {
            if (editor.GetFile().Data.Source.Bones[i].Active)
            {
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionX" + (i + 1)); index += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionY" + (i + 1)); index += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "PositionZ" + (i + 1)); index += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardX" + (i + 1)); index  += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardY" + (i + 1)); index  += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "ForwardZ" + (i + 1)); index  += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpX" + (i + 1)); index       += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpY" + (i + 1)); index       += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "UpZ" + (i + 1)); index       += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityX" + (i + 1)); index += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityY" + (i + 1)); index += 1;
                file.WriteLine(index + " " + editor.GetFile().Data.Source.Bones[i].Name + "VelocityZ" + (i + 1)); index += 1;
            }
        }

        if (phaseModule != null)
        {
            file.WriteLine(index + " " + "PhaseX"); index      += 1;
            file.WriteLine(index + " " + "PhaseY"); index      += 1;
            file.WriteLine(index + " " + "PhaseUpdate"); index += 1;
        }

        /*
         * if(contactModule != null) {
         *      for(int i=0; i<contactModule.Functions.Length; i++) {
         *              file.WriteLine(index + " " + "Contact" + editor.GetFile().Data.Source.Bones[contactModule.Functions[i].Sensor].Name); index += 1;
         *      }
         * }
         */

        yield return(new WaitForSeconds(0f));

        file.Close();

        Exporting = false;
    }
示例#8
0
    public Trajectory GetTrajectory(bool mirrored)
    {
        StyleModule styleModule = Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)Data.GetModule(Module.TYPE.Style);
        PhaseModule phaseModule = Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)Data.GetModule(Module.TYPE.Phase);

        Trajectory trajectory = new Trajectory(12, styleModule == null ? 0 : styleModule.Functions.Length);

        //Current
        trajectory.Points[6].SetTransformation(GetRootTransformation(mirrored));
        trajectory.Points[6].SetVelocity(GetRootVelocity(mirrored));
        trajectory.Points[6].SetSpeed(GetSpeed(mirrored));
        trajectory.Points[6].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(this);
        trajectory.Points[6].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(this, mirrored);

        //Past
        for (int i = 0; i < 6; i++)
        {
            float delta = -1f + (float)i / 6f;
            if (Timestamp + delta < 0f)
            {
                float pivot     = -Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ? 1f : Mathf.Abs(pivot / clamped);
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[i].SetPosition(Data.GetFirstFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetFirstFrame().GetRootPosition(mirrored)));
                trajectory.Points[i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[i].SetSpeed(reference.GetSpeed(mirrored));
                trajectory.Points[i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(reference);
                trajectory.Points[i].Phase  = phaseModule == null ? 0f : 1f - phaseModule.GetPhase(reference, mirrored);
            }
            else
            {
                Frame previous = Data.GetFrame(Mathf.Clamp(Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[i].SetTransformation(previous.GetRootTransformation(mirrored));
                trajectory.Points[i].SetVelocity(previous.GetRootVelocity(mirrored));
                trajectory.Points[i].SetSpeed(previous.GetSpeed(mirrored));
                trajectory.Points[i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(previous);
                trajectory.Points[i].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(previous, mirrored);
            }
        }

        //Future
        for (int i = 1; i <= 5; i++)
        {
            float delta = (float)i / 5f;
            if (Timestamp + delta > Data.GetTotalTime())
            {
                float pivot     = 2f * Data.GetTotalTime() - Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ?1f : Mathf.Abs((Data.GetTotalTime() - pivot) / (Data.GetTotalTime() - clamped));
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[6 + i].SetPosition(Data.GetLastFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetLastFrame().GetRootPosition(mirrored)));
                trajectory.Points[6 + i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[6 + i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].SetSpeed(reference.GetSpeed(mirrored));
                trajectory.Points[6 + i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(reference);
                trajectory.Points[6 + i].Phase  = phaseModule == null ? 0f : 1f - phaseModule.GetPhase(reference, mirrored);
            }
            else
            {
                Frame future = Data.GetFrame(Mathf.Clamp(Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[6 + i].SetTransformation(future.GetRootTransformation(mirrored));
                trajectory.Points[6 + i].SetVelocity(future.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].SetSpeed(future.GetSpeed(mirrored));
                trajectory.Points[6 + i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(future);
                trajectory.Points[6 + i].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(future, mirrored);
            }
        }

        return(trajectory);
    }
示例#9
0
    public Trajectory GetTrajectory(Frame frame, bool mirrored)
    {
        StyleModule styleModule = Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)Data.GetModule(Module.TYPE.Style);
        PhaseModule phaseModule = Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)Data.GetModule(Module.TYPE.Phase);

        Trajectory trajectory = new Trajectory(12, styleModule == null ? new string[0] : styleModule.GetNames());

        //Current
        trajectory.Points[6].SetTransformation(frame.GetRootTransformation(mirrored));
        trajectory.Points[6].SetVelocity(frame.GetRootVelocity(mirrored));
        trajectory.Points[6].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(frame);
        trajectory.Points[6].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(frame, mirrored);

        //Past
        for (int i = 0; i < 6; i++)
        {
            float delta = -1f + (float)i / 6f;
            if (frame.Timestamp + delta < 0f)
            {
                float pivot     = -frame.Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ? 1f : Mathf.Abs(pivot / clamped);
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[i].SetPosition(Data.GetFirstFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetFirstFrame().GetRootPosition(mirrored)));
                trajectory.Points[i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(reference);
                trajectory.Points[i].Phase  = phaseModule == null ? 0f : Mathf.Repeat(phaseModule.GetPhase(Data.GetFirstFrame(), mirrored) - Utility.PhaseUpdate(phaseModule.GetPhase(Data.GetFirstFrame(), mirrored), phaseModule.GetPhase(reference, mirrored)), 1f);
            }
            else
            {
                Frame previous = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[i].SetTransformation(previous.GetRootTransformation(mirrored));
                trajectory.Points[i].SetVelocity(previous.GetRootVelocity(mirrored));
                trajectory.Points[i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(previous);
                trajectory.Points[i].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(previous, mirrored);
            }
        }

        //Future
        for (int i = 1; i <= 5; i++)
        {
            float delta = (float)i / 5f;
            if (frame.Timestamp + delta > Data.GetTotalTime())
            {
                float pivot     = 2f * Data.GetTotalTime() - frame.Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ?1f : Mathf.Abs((Data.GetTotalTime() - pivot) / (Data.GetTotalTime() - clamped));
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[6 + i].SetPosition(Data.GetLastFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetLastFrame().GetRootPosition(mirrored)));
                trajectory.Points[6 + i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[6 + i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(reference);
                trajectory.Points[6 + i].Phase  = phaseModule == null ? 0f : Mathf.Repeat(phaseModule.GetPhase(Data.GetLastFrame(), mirrored) + Utility.PhaseUpdate(phaseModule.GetPhase(reference, mirrored), phaseModule.GetPhase(Data.GetLastFrame(), mirrored)), 1f);
            }
            else
            {
                Frame future = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[6 + i].SetTransformation(future.GetRootTransformation(mirrored));
                trajectory.Points[6 + i].SetVelocity(future.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].Styles = styleModule == null ? new float[0] : styleModule.GetStyle(future);
                trajectory.Points[6 + i].Phase  = phaseModule == null ? 0f : phaseModule.GetPhase(future, mirrored);
            }
        }

        /*
         * //Signals
         * for(int i=0; i<7; i++) {
         *      float delta = -2f + (float)i/6f;
         *      if(frame.Timestamp + delta < 0f) {
         *              float pivot = - frame.Timestamp - delta;
         *              float clamped = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
         *              Frame reference = Data.GetFrame(clamped);
         *              trajectory.Points[i].Signals = ArrayExtensions.Sub(styleModule.GetInverseSignal(reference, window), styleModule.GetStyle(reference, window));
         *      } else {
         *              Frame pivot = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
         *              trajectory.Points[i].Signals = ArrayExtensions.Sub(styleModule.GetSignal(pivot, window), styleModule.GetStyle(pivot, window));
         *      }
         * }
         * for(int i=1; i<=5; i++) {
         *      float delta = -1f + (float)i/5f;
         *      if(frame.Timestamp + delta < 0f) {
         *              float pivot = - frame.Timestamp - delta;
         *              float clamped = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
         *              Frame reference = Data.GetFrame(clamped);
         *              trajectory.Points[6+i].Signals = ArrayExtensions.Sub(styleModule.GetInverseSignal(reference, window), styleModule.GetStyle(reference, window));
         *      } else {
         *              Frame pivot = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
         *              trajectory.Points[6+i].Signals = ArrayExtensions.Sub(styleModule.GetSignal(pivot, window), styleModule.GetStyle(pivot, window));
         *      }
         * }
         *
         * //Finish
         * for(int i=0; i<trajectory.GetLast().Signals.Length; i++) {
         *      for(int j=7; j<12; j++) {
         *              if(trajectory.GetLast().Signals[i] > 0f && trajectory.GetLast().Signals[i] < 1f) {
         *                      int pivot = j-1;
         *                      trajectory.Points[j].Styles[i] = Mathf.Max(trajectory.Points[pivot].Styles[i], trajectory.Points[j].Styles[i]);
         *              }
         *              if(trajectory.GetLast().Signals[i] < 0f && trajectory.GetLast().Signals[i] > -1f) {
         *                      int pivot = j-1;
         *                      trajectory.Points[j].Styles[i] = Mathf.Min(trajectory.Points[pivot].Styles[i], trajectory.Points[j].Styles[i]);
         *              }
         *              if(trajectory.GetLast().Signals[i] == 0f) {
         *                      trajectory.Points[j].Styles[i] = 0f;
         *              }
         *              if(trajectory.GetLast().Signals[i] == 1f || trajectory.GetLast().Signals[i] == -1f) {
         *                      trajectory.Points[j].Styles[i] = trajectory.Points[6].Styles[i];
         *              }
         *      }
         * }
         * if(trajectory.GetLast().Signals.AbsSum() == 0f) {
         *      for(int j=7; j<12; j++) {
         *              trajectory.Points[j].Styles = trajectory.Points[6].Styles;
         *      }
         * }
         */

        //Signals
        for (int i = 0; i < 7; i++)
        {
            float delta = -1f + (float)i / 6f;
            if (frame.Timestamp + delta < 0f)
            {
                float pivot     = -frame.Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[i].Signals = styleModule.GetInverseSignal(reference);
            }
            else
            {
                Frame pivot = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[i].Signals = styleModule.GetSignal(pivot);
            }
        }
        for (int i = 7; i < 12; i++)
        {
            trajectory.Points[i].Signals = (float[])trajectory.Points[6].Signals.Clone();
        }

        //Finish
        for (int i = 0; i < trajectory.GetLast().Signals.Length; i++)
        {
            for (int j = 7; j < 12; j++)
            {
                if (trajectory.GetLast().Signals[i] > 0f && trajectory.GetLast().Signals[i] < 1f)
                {
                    int pivot = j - 1;
                    trajectory.Points[j].Styles[i] = Mathf.Max(trajectory.Points[pivot].Styles[i], trajectory.Points[j].Styles[i]);
                }
                if (trajectory.GetLast().Signals[i] < 0f && trajectory.GetLast().Signals[i] > -1f)
                {
                    int pivot = j - 1;
                    trajectory.Points[j].Styles[i] = Mathf.Min(trajectory.Points[pivot].Styles[i], trajectory.Points[j].Styles[i]);
                }
                if (trajectory.GetLast().Signals[i] == 0f)
                {
                    trajectory.Points[j].Styles[i] = trajectory.Points[6].Styles[i];
                }
                if (trajectory.GetLast().Signals[i] == 1f || trajectory.GetLast().Signals[i] == -1f)
                {
                    trajectory.Points[j].Styles[i] = trajectory.Points[6].Styles[i];
                }
            }
        }
        if (trajectory.GetLast().Signals.AbsSum() == 0f)
        {
            for (int j = 7; j < 12; j++)
            {
                trajectory.Points[j].Styles = (float[])trajectory.Points[6].Styles.Clone();
            }
        }

        //for(int i=0; i<trajectory.Points.Length; i++) {
        //	for(int j=0; j<trajectory.Points[i].Signals.Length; j++) {
        //		trajectory.Points[i].Signals[j] = Mathf.Sign(trajectory.Points[i].Signals[j]) * Mathf.Pow(Mathf.Abs(trajectory.Points[i].Signals[j]), 0.5f);
        //	}
        //}

        return(trajectory);
    }
示例#10
0
    private IEnumerator Process()
    {
        if (Editor != null)
        {
            Processing = true;
            foreach (Asset a in Assets)
            {
                a.Processed = false;
            }
            int count = 0;

            if (Pipeline == PIPELINE.Basketball)
            {
                string     referenceBone = string.Empty;
                MotionData referenceData = null;
                foreach (Asset a in Assets)
                {
                    if (a.Selected)
                    {
                        count += 1;
                        MotionData data = OfflineProcessing ? Editor.GetAsset(a.GUID) : Editor.LoadData(a.GUID);
                        while (!OfflineProcessing && !data.GetScene().isLoaded)
                        {
                            Debug.Log("Waiting for scene being loaded...");
                            yield return(new WaitForSeconds(0f));
                        }
                        //START OF PROCESSING

                        // Reset motion data
                        foreach (Frame frame in data.Frames)
                        {
                            frame.ResetTransformations();
                        }

                        // Global
                        data.RemoveAllModules();
                        data.MirrorAxis = Axis.ZPositive;

                        // 1on1 Ball Copying
                        {
                            string GetID(MotionData asset)
                            {
                                return(asset.GetName().Substring(0, asset.GetName().LastIndexOf("_P0")));
                            }

                            referenceBone = "Player 01:Ball";
                            if (data.GetName().Contains("_P0"))
                            {
                                if (data.GetName().Contains("_P01"))
                                {
                                    referenceData = data;
                                }
                                else if (GetID(data) == GetID(referenceData))
                                {
                                    data.SampleTransformations(referenceData, referenceBone);
                                }
                                else
                                {
                                    Debug.LogError("Skipping asset " + data.GetName() + " as information of P01 is not of same capture.");
                                }
                            }
                            else
                            {
                                Debug.LogError("Skipping asset " + data.GetName() + " as it does not contain player information.");
                            }
                        }

                        {
                            RootModule root = data.AddModule <RootModule>();
                            root.Root          = data.Source.FindBone("Player 01:Hips").Index;
                            root.RightShoulder = data.Source.FindBone("Player 01:LeftShoulder").Index;
                            root.LeftShoulder  = data.Source.FindBone("Player 01:RightShoulder").Index;
                            root.RightHip      = data.Source.FindBone("Player 01:LeftUpLeg").Index;
                            root.LeftHip       = data.Source.FindBone("Player 01:RightUpLeg").Index;
                            root.Neck          = data.Source.FindBone("Player 01:Neck").Index;
                            root.Hips          = data.Source.FindBone("Player 01:Hips").Index;
                            root.Smooth        = true;
                            root.Topology      = RootModule.TOPOLOGY.Biped;
                            root.ForwardAxis   = Axis.XPositive;
                        }

                        {
                            ContactModule contact = data.AddModule <ContactModule>();
                            contact.Clear();
                            contact.AddSensor("Player 01:LeftFootEnd", "Player 01:LeftFootEnd", Vector3.zero, 0.075f, 1f, -1);
                            contact.AddSensor("Player 01:RightFootEnd", "Player 01:RightFootEnd", Vector3.zero, 0.075f, 1f, -1);
                            contact.AddSensor("Player 01:LeftHand", "Player 01:LeftHand", new Vector3(-0.1f, 0f, 0f), 0.075f, 0f, -1);
                            contact.AddSensor("Player 01:RightHand", "Player 01:RightHand", new Vector3(-0.1f, 0f, 0f), 0.075f, 0f, -1);
                            contact.AddSensor("Player 01:Ball", "Player 01:Ball", Vector3.zero, 0.2f, 0f, LayerMask.GetMask("Ground"));
                            contact.CaptureContacts(Editor);
                        }

                        {
                            DribbleModule dribble = data.AddModule <DribbleModule>();
                            dribble.Area   = 2.5f;
                            dribble.Radius = 0.125f;
                            dribble.Axis   = Axis.YPositive;
                            Matrix4x4[] motion = dribble.CleanupBallTransformations(false);
                            for (int i = 0; i < data.Frames.Length; i++)
                            {
                                data.Frames[i].Transformations[dribble.Ball] = motion[i];
                            }
                            data.GetModule <ContactModule>().CaptureContacts(Editor);
                        }

                        {
                            StyleModule   style   = data.AddModule <StyleModule>();
                            RootModule    root    = data.GetModule <RootModule>();
                            DribbleModule dribble = data.GetModule <DribbleModule>();
                            style.Clear();
                            StyleModule.StyleFunction standing  = style.AddStyle("Stand");
                            StyleModule.StyleFunction moving    = style.AddStyle("Move");
                            StyleModule.StyleFunction dribbling = style.AddStyle("Dribble");
                            StyleModule.StyleFunction holding   = style.AddStyle("Hold");
                            StyleModule.StyleFunction shooting  = style.AddStyle("Shoot");
                            float threshold = 1f;
                            for (int f = 0; f < data.Frames.Length; f++)
                            {
                                float[] timestamps = data.SimulateTimestamps(data.Frames[f], 30);
                                float[] weights    = new float[timestamps.Length];
                                for (int j = 0; j < timestamps.Length; j++)
                                {
                                    weights[j] = Mathf.Clamp(root.GetRootVelocity(timestamps[j], false).magnitude, 0f, threshold);
                                    weights[j] = weights[j].Normalize(0f, threshold, 0, 1f);
                                    weights[j] = weights[j].SmoothStep(2f, 0.5f);
                                }
                                float weight = weights.Gaussian().SmoothStep(2f, 0.5f);
                                standing.Values[f]  = 1f - weight;
                                moving.Values[f]    = weight;
                                dribbling.Values[f] = dribble.IsDribbling(data.Frames[f].Timestamp, false) ? 1f : 0f;
                                holding.Values[f]   = dribble.IsHolding(data.Frames[f].Timestamp, false) ? 1f : 0f;
                                shooting.Values[f]  = dribble.IsShooting(data.Frames[f].Timestamp, false) ? 1f : 0f;
                            }
                            style.Mode = StyleModule.DRAWING.Frames;
                            style.GenerateKeys();
                        }

                        {
                            PhaseModule   phase   = data.AddModule <PhaseModule>();
                            ContactModule contact = data.GetModule <ContactModule>();
                            phase.Inspect = true;
                            phase.SetFunctions(contact.GetNames());
                            phase.ShowNormalized   = true;
                            phase.ShowHighlighted  = true;
                            phase.ShowValues       = true;
                            phase.ShowFitting      = true;
                            phase.ShowZero         = true;
                            phase.ShowPhase        = true;
                            phase.ShowWindow       = false;
                            phase.DisplayValues    = false;
                            phase.MaxIterations    = 50;
                            phase.Individuals      = 50;
                            phase.Elites           = 5;
                            phase.Exploration      = 0.2f;
                            phase.Memetism         = 0.1f;
                            phase.MaxFrequency     = 4f;
                            phase.RescalingMethod  = PhaseModule.Rescaling.Window;
                            phase.ApplyButterworth = true;
                            phase.StartFitting();
                            while (phase.IsFitting())
                            {
                                yield return(new WaitForSeconds(0f));
                            }
                        }

                        //END OF PROCESSING
                        data.MarkDirty();
                        a.Processed = true;
                    }
                }
                foreach (Asset a in Assets)
                {
                    if (a.Selected)
                    {
                        MotionData data = Editor.LoadData(a.GUID);
                        while (!data.GetScene().isLoaded)
                        {
                            Debug.Log("Waiting for scene being loaded...");
                            yield return(new WaitForSeconds(0f));
                        }
                        //START OF PROCESSING

                        data.GetModule <DribbleModule>().ComputeInteraction();

                        //END OF PROCESSING
                        if (SaveAfterProcessing)
                        {
                            data.MarkDirty(true, !OfflineProcessing);
                        }
                        a.Processed = true;
                        yield return(new WaitForSeconds(0f));
                    }
                }
                if (SaveAfterProcessing)
                {
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }

            if (Pipeline == PIPELINE.Quadruped)
            {
                foreach (Asset a in Assets)
                {
                    if (a.Selected)
                    {
                        count += 1;
                        MotionData data = OfflineProcessing ? Editor.GetAsset(a.GUID) : Editor.LoadData(a.GUID);
                        while (!OfflineProcessing && !data.GetScene().isLoaded)
                        {
                            Debug.Log("Waiting for scene being loaded...");
                            yield return(new WaitForSeconds(0f));
                        }
                        // START OF PROCESSING

                        // Reset motion data
                        foreach (Frame frame in data.Frames)
                        {
                            frame.ResetTransformations();
                        }

                        // Global
                        data.RemoveAllModules();
                        data.Scale      = 0.01f;
                        data.MirrorAxis = Axis.ZPositive;
                        data.Source.FindBone("Head").Alignment      = new Vector3(90f, 0f, 0f);
                        data.Source.FindBone("Tail").Alignment      = new Vector3(-45f, 0f, 0f);
                        data.Source.FindBone("Tail1").Alignment     = new Vector3(-45f, 0f, 0f);
                        data.Source.FindBone("Tail1Site").Alignment = new Vector3(-45f, 0f, 0f);

                        {
                            ContactModule contact = data.AddModule <ContactModule>();
                            contact.Clear();
                            contact.AddSensor("Hips", "Hips", Vector3.zero, 0.2f, 1f, LayerMask.GetMask("Ground"));
                            contact.AddSensor("Neck", "Neck", Vector3.zero, 0.25f, 1f, LayerMask.GetMask("Ground"));
                            contact.AddSensor("LeftHandSite", new string[] { "LeftForeArm", "LeftHandSite" }, Vector3.zero, 1f / 30f, 1f, LayerMask.GetMask("Ground"));
                            contact.AddSensor("RightHandSite", new string[] { "RightForeArm", "RightHandSite" }, Vector3.zero, 1f / 30f, 1f, LayerMask.GetMask("Ground"));
                            contact.AddSensor("LeftFootSite", "LeftFootSite", Vector3.zero, 1f / 30f, 1f, LayerMask.GetMask("Ground"));
                            contact.AddSensor("RightFootSite", "RightFootSite", Vector3.zero, 1f / 30f, 1f, LayerMask.GetMask("Ground"));
                            contact.CaptureContacts(Editor);
                        }

                        {
                            StyleModule style = data.AddModule <StyleModule>();
                            RootModule  root  = data.AddModule <RootModule>();
                            root.Topology = RootModule.TOPOLOGY.Quadruped;
                            ContactModule contact = data.GetModule <ContactModule>();
                            style.Clear();
                            StyleModule.StyleFunction idling   = style.AddStyle("Idle");
                            StyleModule.StyleFunction moving   = style.AddStyle("Move");
                            StyleModule.StyleFunction sitting  = style.AddStyle("Sit");
                            StyleModule.StyleFunction resting  = style.AddStyle("Rest");
                            StyleModule.StyleFunction standing = style.AddStyle("Stand");
                            StyleModule.StyleFunction jumping  = style.AddStyle("Jump");
                            StyleModule.StyleFunction speed    = style.AddStyle("Speed");
                            float[]        timeWindow          = data.GetTimeWindow(MotionEditor.GetInstance().PastWindow + MotionEditor.GetInstance().FutureWindow, 1f);
                            float[]        contactHeights      = new float[data.Frames.Length];
                            List <float[]> sitPatterns         = new List <float[]>()
                            {
                                new float[] { 1f, 0f, 1f, 1f, 1f, 1f },
                                new float[] { 1f, 0f, 0f, 1f, 1f, 1f },
                                new float[] { 1f, 0f, 1f, 0f, 1f, 1f }
                            };
                            List <float[]> restPatterns = new List <float[]>()
                            {
                                new float[] { 1f, 1f, 1f, 1f, 1f, 1f }
                            };
                            List <float[]> standPatterns = new List <float[]>()
                            {
                                new float[] { 1f, 0f, 0f, 0f, 1f, 1f }
                            };
                            List <float[]> jumpPatterns = new List <float[]>()
                            {
                                new float[] { 0f, 0f, 0f, 0f, 0f, 0f }
                            };
                            for (int i = 0; i < data.Frames.Length; i++)
                            {
                                for (int j = 0; j < contact.Sensors.Length; j++)
                                {
                                    contactHeights[i] += data.Frames[i].GetBoneTransformation(contact.Sensors[j].Bones.Last(), false).GetPosition().y;
                                }
                                contactHeights[i] /= contact.Sensors.Length;
                            }
                            for (int f = 0; f < data.Frames.Length; f++)
                            {
                                float weight = GetMovementWeight(data.Frames[f].Timestamp, 0.5f, 0.5f);
                                idling.Values[f] = 1f - weight;
                                moving.Values[f] = weight;
                                float   sit     = GetContactsWeight(data.Frames[f].Timestamp, 0.5f, contact, sitPatterns, 0f, 1f);
                                float   rest    = GetContactsWeight(data.Frames[f].Timestamp, 0.5f, contact, restPatterns, 0f, 1f);
                                float   stand   = GetContactsWeight(data.Frames[f].Timestamp, 0.5f, contact, standPatterns, 0f, 1f);
                                float   jump    = GetContactsWeight(data.Frames[f].Timestamp, 0.5f, contact, jumpPatterns, 0.3f, 0.1f);
                                float[] actions = new float[] { sit, rest, stand, jump };
                                Utility.SoftMax(ref actions);
                                sitting.Values[f]  = sit;
                                resting.Values[f]  = rest;
                                standing.Values[f] = stand;
                                jumping.Values[f]  = jump;
                                speed.Values[f]    = GetRootSpeed(data.Frames[f].Timestamp);
                            }

                            float GetRootSpeed(float timestamp)
                            {
                                return(Compute());

                                float Compute()
                                {
                                    Vector3[] positions = new Vector3[timeWindow.Length];
                                    for (int i = 0; i < timeWindow.Length; i++)
                                    {
                                        positions[i] = root.GetRootPosition(timestamp + timeWindow[i], false);
                                    }
                                    float length = 0f;

                                    for (int i = 1; i < positions.Length; i++)
                                    {
                                        length += Vector3.Distance(positions[i - 1], positions[i]);
                                    }
                                    return(length / (timeWindow.Last() - timeWindow.First()));
                                }
                            }

                            float GetMovementWeight(float timestamp, float window, float threshold)
                            {
                                float[] weights = new float[timeWindow.Length];
                                for (int j = 0; j < timeWindow.Length; j++)
                                {
                                    weights[j] = Mathf.Clamp(root.GetRootVelocity(timestamp + timeWindow[j], false).magnitude, 0f, threshold) / threshold;
                                }

                                float[] gradients = new float[weights.Length - 1];
                                for (int i = 0; i < gradients.Length; i++)
                                {
                                    gradients[i] = (weights[i + 1] - weights[i]) / (timeWindow[i + 1] - timeWindow[i]);
                                }
                                float gradient = Mathf.Abs(gradients.Gaussian());

                                return(weights.Gaussian(gradient).SmoothStep(2f, 0.5f));
                            }

                            float GetContactsWeight(float timestamp, float window, ContactModule module, List <float[]> patterns, float heightThreshold, float power)
                            {
                                float ContactGaussian(float t)
                                {
                                    float[] weights = new float[timeWindow.Length];
                                    for (int j = 0; j < timeWindow.Length; j++)
                                    {
                                        bool match = false;
                                        for (int i = 0; i < patterns.Count; i++)
                                        {
                                            float[] contacts = module.GetContacts(t + timeWindow[j], false);
                                            match = ArrayExtensions.Equal(contacts, patterns[i]).All(true);
                                            if (match)
                                            {
                                                break;
                                            }
                                        }
                                        if (match && heightThreshold != 0f && contactHeights[data.GetFrame(t).Index - 1] < heightThreshold)
                                        {
                                            match = false;
                                        }
                                        weights[j] = match ? 1f : 0f;
                                    }
                                    return(weights.Gaussian());
                                }

                                float weight = ContactGaussian(timestamp);

                                weight = Mathf.Pow(weight, 1f - weight);
                                return(Mathf.Pow(weight, power));
                            }

                            style.Mode = StyleModule.DRAWING.Frames;
                        }

                        {
                            PhaseModule phase = data.AddModule <PhaseModule>();
                            phase.Inspect = true;
                            RootModule    root    = data.GetModule <RootModule>();
                            ContactModule contact = data.GetModule <ContactModule>();
                            phase.SetFunctions(contact.GetNames());
                            phase.ShowNormalized   = true;
                            phase.ShowHighlighted  = true;
                            phase.ShowValues       = true;
                            phase.ShowFitting      = true;
                            phase.ShowZero         = true;
                            phase.ShowPhase        = true;
                            phase.ShowWindow       = false;
                            phase.DisplayValues    = false;
                            phase.MaxIterations    = 50;
                            phase.Individuals      = 100;
                            phase.Elites           = 10;
                            phase.Exploration      = 0.2f;
                            phase.Memetism         = 0.1f;
                            phase.MaxFrequency     = 4f;
                            phase.RescalingMethod  = PhaseModule.Rescaling.Window;
                            phase.ApplyButterworth = true;

                            phase.StartFitting();
                            while (phase.IsFitting())
                            {
                                yield return(new WaitForSeconds(0f));
                            }
                        }

                        //END OF PROCESSING
                        if (SaveAfterProcessing)
                        {
                            data.MarkDirty(true, !OfflineProcessing);
                        }
                        a.Processed = true;
                        yield return(new WaitForSeconds(0f));
                    }
                }

                for (int i = 0; i < Editor.Assets.Length; i++)
                {
                    Editor.GetAsset(i).ResetSequences();
                    Editor.GetAsset(i).Export = false;
                }
                Editor.GetAsset(0).Export = true;
                Editor.GetAsset(0).SetSequence(0, 180, 1531);
                Editor.GetAsset(2).Export = true;
                Editor.GetAsset(2).SetSequence(0, 680, 820);
                Editor.GetAsset(6).Export = true;
                Editor.GetAsset(6).SetSequence(0, 90, 593);
                Editor.GetAsset(7).Export = true;
                Editor.GetAsset(7).SetSequence(0, 290, 1072);
                Editor.GetAsset(8).Export = true;
                Editor.GetAsset(8).SetSequence(0, 1, 50);
                Editor.GetAsset(8).SetSequence(1, 400, 911);
                Editor.GetAsset(9).Export  = true;
                Editor.GetAsset(10).Export = true;
                Editor.GetAsset(10).SetSequence(0, 230, 548);
                Editor.GetAsset(11).Export = true;
                Editor.GetAsset(11).SetSequence(0, 400, 567);
                Editor.GetAsset(12).Export = true;
                Editor.GetAsset(13).Export = true;
                Editor.GetAsset(14).Export = true;
                Editor.GetAsset(16).Export = true;
                Editor.GetAsset(16).SetSequence(0, 200, 550);
                Editor.GetAsset(17).Export = true;
                Editor.GetAsset(17).SetSequence(0, 470, 720);
                Editor.GetAsset(18).Export = true;
                Editor.GetAsset(18).SetSequence(0, 175, 395);
                Editor.GetAsset(19).Export = true;
                Editor.GetAsset(19).SetSequence(0, 300, 750);
                Editor.GetAsset(19).SetSequence(1, 1040, 1079);
                Editor.GetAsset(20).Export = true;
                Editor.GetAsset(21).Export = true;
                Editor.GetAsset(21).SetSequence(0, 1, 1300);
                Editor.GetAsset(21).SetSequence(1, 2950, 3530);
                Editor.GetAsset(21).SetSequence(2, 3730, 4200);
                Editor.GetAsset(22).Export = true;
                Editor.GetAsset(23).Export = true;
                Editor.GetAsset(23).Export = true;
                Editor.GetAsset(24).Export = true;
                Editor.GetAsset(24).SetSequence(0, 200, 630);
                Editor.GetAsset(25).Export = true;
                Editor.GetAsset(25).SetSequence(0, 1, 2690);
                Editor.GetAsset(25).SetSequence(1, 2760, 4336);
                Editor.GetAsset(26).Export = true;
                Editor.GetAsset(27).Export = true;
                Editor.GetAsset(27).SetSequence(0, 1, 1100);
                Editor.GetAsset(27).SetSequence(1, 2820, 3940);
                Editor.GetAsset(27).SetSequence(2, 4100, 4500);
                Editor.GetAsset(27).SetSequence(3, 5660, 6010);
                Editor.GetAsset(27).SetSequence(4, 6600, 7200);
                Editor.GetAsset(27).SetSequence(5, 12300, 12850);
                Editor.GetAsset(27).SetSequence(6, 13200, 13399);
                Editor.GetAsset(28).Export = true;
                Editor.GetAsset(28).SetSequence(0, 920, 985);
                Editor.GetAsset(28).SetSequence(1, 1700, 1907);
                Editor.GetAsset(29).Export = true;
                Editor.GetAsset(29).SetSequence(0, 250, 790);
                Editor.GetAsset(29).SetSequence(1, 970, 1575);
                Editor.GetAsset(29).SetSequence(2, 1630, 1750);
                Editor.GetAsset(30).Export = true;
                Editor.GetAsset(30).SetSequence(0, 1790, 1920);
                Editor.GetAsset(30).SetSequence(1, 2070, 2470);
                Editor.GetAsset(30).SetSequence(2, 2770, 3025);
                Editor.GetAsset(31).Export = true;
                Editor.GetAsset(31).SetSequence(0, 170, 500);
                Editor.GetAsset(31).SetSequence(1, 1250, 2460);
                Editor.GetAsset(31).SetSequence(2, 3040, 3200);
                Editor.GetAsset(31).SetSequence(3, 4680, 6550);
                Editor.GetAsset(31).SetSequence(4, 7600, 9450);
                Editor.GetAsset(31).SetSequence(5, 11540, 11691);
                Editor.GetAsset(32).Export = true;
                Editor.GetAsset(32).SetSequence(0, 1, 300);
                Editor.GetAsset(32).SetSequence(1, 1360, 1540);
                Editor.GetAsset(32).SetSequence(2, 2380, 3086);
                Editor.GetAsset(33).Export = true;
                Editor.GetAsset(33).SetSequence(0, 1, 1170);
                Editor.GetAsset(33).SetSequence(1, 1980, 2160);
                Editor.GetAsset(33).SetSequence(2, 7830, 8090);
                Editor.GetAsset(34).Export = true;
                Editor.GetAsset(34).SetSequence(0, 1, 270);
                Editor.GetAsset(34).SetSequence(1, 2490, 2856);
                Editor.GetAsset(35).Export = true;
                Editor.GetAsset(37).Export = true;
                Editor.GetAsset(38).Export = true;
                Editor.GetAsset(38).SetSequence(0, 3330, 3900);
                Editor.GetAsset(39).Export = true;
                Editor.GetAsset(39).SetSequence(0, 880, 920);
                Editor.GetAsset(39).SetSequence(1, 1280, 5052);
                Editor.GetAsset(41).Export = true;
                Editor.GetAsset(41).SetSequence(0, 4690, 6190);
                Editor.GetAsset(42).Export = true;
                Editor.GetAsset(42).SetSequence(0, 900, 3594);
                Editor.GetAsset(43).Export = true;
                Editor.GetAsset(43).SetSequence(0, 1, 500);
                Editor.GetAsset(43).SetSequence(1, 4340, 4577);
                Editor.GetAsset(44).Export = true;
                Editor.GetAsset(44).SetSequence(0, 1, 700);
                Editor.GetAsset(44).SetSequence(1, 950, 2000);
                Editor.GetAsset(45).Export = true;
                Editor.GetAsset(45).SetSequence(0, 1, 410);
                Editor.GetAsset(45).SetSequence(1, 680, 778);
                Editor.GetAsset(46).Export = true;
                Editor.GetAsset(46).SetSequence(0, 175, 235);
                Editor.GetAsset(47).Export = true;
                Editor.GetAsset(47).SetSequence(0, 275, 498);
                Editor.GetAsset(48).Export = true;
                Editor.GetAsset(48).SetSequence(0, 1, 220);
                Editor.GetAsset(48).SetSequence(1, 675, 748);
                Editor.GetAsset(49).Export = true;
                Editor.GetAsset(49).SetSequence(0, 1, 700);
                Editor.GetAsset(49).SetSequence(1, 1510, 8300);
                Editor.GetAsset(50).Export = true;
                Editor.GetAsset(50).SetSequence(0, 200, 1000);
                Editor.GetAsset(50).SetSequence(1, 1850, 2100);
                Editor.GetAsset(50).SetSequence(2, 4150, 4700);
                Editor.GetAsset(50).SetSequence(3, 5030, 5356);

                //Mark for saving
                for (int i = 0; i < Editor.Assets.Length; i++)
                {
                    Editor.GetAsset(i).MarkDirty(true, false);
                }

                if (SaveAfterProcessing)
                {
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }

            Processing = false;
            foreach (Asset a in Assets)
            {
                a.Processed = false;
            }
            yield return(new WaitForSeconds(0f));

            Debug.Log("Finished processing " + count + " assets.");
        }
    }
示例#11
0
    public Trajectory GetTrajectory(Frame frame, bool mirrored)
    {
        StyleModule styleModule = Data.GetModule(Module.TYPE.Style) == null ? null : (StyleModule)Data.GetModule(Module.TYPE.Style);
        PhaseModule phaseModule = Data.GetModule(Module.TYPE.Phase) == null ? null : (PhaseModule)Data.GetModule(Module.TYPE.Phase);

        Trajectory trajectory = new Trajectory(12, styleModule == null ? new string[0] : styleModule.GetNames());

        int window = 5;

        //Current
        trajectory.Points[6].SetTransformation(frame.GetRootTransformation(mirrored));
        trajectory.Points[6].SetVelocity(frame.GetRootVelocity(mirrored));
        trajectory.Points[6].SetSpeed(frame.GetSpeed(mirrored));
        trajectory.Points[6].Styles  = styleModule == null ? new float[0] : styleModule.GetStyle(frame, window);
        trajectory.Points[6].Phase   = phaseModule == null ? 0f : phaseModule.GetPhase(frame, mirrored, window);
        trajectory.Points[6].Signals = styleModule == null ? new float[0] : styleModule.GetSignal(frame, window);

        //Past
        for (int i = 0; i < 6; i++)
        {
            float delta = -1f + (float)i / 6f;
            if (frame.Timestamp + delta < 0f)
            {
                float pivot     = -frame.Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ? 1f : Mathf.Abs(pivot / clamped);
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[i].SetPosition(Data.GetFirstFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetFirstFrame().GetRootPosition(mirrored)));
                trajectory.Points[i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[i].SetSpeed(reference.GetSpeed(mirrored));
                trajectory.Points[i].Styles  = styleModule == null ? new float[0] : styleModule.GetStyle(reference, window);
                trajectory.Points[i].Phase   = phaseModule == null ? 0f : Mathf.Repeat(phaseModule.GetPhase(Data.GetFirstFrame(), mirrored, window) - Utility.GetLinearPhaseUpdate(phaseModule.GetPhase(Data.GetFirstFrame(), mirrored, window), phaseModule.GetPhase(reference, mirrored, window)), 1f);
                trajectory.Points[i].Signals = styleModule == null ? new float[0] : styleModule.GetInverseSignal(reference, window);
            }
            else
            {
                Frame previous = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[i].SetTransformation(previous.GetRootTransformation(mirrored));
                trajectory.Points[i].SetVelocity(previous.GetRootVelocity(mirrored));
                trajectory.Points[i].SetSpeed(previous.GetSpeed(mirrored));
                trajectory.Points[i].Styles  = styleModule == null ? new float[0] : styleModule.GetStyle(previous, window);
                trajectory.Points[i].Phase   = phaseModule == null ? 0f : phaseModule.GetPhase(previous, mirrored, window);
                trajectory.Points[i].Signals = styleModule == null ? new float[0] : styleModule.GetSignal(previous, window);
            }
        }

        //Future
        for (int i = 1; i <= 5; i++)
        {
            float delta = (float)i / 5f;
            if (frame.Timestamp + delta > Data.GetTotalTime())
            {
                float pivot     = 2f * Data.GetTotalTime() - frame.Timestamp - delta;
                float clamped   = Mathf.Clamp(pivot, 0f, Data.GetTotalTime());
                float ratio     = pivot == clamped ?1f : Mathf.Abs((Data.GetTotalTime() - pivot) / (Data.GetTotalTime() - clamped));
                Frame reference = Data.GetFrame(clamped);
                trajectory.Points[6 + i].SetPosition(Data.GetLastFrame().GetRootPosition(mirrored) - ratio * (reference.GetRootPosition(mirrored) - Data.GetLastFrame().GetRootPosition(mirrored)));
                trajectory.Points[6 + i].SetRotation(reference.GetRootRotation(mirrored));
                trajectory.Points[6 + i].SetVelocity(reference.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].SetSpeed(reference.GetSpeed(mirrored));
                trajectory.Points[6 + i].Styles  = styleModule == null ? new float[0] : styleModule.GetStyle(reference, window);
                trajectory.Points[6 + i].Phase   = phaseModule == null ? 0f : Mathf.Repeat(phaseModule.GetPhase(Data.GetLastFrame(), mirrored, window) + Utility.GetLinearPhaseUpdate(phaseModule.GetPhase(reference, mirrored, window), phaseModule.GetPhase(Data.GetLastFrame(), mirrored, window)), 1f);
                trajectory.Points[6 + i].Signals = styleModule == null ? new float[0] : styleModule.GetInverseSignal(reference, window);
            }
            else
            {
                Frame future = Data.GetFrame(Mathf.Clamp(frame.Timestamp + delta, 0f, Data.GetTotalTime()));
                trajectory.Points[6 + i].SetTransformation(future.GetRootTransformation(mirrored));
                trajectory.Points[6 + i].SetVelocity(future.GetRootVelocity(mirrored));
                trajectory.Points[6 + i].SetSpeed(future.GetSpeed(mirrored));
                trajectory.Points[6 + i].Styles  = styleModule == null ? new float[0] : styleModule.GetStyle(future, window);
                trajectory.Points[6 + i].Phase   = phaseModule == null ? 0f : phaseModule.GetPhase(future, mirrored, window);
                trajectory.Points[6 + i].Signals = styleModule == null ? new float[0] : styleModule.GetSignal(future, window);
            }
        }
        return(trajectory);
    }
示例#12
0
    public TimeSeries GetTimeSeries(Frame frame, bool mirrored, int pastKeys, int futureKeys, float pastWindow, float futureWindow, int resolution, float delta)
    {
        TimeSeries timeSeries = new TimeSeries(pastKeys, futureKeys, pastWindow, futureWindow, resolution);

        foreach (Module module in Data.Modules)
        {
            if (module is RootModule)
            {
                RootModule      m      = (RootModule)module;
                TimeSeries.Root series = new TimeSeries.Root(timeSeries);
                for (int i = 0; i < timeSeries.Samples.Length; i++)
                {
                    float t = frame.Timestamp + timeSeries.Samples[i].Timestamp;
                    if (t < 0f || t > Data.GetTotalTime())
                    {
                        series.Transformations[i] = m.GetEstimatedRootTransformation(frame, timeSeries.Samples[i].Timestamp, mirrored);
                        series.Velocities[i]      = m.GetEstimatedRootVelocity(frame, timeSeries.Samples[i].Timestamp, mirrored, delta);
                    }
                    else
                    {
                        series.Transformations[i] = m.GetRootTransformation(Data.GetFrame(t), mirrored);
                        series.Velocities[i]      = m.GetRootVelocity(Data.GetFrame(t), mirrored, delta);
                    }
                }
            }
            if (module is StyleModule)
            {
                StyleModule      m      = (StyleModule)module;
                TimeSeries.Style series = new TimeSeries.Style(timeSeries, m.GetNames());
                for (int i = 0; i < timeSeries.Samples.Length; i++)
                {
                    float t = frame.Timestamp + timeSeries.Samples[i].Timestamp;
                    series.Values[i] = m.GetStyles(Data.GetFrame(t));
                }
            }
            if (module is GoalModule)
            {
                GoalModule      m      = (GoalModule)module;
                TimeSeries.Goal series = new TimeSeries.Goal(timeSeries, m.GetNames());
                for (int i = 0; i < timeSeries.Samples.Length; i++)
                {
                    float t = frame.Timestamp + timeSeries.Samples[i].Timestamp;
                    series.Transformations[i] = m.Target.GetGoalTransformation(frame, timeSeries.Samples[i].Timestamp, mirrored, delta);
                    series.Values[i]          = m.GetActions(Data.GetFrame(t), delta);
                }
            }
            if (module is ContactModule)
            {
                ContactModule      m      = (ContactModule)module;
                TimeSeries.Contact series = new TimeSeries.Contact(timeSeries, m.GetNames());
                for (int i = 0; i < timeSeries.Samples.Length; i++)
                {
                    float t = frame.Timestamp + timeSeries.Samples[i].Timestamp;
                    series.Values[i] = m.GetContacts(Data.GetFrame(t), mirrored);
                }
            }
            if (module is PhaseModule)
            {
                PhaseModule      m      = (PhaseModule)module;
                TimeSeries.Phase series = new TimeSeries.Phase(timeSeries);
                for (int i = 0; i < timeSeries.Samples.Length; i++)
                {
                    float t = frame.Timestamp + timeSeries.Samples[i].Timestamp;
                    series.Values[i] = m.GetPhase(Data.GetFrame(t), mirrored);
                }
            }
        }
        return(timeSeries);
    }
示例#13
0
    public string[] GenerateLines(MotionData data)
    {
        string[] result = new string[data.Frames.Length - 60];

        for (int i = 30; i < data.Frames.Length - 30; i++)
        {
            if (data.Modules != null)
            {
                for (int k = 0; k < data.Modules.Length; k++)
                {
                    switch (data.Modules[k].GetID())
                    {
                    case Module.ID.Velocity:
                    {
                        VelocityModule module = (VelocityModule)data.GetModule(Module.ID.Velocity);
                        module.GetTransformations(data.GetFrame(i));
                        module.GetVelocities(data.GetFrame(i), 1.0f);
                        for (int j = 0; j < data.Root.Bones.Length; j++)
                        {
                            if (module.Selected[j])
                            {
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().z.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().z.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().z.ToString() + " ";
                                result[i - 30] += module.Velocities[j].x.ToString() + " ";
                                result[i - 30] += module.Velocities[j].y.ToString() + " ";
                                result[i - 30] += module.Velocities[j].z.ToString() + " ";
                            }
                        }
                        break;
                    }

                    case Module.ID.Action:
                    {
                        ActionModule module = (ActionModule)data.GetModule(Module.ID.Action);
                        result[i - 30] += module.GetHotVector(i) + " ";

                        break;
                    }

                    case Module.ID.Phase:
                    {
                        PhaseModule module = (PhaseModule)data.GetModule(Module.ID.Phase);
                        result[i - 30] += module.Phases[1].LocalPhase.Phase[i] + " ";
                        result[i - 30] += module.Phases[2].LocalPhase.Phase[i] + " ";
                        break;
                    }

                    case Module.ID.Trajectory:
                    {
                        TrajectoryModule module = (TrajectoryModule)data.GetModule(Module.ID.Trajectory);
                        for (int j = 0; j < module.Pivots.Length; j++)
                        {
                            for (int p = 0; p < module.Pivots[j].Transformations.Length; p++)
                            {
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().x.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().y.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().z.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].x.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].y.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].z.ToString() + " ";
                                result[i - 30] += module.Pivots[j].HotVectors[p] + " ";
                                result[i - 30] += module.Pivots[j].Phases[p].ToString() + " ";
                            }
                        }
                        break;
                    }
                    }
                }
            }
        }

        return(result);
    }
示例#14
0
    public void ExportLabels(MotionData data)
    {
        Lines = new string[0];
        if (data.Modules != null)
        {
            for (int k = 0; k < data.Modules.Length; k++)
            {
                switch (data.Modules[k].GetID())
                {
                case Module.ID.Velocity:
                {
                    VelocityModule module = (VelocityModule)data.GetModule(Module.ID.Velocity);
                    for (int j = 0; j < data.Root.Bones.Length; j++)
                    {
                        if (module.Selected[j])
                        {
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityZ");
                        }
                    }
                    break;
                }

                case Module.ID.Action:
                {
                    ActionModule module = (ActionModule)data.GetModule(Module.ID.Action);
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action Neutral");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action CrossArms");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action LHOnHip");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action RHOnHip");

                    break;
                }

                case Module.ID.Phase:
                {
                    PhaseModule module = (PhaseModule)data.GetModule(Module.ID.Phase);
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Phase LeftHand");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Phase RightHand");
                    break;
                }

                case Module.ID.Trajectory:
                {
                    TrajectoryModule module = (TrajectoryModule)data.GetModule(Module.ID.Trajectory);
                    for (int j = 0; j < module.Pivots.Length; j++)
                    {
                        for (int p = 0; p < module.Pivots[j].Transformations.Length; p++)
                        {
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action Neutral");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action CrossArms");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action LHOnHip");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action RHOnHip");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Phase");
                        }
                    }
                    break;
                }
                }
            }
        }

        string FileName = Destination + "/" + "Labels.txt";

        if (!File.Exists(FileName))
        {
            using (FileStream fs = File.Create(FileName)) { }
            Debug.Log("Create new file: " + FileName);
            File.AppendAllLines(FileName, Lines);
        }
        else
        {
            File.WriteAllLines(FileName, Lines);
        }

        Debug.Log("Export Labels Successfully!");
    }