Exemple #1
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public override void Unserialize(System.IO.BinaryReader reader)
        {
            tried   = false;
            version = reader.ReadUInt32();

            string name = reader.ReadString();
            uint   myid = reader.ReadUInt32();

            sgres.Unserialize(reader);
            sgres.BlockID = myid;

            if (Parent.Fast)
            {
                elements.Clear();
                links.Clear();
                groups.Clear();
                joints.Clear();
                return;
            }

            int count = reader.ReadInt32();

            elements.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcElement e = new GmdcElement(this);
                e.Unserialize(reader);
                elements.Add(e);
            }

            count = reader.ReadInt32();
            links.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcLink l = new GmdcLink(this);
                l.Unserialize(reader);
                links.Add(l);
            }

            count = reader.ReadInt32();
            groups.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcGroup g = new GmdcGroup(this);
                g.Unserialize(reader);
                groups.Add(g);
            }

            model.Unserialize(reader);

            count = reader.ReadInt32();
            joints.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcJoint s = new GmdcJoint(this);
                s.Unserialize(reader);
                joints.Add(s);
            }
        }
Exemple #2
0
        /// <summary>
        /// Remove the Group with the given Index from the File
        /// </summary>
        /// <param name="index">The index of the Element</param>
        public void RemoveGroup(int index)
        {
            if (index < groups.Count)
            {
                GmdcGroup g = groups[index];
                int       n = g.LinkIndex;
                g.LinkIndex = -1;
                RemoveLink(n);

                groups.RemoveAt(index);
            }
        }
Exemple #3
0
        void AddEnvelopes(GmdcGroup g, Ambertation.Scenes.Mesh m, GmdcElement bonee, GmdcElement bonewighte, Hashtable jointmap)
        {
            if (bonee != null && true)
            {
                int pos = 0;
                foreach (SimPe.Plugin.Gmdc.GmdcElementValueOneInt vi in bonee.Values)
                {
                    byte[]       data = vi.Bytes;
                    IntArrayList used = new IntArrayList();

                    for (int datapos = 0; datapos < 3; datapos++)                 //we can only store 3 bone weights
                    {
                        byte b = data[datapos];
                        if (b != 0xff && b < g.UsedJoints.Count)
                        {
                            int bnr = g.UsedJoints[b];
                            if (used.Contains(bnr))
                            {
                                continue;
                            }


                            used.Add(bnr);
                            Ambertation.Scenes.Joint nj = jointmap[bnr] as Ambertation.Scenes.Joint;
                            if (nj != null)
                            {
                                double w = 1;
                                if (bonewighte != null)
                                {
                                    if (bonewighte.Values.Count > pos)
                                    {
                                        SimPe.Plugin.Gmdc.GmdcElementValueBase v = bonewighte.Values[pos];
                                        if (datapos < v.Data.Length)
                                        {
                                            w = v.Data[datapos];
                                        }
                                    }
                                }

                                //if there is no envelope for nj, make sure we get a new one
                                //with pos 0-Weights inserted
                                Ambertation.Scenes.Envelope e = m.GetJointEnvelope(nj, pos);
                                e.Weights.Add(w);
                                //added = true;
                            }
                        }
                    }

                    pos++;
                    m.SyncEnvelopeLenghts(pos); //fill all unset EnvelopeWeights with 0
                }                               // bonee.Values
            }
        }