示例#1
0
        void TvModulosAfterCheck(object sender, TreeViewEventArgs e)
        {
            PropertyInfo p    = (PropertyInfo)e.Node.Tag;
            RootModule   rmod = (RootModule)p.GetValue(this._doc, null);

            rmod.Enabled = e.Node.Checked;
        }
    public SphereMap GetSphereMap(Frame frame, bool mirrored)
    {
        SphereMap  sensor = new SphereMap(Radius, Mask);
        RootModule module = (RootModule)Data.GetModule(ID.Root);

        sensor.Sense(module == null ? Matrix4x4.identity : module.GetRootTransformation(frame, mirrored));
        return(sensor);
    }
示例#3
0
 private RootModule GetRootModule()
 {
     if (RootModule == null)
     {
         RootModule = Data.GetModule <RootModule>();
     }
     return(RootModule);
 }
示例#4
0
    private Matrix4x4 GetRoot(float timestamp, bool mirrored)
    {
        RootModule root = GetRootModule();

        if (root == null)
        {
            return(Matrix4x4.identity);
        }
        return(root.GetRootTransformation(timestamp, mirrored));
    }
示例#5
0
    public bool IsDribbling(float timestamp, bool mirrored)
    {
        if (!InsideControlRadius())
        {
            return(false);
        }
        ContactModule contact = GetContactModule();

        if (contact == null)
        {
            return(false);
        }
        ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
        ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
        if (left == null || right == null)
        {
            return(false);
        }
        //Check holding contacts
        if (left.GetContact(timestamp, mirrored) == 1f && right.GetContact(timestamp, mirrored) == 1f)
        {
            return(false);
        }
        //Check dribble contact
        if (left.GetContact(timestamp, mirrored) == 1f ^ right.GetContact(timestamp, mirrored) == 1f)
        {
            return(true);
        }
        //Check if contact happened before and happens again after within the future and past window
        float window   = 1f;
        Frame previous = contact.GetPreviousContactFrame(Data.GetFrame(timestamp), mirrored, left, right);

        if (previous == null || previous.Timestamp < timestamp - window)
        {
            return(false);
        }
        Frame next = contact.GetNextContactFrame(Data.GetFrame(timestamp), mirrored, left, right);

        if (next != null && next.Timestamp - timestamp <= window)
        {
            return(left.GetContact(next.Timestamp, mirrored) == 1f ^ right.GetContact(next.Timestamp, mirrored) == 1f);
        }
        return(false);

        bool InsideControlRadius()
        {
            RootModule root = GetRootModule();

            if (root == null)
            {
                return(false);
            }
            return(Vector3.Distance(root.GetRootPosition(timestamp, mirrored).ZeroY(), GetBallPosition(timestamp, mirrored).ZeroY()) <= GetControlRadius());
        }
    }
示例#6
0
        void TvModulosBeforeCheck(object sender, TreeViewCancelEventArgs e)
        {
            PropertyInfo p    = (PropertyInfo)e.Node.Tag;
            RootModule   rmod = (RootModule)p.GetValue(this._doc, null);

            if (e.Node.Checked && rmod.HasData)
            {
                DialogResult r = MessageBox.Show("Se perderán todos los datos asociados a este módulo del documento cargado en memoria (los cambios no afectan al documento en origen). ¿Deshabilitar de todas formas?", "Gestor de plantillas SGD", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (r == DialogResult.No)
                {
                    e.Cancel = true;
                }
            }
        }
示例#7
0
        internal override void BeforeVisitChild()
        {
            base.BeforeVisitChild();

            // Not supported in VB.Net
            // VB6 reference: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa243378(v=vs.60)

            var m = new UnSupportedGoSubReturn(ParserContext.Start.Line, ParserContext.Start.Column);

            RootModule.AddConversionMessage(m);
            var c = new VBConversionMessage(m);

            ParentCodeBlock.AddCodeModel(c);
        }
示例#8
0
    public CuboidMap GetCuboidMap(Frame frame, bool mirrored)
    {
        CuboidMap  sensor = new CuboidMap(Resolution);
        RootModule module = (RootModule)Data.GetModule(ID.Root);

        if (module != null)
        {
            Vector3    position = module.GetRootPosition(frame, mirrored);
            Quaternion rotation = module.GetRootRotation(frame, mirrored);
            sensor.Sense(Matrix4x4.TRS(position + new Vector3(0f, 0.5f * Size.y, 0f), rotation, Vector3.one), Mask, Size);
        }
        else
        {
            sensor.Sense(frame.GetBoneTransformation(0, mirrored), Mask, Size);
        }
        return(sensor);
    }
示例#9
0
    public DistanceMap GetDistanceMap(Frame frame, bool mirrored)
    {
        DistanceMap sensor = new DistanceMap(Resolution);
        RootModule  module = Data.GetModule <RootModule>();

        if (module != null)
        {
            Vector3    position = module.GetRootPosition(frame.Timestamp, mirrored);
            Quaternion rotation = module.GetRootRotation(frame.Timestamp, mirrored);
            sensor.Sense(Matrix4x4.TRS(position + new Vector3(0f, 0.5f * Size.y, 0f), rotation, Vector3.one), Mask, Size);
        }
        else
        {
            sensor.Sense(frame.GetBoneTransformation(0, mirrored), Mask, Size);
        }
        return(sensor);
    }
示例#10
0
        // For Demo
        internal override void BeforeVisitChild()
        {
            // Let base class parse other things first before adding warning
            base.BeforeVisitChild();

            // Give warning for Class_Terminate, cannot convert with 100% same behavior, requires manual re-factoring if doing critical tasks.
            var ctx        = ParserContext as VisualBasic6Parser.SubStmtContext;
            var methodName = ctx.ambiguousIdentifier().GetText();

            if (methodName.Equals("Class_Terminate", StringComparison.InvariantCultureIgnoreCase))
            {
                var m = new UnSupportedClassTerminate(ParserContext.Start.Line, ParserContext.Start.Column);
                RootModule.AddConversionMessage(m);
                var c = new VBConversionMessage(m);
                ParentCodeBlock.AddCodeModel(c);
            }
        }
示例#11
0
    public CylinderMap GetCylinderMap(Frame frame, bool mirrored)
    {
        CylinderMap sensor = new CylinderMap(Size, Resolution, Layers, Overlap);
        RootModule  module = (RootModule)Data.GetModule(ID.Root);

        if (module != null)
        {
            Vector3    position = module.GetRootPosition(frame, mirrored);
            Quaternion rotation = module.GetRootRotation(frame, mirrored);
            sensor.Sense(Matrix4x4.TRS(position + new Vector3(0f, 0f, 0f), rotation, Vector3.one), Mask);
        }
        else
        {
            sensor.Sense(frame.GetBoneTransformation(0, mirrored), Mask);
        }
        Samples = sensor.Points.Length;
        return(sensor);
    }
示例#12
0
    private bool HasControl(float timestamp, bool mirrored)
    {
        return(InsideRegion() && HasContact());

        bool InsideRegion()
        {
            RootModule root = GetRootModule();

            if (root == null)
            {
                return(false);
            }
            return(Vector3.Distance(root.GetRootPosition(timestamp, mirrored).ZeroY(), GetBallPosition(timestamp, mirrored).ZeroY()) <= GetControlRadius());
        }

        bool HasContact()
        {
            ContactModule contact = GetContactModule();

            if (contact == null)
            {
                return(false);
            }
            ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
            ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
            if (left == null || right == null)
            {
                return(false);
            }
            float window = 1f;

            foreach (Frame f in Data.GetFrames(timestamp - window, timestamp + window))
            {
                if (contact.HasContact(f, mirrored, left, right))
                {
                    return(true);
                }
            }
            return(false);
        }
    }
示例#13
0
        public CuboidMap GetInteractionGeometry(Frame frame, bool mirrored, float delta)
        {
            Interaction interaction = FindInteraction(frame);

            if (interaction == null)
            {
                RootModule module = Module.Data.GetModule(ID.Root) == null ? null : (RootModule)Module.Data.GetModule(ID.Root);
                CuboidMap  sensor = new CuboidMap(new Vector3Int(PropResolution, PropResolution, PropResolution));
                sensor.Sense(module == null ? Matrix4x4.identity : module.GetRootTransformation(frame, mirrored), LayerMask.GetMask("Interaction"), Vector3.zero);
                return(sensor);
            }
            else
            {
                CuboidMap sensor = new CuboidMap(new Vector3Int(PropResolution, PropResolution, PropResolution));
                sensor.Sense(interaction.GetCenter(), LayerMask.GetMask("Interaction"), interaction.GetExtents());
                Transformation transformation = interaction.GetComponent <Transformation>();
                if (transformation != null)
                {
                    sensor.Retransform(interaction.GetCenter(transformation.GetTransformation(GetTargetFrame(frame, delta), mirrored)));
                }
                return(sensor);
            }
        }
示例#14
0
        public Vector3 GetGoalPosition(Frame reference, float offset, bool mirrored, float delta)
        {
            Frame frame = Module.Data.GetFrame(reference.Timestamp + offset);

            if ((GetPivot(frame) == Pivot.DynamicObject || GetPivot(frame) == Pivot.StaticObject))
            {
                Interaction interaction = FindInteraction(frame);
                if (interaction == null)
                {
                    return(Vector3.zero);
                }
                else
                {
                    if (interaction.ContainsContact(GetSpecifier(frame)))
                    {
                        return(interaction.GetContact(GetSpecifier(frame)).GetPosition());
                    }
                    else
                    {
                        return(interaction.GetCenter(GetTargetFrame(frame, delta), mirrored).GetPosition());
                    }
                }
            }
            else
            {
                RootModule module = Module.Data.GetModule(ID.Root) == null ? null : (RootModule)Module.Data.GetModule(ID.Root);
                if (module == null)
                {
                    return(Vector3.zero);
                }
                else
                {
                    return(module.GetEstimatedRootPosition(reference, GetTargetTimestamp(frame, delta) - frame.Timestamp + offset, mirrored));
                }
            }
        }
示例#15
0
        public Quaternion GetGoalRotation(Frame reference, float offset, bool mirrored, float delta)
        {
            Frame frame = Module.Data.GetFrame(reference.Timestamp + offset);

            if ((GetPivot(frame) == Pivot.DynamicObject || GetPivot(frame) == Pivot.StaticObject))
            {
                Interaction interaction = FindInteraction(frame);
                if (interaction == null)
                {
                    return(Quaternion.identity);
                }
                else
                {
                    if (interaction.ContainsContact(GetSpecifier(frame)))
                    {
                        return(interaction.GetContact(GetSpecifier(frame)).GetRotation());
                    }
                    else
                    {
                        return(Quaternion.LookRotation(Vector3.ProjectOnPlane(interaction.GetCenter(GetTargetFrame(frame, delta), mirrored).GetForward(), Vector3.up).normalized, Vector3.up));
                    }
                }
            }
            else
            {
                RootModule module = Module.Data.GetModule(ID.Root) == null ? null : (RootModule)Module.Data.GetModule(ID.Root);
                if (module == null)
                {
                    return(Quaternion.identity);
                }
                else
                {
                    return(module.GetEstimatedRootRotation(reference, GetTargetTimestamp(frame, delta) - frame.Timestamp + offset, mirrored));
                }
            }
        }
示例#16
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.");
        }
    }
    public void LoadFrame(float timestamp)
    {
        Timestamp = timestamp;
        Actor      actor  = GetActor();
        Scene      scene  = Data.GetScene();
        Frame      frame  = GetCurrentFrame();
        RootModule module = (RootModule)Data.GetModule(Module.ID.Root);
        Matrix4x4  root   = module == null?frame.GetBoneTransformation(0, Mirror) : module.GetRootTransformation(frame, Mirror);

        actor.transform.position = root.GetPosition();
        actor.transform.rotation = root.GetRotation();
        UpdateBoneMapping();
        for (int i = 0; i < actor.Bones.Length; i++)
        {
            if (BoneMapping[i] == -1)
            {
                Debug.Log("Bone " + actor.Bones[i].GetName() + " could not be mapped.");
            }
            else
            {
                Matrix4x4 transformation = frame.GetBoneTransformation(BoneMapping[i], Mirror);
                Vector3   velocity       = frame.GetBoneVelocity(BoneMapping[i], Mirror, 1f / TargetFramerate);
                Vector3   acceleration   = frame.GetBoneAcceleration(BoneMapping[i], Mirror, 1f / TargetFramerate);
                Vector3   force          = frame.GetBoneMass(BoneMapping[i], Mirror) * acceleration;
                actor.Bones[i].Transform.position = transformation.GetPosition();
                actor.Bones[i].Transform.rotation = transformation.GetRotation();
                actor.Bones[i].Velocity           = velocity;
                actor.Bones[i].Acceleration       = acceleration;
                actor.Bones[i].Force = force;
            }
        }
        foreach (GameObject instance in scene.GetRootGameObjects())
        {
            instance.transform.localScale = Vector3.one.GetMirror(Mirror ? Data.MirrorAxis : Axis.None);
            foreach (SceneEvent e in instance.GetComponentsInChildren <SceneEvent>(true))
            {
                if (Callbacks)
                {
                    e.Callback(this);
                }
                else
                {
                    e.Identity(this);
                }
            }
        }
        foreach (Module m in Data.Modules)
        {
            if (Callbacks)
            {
                m.Callback(this);
            }
        }
        if (CameraFocus)
        {
            if (SceneView.lastActiveSceneView != null)
            {
                /*
                 * Vector3 lastPosition = SceneView.lastActiveSceneView.camera.transform.position;
                 * Quaternion lastRotation = SceneView.lastActiveSceneView.camera.transform.rotation;
                 * Vector3 position = GetActor().GetRoot().position;
                 * position.y += FocusHeight;
                 * Quaternion rotation = GetActor().GetRoot().rotation;
                 * rotation.x = 0f;
                 * rotation.z = 0f;
                 * rotation = Quaternion.Euler(0f, Mirror ? Mathf.Repeat(FocusAngle + 0f, 360f) : FocusAngle, 0f) * rotation;
                 * position += FocusOffset * (rotation * Vector3.right);
                 * SceneView.lastActiveSceneView.LookAtDirect(Vector3.Lerp(lastPosition, position, 1f-FocusSmoothing), Quaternion.Slerp(lastRotation, rotation, (1f-FocusSmoothing)), FocusDistance*(1f-FocusSmoothing));
                 */

                Vector3    lastPosition = SceneView.lastActiveSceneView.camera.transform.position;
                Quaternion lastRotation = SceneView.lastActiveSceneView.camera.transform.rotation;
                Vector3    position     = GetActor().GetRoot().position;
                position   += Quaternion.Euler(0f, FocusAngle, 0f) * (FocusDistance * Vector3.forward);
                position.y += FocusHeight;
                Quaternion rotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(GetActor().GetRoot().position - position, Vector3.up).normalized, Vector3.up);
                SceneView.lastActiveSceneView.LookAtDirect(Vector3.Lerp(lastPosition, position, 1f - FocusSmoothing), Quaternion.Slerp(lastRotation, rotation, (1f - FocusSmoothing)), FocusDistance * (1f - FocusSmoothing));
            }
        }
    }
示例#18
0
    public void ComputeInteraction()
    {
        Interactors = new string[Data.Frames.Length];
        for (int i = 0; i < Interactors.Length; i++)
        {
            Interactors[i] = null;
        }

        bool IsValid(MotionData asset)
        {
            return(asset.GetName().Contains("_P0"));
        }

        string GetID(MotionData asset)
        {
            return(asset.GetName().Substring(0, asset.GetName().LastIndexOf("_P0")));
        }

        MotionEditor editor = MotionEditor.GetInstance();

        if (editor.GetAsset() != Data)
        {
            Debug.Log("Asset " + Data.GetName() + " is not loaded.");
            return;
        }
        if (IsValid(Data))
        {
            int pivot = editor.GetAssetIndex();

            //Collect all assets of same capture
            List <MotionData> assets = new List <MotionData>();
            assets.Add(Data);
            for (int i = pivot - 1; i >= 0; i--)
            {
                MotionData asset = editor.GetAsset(i);
                if (IsValid(asset) && GetID(Data) == GetID(asset))
                {
                    assets.Add(asset);
                }
                else
                {
                    break;
                }
            }
            for (int i = pivot + 1; i < editor.Assets.Length; i++)
            {
                MotionData asset = editor.GetAsset(i);
                if (IsValid(asset) && GetID(Data) == GetID(asset))
                {
                    assets.Add(asset);
                }
                else
                {
                    break;
                }
            }

            //Find closest interaction inside area
            for (int i = 0; i < Data.Frames.Length; i++)
            {
                Frame     frame    = Data.Frames[i];
                Matrix4x4 root     = GetRoot(frame.Timestamp, false);
                float     distance = GetInteractionRadius();
                foreach (MotionData data in assets)
                {
                    if (Data != data)
                    {
                        RootModule m = Data.GetModule <RootModule>();
                        if (m != null)
                        {
                            Matrix4x4 candidate = m.GetRootTransformation(frame.Timestamp, false);
                            float     d         = Vector3.Distance(root.GetPosition(), candidate.GetPosition());
                            if (d < distance)
                            {
                                distance       = d;
                                Interactors[i] = Utility.GetAssetGUID(data);
                            }
                        }
                    }
                }
            }
        }
    }
示例#19
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);
    }
示例#20
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (NestedModules.Expression != null)
            {
                targetCommand.AddParameter("NestedModules", NestedModules.Get(context));
            }

            if (Guid.Expression != null)
            {
                targetCommand.AddParameter("Guid", Guid.Get(context));
            }

            if (Author.Expression != null)
            {
                targetCommand.AddParameter("Author", Author.Get(context));
            }

            if (CompanyName.Expression != null)
            {
                targetCommand.AddParameter("CompanyName", CompanyName.Get(context));
            }

            if (Copyright.Expression != null)
            {
                targetCommand.AddParameter("Copyright", Copyright.Get(context));
            }

            if (RootModule.Expression != null)
            {
                targetCommand.AddParameter("RootModule", RootModule.Get(context));
            }

            if (ModuleVersion.Expression != null)
            {
                targetCommand.AddParameter("ModuleVersion", ModuleVersion.Get(context));
            }

            if (Description.Expression != null)
            {
                targetCommand.AddParameter("Description", Description.Get(context));
            }

            if (ProcessorArchitecture.Expression != null)
            {
                targetCommand.AddParameter("ProcessorArchitecture", ProcessorArchitecture.Get(context));
            }

            if (PowerShellVersion.Expression != null)
            {
                targetCommand.AddParameter("PowerShellVersion", PowerShellVersion.Get(context));
            }

            if (ClrVersion.Expression != null)
            {
                targetCommand.AddParameter("ClrVersion", ClrVersion.Get(context));
            }

            if (DotNetFrameworkVersion.Expression != null)
            {
                targetCommand.AddParameter("DotNetFrameworkVersion", DotNetFrameworkVersion.Get(context));
            }

            if (PowerShellHostName.Expression != null)
            {
                targetCommand.AddParameter("PowerShellHostName", PowerShellHostName.Get(context));
            }

            if (PowerShellHostVersion.Expression != null)
            {
                targetCommand.AddParameter("PowerShellHostVersion", PowerShellHostVersion.Get(context));
            }

            if (RequiredModules.Expression != null)
            {
                targetCommand.AddParameter("RequiredModules", RequiredModules.Get(context));
            }

            if (TypesToProcess.Expression != null)
            {
                targetCommand.AddParameter("TypesToProcess", TypesToProcess.Get(context));
            }

            if (FormatsToProcess.Expression != null)
            {
                targetCommand.AddParameter("FormatsToProcess", FormatsToProcess.Get(context));
            }

            if (ScriptsToProcess.Expression != null)
            {
                targetCommand.AddParameter("ScriptsToProcess", ScriptsToProcess.Get(context));
            }

            if (RequiredAssemblies.Expression != null)
            {
                targetCommand.AddParameter("RequiredAssemblies", RequiredAssemblies.Get(context));
            }

            if (FileList.Expression != null)
            {
                targetCommand.AddParameter("FileList", FileList.Get(context));
            }

            if (ModuleList.Expression != null)
            {
                targetCommand.AddParameter("ModuleList", ModuleList.Get(context));
            }

            if (FunctionsToExport.Expression != null)
            {
                targetCommand.AddParameter("FunctionsToExport", FunctionsToExport.Get(context));
            }

            if (AliasesToExport.Expression != null)
            {
                targetCommand.AddParameter("AliasesToExport", AliasesToExport.Get(context));
            }

            if (VariablesToExport.Expression != null)
            {
                targetCommand.AddParameter("VariablesToExport", VariablesToExport.Get(context));
            }

            if (CmdletsToExport.Expression != null)
            {
                targetCommand.AddParameter("CmdletsToExport", CmdletsToExport.Get(context));
            }

            if (DscResourcesToExport.Expression != null)
            {
                targetCommand.AddParameter("DscResourcesToExport", DscResourcesToExport.Get(context));
            }

            if (PrivateData.Expression != null)
            {
                targetCommand.AddParameter("PrivateData", PrivateData.Get(context));
            }

            if (Tags.Expression != null)
            {
                targetCommand.AddParameter("Tags", Tags.Get(context));
            }

            if (ProjectUri.Expression != null)
            {
                targetCommand.AddParameter("ProjectUri", ProjectUri.Get(context));
            }

            if (LicenseUri.Expression != null)
            {
                targetCommand.AddParameter("LicenseUri", LicenseUri.Get(context));
            }

            if (IconUri.Expression != null)
            {
                targetCommand.AddParameter("IconUri", IconUri.Get(context));
            }

            if (ReleaseNotes.Expression != null)
            {
                targetCommand.AddParameter("ReleaseNotes", ReleaseNotes.Get(context));
            }

            if (HelpInfoUri.Expression != null)
            {
                targetCommand.AddParameter("HelpInfoUri", HelpInfoUri.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (DefaultCommandPrefix.Expression != null)
            {
                targetCommand.AddParameter("DefaultCommandPrefix", DefaultCommandPrefix.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }