BsHandleDrawManager.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGpuParams.h"
  4. namespace BansheeEngine
  5. {
  6. class HandleDrawManagerCore;
  7. class BS_ED_EXPORT HandleDrawManager
  8. {
  9. public:
  10. HandleDrawManager();
  11. ~HandleDrawManager();
  12. void setColor(const Color& color);
  13. void setTransform(const Matrix4& transform);
  14. void drawCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
  15. void drawSphere(const Vector3& position, float radius, float size = 1.0f);
  16. void drawWireCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
  17. void drawWireSphere(const Vector3& position, float radius, float size = 1.0f);
  18. void drawCone(const Vector3& base, const Vector3& normal, float height, float radius, float size = 1.0f);
  19. void drawLine(const Vector3& start, const Vector3& end, float size = 1.0f);
  20. void drawDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
  21. void drawWireDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
  22. void drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
  23. void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
  24. void drawRect(const Rect3& area, float size = 1.0f);
  25. void draw(const CameraHandlerPtr& camera);
  26. private:
  27. friend class HandleDrawManagerCore;
  28. void initializeCore(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat);
  29. void destroyCore(HandleDrawManagerCore* core);
  30. static const UINT32 SPHERE_QUALITY;
  31. static const UINT32 WIRE_SPHERE_QUALITY;
  32. static const UINT32 ARC_QUALITY;
  33. Matrix4 mTransform;
  34. HandleDrawManagerCore* mCore;
  35. DrawHelper* mDrawHelper;
  36. };
  37. class BS_ED_EXPORT HandleDrawManagerCore
  38. {
  39. struct SolidMaterialData
  40. {
  41. SPtr<MaterialCore> mat;
  42. GpuParamMat4Core mViewProj;
  43. GpuParamVec4Core mViewDir;
  44. };
  45. struct WireMaterialData
  46. {
  47. SPtr<MaterialCore> mat;
  48. GpuParamMat4Core mViewProj;
  49. };
  50. enum class MeshType
  51. {
  52. Solid, Wire
  53. };
  54. struct MeshData
  55. {
  56. MeshData(const SPtr<MeshCoreBase>& mesh, MeshType type)
  57. :mesh(mesh), type(type)
  58. { }
  59. SPtr<MeshCoreBase> mesh;
  60. MeshType type;
  61. };
  62. struct PrivatelyConstruct { };
  63. public:
  64. HandleDrawManagerCore(const PrivatelyConstruct& dummy) { }
  65. private:
  66. friend class HandleDrawManager;
  67. void initialize(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat);
  68. void updateData(const SPtr<CameraHandlerCore>& camera, const Vector<MeshData>& meshes);
  69. void render();
  70. SPtr<CameraHandlerCore> mCamera;
  71. Vector<MeshData> mMeshes;
  72. // Immutable
  73. SolidMaterialData mSolidMaterial;
  74. WireMaterialData mWireMaterial;
  75. };
  76. }