AnimationGizmo.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using bs;
  4. namespace bs.Editor
  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. AABox bounds = new AABox();
  25. bool useAnimBounds = animation.UseBounds;
  26. if (!useAnimBounds)
  27. {
  28. Renderable renderable = so.GetComponent<Renderable>();
  29. if (renderable != null)
  30. bounds = renderable.Bounds.Box;
  31. else
  32. useAnimBounds = true;
  33. }
  34. if (useAnimBounds)
  35. {
  36. bounds = animation.Bounds;
  37. bounds.TransformAffine(so.WorldTransform);
  38. }
  39. Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f);
  40. }
  41. }
  42. /** @} */
  43. }