private void CreateJoint(JitterPhysics physicsManager) { if (JointType == JointType.FixedAngle) { CreateFixedAngleJoint(); } if (JointType == JointType.PointOnLine) { CreatePointOnLineJoint(); } if (JointType == JointType.PointOnPoint) { CreatePointOnPointJoint(); } if (JointType == JointType.PointPointDistance) { CreatePointPointDistanceJoint(); } if (JointType == JointType.Hinge) { CreateHingeJoint(physicsManager); } if (JointType == JointType.Prismatic) { CreatePrismaticJoint(physicsManager); } if (JointType == JointType.SingleBodyPointOnLine) { CreateSingleBodyPointOnLineJoint(); } }
public JitterJoint(JitterPhysics physicsManager, JointType jointType, PhysicsBody bodyA, PhysicsBody bodyB, object[] args) : base(jointType, bodyA, bodyB, args) { CreateJoint(physicsManager); if (Constraint != null) physicsManager.jitterWorld.AddConstraint(Constraint); if (Joint != null) Joint.Activate(); }
public JitterJoint(JitterPhysics physicsManager, JointType jointType, PhysicsBody bodyA, PhysicsBody bodyB, object[] args) : base(jointType, bodyA, bodyB, args) { CreateJoint(physicsManager); if (Constraint != null) { physicsManager.jitterWorld.AddConstraint(Constraint); } if (Joint != null) { Joint.Activate(); } }
private void CreatePrismaticJoint(JitterPhysics physicsManager) { Joint = new PrismaticJoint(physicsManager.jitterWorld, RigidBodyA, RigidBodyB, ArrayExtensions.GetWithDefault <PropertyType, float>(Properties, PropertyType.MinimumDistance), ArrayExtensions.GetWithDefault <PropertyType, float>(Properties, PropertyType.MaximumDistance)); float minimumSoftness = ArrayExtensions.GetWithDefault <PropertyType, float>(Properties, PropertyType.MinimumSoftness); float maximumSoftness = ArrayExtensions.GetWithDefault <PropertyType, float>(Properties, PropertyType.MaximumSoftness); (Joint as PrismaticJoint).MaximumDistanceConstraint.Softness = maximumSoftness; (Joint as PrismaticJoint).MinimumDistanceConstraint.Softness = minimumSoftness; }
private void CreateHingeJoint(JitterPhysics physicsManager) { JVector position; Vector3D tempVector = ArrayExtensions.GetWithDefault <PropertyType, Vector3D>(Properties, PropertyType.Position); JitterDatatypesMapping.Convert(ref tempVector, out position); JVector hingeAxis; tempVector = ArrayExtensions.GetWithDefault <PropertyType, Vector3D>(Properties, PropertyType.HingeAxis); JitterDatatypesMapping.Convert(ref tempVector, out hingeAxis); Joint = new HingeJoint(physicsManager.jitterWorld, RigidBodyA, RigidBodyB, position, hingeAxis); }
public JitterBody(JitterPhysics physicsManager, PhysicsShape shape, Vector3D initialPosition, float mass, float restitution) : base(shape) { CreateShape(); RotationMatrix = Matrix.Identity; jitterBody = new RigidBody(jitterShape) { IsStatic = false, Mass = mass, Material = { Restitution = restitution }, Position = JitterDatatypesMapping.Convert(ref initialPosition), Tag = this }; physicsManager.jitterWorld.AddBody(jitterBody); }
private void CreateJoint(JitterPhysics physicsManager) { if (JointType == JointType.FixedAngle) CreateFixedAngleJoint(); if (JointType == JointType.PointOnLine) CreatePointOnLineJoint(); if (JointType == JointType.PointOnPoint) CreatePointOnPointJoint(); if (JointType == JointType.PointPointDistance) CreatePointPointDistanceJoint(); if (JointType == JointType.Hinge) CreateHingeJoint(physicsManager); if (JointType == JointType.Prismatic) CreatePrismaticJoint(physicsManager); if (JointType == JointType.SingleBodyPointOnLine) CreateSingleBodyPointOnLineJoint(); }
private void CreatePrismaticJoint(JitterPhysics physicsManager) { Joint = new PrismaticJoint(physicsManager.jitterWorld, RigidBodyA, RigidBodyB, ArrayExtensions.GetWithDefault<PropertyType, float>(Properties, PropertyType.MinimumDistance), ArrayExtensions.GetWithDefault<PropertyType, float>(Properties, PropertyType.MaximumDistance)); float minimumSoftness = ArrayExtensions.GetWithDefault<PropertyType, float>(Properties, PropertyType.MinimumSoftness); float maximumSoftness = ArrayExtensions.GetWithDefault<PropertyType, float>(Properties, PropertyType.MaximumSoftness); (Joint as PrismaticJoint).MaximumDistanceConstraint.Softness = maximumSoftness; (Joint as PrismaticJoint).MinimumDistanceConstraint.Softness = minimumSoftness; }
private void CreateHingeJoint(JitterPhysics physicsManager) { JVector position; Vector3D tempVector = ArrayExtensions.GetWithDefault<PropertyType, Vector3D>(Properties, PropertyType.Position); JitterDatatypesMapping.Convert(ref tempVector, out position); JVector hingeAxis; tempVector = ArrayExtensions.GetWithDefault<PropertyType, Vector3D>(Properties, PropertyType.HingeAxis); JitterDatatypesMapping.Convert(ref tempVector, out hingeAxis); Joint = new HingeJoint(physicsManager.jitterWorld, RigidBodyA, RigidBodyB, position, hingeAxis); }