AnimationGizmo.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /** @addtogroup Gizmos
  7. * @{
  8. */
  9. /// <summary>
  10. /// Handles drawing of gizmos for the <see cref="Animation"/> component.
  11. /// </summary>
  12. internal class AnimationGizmo
  13. {
  14. /// <summary>
  15. /// Method called by the runtime when gizmos are meant to be drawn.
  16. /// </summary>
  17. /// <param name="animation">Animation component to draw gizmo for.</param>
  18. [DrawGizmo(DrawGizmoFlags.Selected | DrawGizmoFlags.ParentSelected)]
  19. private static void DrawGizmo(Animation animation)
  20. {
  21. SceneObject so = animation.SceneObject;
  22. Gizmos.Color = Color.Green;
  23. Gizmos.Transform = Matrix4.Identity;
  24. Matrix4 parentTfrm;
  25. if (so.Parent != null)
  26. parentTfrm = so.Parent.WorldTransform;
  27. else
  28. parentTfrm = Matrix4.Identity;
  29. AABox bounds = animation.Bounds;
  30. bounds.TransformAffine(parentTfrm);
  31. Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f);
  32. }
  33. }
  34. /** @} */
  35. }