public JointVehicleMotor ConnectWheel(VehiclePartEntity wheel, bool driving, bool powered) { wheel.SetFriction(2.5f); Vector3 left = Quaternion.Transform(new Vector3(-1, 0, 0), wheel.GetOrientation()); Vector3 up = Quaternion.Transform(new Vector3(0, 0, 1), wheel.GetOrientation()); JointSlider pointOnLineJoint = new JointSlider(this, wheel, -new Location(up)); JointLAxisLimit suspensionLimit = new JointLAxisLimit(this, wheel, 0f, 0.1f, wheel.GetPosition(), wheel.GetPosition(), -new Location(up)); JointPullPush spring = new JointPullPush(this, wheel, -new Location(up), true); BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(wheel.Body, this.Body, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase); // TODO: How necessary is this? Should we replicate this clientside? if (driving) { JointSpinner spinner = new JointSpinner(this, wheel, new Location(-left)); TheRegion.AddJoint(spinner); } else { JointSwivelHinge swivelhinge = new JointSwivelHinge(this, wheel, new Location(up), new Location(-left)); TheRegion.AddJoint(swivelhinge); } TheRegion.AddJoint(pointOnLineJoint); TheRegion.AddJoint(suspensionLimit); TheRegion.AddJoint(spring); if (powered) { JointVehicleMotor motor = new JointVehicleMotor(this, wheel, new Location(driving ? left : up), !driving); TheRegion.AddJoint(motor); return motor; } return null; }
public void ConnectFlap(VehiclePartEntity flap, FDSSection flapDat) { JointBallSocket jbs = new JointBallSocket(this, flap, flap.GetPosition()); // TODO: necessity? TheRegion.AddJoint(jbs); JointNoCollide jnc = new JointNoCollide(this, flap); TheRegion.AddJoint(jnc); string mode = flapDat.GetString("mode"); VehicleFlap vf = new VehicleFlap() { MaxAngle = flapDat.GetDouble("max_angle", 10).Value, Speed = flapDat.GetDouble("corrective_speed", 2.25).Value }; if (mode == "roll/l") { JointHinge jh = new JointHinge(this, flap, new Location(1, 0, 0)); TheRegion.AddJoint(jh); JointVehicleMotor jvm = new JointVehicleMotor(this, flap, new Location(1, 0, 0), true); TheRegion.AddJoint(jvm); vf.JVM = jvm; Flaps_RollL.Add(vf); } else if (mode == "roll/r") { JointHinge jh = new JointHinge(this, flap, new Location(1, 0, 0)); TheRegion.AddJoint(jh); JointVehicleMotor jvm = new JointVehicleMotor(this, flap, new Location(1, 0, 0), true); TheRegion.AddJoint(jvm); vf.JVM = jvm; Flaps_RollR.Add(vf); } else if (mode == "yaw") { JointHinge jh = new JointHinge(this, flap, new Location(0, 0, 1)); TheRegion.AddJoint(jh); JointVehicleMotor jvm = new JointVehicleMotor(this, flap, new Location(0, 0, 1), true); TheRegion.AddJoint(jvm); vf.JVM = jvm; Flaps_Yaw.Add(vf); } else if (mode == "pitch") { JointHinge jh = new JointHinge(this, flap, new Location(1, 0, 0)); TheRegion.AddJoint(jh); JointVehicleMotor jvm = new JointVehicleMotor(this, flap, new Location(1, 0, 0), true); TheRegion.AddJoint(jvm); vf.JVM = jvm; Flaps_Pitch.Add(vf); } }
public JointVehicleMotor ConnectWheel(VehiclePartEntity wheel, bool driving, bool powered) { wheel.SetFriction(2.5f); Vector3 left = Quaternion.Transform(new Vector3(-1, 0, 0), wheel.GetOrientation()); Vector3 up = Quaternion.Transform(new Vector3(0, 0, 1), wheel.GetOrientation()); JointSlider pointOnLineJoint = new JointSlider(this, wheel, -new Location(up)); JointLAxisLimit suspensionLimit = new JointLAxisLimit(this, wheel, 0f, 0.1f, wheel.GetPosition(), wheel.GetPosition(), -new Location(up)); JointPullPush spring = new JointPullPush(this, wheel, -new Location(up), true); BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(wheel.Body, this.Body, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase); // TODO: How necessary is this? Should we replicate this clientside? if (driving) { JointSpinner spinner = new JointSpinner(this, wheel, new Location(-left)); TheRegion.AddJoint(spinner); } else { JointSwivelHinge swivelhinge = new JointSwivelHinge(this, wheel, new Location(up), new Location(-left)); TheRegion.AddJoint(swivelhinge); } TheRegion.AddJoint(pointOnLineJoint); TheRegion.AddJoint(suspensionLimit); TheRegion.AddJoint(spring); if (powered) { JointVehicleMotor motor = new JointVehicleMotor(this, wheel, new Location(driving ? left : up), !driving); TheRegion.AddJoint(motor); return(motor); } return(null); }
public JointVehicleMotor ConnectWheel(VehiclePartEntity wheel, bool driving, bool powered, double susp) { TheRegion.AddJoint(new ConstWheelStepUp(wheel, wheel.StepHeight)); wheel.SetFriction(2.5f); Vector3 left = BEPUutilities.Quaternion.Transform(new Vector3(-1, 0, 0), wheel.GetOrientation()); Vector3 up = BEPUutilities.Quaternion.Transform(new Vector3(0, 0, 1), wheel.GetOrientation()); JointSlider pointOnLineJoint = new JointSlider(this, wheel, -new Location(up)); JointLAxisLimit suspensionLimit = new JointLAxisLimit(this, wheel, 0f, susp, wheel.GetPosition(), wheel.GetPosition(), -new Location(up)); JointPullPush spring = new JointPullPush(this, wheel, -new Location(up), true); if (driving) { JointSpinner spinner = new JointSpinner(this, wheel, new Location(-left)); TheRegion.AddJoint(spinner); } else { JointSwivelHinge swivelhinge = new JointSwivelHinge(this, wheel, new Location(up), new Location(-left)); TheRegion.AddJoint(swivelhinge); } TheRegion.AddJoint(pointOnLineJoint); TheRegion.AddJoint(suspensionLimit); TheRegion.AddJoint(spring); JointNoCollide jnc = new JointNoCollide(this, wheel); TheRegion.AddJoint(jnc); if (powered) { JointVehicleMotor motor = new JointVehicleMotor(this, wheel, new Location(driving ? left : up), !driving); TheRegion.AddJoint(motor); return(motor); } return(null); }