WhiteBoxManipulatorViews.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzToolsFramework/Manipulators/ManipulatorView.h>
  10. #include <WhiteBox/WhiteBoxToolApi.h>
  11. namespace AzFramework
  12. {
  13. class DebugDisplayRequests;
  14. }
  15. namespace WhiteBox
  16. {
  17. //! Displays a polygon with an outline around the edge.
  18. class ManipulatorViewPolygon : public AzToolsFramework::ManipulatorView
  19. {
  20. public:
  21. AZ_CLASS_ALLOCATOR_DECL
  22. AZ_RTTI(ManipulatorViewPolygon, "{B2290233-1D42-4AF5-8949-7CF9601832E2}", AzToolsFramework::ManipulatorView)
  23. ManipulatorViewPolygon();
  24. void Draw(
  25. AzToolsFramework::ManipulatorManagerId managerId,
  26. const AzToolsFramework::ManipulatorManagerState& managerState,
  27. AzToolsFramework::ManipulatorId manipulatorId, const AzToolsFramework::ManipulatorState& manipulatorState,
  28. AzFramework::DebugDisplayRequests& debugDisplay, const AzFramework::CameraState& cameraState,
  29. const AzToolsFramework::ViewportInteraction::MouseInteraction& mouseInteraction) override;
  30. AZ::Transform m_polygonViewOverlapOffset;
  31. AZStd::vector<AZ::Vector3> m_triangles;
  32. Api::VertexPositionsCollection m_outlines;
  33. AZ::Color m_outlineColor = AZ::Color(1.0f, 1.0f, 0.0f, 1.0f); //!< Yellow
  34. AZ::Color m_fillColor = AZ::Color(1.0f, 1.0f, 0.0f, 0.5f); //!< Yellow
  35. };
  36. class ManipulatorViewEdge : public AzToolsFramework::ManipulatorView
  37. {
  38. public:
  39. AZ_CLASS_ALLOCATOR_DECL
  40. AZ_RTTI(ManipulatorViewEdge, "{42F07925-5B2F-4CC6-9033-CF2FE548BF8A}", AzToolsFramework::ManipulatorView)
  41. ManipulatorViewEdge();
  42. void Draw(
  43. AzToolsFramework::ManipulatorManagerId managerId,
  44. const AzToolsFramework::ManipulatorManagerState& managerState,
  45. AzToolsFramework::ManipulatorId manipulatorId, const AzToolsFramework::ManipulatorState& manipulatorState,
  46. AzFramework::DebugDisplayRequests& debugDisplay, const AzFramework::CameraState& cameraState,
  47. const AzToolsFramework::ViewportInteraction::MouseInteraction& mouseInteraction) override;
  48. void SetColor(const AZ::Color& color, const AZ::Color& hoverColor);
  49. void SetWidth(float width, float hoverWidth);
  50. AZ::Vector3 m_start;
  51. AZ::Vector3 m_end;
  52. AZStd::array<float, 2> m_width;
  53. AZStd::array<AZ::Color, 2> m_color;
  54. AZStd::array<bool, 2> m_vertexStartEndHidden; //!< When this manipulator view was created, were the adjoining
  55. //!< vertex handles hidden or not.
  56. };
  57. void TranslatePoints(AZStd::vector<AZ::Vector3>& points, const AZ::Vector3& offset);
  58. AZStd::unique_ptr<ManipulatorViewPolygon> CreateManipulatorViewPolygon(
  59. const AZStd::vector<AZ::Vector3>& triangles, const Api::VertexPositionsCollection& outlines);
  60. AZStd::unique_ptr<ManipulatorViewEdge> CreateManipulatorViewEdge(const AZ::Vector3& start, const AZ::Vector3& end);
  61. } // namespace WhiteBox