D6JointInspector.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. for (int i = 0; i < (int)D6JointAxis.Count; i++)
  23. {
  24. D6JointAxis axis = (D6JointAxis)i;
  25. string entryName = Enum.GetName(typeof(D6JointAxis), axis);
  26. drawer.AddField(entryName, () => joint.GetMotion(axis), x => joint.SetMotion(axis, x));
  27. }
  28. drawer.AddField("Drive position", () => joint.DrivePosition, x => joint.SetDriveTransform(x, joint.DriveRotation));
  29. drawer.AddField("Drive rotation", () => joint.DriveRotation.ToEuler(), x => joint.SetDriveTransform(joint.DrivePosition, Quaternion.FromEuler(x)));
  30. drawer.AddField("Drive linear velocity", () => joint.DriveLinearVelocity, x => joint.SetDriveVelocity(x, joint.DriveAngularVelocity));
  31. drawer.AddField("Drive angular velocity", () => joint.DriveAngularVelocity, x => joint.SetDriveVelocity(joint.DriveLinearVelocity, x));
  32. for (int i = 0; i < (int)D6JointDriveType.Count; i++)
  33. {
  34. D6JointDriveType type = (D6JointDriveType)i;
  35. string entryName = Enum.GetName(typeof(D6JointDriveType), type);
  36. drawer.AddField(entryName, () => joint.GetDrive(type), x => joint.SetDrive(type, x));
  37. }
  38. }
  39. }
  40. /** @} */
  41. }