Exemplo n.º 1
0
 /// <summary>
 /// Constructs a new constraint which restricts the linear and angular motion between two entities.
 /// This constructs the internal constraints, but does not configure them.  Before using a constraint constructed in this manner,
 /// ensure that its active constituent constraints are properly configured.  The entire group as well as all internal constraints are initially inactive (IsActive = false).
 /// </summary>
 public WeldJoint()
 {
     IsActive        = false;
     BallSocketJoint = new BallSocketJoint();
     NoRotationJoint = new NoRotationJoint();
     Add(BallSocketJoint);
     Add(NoRotationJoint);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a new constraint which restricts two degrees of linear freedom and all three degrees of angular freedom.
        /// This constructs the internal constraints, but does not configure them.  Before using a constraint constructed in this manner,
        /// ensure that its active constituent constraints are properly configured.  The entire group as well as all internal constraints are initially inactive (IsActive = false).
        /// </summary>
        public PrismaticJoint()
        {
            IsActive         = false;
            PointOnLineJoint = new PointOnLineJoint();
            AngularJoint     = new NoRotationJoint();
            Limit            = new LinearAxisLimit();
            Motor            = new LinearAxisMotor();

            Add(PointOnLineJoint);
            Add(AngularJoint);
            Add(Limit);
            Add(Motor);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs a new constraint which restricts the linear and angular motion between two entities.
 /// </summary>
 /// <param name="connectionA">First entity of the constraint pair.</param>
 /// <param name="connectionB">Second entity of the constraint pair.</param>
 /// <param name="anchor">The location of the weld.</param>
 public WeldJoint(Entity connectionA, Entity connectionB, System.Numerics.Vector3 anchor)
 {
     if (connectionA == null)
     {
         connectionA = TwoEntityConstraint.WorldEntity;
     }
     if (connectionB == null)
     {
         connectionB = TwoEntityConstraint.WorldEntity;
     }
     BallSocketJoint = new BallSocketJoint(connectionA, connectionB, anchor);
     NoRotationJoint = new NoRotationJoint(connectionA, connectionB);
     Add(BallSocketJoint);
     Add(NoRotationJoint);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a new constraint which restricts the linear and angular motion between two entities.
 /// </summary>
 /// <param name="connectionA">First entity of the constraint pair.</param>
 /// <param name="connectionB">Second entity of the constraint pair.</param>
 public WeldJoint(Entity connectionA, Entity connectionB)
 {
     if (connectionA == null)
     {
         connectionA = TwoEntityConstraint.WorldEntity;
     }
     if (connectionB == null)
     {
         connectionB = TwoEntityConstraint.WorldEntity;
     }
     BallSocketJoint = new BallSocketJoint(connectionA, connectionB, (connectionA.position + connectionB.position) * .5f);
     NoRotationJoint = new NoRotationJoint(connectionA, connectionB);
     Add(BallSocketJoint);
     Add(NoRotationJoint);
 }
Exemplo n.º 5
0
        public ISpaceObject CreateJoint(BEPUphysics.Entities.Entity entity1, BEPUphysics.Entities.Entity entity2, Vector3 pos, Vector3 direction, Vector3 anchor)
        {
            // entity1 is us
            // entity2 is the main map we are attaching to
            Vector3 originalPos = entity1.Position;

            entity1.Position = pos;
            this.joint       = new NoRotationJoint(entity2, entity1);
            entity1.Position = originalPos;
            if (this.mover != null && this.mover.Space != null)
            {
                this.main.Space.Remove(this.mover);
            }
            this.mover = new EntityMover(entity1);
            this.main.Space.Add(this.mover);
            this.physicsUpdated(entity1.Mass, entity1.Volume);
            return(this.joint);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Constructs a new constraint which restricts two degrees of linear freedom and all three degrees of angular freedom.
 /// </summary>
 /// <param name="connectionA">First entity of the constraint pair.</param>
 /// <param name="connectionB">Second entity of the constraint pair.</param>
 /// <param name="lineAnchor">Location of the anchor for the line to be attached to connectionA in world space.</param>
 /// <param name="lineDirection">Axis in world space to be attached to connectionA along which connectionB can move.</param>
 /// <param name="pointAnchor">Location of the anchor for the point to be attached to connectionB in world space.</param>
 public PrismaticJoint(Entity connectionA, Entity connectionB, Vector3 lineAnchor, Vector3 lineDirection, Vector3 pointAnchor)
 {
     if (connectionA == null)
     {
         connectionA = TwoEntityConstraint.WorldEntity;
     }
     if (connectionB == null)
     {
         connectionB = TwoEntityConstraint.WorldEntity;
     }
     PointOnLineJoint = new PointOnLineJoint(connectionA, connectionB, lineAnchor, lineDirection, pointAnchor);
     AngularJoint     = new NoRotationJoint(connectionA, connectionB);
     Limit            = new LinearAxisLimit(connectionA, connectionB, lineAnchor, pointAnchor, lineDirection, 0, 0);
     Motor            = new LinearAxisMotor(connectionA, connectionB, lineAnchor, pointAnchor, lineDirection);
     Limit.IsActive   = false;
     Motor.IsActive   = false;
     Add(PointOnLineJoint);
     Add(AngularJoint);
     Add(Limit);
     Add(Motor);
 }