using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace BansheeEngine { /** @addtogroup Physics * @{ */ /// /// Base class for all Joint types. Joints constrain how two rigidbodies move relative to one another (for example a door /// hinge). One of the bodies in the joint must always be movable (non-kinematic). /// [ShowInInspector] public partial class Joint : Component { private Joint(bool __dummy0) { } protected Joint() { } /// /// Determines the maximum force the joint can apply before breaking. Broken joints no longer participate in physics /// simulation. /// [ShowInInspector] [NativeWrapper] public float BreakForce { get { return Internal_getBreakForce(mCachedPtr); } set { Internal_setBreakForce(mCachedPtr, value); } } /// /// Determines the maximum torque the joint can apply before breaking. Broken joints no longer participate in physics /// simulation. /// [ShowInInspector] [NativeWrapper] public float BreakTorque { get { return Internal_getBreakTorque(mCachedPtr); } set { Internal_setBreakTorque(mCachedPtr, value); } } /// Determines whether collision between the two bodies managed by the joint are enabled. [ShowInInspector] [NativeWrapper] public bool EnableCollision { get { return Internal_getEnableCollision(mCachedPtr); } set { Internal_setEnableCollision(mCachedPtr, value); } } /// Triggered when the joint's break force or torque is exceeded. public event Action OnJointBreak; /// Determines a body managed by the joint. One of the bodies must be movable (non-kinematic). public Rigidbody GetBody(JointBody body) { return Internal_getBody(mCachedPtr, body); } /// Determines a body managed by the joint. One of the bodies must be movable (non-kinematic). public void SetBody(JointBody body, Rigidbody value) { Internal_setBody(mCachedPtr, body, value); } /// Returns the position relative to the body, at which the body is anchored to the joint. public Vector3 GetPosition(JointBody body) { Vector3 temp; Internal_getPosition(mCachedPtr, body, out temp); return temp; } /// Returns the rotation relative to the body, at which the body is anchored to the joint. public Quaternion GetRotation(JointBody body) { Quaternion temp; Internal_getRotation(mCachedPtr, body, out temp); return temp; } /// Sets the position and rotation relative to the body, at which the body is anchored to the joint. public void SetTransform(JointBody body, Vector3 position, Quaternion rotation) { Internal_setTransform(mCachedPtr, body, ref position, ref rotation); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern Rigidbody Internal_getBody(IntPtr thisPtr, JointBody body); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setBody(IntPtr thisPtr, JointBody body, Rigidbody value); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_getPosition(IntPtr thisPtr, JointBody body, out Vector3 __output); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_getRotation(IntPtr thisPtr, JointBody body, out Quaternion __output); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setTransform(IntPtr thisPtr, JointBody body, ref Vector3 position, ref Quaternion rotation); [MethodImpl(MethodImplOptions.InternalCall)] private static extern float Internal_getBreakForce(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setBreakForce(IntPtr thisPtr, float force); [MethodImpl(MethodImplOptions.InternalCall)] private static extern float Internal_getBreakTorque(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setBreakTorque(IntPtr thisPtr, float torque); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Internal_getEnableCollision(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_setEnableCollision(IntPtr thisPtr, bool value); private void Internal_onJointBreak() { OnJointBreak?.Invoke(); } } /** @} */ }