Beispiel #1
0
    public void AddForce(Vector3 force, ForceMode forceMode = ForceMode.Force)
    {
        if (!IsKinematic)
        {
            TSVector vector = Convert(force);

            switch (forceMode)
            {
            case ForceMode.Acceleration:
                entity.Input.AddAcceleration(vector, false, false);
                break;

            case ForceMode.Force:
                entity.Input.AddAcceleration(vector, true, false);
                break;

            case ForceMode.VelocityChange:
                entity.Input.AddVelocity(vector, false, false);
                break;

            case ForceMode.Impulse:
                entity.Input.AddVelocity(vector, true, false);
                break;
            }
        }
    }
Beispiel #2
0
    public void AddRelativeTorque(Vector3 torque, ForceMode forceMode = ForceMode.Force)
    {
        if (!IsKinematic && !FreezeRotation)
        {
            TSVector vector = Convert(torque);

            switch (forceMode)
            {
            case ForceMode.Acceleration:
                entity.Input.AddAngularAcceleration(vector, false, true);
                break;

            case ForceMode.Force:
                entity.Input.AddAngularAcceleration(vector, true, true);
                break;

            case ForceMode.VelocityChange:
                entity.Input.AddAngularVelocity(vector, false, true);
                break;

            case ForceMode.Impulse:
                entity.Input.AddAngularVelocity(vector, true, true);
                break;
            }
        }
    }
Beispiel #3
0
    public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode forceMode = ForceMode.Force)
    {
        if (!IsKinematic)
        {
            if (FreezeRotation)
            {
                AddForce(force, forceMode);
            }
            else
            {
                TSVector vector         = Convert(force);
                TSVector vectorPosition = Convert(position);

                switch (forceMode)
                {
                case ForceMode.Acceleration:
                    entity.Input.AddAccelerationAtPosition(vector, vectorPosition, false, false);
                    break;

                case ForceMode.Force:
                    entity.Input.AddAccelerationAtPosition(vector, vectorPosition, true, false);
                    break;

                case ForceMode.VelocityChange:
                    entity.Input.AddVelocityAtPosition(vector, vectorPosition, false, false);
                    break;

                case ForceMode.Impulse:
                    entity.Input.AddVelocityAtPosition(vector, vectorPosition, true, false);
                    break;
                }
            }
        }
    }
Beispiel #4
0
 private Vector3 Convert(TSVector vector)
 {
     return(new Vector3(
                (float)vector.X,
                (float)vector.Y,
                (float)vector.Z
                ));
 }
Beispiel #5
0
    public Vector3 GetRelativePointVelocity(Vector3 relativePoint)
    {
        TSVector position = Convert(relativePoint);

        return(Convert(
                   entity.State.Velocity
                   + entity.State.AngularVelocity.Cross(position)
                   ));
    }
Beispiel #6
0
    public Vector3 GetPointVelocity(Vector3 worldPoint)
    {
        TSVector position = entity.State.ToLocalPoint(Convert(worldPoint));

        return(Convert(
                   entity.State.Velocity
                   + entity.State.AngularVelocity.Cross(position)
                   ));
    }