/// <summary> /// Constructs a spherical joint. /// </summary> /// <param name="connectionA">First connected entity.</param> /// <param name="connectionB">Second connected entity.</param> /// <param name="anchorLocation">Location of the socket.</param> public BallSocketJoint(Entity connectionA, Entity connectionB, ref Vector3 anchorLocation) { ConnectionA = connectionA; ConnectionB = connectionB; Vector3 tmp; anchorLocation.Sub( ref ConnectionA.position, out tmp ); OffsetA = tmp; anchorLocation.Sub( ref ConnectionB.position, out tmp ); OffsetB = tmp; }
/// <summary> /// Gets or sets the offset in world space from the center of mass of connection A to the anchor point. /// </summary> public void SetAnchorB(ref Vector3 value) { Vector3 tmp; value.Sub(ref ConnectionB.Position, out tmp); Quaternion.Transform(ref tmp, ref ConnectionB.ConjOrientation, out LocalAnchorB); }
///<summary> /// Constructs a triangle shape. /// The vertices will be recentered. If the center is needed, use the other constructor. ///</summary> ///<param name="vA">First vertex in the triangle.</param> ///<param name="vB">Second vertex in the triangle.</param> ///<param name="vC">Third vertex in the triangle.</param> public TriangleShape(Vector3 vA, Vector3 vB, Vector3 vC) { //Recenter. Convexes should contain the origin. Vector3 center; vA.Add2( ref vB, ref vC, out center ); center.Mult( 1 / 3, out center ); //= ( vA + vB + vC) / 3; vA.Sub( ref center, out this.vA ); vB.Sub( ref center, out this.vB ); vC.Sub( ref center, out this.vC ); UpdateConvexShapeInfo( ComputeDescription(vA, vB, vC, collisionMargin)); }