public override void LoadData(ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData(ref oXml);

             oXml.IntoElem();

            if(oXml.FindChildElement("MuscleID", false))
            {
              string strMuscleID = oXml.GetChildString("MuscleID");
              if(m_doOrganism != null && strMuscleID.Trim().Length > 0)
                {
                    AnimatTools.DataObjects.Physical.BodyPart rbPart = (AnimatTools.DataObjects.Physical.BodyPart) m_doOrganism.FindBodyPart(strMuscleID, false);
                    if(rbPart != null)
                        m_thMuscle = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doOrganism, rbPart, m_tpBodyPartType);
                }
            }
            else
                m_thMuscle = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doOrganism, null, m_tpBodyPartType);

            m_strMuscleLengthData = oXml.GetChildString("MuscleLengthData", m_strMuscleLengthData);

            if(oXml.FindChildElement("Conductance", false))
                m_snConductance.LoadData(ref oXml, "Conductance");

            if(oXml.FindChildElement("RestPotential", false))
                m_snRestPotential.LoadData(ref oXml, "RestPotential");

            oXml.OutOfElem();
        }
예제 #2
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
        }
        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_bVisible = oXml.GetChildBool("IsVisible", m_bVisible);

            if(m_strID.Trim().Length == 0)
                m_strID = System.Guid.NewGuid().ToString();

            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;
            }

            m_fRadius = oXml.GetChildFloat("Radius", m_fRadius);
            //m_fHeight = oXml.GetChildFloat("Height", m_fHeight);

            if(oXml.FindChildElement("Direction",false))
            {
                this.m_v3Direction = new Vector3();
                Vec3d vDirection = Util.LoadVec3d(ref oXml, "Direction", this);
                m_v3Direction.X = (float)vDirection.X;
                m_v3Direction.Y = (float)vDirection.Y;
                m_v3Direction.Z = (float)vDirection.Z;
            }
            if(oXml.FindChildElement("OrientationMatrix", false))
            {
                m_mtxOrientation = Util_DX.LoadMatrix(ref oXml, "OrientationMatrix");
                m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(Orientation);
                this.Rotation = new Vec3d(null,Geometry.RadianToDegree(m_v3Rotation.X),Geometry.RadianToDegree(m_v3Rotation.Y),Geometry.RadianToDegree(m_v3Rotation.Z));
            }

            if(oXml.FindChildElement("TranslationMatrix",false))
                m_mtxTranslation = Util_DX.LoadMatrix(ref oXml,"TranslationMatrix");

            oXml.OutOfElem(); //Outof RigidBody Element
        }
        public override void LoadData(ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData(ref oXml);

            oXml.IntoElem();

            if(oXml.FindChildElement("PrimaryAttachmentID", false))
            {
              string strAttachID = oXml.GetChildString("PrimaryAttachmentID");
                if(m_doStructure != null && strAttachID.Trim().Length > 0)
                {
                    AnimatTools.DataObjects.Physical.BodyPart rbPart = (AnimatTools.DataObjects.Physical.BodyPart) m_doStructure.FindBodyPart(strAttachID, false);
                    if(rbPart != null)
                        m_thPrimaryAttachment = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doStructure, rbPart, m_tpBodyPartType);
                }
            }
            else
                m_thPrimaryAttachment = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doStructure, null, m_tpBodyPartType);

            if(oXml.FindChildElement("SecondaryAttachmentID", false))
            {
                string strAttachID = oXml.GetChildString("SecondaryAttachmentID");
                if(m_doStructure != null && strAttachID.Trim().Length > 0)
                {
                    AnimatTools.DataObjects.Physical.BodyPart rbPart = (AnimatTools.DataObjects.Physical.BodyPart) m_doStructure.FindBodyPart(strAttachID, false);
                    if(rbPart != null)
                        m_thSecondaryAttachment = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doStructure, rbPart, m_tpBodyPartType);
                }
            }
            else
                m_thSecondaryAttachment = new AnimatTools.TypeHelpers.LinkedBodyPartList(m_doStructure, null, m_tpBodyPartType);

            m_fltProportionalGain = oXml.GetChildFloat("PGain", m_fltProportionalGain);
            m_fltDerivativeGain = oXml.GetChildFloat("DGain", m_fltDerivativeGain);
            m_fltIntegratorGain = oXml.GetChildFloat("IGain", m_fltIntegratorGain);
            m_fltMaxIntegratorValue = oXml.GetChildFloat("MaxIValue", m_fltMaxIntegratorValue);
            m_snVelocity.LoadData(ref oXml, "Velocity");
            m_snMaxForce.LoadData(ref oXml, "MaxForce");

            SetPositionUnits();
            oXml.OutOfElem();
        }
예제 #5
0
        public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();
            m_fltHeight = oXml.GetChildFloat("Height", m_fltHeight);
            m_strHeightFieldImage = oXml.GetChildString("HeightFieldImage", m_strHeightFieldImage);

            if(oXml.FindChildElement("MapLocation", false))
                m_vMapLocation = Util.LoadVec3d(ref oXml, "MapLocation", this);

            if(oXml.FindChildElement("MapSize", false))
                m_vMapSize = Util.LoadVec3d(ref oXml, "MapSize", this);

            m_fltMapScale = oXml.GetChildFloat("MapScale", m_fltMapScale);
            oXml.OutOfElem(); //out of body
        }
        public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData(ref dsSim, ref doStructure, ref oXml);

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

            if(oXml.FindChildElement("NaturalLength", false))
                m_snNaturalLength.LoadData(ref oXml, "NaturalLength");

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

            //This code converts old versions of the spring code into
            //the new version that has multiple attachment points
            if(oXml.FindChildElement("PrimaryAttachmentID", false))
            {
                m_aryAttachmentPointIDs.Clear();

                string strAttachID;
                if(oXml.FindChildElement("PrimaryAttachmentID", false))
                {
                    strAttachID = oXml.GetChildString("PrimaryAttachmentID");
                    m_aryAttachmentPointIDs.Add(strAttachID);
                }

                if(oXml.FindChildElement("SecondaryAttachmentID", false))
                {
                    strAttachID = oXml.GetChildString("SecondaryAttachmentID");
                    m_aryAttachmentPointIDs.Add(strAttachID);
                }
            }

            if(oXml.FindChildElement("ForceType", false))
                m_eForceType = (VortexAnimatTools.DataObjects.Physical.RigidBodies.MultiSegmentSpring.enumForceTypes) Enum.Parse(typeof(VortexAnimatTools.DataObjects.Physical.RigidBodies.MultiSegmentSpring.enumForceTypes), oXml.GetChildString("ForceType"), true);

            oXml.OutOfElem(); //Outof RigidBody Element
        }
        public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData(ref dsSim, ref doStructure, ref oXml);

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

            string strOdorTypeID = oXml.GetChildString("OdorTypeID", "");
            if(strOdorTypeID.Length > 0)
            {
                if(Util.Environment.OdorTypes.Contains(strOdorTypeID))
                    m_thOdorType.OdorType = Util.Environment.OdorTypes.GetItem(strOdorTypeID);
            }

            oXml.OutOfElem(); //Outof RigidBody Element
        }
예제 #8
0
        public static Matrix LoadMatrix(ref AnimatTools.Interfaces.StdXml oXml, string strName)
        {
            string str = oXml.GetChildString(strName);
            string[] strMtxElem = str.Split(',');

            Matrix mtx = new Matrix();
            mtx.M11 = float.Parse(strMtxElem[0]);
            mtx.M12 = float.Parse(strMtxElem[1]);
            mtx.M13 = float.Parse(strMtxElem[2]);
            mtx.M14 = float.Parse(strMtxElem[3]);

            mtx.M21 = float.Parse(strMtxElem[4]);
            mtx.M22 = float.Parse(strMtxElem[5]);
            mtx.M23 = float.Parse(strMtxElem[6]);
            mtx.M24 = float.Parse(strMtxElem[7]);

            mtx.M31 = float.Parse(strMtxElem[8]);
            mtx.M32 = float.Parse(strMtxElem[9]);
            mtx.M33 = float.Parse(strMtxElem[10]);
            mtx.M34 = float.Parse(strMtxElem[11]);

            mtx.M41 = float.Parse(strMtxElem[12]);
            mtx.M42 = float.Parse(strMtxElem[13]);
            mtx.M43 = float.Parse(strMtxElem[14]);
            mtx.M44 = float.Parse(strMtxElem[15]);

            return mtx;
        }