public ISphericalJoint Create(SphericalJointDescriptor descriptor)
            {
                var constraint = new DigitalRuneSphericalJoint(descriptor);

                _simulator._wrappedSimulation.Constraints.Add(constraint.WrappedSphericalJoint);
                return(constraint);
            }
Пример #2
0
        internal SphericalJoint(PhysXSimulator simulator, SphericalJointDescriptor descriptor)
        {
            Actor wrappedActorA = ((RigidBody)descriptor.RigidBodyA).WrappedActor;

            if (!wrappedActorA.IsDynamic)
            {
                var vector4 = GMath.mul(new Vector4(descriptor.AnchorPositionALocal, 1), descriptor.RigidBodyA.Pose);
                descriptor.AnchorPositionALocal = new Vector3(vector4.X, vector4.Y, vector4.Z);
                wrappedActorA = null;
            }


            Actor wrappedActorB = ((RigidBody)descriptor.RigidBodyB).WrappedActor;

            if (!wrappedActorB.IsDynamic)
            {
                var vector4 = GMath.mul(new Vector4(descriptor.AnchorPositionBLocal, 1), descriptor.RigidBodyB.Pose);
                descriptor.AnchorPositionBLocal = new Vector3(vector4.X, vector4.Y, vector4.Z);
                wrappedActorB = null;
            }

            var sphericalJointDescription = new SphericalJointDescription
            {
                Actor1       = wrappedActorA,
                Actor2       = wrappedActorB,
                LocalAnchor1 = descriptor.AnchorPositionALocal.ToPhysX(),
                LocalAnchor2 = descriptor.AnchorPositionBLocal.ToPhysX(),
                JointFlags   = JointFlag.CollisionEnabled
            };

            _wrappedSphericalJoint = (PX.SphericalJoint)simulator._wrappedScene.CreateJoint(sphericalJointDescription);
            _rigidBodyA            = descriptor.RigidBodyA;
            _rigidBodyB            = descriptor.RigidBodyB;
            _anchorPositionALocal  = descriptor.AnchorPositionALocal;
            _anchorPositionBLocal  = descriptor.AnchorPositionBLocal;
            UserData = descriptor.UserData;
        }
Пример #3
0
        internal DigitalRuneSphericalJoint(SphericalJointDescriptor descriptor)
        {
            WrappedSphericalJoint = new BallJoint();

            #region set RigidBodies
            if (!(descriptor.RigidBodyA is RigidBody))
            {
                throw new ArgumentException(String.Format("The type of the property 'RigidBodyA' must be '{0}'.", typeof(RigidBody)));
            }
            WrappedSphericalJoint.BodyA = ((RigidBody)descriptor.RigidBodyA).WrappedRigidBody;
            _rigidBodyA = descriptor.RigidBodyA;

            if (!(descriptor.RigidBodyB is RigidBody))
            {
                throw new ArgumentException("The type of the property 'RigidBodyB' must be 'System.Physics.DigitalRune.RigidBody'.");
            }
            WrappedSphericalJoint.BodyB = ((RigidBody)descriptor.RigidBodyB).WrappedRigidBody;
            _rigidBodyB = descriptor.RigidBodyB;
            #endregion
            WrappedSphericalJoint.AnchorPositionALocal = descriptor.AnchorPositionALocal.ToDigitalRune();
            WrappedSphericalJoint.AnchorPositionBLocal = descriptor.AnchorPositionBLocal.ToDigitalRune();

            Descriptor = descriptor;
        }
 public DefaultSphericalJoint(SphericalJointDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
Пример #5
0
 public static ISphericalJoint CreateSphericalJoint(this IFactory <IConstraint> factory,
                                                    SphericalJointDescriptor descriptor)
 {
     return(factory.Create <ISphericalJoint, SphericalJointDescriptor>(descriptor));
 }
Пример #6
0
 ISphericalJoint IFactoryOf <ISphericalJoint, SphericalJointDescriptor> .Create(SphericalJointDescriptor descriptor)
 {
     return(new SphericalJoint(_simulator, descriptor));
 }