CubemapGenerator.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <Atomic/Graphics/GraphicsDefs.h>
  24. #include "EditorComponent.h"
  25. namespace Atomic
  26. {
  27. class Node;
  28. class Zone;
  29. class Camera;
  30. class Viewport;
  31. class Texture2D;
  32. class RenderSurface;
  33. class RenderPath;
  34. class Image;
  35. }
  36. using namespace Atomic;
  37. namespace AtomicEditor
  38. {
  39. class CubemapGenerator : public EditorComponent
  40. {
  41. OBJECT(CubemapGenerator);
  42. public:
  43. /// Construct.
  44. CubemapGenerator(Context* context);
  45. /// Destruct.
  46. virtual ~CubemapGenerator();
  47. /// Register object factory.
  48. static void RegisterObject(Context* context);
  49. bool Render();
  50. int GetImageSize() const { return imageSize_; }
  51. void SetImageSize(int size) { imageSize_ = size; }
  52. protected:
  53. private:
  54. void HandleBeginFrame(StringHash eventType, VariantMap& eventData);
  55. void HandleEndFrame(StringHash eventType, VariantMap& eventData);
  56. bool InitRender();
  57. bool InitPaths();
  58. void EndRender();
  59. void SaveCubemapXML();
  60. SharedPtr<Image> GetImage(Texture2D* tex2d);
  61. CubeMapFace GetFaceForCycle(int cycle);
  62. String GetFaceName(CubeMapFace face);
  63. Quaternion RotationOf(CubeMapFace face);
  64. SharedPtr<Node> cameraNode_;
  65. SharedPtr<Camera> camera_;
  66. SharedPtr<Viewport> viewport_;
  67. SharedPtr<Texture2D> renderImage_;
  68. SharedPtr<RenderSurface> renderSurface_;
  69. int updateCycle_;
  70. int imageSize_;
  71. String namePrefix_;
  72. String outputPathAbsolute_;
  73. String resourcePath_;
  74. WeakPtr<SceneEditor3D> sceneEditor_;
  75. };
  76. }