BsHandleDrawManager.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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);
  15. void drawSphere(const Vector3& position, float radius);
  16. void drawWireCube(const Vector3& position, const Vector3& extents);
  17. void drawWireSphere(const Vector3& position, float radius);
  18. void drawCone(const Vector3& base, const Vector3& normal, float height, float radius);
  19. void drawLine(const Vector3& start, const Vector3& end);
  20. void drawDisc(const Vector3& position, const Vector3& normal, float radius);
  21. void drawWireDisc(const Vector3& position, const Vector3& normal, float radius);
  22. void drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle);
  23. void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle);
  24. void drawRect(const Rect3& area);
  25. void draw(const HCamera& camera);
  26. private:
  27. friend class HandleDrawManagerCore;
  28. void initializeCore(const MaterialProxyPtr& wireMatProxy, const MaterialProxyPtr& solidMatProxy);
  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. HandleDrawManagerCore* mCore;
  34. DrawHelper* mDrawHelper;
  35. TransientMeshPtr mSolidMesh;
  36. TransientMeshPtr mWireMesh;
  37. };
  38. class BS_ED_EXPORT HandleDrawManagerCore
  39. {
  40. struct SolidMaterialData
  41. {
  42. MaterialProxyPtr proxy;
  43. GpuParamMat4 mViewProj;
  44. };
  45. struct WireMaterialData
  46. {
  47. MaterialProxyPtr proxy;
  48. GpuParamMat4 mViewProj;
  49. };
  50. struct PrivatelyConstruct { };
  51. public:
  52. HandleDrawManagerCore(const PrivatelyConstruct& dummy) { }
  53. private:
  54. friend class HandleDrawManager;
  55. void initialize(const MaterialProxyPtr& wireMatProxy, const MaterialProxyPtr& solidMatProxy);
  56. void updateData(const RenderTargetPtr& rt, const MeshProxyPtr& solidMeshProxy, const MeshProxyPtr& wireMeshProxy);
  57. void render(const CameraProxy& camera);
  58. void renderSolid(Matrix4 viewMatrix, Matrix4 projMatrix, MeshProxyPtr mesh);
  59. void renderWire(Matrix4 viewMatrix, Matrix4 projMatrix, MeshProxyPtr mesh);
  60. RenderTargetPtr mSceneRenderTarget;
  61. MeshProxyPtr mSolidMeshProxy;
  62. MeshProxyPtr mWireMeshProxy;
  63. // Immutable
  64. SolidMaterialData mSolidMaterial;
  65. WireMaterialData mWireMaterial;
  66. };
  67. }