예제 #1
0
        public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            m_aryChildBodies.Clear();

            oXml.IntoElem(); //'Into RigidBody Element

            m_strID = oXml.GetChildString("ID");
            m_strName = oXml.GetChildString("Name", m_strID);
            m_strDescription = oXml.GetChildString("Description", "");

            if(m_strName.Trim().Length == 0)
                m_strName = m_strID;

            if(oXml.FindChildElement("Color", false))
            {
                System.Drawing.Color oColor = Util.LoadColor(ref oXml, "Color");
                this.Alpha = oColor.A;
                this.Color = oColor;
            }

            if(oXml.FindChildElement("MuscleAttachments", false))
            {
                oXml.IntoElem();

                oXml.AddChildElement("Description", m_strDescription);

                if(oXml.NumberOfChildren() > 2)
                    throw new System.Exception("The standard spring can not have more than 2 attachment points.");
                else if(oXml.NumberOfChildren() == 2)
                {
                    oXml.FindChildByIndex(0);
                    m_strPrimaryAttachID = oXml.GetChildString();
                    oXml.FindChildByIndex(1);
                    m_strSecondaryAttachID = oXml.GetChildString();
                }
                else if(oXml.NumberOfChildren() == 1)
                {
                    oXml.FindChildByIndex(0);
                    m_strPrimaryAttachID = oXml.GetChildString();
                }
                else
                {
                    m_strPrimaryAttachID = "";
                    m_strSecondaryAttachID = "";
                }

                oXml.OutOfElem();
            }
            else
            {
                if(oXml.FindChildElement("PrimaryAttachmentID", false))
                    m_strPrimaryAttachID = oXml.GetChildString("PrimaryAttachmentID");

                if(oXml.FindChildElement("SecondaryAttachmentID", false))
                    m_strSecondaryAttachID = oXml.GetChildString("SecondaryAttachmentID");
            }

            m_snNaturalLength.LoadData(ref oXml, "NaturalLength");
            m_snStiffness.LoadData(ref oXml, "Stiffness");
            m_snDamping.LoadData(ref oXml, "Damping");

            m_bEnabled = oXml.GetChildBool("Enabled", m_bEnabled);
            m_bVisible = oXml.GetChildBool("IsVisible", m_bVisible);

            oXml.OutOfElem(); //Outof RigidBody Element
        }