Esempio n. 1
0
 public ScriptModifier()
 {
     Name       = new Slot("Name");
     Name.value = "";
     Col        = new Slot("Color");
     Col.value  = new Color(0.7f, 0.8f, 1.0f, 1.0f);
     Prev       = new PoseSlot("Prev");
 }
Esempio n. 2
0
        public PoseBlend()
        {
            Name  = new Slot("Name");
            Count = new Slot("Count");
            Index = new Slot("Index");
            Poses = new PoseSlot[0];

            Name.value = "Pose Blend";
            UpdateCount(2);
            Index.value = 0;
        }
Esempio n. 3
0
 public Modifier()
 {
     output      = new YPROutput();
     nodes       = new List <Node> ();
     Name        = new Slot("Name");
     Name.value  = "Camera Mode";
     Prev        = new PoseSlot("Prev");
     time        = 0;
     Life        = new Slot("Life");
     Life.value  = 1e+20;
     Col         = new Slot("Color");
     Col.value   = new Color(1.0f, 0.8f, 1.0f, 1.0f);
     graphCenter = new Vector2(-150, 100);
 }
Esempio n. 4
0
        public void UpdateCount(int count)
        {
            count       = Mathf.Clamp(count, 1, 16);
            Count.input = null;
            Count.value = count;
            PoseSlot[] new_poses = new PoseSlot[count];
            int        old_count = Poses.Length;
            int        min_count = Mathf.Min(count, old_count);

            Array.Copy(Poses, new_poses, min_count);
            for (int i = 0; i < count; ++i)
            {
                if (new_poses[i] == null)
                {
                    new_poses[i] = new PoseSlot("P[" + i.ToString() + "]");
                }
            }
            Poses   = new_poses;
            Weights = new float[count];
            Weights[currentIndex] = 1f;
        }
Esempio n. 5
0
        internal override void Read(System.IO.BinaryReader r)
        {
            if (controller == null)
            {
                Debug.LogError("no modifier!");
                return;
            }

            editorPos.x = r.ReadSingle();
            editorPos.y = r.ReadSingle();

            Slot[] _slots = this.slots;
            int    scnt   = r.ReadInt32();

            for (int s = 0; s < scnt; ++s)
            {
                string _name = r.ReadString();
                Slot   slot  = null;
                for (int i = 0; i < _slots.Length; ++i)
                {
                    if (_slots[i].name == _name)
                    {
                        slot = _slots[i];
                        break;
                    }
                }

                if (slot != null)
                {
                    int index = r.ReadInt32();
                    if (index != -1)
                    {
                        slot.input = null;
                        if (index >= 0 && index < controller.nodes.Count)
                        {
                            slot.input = controller.nodes[index];
                        }
                    }
                    else
                    {
                        slot.input = null;
                        slot.value.Read(r);
                    }
                }
                else
                {
                    int index = r.ReadInt32();
                    if (index == -1)
                    {
                        Var v = Var.Null;
                        v.Read(r);
                    }
                }
            }

            UpdateCount(Mathf.RoundToInt(Count.value.value_f));

            PoseSlot[] _poseslots = this.poseslots;
            int        sscnt      = r.ReadInt32();

            for (int s = 0; s < sscnt; ++s)
            {
                string   _name    = r.ReadString();
                PoseSlot poseslot = null;
                for (int i = 0; i < _poseslots.Length; ++i)
                {
                    if (_poseslots[i].name == _name)
                    {
                        poseslot = _poseslots[i];
                        break;
                    }
                }

                int index = r.ReadInt32();
                if (poseslot != null)
                {
                    if (index != -1)
                    {
                        poseslot.input = null;
                        if (index >= 0 && index < controller.posenodes.Count)
                        {
                            poseslot.input = controller.posenodes[index];
                        }
                        if (poseslot.input == this)
                        {
                            poseslot.input = null;
                        }
                    }
                    else
                    {
                        poseslot.input = null;
                        poseslot.value = Pose.Default;
                    }
                }
            }

            int dl = r.ReadInt32();

            data = r.ReadBytes(dl);
        }
Esempio n. 6
0
 public FinalPose()
 {
     Final = new PoseSlot("Final");
 }
Esempio n. 7
0
        internal virtual void Read(BinaryReader r)
        {
            if (controller == null)
            {
                Debug.LogError("no modifier!");
                return;
            }

            editorPos.x = r.ReadSingle();
            editorPos.y = r.ReadSingle();

            Slot[] _slots = this.slots;
            int    scnt   = r.ReadInt32();

            for (int s = 0; s < scnt; ++s)
            {
                string _name = r.ReadString();
                Slot   slot  = null;
                for (int i = 0; i < _slots.Length; ++i)
                {
                    if (_slots[i].name == _name)
                    {
                        slot = _slots[i];
                        break;
                    }
                }

                if (slot != null)
                {
                    int index = r.ReadInt32();
                    if (index != -1)
                    {
                        slot.input = null;
                        if (index >= 0 && index < controller.nodes.Count)
                        {
                            slot.input = controller.nodes[index];
                        }
                    }
                    else
                    {
                        slot.input = null;
                        slot.value.Read(r);
                    }
                }
                else
                {
                    int index = r.ReadInt32();
                    if (index == -1)
                    {
                        Var v = Var.Null;
                        v.Read(r);
                    }
                }
            }

            PoseSlot[] _poseslots = this.poseslots;
            int        sscnt      = r.ReadInt32();

            for (int s = 0; s < sscnt; ++s)
            {
                string   _name    = r.ReadString();
                PoseSlot poseslot = null;
                for (int i = 0; i < _poseslots.Length; ++i)
                {
                    if (_poseslots[i].name == _name)
                    {
                        poseslot = _poseslots[i];
                        break;
                    }
                }

                int index = r.ReadInt32();
                if (poseslot != null)
                {
                    if (index != -1)
                    {
                        poseslot.input = null;
                        if (index >= 0 && index < controller.posenodes.Count)
                        {
                            poseslot.input = controller.posenodes[index];
                        }
                        if (poseslot.input == this)
                        {
                            poseslot.input = null;
                        }
                    }
                    else
                    {
                        poseslot.input = null;
                        poseslot.value = Pose.Default;
                    }
                }
            }

            int dl = r.ReadInt32();

            data = r.ReadBytes(dl);

            if (this is Modifier)
            {
                ModifierAsset ma = ScriptableObject.CreateInstance <ModifierAsset>();
                ma.modifier = this as Modifier;
                ma.data     = new byte[dl];
                Array.Copy(data, ma.data, dl);
                ma.Load(false);
                ModifierAsset.DestroyImmediate(ma);
            }
        }
Esempio n. 8
0
        internal virtual void Write(BinaryWriter w)
        {
            if (controller == null)
            {
                Debug.LogError("no controller!");
                return;
            }

            w.Write(editorPos.x);
            w.Write(editorPos.y);

            Slot[] _slots = this.slots;
            w.Write(_slots.Length);
            for (int s = 0; s < _slots.Length; ++s)
            {
                Slot slot = _slots[s];
                w.Write(slot.name);
                if (slot.input != null)
                {
                    int index = -1;
                    for (int k = 0; k < controller.nodes.Count; ++k)
                    {
                        if (slot.input == controller.nodes[k])
                        {
                            index = k;
                            break;
                        }
                    }
                    w.Write(index);
                }
                else
                {
                    w.Write((int)-1);
                    slot.value.Write(w);
                }
            }

            PoseSlot[] _poseslots = this.poseslots;
            w.Write(_poseslots.Length);
            for (int s = 0; s < _poseslots.Length; ++s)
            {
                PoseSlot poseslot = _poseslots[s];
                w.Write(poseslot.name);
                if (poseslot.input != null)
                {
                    int index = -1;
                    for (int k = 0; k < controller.posenodes.Count; ++k)
                    {
                        if (poseslot.input == controller.posenodes[k])
                        {
                            index = k;
                            break;
                        }
                    }
                    w.Write(index);
                }
                else
                {
                    w.Write((int)-1);
                }
            }

            data = new byte[0];

            if (this is Modifier)
            {
                ModifierAsset ma = ScriptableObject.CreateInstance <ModifierAsset>();
                ma.modifier = this as Modifier;
                ma.Save();
                data = new byte[ma.data.Length];
                Array.Copy(ma.data, data, ma.data.Length);
                ModifierAsset.DestroyImmediate(ma);
            }

            w.Write((int)(data.Length));
            w.Write(data, 0, (int)(data.Length));
        }
Esempio n. 9
0
 public SetUserPose()
 {
     V = new Slot("Var");
     P = new PoseSlot("Pose");
 }