Пример #1
0
        /// <summary>
        /// Updates all GUI elements from current values in the joint.
        /// </summary>
        /// <param name="joint">Joint to update the GUI from.</param>
        protected virtual void Refresh(Joint joint)
        {
            targetField.Value = joint.GetRigidbody(JointBody.Target);
            anchorField.Value = joint.GetRigidbody(JointBody.Anchor);

            if (showOffsets)
            {
                targetOffsetField.Value = joint.GetPosition(JointBody.Target);
                anchorOffsetField.Value = joint.GetPosition(JointBody.Anchor);
            }

            breakForceField.Value = joint.BreakForce;
            breakTorqueField.Value = joint.BreakTorque;
            collisionField.Value = joint.EnableCollision;
        }
Пример #2
0
        /// <summary>
        /// Returns the anchor position for the specified joint body. Anchor represents the world position of the rigidbody
        /// added to the offset provided by the joint.
        /// </summary>
        /// <param name="joint">Joint from which to retrieve the body.</param>
        /// <param name="body">Body to retrieve the anchor for.</param>
        /// <returns>Anchor position in world space.</returns>
        private static Vector3 GetAnchor(Joint joint, JointBody body)
        {
            Rigidbody rigidbody = joint.GetRigidbody(body);
            Vector3 anchor = joint.GetPosition(body);

            if (rigidbody != null)
            {
                Quaternion worldRot = rigidbody.SceneObject.Rotation;
                anchor = worldRot.Rotate(anchor) + rigidbody.SceneObject.Position;
            }
            else
            {
                Quaternion worldRot = joint.SceneObject.Rotation;
                anchor = worldRot.Rotate(anchor) + joint.SceneObject.Position;
            }

            return anchor;
        }