internal GearJoint(GearJointDef def) : base(def) { JointType type1 = def.joint1.JointType; JointType type2 = def.joint2.JointType; Debug.Assert(type1 == JointType.Revolute || type1 == JointType.Prismatic); Debug.Assert(type2 == JointType.Revolute || type2 == JointType.Prismatic); Debug.Assert(def.joint1.GetBody1().IsStatic); Debug.Assert(def.joint2.GetBody1().IsStatic); _revolute1 = null; _prismatic1 = null; _revolute2 = null; _prismatic2 = null; float coordinate1, coordinate2; _ground1 = def.joint1.GetBody1(); _bodyA = def.joint1.GetBody2(); if (type1 == JointType.Revolute) { _revolute1 = (RevoluteJoint)def.joint1; _groundAnchor1 = _revolute1._localAnchor1; _localAnchor1 = _revolute1._localAnchor2; coordinate1 = _revolute1.GetJointAngle(); } else { _prismatic1 = (PrismaticJoint)def.joint1; _groundAnchor1 = _prismatic1._localAnchor1; _localAnchor1 = _prismatic1._localAnchor2; coordinate1 = _prismatic1.GetJointTranslation(); } _ground2 = def.joint2.GetBody1(); _bodyB = def.joint2.GetBody2(); if (type2 == JointType.Revolute) { _revolute2 = (RevoluteJoint)def.joint2; _groundAnchor2 = _revolute2._localAnchor1; _localAnchor2 = _revolute2._localAnchor2; coordinate2 = _revolute2.GetJointAngle(); } else { _prismatic2 = (PrismaticJoint)def.joint2; _groundAnchor2 = _prismatic2._localAnchor1; _localAnchor2 = _prismatic2._localAnchor2; coordinate2 = _prismatic2.GetJointTranslation(); } _ratio = def.ratio; _ant = coordinate1 + _ratio * coordinate2; _impulse = 0.0f; }
internal static Joint Create(JointDef def) { Joint joint = null; switch (def.type) { case JointType.Distance: { joint = new DistanceJoint((DistanceJointDef)def); } break; case JointType.Mouse: { joint = new MouseJoint((MouseJointDef)def); } break; case JointType.Prismatic: { joint = new PrismaticJoint((PrismaticJointDef)def); } break; case JointType.Revolute: { joint = new RevoluteJoint((RevoluteJointDef)def); } break; case JointType.Pulley: { joint = new PulleyJoint((PulleyJointDef)def); } break; case JointType.Gear: { joint = new GearJoint((GearJointDef)def); } break; case JointType.Line: { joint = new LineJoint((LineJointDef)def); } break; default: Debug.Assert(false); break; } return(joint); }
internal static Joint Create(JointDef def) { Joint joint = null; switch (def.type) { case JointType.Distance: { joint = new DistanceJoint((DistanceJointDef)def); } break; case JointType.Mouse: { joint = new MouseJoint((MouseJointDef)def); } break; case JointType.Prismatic: { joint = new PrismaticJoint((PrismaticJointDef)def); } break; case JointType.Revolute: { joint = new RevoluteJoint((RevoluteJointDef)def); } break; case JointType.Pulley: { joint = new PulleyJoint((PulleyJointDef)def); } break; case JointType.Gear: { joint = new GearJoint((GearJointDef)def); } break; case JointType.Line: { joint = new LineJoint((LineJointDef)def); } break; default: Debug.Assert(false); break; } return joint; }