public Signal AddSignal(string name)
    {
        Signal signal = new Signal(this, name);

        ArrayExtensions.Add(ref Signals, signal);
        return(signal);
    }
示例#2
0
    private Segment AddSegment(string name, Segment parent)
    {
        Segment segment = new Segment(name, parent, Hierarchy.Length);

        ArrayExtensions.Add(ref Hierarchy, segment);
        return(segment);
    }
示例#3
0
 public void DefaultAction()
 {
     ArrayExtensions.Add(ref Actions, new Action(this, "Neutral"));
     ArrayExtensions.Add(ref Actions, new Action(this, "Cross Arms"));
     ArrayExtensions.Add(ref Actions, new Action(this, "LH on Hip"));
     ArrayExtensions.Add(ref Actions, new Action(this, "RH on Hip"));
 }
    public Sensor AddSensor(string bone, Vector3 offset, float threshold, float tolerance, float velocity, Sensor.ID capture, Sensor.ID edit)
    {
        Sensor sensor = new Sensor(this, Data.Source.FindBone(bone).Index, offset, threshold, tolerance, velocity, capture, edit);

        ArrayExtensions.Add(ref Sensors, sensor);
        return(sensor);
    }
示例#5
0
    public Module AddModule(Module.ID type)
    {
        Module module = System.Array.Find(Modules, x => x.GetID() == type);

        if (module != null)
        {
            Debug.Log("Module of type " + type + " already exists in " + GetName() + ".");
        }
        else
        {
            string id = type + "Module";
            module = (Module)ScriptableObject.CreateInstance(id);
            if (module == null)
            {
                Debug.Log("Module of class type " + id + " could not be loaded in " + GetName() + ".");
            }
            else
            {
                module.Init(this);
                ArrayExtensions.Add(ref Modules, module);
                AssetDatabase.AddObjectToAsset(Modules.Last(), this);
            }
        }
        return(module);
    }
示例#6
0
    public void ExtractSkeleton(Transform[] bones)
    {
        ArrayExtensions.Clear(ref Bones);
        Action <Transform, Bone> recursion = null;

        recursion = new Action <Transform, Bone>((transform, parent) => {
            if (System.Array.Find(bones, x => x == transform))
            {
                Bone bone = new Bone(this, transform, Bones.Length);
                ArrayExtensions.Add(ref Bones, bone);
                if (parent != null)
                {
                    bone.Parent = parent.Index;
                    bone.ComputeLength();
                    ArrayExtensions.Add(ref parent.Childs, bone.Index);
                }
                parent = bone;
            }
            for (int i = 0; i < transform.childCount; i++)
            {
                recursion(transform.GetChild(i), parent);
            }
        });
        recursion(GetRoot(), null);
    }
示例#7
0
    public void AddModule(Module.TYPE type)
    {
        if (System.Array.Find(Modules, x => x.Type() == type))
        {
            Debug.Log("Module of type " + type.ToString() + " already exists.");
        }
        else
        {
            switch (type)
            {
            case Module.TYPE.Style:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <StyleModule>().Initialise(this));
                break;

            case Module.TYPE.Phase:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <PhaseModule>().Initialise(this));
                break;

            case Module.TYPE.Contact:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <ContactModule>().Initialise(this));
                break;

            case Module.TYPE.DepthMap:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <DepthMapModule>().Initialise(this));
                break;

            case Module.TYPE.HeightMap:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <HeightMapModule>().Initialise(this));
                break;
            }
            AssetDatabase.AddObjectToAsset(Modules[Modules.Length - 1], this);
        }
    }
示例#8
0
    public void AddModule(Module.TYPE type)
    {
        if (System.Array.Find(Modules, x => x.Type() == type))
        {
            Debug.Log("Module of type " + type.ToString() + " already exists.");
        }
        else
        {
            switch (type)
            {
            case Module.TYPE.Trajectory:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <TrajectoryModule>().Initialise(this));
                break;

            case Module.TYPE.Style:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <StyleModule>().Initialise(this));
                break;

            case Module.TYPE.Phase:
                ArrayExtensions.Add(ref Modules, ScriptableObject.CreateInstance <PhaseModule>().Initialise(this));
                break;

            default:
                Debug.Log("Module of type " + type.ToString() + " not considered.");
                return;
            }
            AssetDatabase.AddObjectToAsset(Modules[Modules.Length - 1], this);
        }
    }
示例#9
0
 public void AddAction(string name)
 {
     if (Array.Exists(Actions, x => x.Name == name))
     {
         Debug.Log("Action with name " + name + " already exists.");
         return;
     }
     ArrayExtensions.Add(ref Actions, new Action(this, name));
 }
示例#10
0
 public void AddStyle(string name)
 {
     if (System.Array.Exists(Functions, x => x.Name == name))
     {
         Debug.Log("Style with name " + name + " already exists.");
         return;
     }
     ArrayExtensions.Add(ref Functions, new StyleFunction(this, name));
 }
 public void AddStyle(string name)
 {
     ArrayExtensions.Add(ref Styles, name);
     for (int i = 0; i < GetTotalFrames(); i++)
     {
         ArrayExtensions.Add(ref Frames[i].StyleFlags, false);
         ArrayExtensions.Add(ref Frames[i].StyleValues, 0);
     }
 }
示例#12
0
 public void AddContact(int sensor)
 {
     if (System.Array.Exists(Functions, x => x.Sensor == sensor))
     {
         Debug.Log("Contact for bone " + sensor + " already exists.");
         return;
     }
     ArrayExtensions.Add(ref Functions, new ContactFunction(this, sensor));
 }
示例#13
0
 public Segment(string name, Segment parent, int index)
 {
     Name  = name;
     Index = index;
     if (parent != null)
     {
         Parent = parent.Index;
         ArrayExtensions.Add(ref parent.Childs, index);
     }
     Childs         = new int[0];
     Transformation = Matrix4x4.identity;
 }
示例#14
0
 public void AddShape(Shape shape)
 {
     if (Shapes == null)
     {
         Shapes = new Shape[0];
         ArrayExtensions.Add(ref Shapes, shape);
     }
     else
     {
         ArrayExtensions.Add(ref Shapes, shape);
     }
 }
示例#15
0
 private void Add(Series series)
 {
     ArrayExtensions.Add(ref Data, series);
     if (series.TimeSeries != null)
     {
         Debug.Log("Data is already added to another time series.");
     }
     else
     {
         series.TimeSeries = this;
     }
 }
示例#16
0
        public override void OnInspectorGUI()
        {
            Target.SolverType = EditorGUILayout.Popup("IK Solver", Target.SolverType, SolverNames);

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            Target.MyActor = EditorGUILayout.ObjectField("Actor:", Target.MyActor, typeof(Actor), true) as Actor;
            if (EditorGUI.EndChangeCheck())
            {
                Target.Chains    = new IKChain[1];
                Target.Chains[0] = new IKChain(0, Target.MyActor.Bones.Length - 1);
            }

            if (GUILayout.Button("New Chain", GUILayout.Width(80.0f)))
            {
                ArrayExtensions.Add(ref Target.Chains, new IKChain(0, Target.MyActor.Bones.Length - 1));
            }
            EditorGUILayout.EndHorizontal();

            if (Target.MyActor != null && Target.Chains.Length > 0)
            {
                BoneNames = Target.MyActor.GetBoneNames();
                for (int i = 0; i < Target.Chains.Length; i++)
                {
                    using (new EditorGUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("IK Chain " + (i + 1));
                        if (GUILayout.Button("Delete", GUILayout.Width(80.0f)))
                        {
                            ArrayExtensions.RemoveAt(ref Target.Chains, i);
                            continue;
                        }
                        EditorGUILayout.EndHorizontal();

                        Target.Chains[i].RootIndex     = EditorGUILayout.Popup("Root Joint", Target.Chains[i].RootIndex, BoneNames);
                        Target.Chains[i].EffectorIndex = EditorGUILayout.Popup("Effector Joint:", Target.Chains[i].EffectorIndex, BoneNames);

                        Target.Chains[i].TargetObject = EditorGUILayout.ObjectField("Target:", Target.Chains[i].TargetObject, typeof(GameObject), true) as GameObject;
                        //if(Target.SolverType == 0)
                        //{
                        //    Target.Chains[i].PoleObject = EditorGUILayout.ObjectField("Pole:", Target.Chains[i].PoleObject, typeof(GameObject), true) as GameObject;
                        //}
                    }
                }
            }

            Target.MaxItr      = EditorGUILayout.IntField("Iteration Time:", Target.MaxItr);
            Target.ErrThrehold = EditorGUILayout.FloatField("Accuracy:", Target.ErrThrehold);

            EditorUtility.SetDirty(target);
        }
示例#17
0
        private void InspectSkeleton(Transform transform, int indent)
        {
            Bone bone = Target.FindBone(transform.name);

            Utility.SetGUIColor(bone == null ? UltiDraw.LightGrey : UltiDraw.Mustard);
            using (new EditorGUILayout.HorizontalScope("Box")) {
                Utility.ResetGUIColor();
                EditorGUILayout.BeginHorizontal();
                for (int i = 0; i < indent; i++)
                {
                    EditorGUILayout.LabelField("|", GUILayout.Width(20f));
                }
                EditorGUILayout.LabelField("-", GUILayout.Width(20f));
                EditorGUILayout.LabelField(transform.name + " " + (bone == null ? string.Empty : "(" + bone.Index.ToString() + ")"), GUILayout.Width(100f), GUILayout.Height(20f));
                GUILayout.FlexibleSpace();

                /*
                 * if(bone != null) {
                 *      Utility.SetGUIColor(UltiDraw.LightGrey);
                 *      using(new EditorGUILayout.HorizontalScope ("Box")) {
                 *              Utility.ResetGUIColor();
                 *              EditorGUILayout.LabelField("Length: " + bone.Length, GUILayout.Width(100f));
                 *      }
                 * }
                 */

                if (Utility.GUIButton("Bone", bone == null ? UltiDraw.White : UltiDraw.DarkGrey, bone == null ? UltiDraw.DarkGrey : UltiDraw.White))
                {
                    Transform[] bones = new Transform[Target.Bones.Length];
                    for (int i = 0; i < bones.Length; i++)
                    {
                        bones[i] = Target.Bones[i].Transform;
                    }
                    if (bone == null)
                    {
                        ArrayExtensions.Add(ref bones, transform);
                        Target.ExtractSkeleton(bones);
                    }
                    else
                    {
                        ArrayExtensions.Remove(ref bones, transform);
                        Target.ExtractSkeleton(bones);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            for (int i = 0; i < transform.childCount; i++)
            {
                InspectSkeleton(transform.GetChild(i), indent + 1);
            }
        }
示例#18
0
 public void Feed(float value, string name, float weight = 1f)
 {
     if (!Setup)
     {
         ArrayExtensions.Add(ref Values, value);
         ArrayExtensions.Add(ref Names, name);
         ArrayExtensions.Add(ref Weights, weight);
     }
     else
     {
         Dim            += 1;
         Values[Dim - 1] = value;
     }
 }
示例#19
0
 public void AddStyle(string name)
 {
     ArrayExtensions.Add(ref Styles, name);
     for (int i = 0; i < GetTotalFrames(); i++)
     {
         ArrayExtensions.Add(ref Frames[i].StyleFlags, false);
         ArrayExtensions.Add(ref Frames[i].StyleValues, 0);
     }
     for (int s = 0; s < Sequences.Length; s++)
     {
         ArrayExtensions.Add(ref Sequences[s].TransitionCopies, 0);
         ArrayExtensions.Add(ref Sequences[s].StyleCopies, 0);
     }
 }
示例#20
0
 public void LoadAnimations()
 {
     Animations = new AnimationClip[0];
     Import     = new bool[0];
     foreach (string file in System.IO.Directory.GetFiles(Source))
     {
         AnimationClip clip = (AnimationClip)AssetDatabase.LoadAssetAtPath(file, typeof(AnimationClip));
         if (clip != null)
         {
             ArrayExtensions.Add(ref Animations, clip);
             ArrayExtensions.Add(ref Import, true);
         }
     }
 }
示例#21
0
 public void Import(string fn, string id)
 {
     for (int i = 0; i < Buffers.Length; i++)
     {
         if (Buffers[i] != null)
         {
             if (Buffers[i].ID == id)
             {
                 Debug.Log("Buffer with ID " + id + " already contained.");
                 return;
             }
         }
     }
     ArrayExtensions.Add(ref Buffers, ReadBinary(fn, id));
 }
示例#22
0
 public void Store(string fn, int rows, int cols, string id)
 {
     for (int i = 0; i < Matrices.Length; i++)
     {
         if (Matrices[i] != null)
         {
             if (Matrices[i].ID == id)
             {
                 Debug.Log("Matrix with ID " + id + " already contained.");
                 return;
             }
         }
     }
     ArrayExtensions.Add(ref Matrices, ReadBinary(fn, rows, cols, id));
 }
示例#23
0
    //public void ParticleIK()
    //{

    //}

    private void SetChainIndices(int index)
    {
        int[]      indices  = new int[0];
        Actor.Bone root     = MyActor.Bones[Chains[index].RootIndex];
        Actor.Bone effector = MyActor.Bones[Chains[index].EffectorIndex];
        Actor.Bone current  = effector;

        while (current != root)
        {
            ArrayExtensions.Add(ref indices, current.Index);
            current = MyActor.Bones[current.Parent];
        }

        ArrayExtensions.Add(ref indices, root.Index);
        Array.Reverse(indices, 0, indices.Length);

        Chains[index].JointIndices = indices;
    }
示例#24
0
    public void AddPlugin(MotionPlugin.TYPE type)
    {
        if (System.Array.Exists(Plugins, x => x.Type == type))
        {
            Debug.Log("Plugin of type " + type.ToString() + " already exists.");
        }
        else
        {
            switch (type)
            {
            case MotionPlugin.TYPE.Style:
                ArrayExtensions.Add(ref Plugins, new StylePlugin(this));
                break;

            case MotionPlugin.TYPE.Phase:
                ArrayExtensions.Add(ref Plugins, new PhasePlugin(this));
                break;
            }
        }
    }
    public void AddContact()
    {
        Transform container = transform.Find("Contacts");

        if (container == null)
        {
            container = new GameObject("Contacts").transform;
            container.SetParent(transform);
            container.localPosition = Vector3.zero;
            container.localRotation = Quaternion.identity;
            container.localScale    = Vector3.one;
        }
        Transform contact = new GameObject("Contact").transform;

        contact.SetParent(container);
        contact.transform.localPosition = Vector3.zero;
        contact.transform.localRotation = Quaternion.identity;
        contact.transform.localScale    = Vector3.one;
        contact.gameObject.layer        = gameObject.layer;
        ArrayExtensions.Add(ref Contacts, contact);
    }
示例#26
0
 protected override void DerivedInspector(MotionEditor editor)
 {
     EditorGUILayout.BeginHorizontal();
     if (Utility.GUIButton("Add Contact", UltiDraw.DarkGrey, UltiDraw.White))
     {
         ArrayExtensions.Add(ref Functions, new ContactFunction(this));
     }
     if (Utility.GUIButton("Remove Contact", UltiDraw.DarkGrey, UltiDraw.White))
     {
         ArrayExtensions.Shrink(ref Functions);
     }
     EditorGUILayout.EndHorizontal();
     if (Utility.GUIButton("Compute", UltiDraw.DarkGrey, UltiDraw.White))
     {
         Compute();
     }
     for (int i = 0; i < Functions.Length; i++)
     {
         Functions[i].Inspector(editor);
     }
 }
示例#27
0
    private void InspectHierarchy(Transform root, Transform transform, int indent)
    {
        Segment segment = FindSegment(transform.name);

        Utility.SetGUIColor(segment == null ? UltiDraw.White : UltiDraw.LightGrey);
        using (new EditorGUILayout.HorizontalScope("Box")) {
            Utility.ResetGUIColor();
            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < indent; i++)
            {
                EditorGUILayout.LabelField("|", GUILayout.Width(20f));
            }
            EditorGUILayout.LabelField("-", GUILayout.Width(20f));
            EditorGUILayout.LabelField(transform.name, GUILayout.Width(100f), GUILayout.Height(20f));
            GUILayout.FlexibleSpace();
            if (Utility.GUIButton("Bone", segment == null ? UltiDraw.White : UltiDraw.DarkGrey, segment == null ? UltiDraw.DarkGrey : UltiDraw.White))
            {
                if (segment == null)
                {
                    string[] names = GetBoneNames();
                    ArrayExtensions.Add(ref names, transform.name);
                    BuildHierarchy(root, names);
                }
                else
                {
                    string[] names = GetBoneNames();
                    ArrayExtensions.Remove(ref names, transform.name);
                    BuildHierarchy(root, names);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            InspectHierarchy(root, transform.GetChild(i), indent + 1);
        }
    }
示例#28
0
 public void Feed(float value, ID type, string name, float weight = 1f)
 {
     Dim += 1;
     if (Values.Length < Dim)
     {
         ArrayExtensions.Add(ref Values, value);
     }
     else
     {
         Values[Dim - 1] = value;
     }
     if (Types.Length < Dim)
     {
         ArrayExtensions.Add(ref Types, type);
     }
     if (Names.Length < Dim)
     {
         ArrayExtensions.Add(ref Names, name);
     }
     if (Weights.Length < Dim)
     {
         ArrayExtensions.Add(ref Weights, weight);
     }
 }
 public void AddMotion(float[] values)
 {
     ArrayExtensions.Add(ref Motions, new Motion(values));
 }
 public void AddBone(string name, string parent, Vector3 offset, int[] channels)
 {
     ArrayExtensions.Add(ref Bones, new Bone(Bones.Length, name, parent, offset, channels));
 }