Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        void AddJoint(Ambertation.Scenes.Joint parent, int index, Hashtable jointmap, ElementOrder component)
        {
            if (!joints)
            {
                return;
            }
            if (index < 0 || index >= gmdc.Joints.Count)
            {
                return;
            }

            GmdcJoint j = gmdc.Joints[index];

            Ambertation.Scenes.Joint nj = parent.CreateChild(j.Name);
            jointmap[index] = nj;

            if (j.AssignedTransformNode != null)
            {
                Vector3f tmp = j.AssignedTransformNode.Transformation.Translation;
                tmp = component.TransformScaled(tmp);
                //tmp = component.ScaleMatrix * tmp;

                nj.Translation.X = tmp.X; nj.Translation.Y = tmp.Y; nj.Translation.Z = tmp.Z;

                Quaternion q = component.TransformRotation(j.AssignedTransformNode.Transformation.Rotation);
                tmp = q.GetEulerAngles();

                //Console.WriteLine("        "+q.ToLinedString());
                nj.Rotation.X = tmp.X; nj.Rotation.Y = tmp.Y; nj.Rotation.Z = tmp.Z;

                IntArrayList li = j.AssignedTransformNode.ChildBlocks;
                foreach (int i in li)
                {
                    SimPe.Interfaces.Scenegraph.ICresChildren cld = j.AssignedTransformNode.GetBlock(i);
                    if (cld is TransformNode)
                    {
                        TransformNode tn = cld as TransformNode;
                        if (tn.JointReference != TransformNode.NO_JOINT)
                        {
                            AddJoint(nj, tn.JointReference, jointmap, component);
                        }
                    }
                }
            }
        }