Esempio n. 1
0
 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();
     }
 }
Esempio n. 2
0
		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();
		}
Esempio n. 3
0
 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();
     }
 }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
		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);
		}
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
		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();
		}
Esempio n. 9
0
		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;
		}
Esempio n. 10
0
		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);
		}