Ejemplo n.º 1
0
        private static void DrawSphericalJoint(SphericalJoint joint)
        {
            Vector3 target = GetAnchor(joint, JointBody.Target);
            Vector3 anchor = GetAnchor(joint, JointBody.Anchor);
            Vector3 center = target;

            Rigidbody rigidbody = joint.GetBody(JointBody.Target);

            if (rigidbody != null)
            {
                center = rigidbody.SceneObject.Position;
            }

            Gizmos.Color = Color.White;
            Gizmos.DrawSphere(center, 0.05f);

            Gizmos.Color = Color.Yellow;
            Gizmos.DrawSphere(target, 0.05f);
            Gizmos.DrawSphere(anchor, 0.05f);

            Gizmos.Color = Color.Green;
            Gizmos.DrawLine(target, center);

            Gizmos.Color = Color.Green;
            if (joint.HasFlag(SphericalJointFlag.Limit))
            {
                LimitConeRange limit = joint.Limit;

                Radian zAngle = MathEx.Min(new Degree(360), limit.zLimitAngle * 2.0f);
                Radian yAngle = MathEx.Min(new Degree(360), limit.yLimitAngle * 2.0f);

                Gizmos.Transform = joint.SceneObject.WorldTransform;
                Gizmos.DrawWireArc(Vector3.Zero, Vector3.ZAxis, 0.25f, zAngle * -0.5f + new Degree(90), zAngle);
                Gizmos.DrawWireArc(Vector3.Zero, Vector3.YAxis, 0.25f, yAngle * -0.5f + new Degree(90), yAngle);

                Gizmos.Color = Color.Red;
                Radian remainingZAngle = new Degree(360) - zAngle;
                Radian remainingYAngle = new Degree(360) - yAngle;

                Gizmos.DrawWireArc(Vector3.Zero, Vector3.ZAxis, 0.25f, zAngle * 0.5f + new Degree(90), remainingZAngle);
                Gizmos.DrawWireArc(Vector3.Zero, Vector3.YAxis, 0.25f, yAngle * 0.5f + new Degree(90), remainingYAngle);
            }
            else
            {
                Gizmos.Color     = Color.Green;
                Gizmos.Transform = joint.SceneObject.WorldTransform;

                Gizmos.DrawWireDisc(Vector3.Zero, Vector3.ZAxis, 0.25f);
                Gizmos.DrawWireDisc(Vector3.Zero, Vector3.YAxis, 0.25f);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a new set of GUI elements for inspecting the limit object.
        /// </summary>
        /// <param name="limit">Initial values to assign to the GUI elements.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        /// <param name="properties">A set of properties that are persisted by the parent inspector. Used for saving state.
        ///                          </param>
        public LimitConeRangeGUI(LimitConeRange limit, GUILayout layout, SerializableProperties properties)
        {
            this.limitData = limit;

            yLimitAngleField.OnChanged   += x => { limitData.yLimitAngle = new Degree(x); MarkAsModified(); };
            yLimitAngleField.OnFocusLost += ConfirmModify;

            zLimitAngleField.OnChanged   += x => { limitData.zLimitAngle = new Degree(x); MarkAsModified(); };
            zLimitAngleField.OnFocusLost += ConfirmModify;

            layout.AddElement(yLimitAngleField);
            layout.AddElement(zLimitAngleField);
            limitCommonGUI              = new LimitCommonGUI("coneRange", limit.GetBase(), layout, properties);
            limitCommonGUI.OnChanged   += x => MarkAsModified();
            limitCommonGUI.OnConfirmed += ConfirmModify;
        }
Ejemplo n.º 3
0
 private static extern void Internal_setLimitSwing(IntPtr thisPtr, ref LimitConeRange limit);
Ejemplo n.º 4
0
 private static extern void Internal_getLimitSwing(IntPtr thisPtr, out LimitConeRange __output);