コード例 #1
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            D6Joint joint = (D6Joint)InspectedObject;

            BuildGUI(joint, true);

            drawer.AddDefault(joint, typeof(D6Joint));

            drawer.BeginCategory("Motion constraints");
            for (int i = 0; i < (int)D6JointAxis.Count; i++)
            {
                D6JointAxis axis      = (D6JointAxis)i;
                string      entryName = Enum.GetName(typeof(D6JointAxis), axis);

                drawer.AddField(entryName, () => joint.GetMotion(axis), x => joint.SetMotion(axis, x));
            }

            drawer.BeginCategory("Drive");
            drawer.AddField("Drive position", () => joint.DrivePosition, x => joint.SetDriveTransform(x, joint.DriveRotation));
            drawer.AddField("Drive rotation", () => joint.DriveRotation.ToEuler(), x => joint.SetDriveTransform(joint.DrivePosition, Quaternion.FromEuler(x)));
            drawer.AddField("Drive linear velocity", () => joint.DriveLinearVelocity, x => joint.SetDriveVelocity(x, joint.DriveAngularVelocity));
            drawer.AddField("Drive angular velocity", () => joint.DriveAngularVelocity, x => joint.SetDriveVelocity(joint.DriveLinearVelocity, x));

            for (int i = 0; i < (int)D6JointDriveType.Count; i++)
            {
                D6JointDriveType type      = (D6JointDriveType)i;
                string           entryName = Enum.GetName(typeof(D6JointDriveType), type);

                drawer.AddField(entryName, () => joint.GetDrive(type), x => joint.SetDrive(type, x));
            }

            drawer.EndCategory();
        }
コード例 #2
0
        public void SetMotion(D6JointAxis axis, D6JointMotion value)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            Internal_SetMotion(unmanagedPtr, axis, value);
#endif
        }
コード例 #3
0
        public D6JointMotion GetMotion(D6JointAxis axis)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            return(Internal_GetMotion(unmanagedPtr, axis));
#endif
        }
コード例 #4
0
        /// <summary>
        /// Allows you to constrain motion of the specified axis. Be aware that when setting drives for a specific axis
        /// you must also take care not to constrain its motion in a conflicting way(for example you cannot add a drive
        /// that moves the joint on X axis, and then lock the X axis).
        ///
        /// Unlocking translations degrees of freedom allows the bodies to move along the subset of the unlocked axes.
        /// (for example unlocking just one translational axis is the equivalent of a slider joint.)
        ///
        /// Angular degrees of freedom are partitioned as twist(around X axis) and swing(around Y and Z axes). Different
        /// effects can be achieves by unlocking their various combinations:
        ///  - If a single degree of angular freedom is unlocked it should be the twist degree as it has extra options for
        ///    that case (for example for a hinge joint).
        ///  - If both swing degrees are unlocked but twist is locked the result is a zero-twist joint.
        ///  - If one swing and one twist degree of freedom are unlocked the result is a zero-swing joint (for example an
        ///    arm attached at the elbow)
        ///  - If all angular degrees of freedom are unlocked the result is the same as the spherical joint.
        /// </summary>
        /// <param name="axis">Axis to change the motion type for.</param>
        /// <param name="motion">Type of motion for the axis.</param>
        public void SetMotion(D6JointAxis axis, D6JointMotion motion)
        {
            if ([email protected][(int)axis] == motion)
            {
                return;
            }

            [email protected][(int)axis] = motion;

            if (Native != null)
            {
                Native.SetMotion(axis, motion);
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates GUI elements for fields specific to the spherical joint.
        /// </summary>
        protected void BuildGUI(D6Joint joint)
        {
            for (int i = 0; i < (int)D6JointAxis.Count; i++)
            {
                D6JointAxis axis      = (D6JointAxis)i;
                string      entryName = Enum.GetName(typeof(D6JointAxis), axis);

                motionFields[i] = new GUIEnumField(typeof(D6JointMotion), new LocEdString(entryName));
                motionFields[i].OnSelectionChanged += x =>
                {
                    joint.SetMotion(axis, (D6JointMotion)x);

                    MarkAsModified();
                    ConfirmModify();
                };
            }

            linearLimitFoldout.AcceptsKeyFocus = false;
            linearLimitFoldout.OnToggled      += x =>
            {
                linearLimitLayout.Active = x;
                Persistent.SetBool("linearLimit_Expanded", x);
            };

            twistLimitFoldout.AcceptsKeyFocus = false;
            twistLimitFoldout.OnToggled      += x =>
            {
                twistLimitLayout.Active = x;
                Persistent.SetBool("twistLimit_Expanded", x);
            };

            swingLimitFoldout.AcceptsKeyFocus = false;
            swingLimitFoldout.OnToggled      += x =>
            {
                swingLimitLayout.Active = x;
                Persistent.SetBool("swingLimit_Expanded", x);
            };

            driveFoldout.AcceptsKeyFocus = false;
            driveFoldout.OnToggled      += x =>
            {
                driveLayout.Active = x;
                Persistent.SetBool("drive_Expanded", x);
            };

            drivePositionField.OnChanged   += x => { joint.SetDriveTransform(x, joint.DriveRotation); MarkAsModified(); };
            drivePositionField.OnFocusLost += ConfirmModify;
            drivePositionField.OnConfirmed += ConfirmModify;

            driveRotationField.OnChanged   += x => { joint.SetDriveTransform(joint.DrivePosition, Quaternion.FromEuler(x)); MarkAsModified(); };
            driveRotationField.OnFocusLost += ConfirmModify;
            driveRotationField.OnConfirmed += ConfirmModify;

            driveLinVelocityField.OnChanged   += x => { joint.SetDriveVelocity(x, joint.DriveAngularVelocity); MarkAsModified(); };
            driveLinVelocityField.OnFocusLost += ConfirmModify;
            driveLinVelocityField.OnConfirmed += ConfirmModify;

            driveAngVelocityField.OnChanged   += x => { joint.SetDriveVelocity(joint.DriveLinearVelocity, x); MarkAsModified(); };
            driveAngVelocityField.OnFocusLost += ConfirmModify;
            driveAngVelocityField.OnConfirmed += ConfirmModify;

            for (int i = 0; i < (int)D6JointAxis.Count; i++)
            {
                Layout.AddElement(motionFields[i]);
            }

            Layout.AddElement(linearLimitFoldout);
            linearLimitLayout = Layout.AddLayoutX();
            {
                linearLimitLayout.AddSpace(10);
                GUILayoutY linearLimitContentsLayout = linearLimitLayout.AddLayoutY();
                limitLinearGUI            = new LimitLinearGUI(joint.LimitLinear, linearLimitContentsLayout, Persistent);
                limitLinearGUI.OnChanged += (x, y) =>
                {
                    joint.LimitLinear = x;
                    joint.LimitLinear.SetBase(y);

                    MarkAsModified();
                };
                limitLinearGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(twistLimitFoldout);
            twistLimitLayout = Layout.AddLayoutX();
            {
                twistLimitLayout.AddSpace(10);
                GUILayoutY twistLimitContentsLayout = twistLimitLayout.AddLayoutY();
                limitTwistGUI            = new LimitAngularRangeGUI(joint.LimitTwist, twistLimitContentsLayout, Persistent);
                limitTwistGUI.OnChanged += (x, y) =>
                {
                    joint.LimitTwist = x;
                    joint.LimitTwist.SetBase(y);

                    MarkAsModified();
                };
                limitTwistGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(swingLimitFoldout);
            swingLimitLayout = Layout.AddLayoutX();
            {
                swingLimitLayout.AddSpace(10);
                GUILayoutY swingLimitContentsLayout = swingLimitLayout.AddLayoutY();
                limitSwingGUI            = new LimitConeRangeGUI(joint.LimitSwing, swingLimitContentsLayout, Persistent);
                limitSwingGUI.OnChanged += (x, y) =>
                {
                    joint.LimitSwing = x;
                    joint.LimitSwing.SetBase(y);

                    MarkAsModified();
                };
                limitSwingGUI.OnConfirmed += ConfirmModify;
            }

            Layout.AddElement(driveFoldout);
            driveLayout = Layout.AddLayoutX();
            {
                driveLayout.AddSpace(10);
                GUILayoutY driveContentsLayout = driveLayout.AddLayoutY();

                for (int i = 0; i < (int)D6JointDriveType.Count; i++)
                {
                    D6JointDriveType type = (D6JointDriveType)i;

                    drivesGUI[i]              = new D6JointDriveGUI(joint.GetDrive(type), driveContentsLayout);
                    drivesGUI[i].OnChanged   += x => { joint.SetDrive(type, x); MarkAsModified(); };
                    drivesGUI[i].OnConfirmed += ConfirmModify;
                }

                driveContentsLayout.AddElement(drivePositionField);
                driveContentsLayout.AddElement(driveRotationField);
                driveContentsLayout.AddElement(driveLinVelocityField);
                driveContentsLayout.AddElement(driveAngVelocityField);
            }

            linearLimitLayout.Active = Persistent.GetBool("linearLimit_Expanded");
            twistLimitLayout.Active  = Persistent.GetBool("twistLimit_Expanded");
            swingLimitLayout.Active  = Persistent.GetBool("swingLimit_Expanded");
            driveLayout.Active       = Persistent.GetBool("drive_Expanded");

            base.BuildGUI(joint, true);
        }
コード例 #6
0
 private static extern void Internal_SetMotion(IntPtr thisPtr, D6JointAxis axis, D6JointMotion motion);
コード例 #7
0
 public void SetMotion(D6JointAxis axis, D6JointMotion motion)
 {
     Internal_SetMotion(mCachedPtr, axis, motion);
 }
コード例 #8
0
 internal static extern void Internal_SetMotion(IntPtr obj, D6JointAxis axis, D6JointMotion value);
コード例 #9
0
 /// <summary>
 /// Sets the motion type around the specified axis.
 /// </summary>
 /// <remarks>
 /// Each axis may independently specify that the degree of freedom is locked (blocking relative movement along or around this axis), limited by the corresponding limit, or free.
 /// </remarks>
 /// <param name="axis">The axis the degree of freedom around which the motion type is specified.</param>
 /// <param name="value">The value.</param>
 public void SetMotion(D6JointAxis axis, D6JointMotion value)
 {
     Internal_SetMotion(unmanagedPtr, axis, value);
 }
コード例 #10
0
 internal static extern D6JointMotion Internal_GetMotion(IntPtr obj, D6JointAxis axis);
コード例 #11
0
 /// <summary>
 /// Gets the motion type around the specified axis.
 /// </summary>
 /// <remarks>
 /// Each axis may independently specify that the degree of freedom is locked (blocking relative movement along or around this axis), limited by the corresponding limit, or free.
 /// </remarks>
 /// <param name="axis">The axis the degree of freedom around which the motion type is specified.</param>
 /// <returns>The value.</returns>
 public D6JointMotion GetMotion(D6JointAxis axis)
 {
     return(Internal_GetMotion(unmanagedPtr, axis));
 }
コード例 #12
0
 /// <summary>
 /// Returns the type of motion constrain for the specified axis.
 /// </summary>
 /// <param name="axis">Axis to retrieve the motion constrain for.</param>
 /// <returns>Motion constrain type for the axis.</returns>
 public D6JointMotion GetMotion(D6JointAxis axis)
 {
     return([email protected][(int)axis]);
 }
コード例 #13
0
ファイル: CD6Joint.generated.cs プロジェクト: nanze81/bsf
 private static extern D6JointMotion Internal_getMotion(IntPtr thisPtr, D6JointAxis axis);
コード例 #14
0
ファイル: CD6Joint.generated.cs プロジェクト: nanze81/bsf
 /// <summary>Returns motion constraint for the specified axis.</summary>
 public D6JointMotion GetMotion(D6JointAxis axis)
 {
     return(Internal_getMotion(mCachedPtr, axis));
 }
コード例 #15
0
ファイル: NativeD6Joint.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_SetMotion(IntPtr thisPtr, D6JointAxis axis, D6JointMotion motion);
コード例 #16
0
ファイル: NativeD6Joint.cs プロジェクト: Ruu/BansheeEngine
 public void SetMotion(D6JointAxis axis, D6JointMotion motion)
 {
     Internal_SetMotion(mCachedPtr, axis, motion);
 }