コード例 #1
0
ファイル: JointInfo.cs プロジェクト: sorceron2000/duality
        /// <summary>
        /// Clones the JointInfo.
        /// </summary>
        /// <returns></returns>
        public JointInfo Clone()
        {
            JointInfo newObj = this.GetType().CreateInstanceOf() as JointInfo;

            this.CopyTo(newObj);
            return(newObj);
        }
コード例 #2
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            GearJointInfo c = target as GearJointInfo;

            c.ratio = this.ratio;
        }
コード例 #3
0
ファイル: JointInfo.cs プロジェクト: sorceron2000/duality
 /// <summary>
 /// Copies this JointInfos data to another one. It is assumed that both are of the same type.
 /// </summary>
 /// <param name="target"></param>
 protected virtual void CopyTo(JointInfo target)
 {
     // Don't copy the parents!
     target.collide    = this.collide;
     target.enabled    = this.enabled;
     target.breakPoint = this.breakPoint;
 }
コード例 #4
0
ファイル: WeldJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			WeldJointInfo c = target as WeldJointInfo;
			c.localAnchorA = this.localAnchorA;
			c.localAnchorB = this.localAnchorB;
			c.refAngle = this.refAngle;
		}
コード例 #5
0
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			FixedFrictionJointInfo c = target as FixedFrictionJointInfo;
			c.localAnchor = this.localAnchor;
			c.maxForce = this.maxForce;
			c.maxTorque = this.maxTorque;
		}
コード例 #6
0
ファイル: RopeJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			RopeJointInfo c = target as RopeJointInfo;
			c.localAnchorB = this.localAnchorB;
			c.localAnchorA = this.localAnchorA;
			c.maxLength = this.maxLength;
		}
コード例 #7
0
ファイル: AngleJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			AngleJointInfo c = target as AngleJointInfo;
			c.angle = this.angle;
			c.biasFactor = this.biasFactor;
			c.softness = this.softness;
			c.maxImpulse = this.maxImpulse;
		}
コード例 #8
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            FixedFrictionJointInfo c = target as FixedFrictionJointInfo;

            c.localAnchor = this.localAnchor;
            c.maxForce    = this.maxForce;
            c.maxTorque   = this.maxTorque;
        }
コード例 #9
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            RopeJointInfo c = target as RopeJointInfo;

            c.localAnchorB = this.localAnchorB;
            c.localAnchorA = this.localAnchorA;
            c.maxLength    = this.maxLength;
        }
コード例 #10
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            WeldJointInfo c = target as WeldJointInfo;

            c.localAnchorA = this.localAnchorA;
            c.localAnchorB = this.localAnchorB;
            c.refAngle     = this.refAngle;
        }
コード例 #11
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            AngleJointInfo c = target as AngleJointInfo;

            c.angle      = this.angle;
            c.biasFactor = this.biasFactor;
            c.softness   = this.softness;
            c.maxImpulse = this.maxImpulse;
        }
コード例 #12
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            FixedMouseJointInfo c = target as FixedMouseJointInfo;

            c.worldAnchor  = this.worldAnchor;
            c.localAnchor  = this.localAnchor;
            c.dampingRatio = this.dampingRatio;
            c.frequency    = this.frequency;
            c.maxForce     = this.maxForce;
        }
コード例 #13
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            FixedDistanceJointInfo c = target as FixedDistanceJointInfo;

            c.worldAnchor  = this.worldAnchor;
            c.localAnchor  = this.localAnchor;
            c.dampingRatio = this.dampingRatio;
            c.frequency    = this.frequency;
            c.length       = this.length;
        }
コード例 #14
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            DistanceJointInfo c = target as DistanceJointInfo;

            c.localAnchorB = this.localAnchorB;
            c.localAnchorA = this.localAnchorA;
            c.dampingRatio = this.dampingRatio;
            c.frequency    = this.frequency;
            c.length       = this.length;
        }
コード例 #15
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            PulleyJointInfo c = target as PulleyJointInfo;

            c.localAnchorB = this.localAnchorB;
            c.localAnchorA = this.localAnchorA;
            c.worldAnchorB = this.worldAnchorB;
            c.worldAnchorA = this.worldAnchorA;
            c.maxLengthA   = this.maxLengthA;
            c.maxLengthB   = this.maxLengthB;
            c.totalLength  = this.totalLength;
            c.ratio        = this.ratio;
        }
コード例 #16
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            LineJointInfo c = target as LineJointInfo;

            c.localAnchorB   = this.localAnchorB;
            c.localAnchorA   = this.localAnchorA;
            c.motorSpeed     = this.motorSpeed;
            c.maxMotorTorque = this.maxMotorTorque;
            c.moveAxis       = this.moveAxis;
            c.motorEnabled   = this.motorEnabled;
            c.dampingRatio   = this.dampingRatio;
            c.frequency      = this.frequency;
        }
コード例 #17
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            FixedPrismaticJointInfo c = target as FixedPrismaticJointInfo;

            c.worldAnchor   = this.worldAnchor;
            c.moveAxis      = this.moveAxis;
            c.refAngle      = this.refAngle;
            c.limitEnabled  = this.limitEnabled;
            c.lowerLimit    = this.lowerLimit;
            c.upperLimit    = this.upperLimit;
            c.motorEnabled  = this.motorEnabled;
            c.motorSpeed    = this.motorSpeed;
            c.maxMotorForce = this.maxMotorForce;
        }
コード例 #18
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            RevoluteJointInfo c = target as RevoluteJointInfo;

            c.localAnchorB   = this.localAnchorB;
            c.localAnchorA   = this.localAnchorA;
            c.motorSpeed     = this.motorSpeed;
            c.maxMotorTorque = this.maxMotorTorque;
            c.motorEnabled   = this.motorEnabled;
            c.limitEnabled   = this.limitEnabled;
            c.lowerLimit     = this.lowerLimit;
            c.upperLimit     = this.upperLimit;
            c.refAngle       = this.refAngle;
        }
コード例 #19
0
		private void DrawJoint(Canvas canvas, JointInfo joint)
		{
			if (joint.ParentBody == null) return;
			if (joint.OtherBody == null) return;

			if (joint is AngleJointInfo)				this.DrawJoint(canvas, joint as AngleJointInfo);
			else if (joint is DistanceJointInfo)		this.DrawJoint(canvas, joint as DistanceJointInfo);
			else if (joint is FrictionJointInfo)		this.DrawJoint(canvas, joint as FrictionJointInfo);
			else if (joint is RevoluteJointInfo)		this.DrawJoint(canvas, joint as RevoluteJointInfo);
			else if (joint is PrismaticJointInfo)		this.DrawJoint(canvas, joint as PrismaticJointInfo);
			else if (joint is WeldJointInfo)			this.DrawJoint(canvas, joint as WeldJointInfo);
			else if (joint is RopeJointInfo)			this.DrawJoint(canvas, joint as RopeJointInfo);
			else if (joint is SliderJointInfo)			this.DrawJoint(canvas, joint as SliderJointInfo);
			else if (joint is LineJointInfo)			this.DrawJoint(canvas, joint as LineJointInfo);
			else if (joint is PulleyJointInfo)			this.DrawJoint(canvas, joint as PulleyJointInfo);
			else if (joint is GearJointInfo)			this.DrawJoint(canvas, joint as GearJointInfo);
		}
コード例 #20
0
        protected override Joint CreateJoint(Body bodyA, Body bodyB)
        {
            if (bodyA == null || bodyB == null)
            {
                return(null);
            }

            RigidBody bodyCmpA = bodyA.UserData as RigidBody;
            RigidBody bodyCmpB = bodyB.UserData as RigidBody;

            if (bodyCmpA == null || bodyCmpB == null)
            {
                return(null);
            }

            JointInfo jointA = bodyCmpA.Joints.FirstOrDefault(j => j is FixedPrismaticJointInfo || j is FixedRevoluteJointInfo || j is PrismaticJointInfo || j is RevoluteJointInfo);
            JointInfo jointB = bodyCmpB.Joints.FirstOrDefault(j => j is FixedPrismaticJointInfo || j is FixedRevoluteJointInfo || j is PrismaticJointInfo || j is RevoluteJointInfo);

            if (jointA == null || jointB == null)
            {
                return(null);
            }

            if (jointA.joint == null)
            {
                jointA.UpdateJoint();
            }
            if (jointB.joint == null)
            {
                jointB.UpdateJoint();
            }
            if (jointA.joint == null || jointB.joint == null)
            {
                return(null);
            }

            return(JointFactory.CreateGearJoint(Scene.PhysicsWorld, jointA.joint, jointB.joint, this.ratio));
        }
コード例 #21
0
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			PrismaticJointInfo c = target as PrismaticJointInfo;
			c.localAnchorA = this.localAnchorA;
			c.localAnchorB = this.localAnchorB;
			c.moveAxis = this.moveAxis;
			c.refAngle = this.refAngle;
			c.limitEnabled = this.limitEnabled;
			c.lowerLimit = this.lowerLimit;
			c.upperLimit = this.upperLimit;
			c.motorEnabled = this.motorEnabled;
			c.motorSpeed = this.motorSpeed;
			c.maxMotorForce = this.maxMotorForce;
		}
コード例 #22
0
        private void DrawJoint(Canvas canvas, JointInfo joint)
        {
            if (joint.BodyA == null) return;
            if (joint.DualJoint && joint.BodyB == null) return;

            if (joint is FixedAngleJointInfo)			this.DrawJoint(canvas, joint as FixedAngleJointInfo);
            else if (joint is FixedDistanceJointInfo)	this.DrawJoint(canvas, joint as FixedDistanceJointInfo);
            else if (joint is FixedMouseJointInfo)		this.DrawJoint(canvas, joint as FixedMouseJointInfo);
            else if (joint is FixedFrictionJointInfo)	this.DrawJoint(canvas, joint as FixedFrictionJointInfo);
            else if (joint is FixedRevoluteJointInfo)	this.DrawJoint(canvas, joint as FixedRevoluteJointInfo);
            else if (joint is FixedPrismaticJointInfo)	this.DrawJoint(canvas, joint as FixedPrismaticJointInfo);
            else if (joint is AngleJointInfo)			this.DrawJoint(canvas, joint as AngleJointInfo);
            else if (joint is DistanceJointInfo)		this.DrawJoint(canvas, joint as DistanceJointInfo);
            else if (joint is FrictionJointInfo)		this.DrawJoint(canvas, joint as FrictionJointInfo);
            else if (joint is RevoluteJointInfo)		this.DrawJoint(canvas, joint as RevoluteJointInfo);
            else if (joint is PrismaticJointInfo)		this.DrawJoint(canvas, joint as PrismaticJointInfo);
            else if (joint is WeldJointInfo)			this.DrawJoint(canvas, joint as WeldJointInfo);
            else if (joint is RopeJointInfo)			this.DrawJoint(canvas, joint as RopeJointInfo);
            else if (joint is SliderJointInfo)			this.DrawJoint(canvas, joint as SliderJointInfo);
            else if (joint is LineJointInfo)			this.DrawJoint(canvas, joint as LineJointInfo);
            else if (joint is PulleyJointInfo)			this.DrawJoint(canvas, joint as PulleyJointInfo);
            else if (joint is GearJointInfo)			this.DrawJoint(canvas, joint as GearJointInfo);
        }
コード例 #23
0
ファイル: GearJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			GearJointInfo c = target as GearJointInfo;
			c.ratio = this.ratio;
		}
コード例 #24
0
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			DistanceJointInfo c = target as DistanceJointInfo;
			c.localAnchorB = this.localAnchorB;
			c.localAnchorA = this.localAnchorA;
			c.dampingRatio = this.dampingRatio;
			c.frequency = this.frequency;
			c.length = this.length;
		}
コード例 #25
0
ファイル: PulleyJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			PulleyJointInfo c = target as PulleyJointInfo;
			c.localAnchorB = this.localAnchorB;
			c.localAnchorA = this.localAnchorA;
			c.worldAnchorB = this.worldAnchorB;
			c.worldAnchorA = this.worldAnchorA;
			c.maxLengthA = this.maxLengthA;
			c.maxLengthB = this.maxLengthB;
			c.totalLength = this.totalLength;
			c.ratio = this.ratio;
		}
コード例 #26
0
ファイル: FixedMouseJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			FixedMouseJointInfo c = target as FixedMouseJointInfo;
			c.worldAnchor = this.worldAnchor;
			c.localAnchor = this.localAnchor;
			c.dampingRatio = this.dampingRatio;
			c.frequency = this.frequency;
			c.maxForce = this.maxForce;
		}
コード例 #27
0
ファイル: RigidBody.cs プロジェクト: griffynn/duality
		/// <summary>
		/// Removes an existing joint from the body.
		/// </summary>
		/// <param name="joint"></param>
		public void RemoveJoint(JointInfo joint)
		{
			if (joint == null) throw new ArgumentNullException("joint");
			if (joint.ParentBody != this) return;

			this.joints.Remove(joint);
			this.AwakeBody();

			if (joint.OtherBody != null)
				joint.OtherBody.AwakeBody();

			joint.ParentBody = null;
			joint.OtherBody = null;
			joint.DestroyJoint();
		}
コード例 #28
0
ファイル: RigidBody.cs プロジェクト: undue/duality
		/// <summary>
		/// Adds a new joint to the Collider
		/// </summary>
		/// <param name="joint"></param>
		public void AddJoint(JointInfo joint, RigidBody other = null)
		{
			if (joint == null) throw new ArgumentNullException("joint");

			if (joint.BodyA != null)		joint.BodyA.RemoveJoint(joint);
			else if (joint.BodyB != null)	joint.BodyB.RemoveJoint(joint);

			joint.BodyA = this;
			joint.BodyB = other;

			if (joint.BodyA != null)
			{
				if (joint.BodyA.joints == null) joint.BodyA.joints = new List<JointInfo>();
				joint.BodyA.joints.Add(joint);
				joint.BodyA.AwakeBody();
			}
			if (joint.BodyB != null)
			{
				if (joint.BodyB.joints == null) joint.BodyB.joints = new List<JointInfo>();
				joint.BodyB.joints.Add(joint);
				joint.BodyB.AwakeBody();
			}

			joint.UpdateJoint();
		}
コード例 #29
0
ファイル: JointInfo.cs プロジェクト: sorceron2000/duality
        void Cloning.ICloneable.CopyDataTo(object targetObj, Cloning.CloneProvider provider)
        {
            JointInfo targetJoint = targetObj as JointInfo;

            this.CopyTo(targetJoint);
        }
コード例 #30
0
ファイル: RigidBody.cs プロジェクト: undue/duality
		/// <summary>
		/// Removes an existing joint from the Collider.
		/// </summary>
		/// <param name="joint"></param>
		public void RemoveJoint(JointInfo joint)
		{
			if (joint == null) throw new ArgumentNullException("joint");
			if (joint.BodyA != this && joint.BodyB != this) return;

			if (joint.BodyA != null)
			{
				if (joint.BodyA.joints != null) joint.BodyA.joints.Remove(joint);
				joint.BodyA.AwakeBody();
				joint.BodyA = null;
			}
			if (joint.BodyB != null)
			{
				if (joint.BodyB.joints != null) joint.BodyB.joints.Remove(joint);
				joint.BodyB.AwakeBody();
				joint.BodyB = null;
			}

			joint.DestroyJoint();
		}
コード例 #31
0
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			FixedRevoluteJointInfo c = target as FixedRevoluteJointInfo;
			c.worldAnchor = this.worldAnchor;
			c.localAnchor = this.localAnchor;
			c.motorSpeed = this.motorSpeed;
			c.maxMotorTorque = this.maxMotorTorque;
			c.motorEnabled = this.motorEnabled;
			c.limitEnabled = this.limitEnabled;
			c.lowerLimit = this.lowerLimit;
			c.upperLimit = this.upperLimit;
			c.refAngle = this.refAngle;
		}
コード例 #32
0
ファイル: JointInfo.cs プロジェクト: KSLcom/duality
		/// <summary>
		/// Copies this JointInfos data to another one. It is assumed that both are of the same type.
		/// </summary>
		/// <param name="target"></param>
		protected virtual void CopyTo(JointInfo target)
		{
			// Don't copy the parents!
			target.collide = this.collide;
			target.enabled = this.enabled;
			target.breakPoint = this.breakPoint;
		}
コード例 #33
0
ファイル: LineJointInfo.cs プロジェクト: KSLcom/duality
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			LineJointInfo c = target as LineJointInfo;
			c.localAnchorB = this.localAnchorB;
			c.localAnchorA = this.localAnchorA;
			c.motorSpeed = this.motorSpeed;
			c.maxMotorTorque = this.maxMotorTorque;
			c.moveAxis = this.moveAxis;
			c.motorEnabled = this.motorEnabled;
			c.dampingRatio = this.dampingRatio;
			c.frequency = this.frequency;
		}
コード例 #34
0
ファイル: RigidBody.cs プロジェクト: griffynn/duality
		/// <summary>
		/// Adds a new joint to the body.
		/// </summary>
		/// <param name="joint"></param>
		public void AddJoint(JointInfo joint, RigidBody other = null)
		{
			if (joint == null) throw new ArgumentNullException("joint");

			if (joint.ParentBody != null)
				joint.ParentBody.RemoveJoint(joint);

			joint.ParentBody = this;
			joint.OtherBody = other;

			if (this.joints == null) this.joints = new List<JointInfo>();
			this.joints.Add(joint);
			this.AwakeBody();

			if (joint.OtherBody != null)
				joint.OtherBody.AwakeBody();

			joint.UpdateJoint();
		}
コード例 #35
0
		protected override void CopyTo(JointInfo target)
		{
			base.CopyTo(target);
			FixedDistanceJointInfo c = target as FixedDistanceJointInfo;
			c.worldAnchor = this.worldAnchor;
			c.localAnchor = this.localAnchor;
			c.dampingRatio = this.dampingRatio;
			c.frequency = this.frequency;
			c.length = this.length;
		}
コード例 #36
0
ファイル: JointInfo.cs プロジェクト: fork-lib2/duality
        void ICloneExplicit.CopyDataTo(object targetObj, CloneProvider provider)
        {
            JointInfo targetJoint = targetObj as JointInfo;

            this.CopyTo(targetJoint);
        }