public AngleLimitJoint CreateAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float min, float max) { AngleLimitJoint angleLimitJoint = CreateAngleLimitJoint(body1, body2, min, max); physicsSimulator.Add(angleLimitJoint); return(angleLimitJoint); }
//angle limit joint public AngleLimitJoint CreateAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float lowerLimit, float upperLimit) { AngleLimitJoint angleLimitJoint = CreateAngleLimitJoint(body1, body2, lowerLimit, upperLimit); physicsSimulator.Add(angleLimitJoint); return(angleLimitJoint); }
public void AddJoint(PhysicsJointMain joint) { string bodyOne = joint.BodyOne; string bodyTwo = joint.BodyTwo; int collisionGroup = joint.CollisionGroup; bool isAngleSpringEnabled = joint.AngleSpringEnabled; float springConstant = joint.AngleSpringConstant; float dampeningConstant = joint.AngleSpringDampningConstant; float angleLowerLimit = (float)joint.AngleLowerLimit; float angleUpperLimit = (float)joint.AngleUpperLimit; Point center = joint.GetCenter(); Vector2 ptCollisionCenter = new Vector2((float)center.X, (float)center.Y); if (!PhysicsObjects.ContainsKey(bodyOne)) { throw new Exception("Cannot add joint for an invalid BodyOne value of '" + bodyOne + "'. If using Behaviors, did you forgot to add a PhysicsObjectBehavior?"); } if (!PhysicsObjects.ContainsKey(bodyTwo)) { throw new Exception("Cannot add joint for an invalid BodyTwo value of '" + bodyTwo + "'. If using Behaviors, did you forgot to add a PhysicsObjectBehavior?"); } Body body1 = PhysicsObjects[bodyOne].BodyObject; Body body2 = PhysicsObjects[bodyTwo].BodyObject; Geom geom1 = PhysicsObjects[bodyOne].GeometryObject; Geom geom2 = PhysicsObjects[bodyTwo].GeometryObject; RevoluteJoint revoluteJoint = JointFactory.Instance.CreateRevoluteJoint(Simulator, body1, body2, ptCollisionCenter); if (isAngleSpringEnabled) { AngleSpring angleSpring = new AngleSpring(body1, body2, springConstant, dampeningConstant); Simulator.Add(angleSpring); } if (angleUpperLimit != -1 && angleLowerLimit != -1) { float upperAngle = (float)DegreesToRadians(angleUpperLimit); float lowerAngle = (float)DegreesToRadians(angleLowerLimit); AngleLimitJoint angleLimitJoint = new AngleLimitJoint(body1, body2, lowerAngle, upperAngle); Simulator.Add(angleLimitJoint); } if (collisionGroup > 0) { geom1.CollisionGroup = collisionGroup; geom2.CollisionGroup = collisionGroup; } // get rid of the UI representation of the joint joint.VisualElement.Visibility = Visibility.Collapsed; }
public AngleLimitJoint CreateAngleLimitJoint(Body body1, Body body2, float min, float max) { AngleLimitJoint angleLimitJoint = new AngleLimitJoint(body1, body2, min, max); return(angleLimitJoint); }
public AngleLimitJoint CreateAngleLimitJoint(Body body1, Body body2, float lowerLimit, float upperLimit) { AngleLimitJoint angleLimitJoint = new AngleLimitJoint(body1, body2, lowerLimit, upperLimit); return(angleLimitJoint); }