| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- namespace BansheeEngine
- {
- /** @cond INTEROP */
- /** @addtogroup Interop
- * @{
- */
- /// <summary>
- /// Wrapper around the native Joint class.
- /// <see cref="Joint"/>
- /// </summary>
- internal class NativeJoint : ScriptObject
- {
- private Joint component;
- /// <summary>
- /// Component that owns the native joint object.
- /// </summary>
- public Joint Component
- {
- get { return component; }
- set { component = value; }
- }
- public float BreakForce
- {
- set { Internal_SetBreakForce(mCachedPtr, value); }
- }
- public float BreakTorque
- {
- set { Internal_SetBreakTorque(mCachedPtr, value); }
- }
- public bool EnableCollision
- {
- set { Internal_SetEnableCollision(mCachedPtr, value); }
- }
- public void SetRigidbody(JointBody body, Rigidbody rigidbody)
- {
- IntPtr rigidbodyPtr = IntPtr.Zero;
- if (rigidbody != null)
- rigidbodyPtr = rigidbody.native.GetCachedPtr();
- Internal_SetBody(mCachedPtr, body, rigidbodyPtr);
- }
- public void SetPosition(JointBody body, Vector3 position)
- {
- Internal_SetPosition(mCachedPtr, body, ref position);
- }
- public void SetRotation(JointBody body, Quaternion rotation)
- {
- Internal_SetRotation(mCachedPtr, body, ref rotation);
- }
-
- public void Destroy()
- {
- Internal_Destroy(mCachedPtr);
- }
- private void Internal_DoOnJointBreak()
- {
- Component.DoOnJointBreak();
- }
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_Destroy(IntPtr thisPtr);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetBody(IntPtr thisPtr, JointBody body, IntPtr rigidbody);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetPosition(IntPtr thisPtr, JointBody body, ref Vector3 position);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetRotation(IntPtr thisPtr, JointBody body, ref Quaternion rotation);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetBreakForce(IntPtr thisPtr, float force);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetBreakTorque(IntPtr thisPtr, float torque);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_SetEnableCollision(IntPtr thisPtr, bool value);
- }
- /// <summary>
- /// Used for passing common Joint initialization data between native and managed code.
- /// </summary>
- [StructLayout(LayoutKind.Sequential), SerializeObject]
- internal struct ScriptCommonJointData // Note: Must match C++ struct ScriptCommonJointData
- {
- public IntPtr[] bodies;
- public Vector3[] positions;
- public Quaternion[] rotations;
- public float breakForce;
- public float breakTorque;
- public bool enableCollision;
- }
- /** @} */
- /** @endcond */
- }
|