D6JointInspector.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using bs;
  5. namespace bs.Editor
  6. {
  7. /** @addtogroup Inspectors
  8. * @{
  9. */
  10. /// <summary>
  11. /// Renders an inspector for the <see cref="D6Joint"/> component.
  12. /// </summary>
  13. [CustomInspector(typeof(D6Joint))]
  14. internal class D6JointInspector : JointInspector
  15. {
  16. /// <inheritdoc/>
  17. protected internal override void Initialize()
  18. {
  19. D6Joint joint = (D6Joint) InspectedObject;
  20. BuildGUI(joint, true);
  21. drawer.AddDefault(joint, typeof(D6Joint));
  22. drawer.BeginCategory("Motion constraints");
  23. for (int i = 0; i < (int)D6JointAxis.Count; i++)
  24. {
  25. D6JointAxis axis = (D6JointAxis)i;
  26. string entryName = Enum.GetName(typeof(D6JointAxis), axis);
  27. drawer.AddField(entryName, () => joint.GetMotion(axis), x => joint.SetMotion(axis, x));
  28. }
  29. drawer.BeginCategory("Drive");
  30. drawer.AddField("Drive position", () => joint.DrivePosition, x => joint.SetDriveTransform(x, joint.DriveRotation));
  31. drawer.AddField("Drive rotation", () => joint.DriveRotation.ToEuler(), x => joint.SetDriveTransform(joint.DrivePosition, Quaternion.FromEuler(x)));
  32. drawer.AddField("Drive linear velocity", () => joint.DriveLinearVelocity, x => joint.SetDriveVelocity(x, joint.DriveAngularVelocity));
  33. drawer.AddField("Drive angular velocity", () => joint.DriveAngularVelocity, x => joint.SetDriveVelocity(joint.DriveLinearVelocity, x));
  34. for (int i = 0; i < (int)D6JointDriveType.Count; i++)
  35. {
  36. D6JointDriveType type = (D6JointDriveType)i;
  37. string entryName = Enum.GetName(typeof(D6JointDriveType), type);
  38. drawer.AddField(entryName, () => joint.GetDrive(type), x => joint.SetDrive(type, x));
  39. }
  40. drawer.EndCategory();
  41. }
  42. }
  43. /** @} */
  44. }