Beispiel #1
0
        void Start()
        {
            Debug.Log("Creating ballandsocket");

            childBody = GetComponentInParent <NewtonBody>();
            Matrix4x4 matrix = Matrix4x4.identity;

            matrix.SetTRS(transform.position, transform.rotation, Vector3.one);

            Debug.Log("ChildBodyPtr:" + childBody.pBody.ToString());

            IntPtr parentBodyPtr = IntPtr.Zero;

            if (ConnectedBody != null)
            {
                parentBodyPtr = ConnectedBody.pBody;
                Debug.Log("ParentBodyPtr:" + parentBodyPtr.ToString());
            }

            if (useFriction)
            {
                joint = NewtonAPI.NewtonCreateBallAndSocketWithFriction(ref matrix, childBody.pBody, parentBodyPtr, friction);
            }
            else
            {
                joint = NewtonAPI.NewtonCreateBallAndSocket(ref matrix, childBody.pBody, parentBodyPtr);
            }

            Debug.Log("Created Joint(" + joint.ToString() + ")");
        }
        void Start()
        {
            Debug.Log("Creating rolling friction");

            childBody = GetComponentInParent <NewtonBody>();
            joint     = NewtonAPI.NewtonCreateRollingFriction(childBody.pBody, Radius, Friction);
        }
        void Start()
        {
            Debug.Log("Creating hinge");

            childBody = GetComponentInParent <NewtonBody>();
            Matrix4x4 matrix = Matrix4x4.identity;

            matrix.SetTRS(transform.position, transform.rotation, Vector3.one);

            IntPtr parentBodyPtr = IntPtr.Zero;

            if (ConnectedBody != null)
            {
                parentBodyPtr = ConnectedBody.pBody;
            }

            joint = NewtonAPI.NewtonCreateHinge(ref matrix, childBody.pBody, parentBodyPtr);
            NewtonAPI.NewtonHingeEnableLimits(joint, EnableLimits);

            NewtonAPI.NewtonHingeSetLimits(joint, MinAngle * Mathf.Deg2Rad, MaxAngle * Mathf.Deg2Rad);
            NewtonAPI.NewtonHingeSetFriction(joint, Friction);
        }