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

            oXml.IntoElem();
            Util.SaveVector(ref oXml, "CollisionBoxSize", new Vec3d(null, m_vGraphicsBoxSize.X, m_vGraphicsBoxSize.Y, m_vGraphicsBoxSize.Z));
            Util.SaveVector(ref oXml, "GraphicsBoxSize", new Vec3d(null, m_vGraphicsBoxSize.X, m_vGraphicsBoxSize.Y, m_vGraphicsBoxSize.Z));

            oXml.OutOfElem(); //out of body
        }
 public override void SaveDataColumnToXml(ref AnimatTools.Interfaces.StdXml oXml)
 {
     oXml.IntoElem();
     oXml.AddChildElement("StimulusID", this.ID);
     oXml.OutOfElem();
 }
        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();

            oXml.IntoChildElement("Constraint");
            m_fltMinAngle = oXml.GetAttribFloat("Low");
            m_fltMaxAngle = oXml.GetAttribFloat("High");
            oXml.OutOfElem(); //out of Constraint

            m_snMinAngle.SetFromValue(Util.RadiansToDegrees(m_fltMinAngle), AnimatTools.Framework.ScaledNumber.enumNumericScale.None);
            m_snMaxAngle.SetFromValue(Util.RadiansToDegrees(m_fltMaxAngle), AnimatTools.Framework.ScaledNumber.enumNumericScale.None);

            m_bEnableMotor = oXml.GetChildBool("EnableMotor");
            m_bServoMotor = oXml.GetChildBool("ServoMotor", m_bServoMotor);
            m_fltServoGain = oXml.GetChildFloat("ServoGain", m_fltServoGain);

            //based on whether this is a servo motor or not the incoming data type will change.
            if(m_bServoMotor)
                m_thIncomingDataType = new AnimatTools.DataObjects.DataType("Position", "Position", "rad", "rad", -3.142, 3.142, ScaledNumber.enumNumericScale.None, ScaledNumber.enumNumericScale.None);
            else
                m_thIncomingDataType = new AnimatTools.DataObjects.DataType("DesiredVelocity", "Desired Velocity", "m/s", "m/s", -5, 5, ScaledNumber.enumNumericScale.None, ScaledNumber.enumNumericScale.None);

            if(oXml.FindChildElement("MaxTorque", false))
                m_snMaxTorque.LoadData(ref oXml, "MaxTorque");

            if(oXml.FindChildElement("MaxVelocity", false))
                m_snMaxTorque.LoadData(ref oXml, "MaxVelocity");

            //			if(oXml.FindChildElement("RotationAxis", false))
            //			{
            //				Vec3d vTmp = Util.LoadVec3d(ref oXml, "RotationAxis", this);
            //				m_v3Axis = new Vector3((float)vTmp.X, (float)vTmp.Y, (float)vTmp.Z);
            //			}

            m_v3Axis = new Vector3(0,0,1);
            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();
                m_fHalfAngle = oXml.GetChildFloat("ConstraintHalfAngle");
                Vec3d v = Util.LoadVec3d(ref oXml,"ConstraintAxis",null);
            //				this.Damping.ActualValue = oXml.GetChildFloat("Damping");
            //				this.Stiffness.ActualValue = oXml.GetChildFloat("Stiffness");

                this.m_v3Rotation.X = (float)v.X;
                this.m_v3Rotation.Y = (float)v.Y;
                this.m_v3Rotation.Z = (float)v.Z;
            oXml.OutOfElem();
        }
        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();
        }
예제 #6
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_fLowerRadius = oXml.GetChildFloat("LowerRadius");
            m_fUpperRadius = oXml.GetChildFloat("UpperRadius");
            m_fHeight = oXml.GetChildFloat("Height");
            m_snHeight.ActualValue = m_fHeight;

            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();

            //get the color of the body
            if(oXml.FindChildElement("Color"))
            {
                System.Drawing.Color oColor = Util.LoadColor(ref oXml, "Color");

                this.Alpha = oColor.A;
                this.Color = oColor;
            }

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

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

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

            oXml.IntoElem();
            oXml.AddChildElement("Height", m_fltHeight);
            oXml.AddChildElement("HeightFieldImage", m_strHeightFieldImage);
            Util.SaveVector(ref oXml, "MapLocation", m_vMapLocation);
            Util.SaveVector(ref oXml, "MapSize", m_vMapSize);
            oXml.AddChildElement("MapScale", m_fltMapScale);
            oXml.OutOfElem(); //out of body
        }
예제 #9
0
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();
            m_snMinimumFoodRadius.SaveData(ref oXml, "MinimumFoodRadius");
            oXml.OutOfElem(); //out of body
        }
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData(ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem(); //Into RigidBody Element

            m_snNaturalLength.SaveData(ref oXml, "NaturalLength");
            m_snStiffness.SaveData(ref oXml, "Stiffness");
            m_snDamping.SaveData(ref oXml, "Damping");
            oXml.AddChildElement("ForceType", m_eForceType.ToString());

            oXml.OutOfElem(); //Outof RigidBody Element
        }
예제 #11
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 SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData(ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem(); //Into RigidBody Element

            m_StimTension.SaveData(ref oXml, "StimulusTension");
            m_LengthTension.SaveData(ref oXml, "LengthTension");
            m_snKse.SaveData(ref oXml, "Kse");
            m_snKpe.SaveData(ref oXml, "Kpe");
            m_snB.SaveData(ref oXml, "B");
            m_snPeLengthPercentage.SaveData(ref oXml, "PeLength");
            m_snMinPeLengthPercentage.SaveData(ref oXml, "MinPeLength");
            m_snIbDischargeConstant.SaveData(ref oXml, "IbDischarge");

            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

            m_StimTension.LoadData(ref oXml, "StimulusTension", "StimTension");
            m_LengthTension.LoadData(ref oXml, "LengthTension", "LengthTension");
            m_snKse.LoadData(ref oXml, "Kse");
            m_snKpe.LoadData(ref oXml, "Kpe");
            m_snB.LoadData(ref oXml, "B");

            if(oXml.FindChildElement("PeLength", false))
            {
                m_snPeLengthPercentage.LoadData(ref oXml, "PeLength");
                m_snMinPeLengthPercentage.LoadData(ref oXml, "MinPeLength");
            }

            //			if(oXml.FindChildElement("IbDischarge", false))
            //				m_snIbDischargeConstant.LoadData(ref oXml, "IbDischarge");

            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();

            if(oXml.FindChildElement("Constraint", false))
            {
                oXml.IntoChildElement("Constraint");
                m_fltMinMovement = oXml.GetAttribFloat("Low");
                m_fltMaxMovement = oXml.GetAttribFloat("High");
                oXml.OutOfElem(); //out of Constraint
            }

            m_fltLength = oXml.GetChildFloat("Length", m_fltLength);
            m_bEnableMotor = oXml.GetChildBool("EnableMotor", false);
            m_bServoMotor = oXml.GetChildBool("ServoMotor", m_bServoMotor);
            m_fltServoGain = oXml.GetChildFloat("ServoGain", m_fltServoGain);

            if(oXml.FindChildElement("MaxForce", false))
                m_snMaxForce.LoadData(ref oXml, "MaxForce");

            if(oXml.FindChildElement("MaxVelocity", false))
                m_snMaxVelocity.LoadData(ref oXml, "MaxVelocity");

            oXml.OutOfElem(); //out of body
        }
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData(ref dsSim, ref doStructure, ref oXml);

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

            oXml.AddChildElement("ApplyTension", m_bApplyTension);
            m_snIaDischargeConstant.SaveData(ref oXml, "IaDischarge");
            m_snIIDischargeConstant.SaveData(ref oXml, "IIDischarge");

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

            oXml.IntoElem();

            if(!oXml.FindChildElement("Constraint", false))
                oXml.AddChildElement("Constraint");
            oXml.IntoElem();
            oXml.SetAttrib("Low",this.m_fltMinMovement);
            oXml.SetAttrib("High", this.m_fltMaxMovement);
            oXml.OutOfElem();

            oXml.AddChildElement("Length", m_fltLength);
            oXml.AddChildElement("EnableMotor",this.m_bEnableMotor);
            oXml.AddChildElement("ServoMotor",this.m_bServoMotor);
            oXml.AddChildElement("ServoGain",this.m_fltServoGain);
            m_snMaxForce.SaveData(ref oXml, "MaxForce");
            m_snMaxVelocity.SaveData(ref oXml, "MaxVelocity");

            RigidBodies.RigidBody_DX rbParent = (RigidBodies.RigidBody_DX)this.Parent;
            Vector3 v3Rot = Util_DX.DecomposeXYZRotationMatrix(this.CombinedTransformationMatrix);;
            float x = Geometry.DegreeToRadian(180);
            m_v3Axis.TransformCoordinate(Matrix.RotationX(Geometry.DegreeToRadian(180)) * Matrix.RotationY(Geometry.DegreeToRadian(180)) * Matrix.RotationZ(Geometry.DegreeToRadian(180)) * Matrix.RotationX(v3Rot.X)* Matrix.RotationY(v3Rot.Y) * Matrix.RotationZ(v3Rot.Z));
            Vec3d vRotationAxis = new Vec3d(null,m_v3Axis.X, m_v3Axis.Y, m_v3Axis.Z);
            Util.SaveVector(ref oXml, "RotationAxis", vRotationAxis);
            m_v3Axis = new Vector3(0,0,1);

            oXml.OutOfElem();
        }
        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();
        }
예제 #19
0
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();

            oXml.AddChildElement("LowerRadius", m_fLowerRadius);
            oXml.AddChildElement("UpperRadius", m_fUpperRadius);
            oXml.AddChildElement("Height", m_fHeight);
            oXml.AddChildElement("CollisionLowerRadius", m_fLowerRadius);
            oXml.AddChildElement("CollisionUpperRadius", m_fUpperRadius);
            oXml.AddChildElement("CollisionHeight", m_fHeight);

            oXml.OutOfElem(); //out of body
        }
        public override void SaveData(ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData(ref oXml);

            oXml.IntoElem();

            if(m_thPrimaryAttachment != null && m_thPrimaryAttachment.BodyPart != null)
                oXml.AddChildElement("PrimaryAttachmentID", m_thPrimaryAttachment.BodyPart.ID);

            if(m_thSecondaryAttachment != null && m_thSecondaryAttachment.BodyPart != null)
                oXml.AddChildElement("SecondaryAttachmentID", m_thSecondaryAttachment.BodyPart.ID);

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

            oXml.OutOfElem();
        }
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            //call the parents SaveData
            base.SaveData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();  //step into element

            SaveCenterOfMass(ref dsSim, ref doStructure, ref oXml);

            SaveLocation(ref dsSim, ref doStructure, ref oXml);  //Save the location of this body

            SaveRotation(ref dsSim, ref doStructure, ref oXml); //Save the rotation of this body

            Util.SaveVector(ref oXml, "Direction", new Vec3d(null, this.Direction.X, this.Direction.Y, this.Direction.Z));

            Util.SaveColor(ref oXml, "Color", m_d3dMaterial.Diffuse); //save the color of this body

            Util_DX.SaveMatrix(ref oXml, "OrientationMatrix", Orientation);
            Util_DX.SaveMatrix(ref oXml, "TranslationMatrix", Translation);
            Util_DX.SaveMatrix(ref oXml, "CombinedTransformationMatrix", this.CombinedTransformationMatrix);

            oXml.OutOfElem(); //step out of the element
        }
        public override void SaveXml(ref AnimatTools.Interfaces.StdXml oXml)
        {
            if(m_doStructure == null)
                throw new System.Exception("No structure was defined for the stimulus '" + m_strName + "'.");

            if(m_doBodyPart == null)
                throw new System.Exception("No bodypart was defined for the stimulus '" + m_strName + "'.");

            if(m_thPrimaryAttachment != null && m_thPrimaryAttachment.BodyPart != null &&
                m_thSecondaryAttachment != null && m_thSecondaryAttachment.BodyPart != null)
            {
                oXml.AddChildElement("Stimulus");

                oXml.IntoElem();
                oXml.AddChildElement("ID", m_strID);
                oXml.AddChildElement("Name", m_strName);
                oXml.AddChildElement("AlwaysActive", m_bAlwaysActive);

                oXml.AddChildElement("ModuleName", this.StimulusModuleName);
                oXml.AddChildElement("Type", this.StimulusClassType);

                oXml.AddChildElement("StartTime", m_snStartTime.ActualValue);
                oXml.AddChildElement("EndTime", m_snEndTime.ActualValue);

                oXml.AddChildElement("StructureID", m_doStructure.ID);
                oXml.AddChildElement("BodyID", m_doBodyPart.ID);

                oXml.AddChildElement("PrimaryAttachID", m_thPrimaryAttachment.BodyPart.ID);
                oXml.AddChildElement("SecondaryAttachID", m_thSecondaryAttachment.BodyPart.ID);
                oXml.AddChildElement("UsePosition", false);
                oXml.AddChildElement("Velocity", m_snVelocity.ActualValue);
                oXml.AddChildElement("MaxForce", m_snMaxForce.ActualValue);
                oXml.AddChildElement("PGain", m_fltProportionalGain);
                oXml.AddChildElement("DGain", m_fltDerivativeGain);
                oXml.AddChildElement("IGain", m_fltIntegratorGain);
                oXml.AddChildElement("MaxIVal", m_fltMaxIntegratorValue);

                oXml.OutOfElem();
            }
        }
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData (ref dsSim, ref doStructure, ref oXml);
            Vector3 v3Rot = Util_DX.DecomposeXYZRotationMatrix(this.CombinedTransformationMatrix);

            Vector3 rot = m_v3Rotation;
            rot.Normalize();
            AnimatTools.Framework.Vec3d v = new Vec3d(null, rot.X, rot.Y, rot.Z);

            oXml.IntoElem();
                //oXml.AddChildElement("Stiffness", this.Stiffness.ActualValue);
                //oXml.AddChildElement("Damping", this.Damping.ActualValue);
                oXml.AddChildElement("ConstraintHalfAngle",m_fHalfAngle);

                m_v3Axis.TransformCoordinate(Matrix.RotationX(Geometry.DegreeToRadian(180)) * Matrix.RotationY(Geometry.DegreeToRadian(180)) * Matrix.RotationZ(Geometry.DegreeToRadian(180)) * Matrix.RotationX(v3Rot.X)* Matrix.RotationY(v3Rot.Y) * Matrix.RotationZ(v3Rot.Z));

                Vec3d vRotationAxis = new Vec3d(null,m_v3Axis.X, m_v3Axis.Y, m_v3Axis.Z);
                Util.SaveVector(ref oXml, "ConstraintAxis", vRotationAxis);
            oXml.OutOfElem();

            m_v3Axis = new Vector3(0,0,1);
        }
예제 #24
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 SaveData(ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData(ref oXml);

            oXml.IntoElem();

            if(m_thMuscle != null && m_thMuscle.BodyPart != null)
                oXml.AddChildElement("MuscleID", m_thMuscle.BodyPart.ID);

            oXml.AddChildElement("MuscleLengthData", m_strMuscleLengthData);
            m_snConductance.SaveData(ref oXml, "Conductance");
            m_snRestPotential.SaveData(ref oXml, "RestPotential");

            oXml.OutOfElem();
        }
예제 #26
0
        public override void SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            oXml.AddChildElement(this.BodyPartType);

            oXml.IntoElem(); //Into RigidBody Element

            oXml.AddChildElement("Name", m_strName);
            oXml.AddChildElement("ID", m_strID);
            oXml.AddChildElement("Type", this.Type);
            oXml.AddChildElement("PartType", this.PartType.ToString());
            oXml.AddChildElement("ModuleName", this.ModuleName);

            Util.SaveColor(ref oXml, "Color", m_d3dMaterial.Diffuse);

            if(m_thPrimaryAttachment != null && m_thPrimaryAttachment.BodyPart != null)
                oXml.AddChildElement("PrimaryAttachmentID", m_thPrimaryAttachment.BodyPart.ID);

            if(m_thSecondaryAttachment != null && m_thSecondaryAttachment.BodyPart != null)
                oXml.AddChildElement("SecondaryAttachmentID", m_thSecondaryAttachment.BodyPart.ID);

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

            oXml.AddChildElement("Enabled", m_bEnabled);
            oXml.AddChildElement("IsVisible", m_bVisible);

            oXml.OutOfElem(); //Outof RigidBody Element
        }
        public override void SaveXml(ref AnimatTools.Interfaces.StdXml oXml)
        {
            if(m_doOrganism == null)
                throw new System.Exception("No organism was defined for the stimulus '" + m_strName + "'.");

            if(m_doNode == null)
                throw new System.Exception("No node was defined for the stimulus '" + m_strName + "'.");

            //I have no idea why, but unders some conditions the object link we have to the node does not point to the
            //actual node. We need to re-get the link to make sure that the node index is actually valid.
            m_doNode = m_doOrganism.FindBehavioralNode(m_doNode.ID, true);

            if(m_doNode != null && m_thMuscle != null && m_thMuscle.BodyPart != null && m_strMuscleLengthData != null && m_strMuscleLengthData.Length > 0)
            {
                oXml.AddChildElement("Stimulus");

                oXml.IntoElem();
                oXml.AddChildElement("ID", m_strID);
                oXml.AddChildElement("Name", m_strName);

                //The module name needs to be blank so it is created from the physics class factory.
                //But we still need to know which neural module to load the neuron from.
                oXml.AddChildElement("ModuleName", this.StimulusModuleName);
                oXml.AddChildElement("NeuralModuleName", m_doNode.DataColumnModuleName);
                oXml.AddChildElement("Type", this.StimulusClassType);

                oXml.AddChildElement("OrganismID", m_doOrganism.ID);
                oXml.AddChildElement("TargetNodeID", m_doNode.NodeIndex);

                oXml.AddChildElement("MuscleID", m_thMuscle.BodyPart.ID);
                oXml.AddChildElement("LengthData", m_strMuscleLengthData);
                oXml.AddChildElement("Conductance", m_snConductance.ActualValue);
                oXml.AddChildElement("RestPotential", m_snRestPotential.ActualValue);

                oXml.OutOfElem();
            }
        }
        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 SaveData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.SaveData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();

            RigidBodies.RigidBody_DX rbParent = (RigidBodies.RigidBody_DX)this.Parent;
            Vector3 v3Rot = Util_DX.DecomposeXYZRotationMatrix(this.CombinedTransformationMatrix);;
            float x = Geometry.DegreeToRadian(180);

            if(!oXml.FindChildElement("Constraint", false))
                oXml.AddChildElement("Constraint");
            oXml.IntoElem();
            oXml.SetAttrib("Low",this.m_fltMinAngle);
            oXml.SetAttrib("High", this.m_fltMaxAngle);
            oXml.OutOfElem();

            oXml.AddChildElement("EnableMotor",this.m_bEnableMotor);
            oXml.AddChildElement("ServoMotor",this.m_bServoMotor);
            oXml.AddChildElement("ServoGain",this.m_fltServoGain);

            m_snMaxTorque.SaveData(ref oXml, "MaxTorque");
            m_snMaxVelocity.SaveData(ref oXml, "MaxVelocity");

            //			if(v3Rot.Y >= 180)
            //				m_v3Axis.TransformCoordinate(/*Matrix.RotationX(Geometry.DegreeToRadian(180))*  Matrix.RotationY(Geometry.DegreeToRadian(180)) * Matrix.RotationZ(Geometry.DegreeToRadian(180)) **/ Matrix.RotationX(v3Rot.X)* Matrix.RotationY(v3Rot.Y) * Matrix.RotationZ(v3Rot.Z));
            //			else
                //m_v3Axis.TransformCoordinate(Matrix.RotationX(Geometry.DegreeToRadian(180)) * Matrix.RotationY(Geometry.DegreeToRadian(180)) * Matrix.RotationZ(Geometry.DegreeToRadian(180)) * Matrix.RotationX(v3Rot.X)* Matrix.RotationY(v3Rot.Y) * Matrix.RotationZ(v3Rot.Z));
            Matrix m = this.CombinedTransformationMatrix;
            m.M41 = 0;
            m.M42 = 0;
            m.M43 = 0;
            //Quaternion q = Quaternion.RotationYawPitchRoll(v3Rot.Y, v3Rot.X, v3Rot.Z);
            //m_v3Axis.TransformCoordinate(Matrix.RotationQuaternion(q));
            m_v3Axis.TransformCoordinate(m);

            //Vec3d vRotationAxis = new Vec3d(null,1, 0, 0);
            Vec3d vRotationAxis = new Vec3d(null,m_v3Axis.X, m_v3Axis.Y, m_v3Axis.Z);
            Util.SaveVector(ref oXml, "RotationAxis", vRotationAxis);

            oXml.OutOfElem();
            m_v3Axis = new Vector3(0,0,1);
        }
예제 #30
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_vGraphicsBoxSize = Util.LoadVec3d(ref oXml, "GraphicsBoxSize", this);
            oXml.OutOfElem(); //out of body
        }