/// <summary> /// Clones the JointInfo. /// </summary> /// <returns></returns> public JointInfo Clone() { JointInfo newObj = this.GetType().CreateInstanceOf() as JointInfo; this.CopyTo(newObj); return(newObj); }
protected override void CopyTo(JointInfo target) { base.CopyTo(target); GearJointInfo c = target as GearJointInfo; c.ratio = this.ratio; }
/// <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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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); }
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)); }
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; }
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); }
/// <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(); }
/// <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(); }
void Cloning.ICloneable.CopyDataTo(object targetObj, Cloning.CloneProvider provider) { JointInfo targetJoint = targetObj as JointInfo; this.CopyTo(targetJoint); }
/// <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(); }
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; }
/// <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(); }
void ICloneExplicit.CopyDataTo(object targetObj, CloneProvider provider) { JointInfo targetJoint = targetObj as JointInfo; this.CopyTo(targetJoint); }