SceneBaker.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright (c) 2014-2017, THUNDERBEAST GAMES LLC All rights reserved
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. //
  21. #pragma once
  22. #include <Atomic/Scene/Scene.h>
  23. #include "GlowTypes.h"
  24. using namespace Atomic;
  25. namespace AtomicGlow
  26. {
  27. class LightRay;
  28. class BakeMesh;
  29. class BakeLight;
  30. class EmbreeScene;
  31. class SceneBaker : public Object
  32. {
  33. ATOMIC_OBJECT(SceneBaker, Object)
  34. public:
  35. SceneBaker(Context* context, const String& projectPath);
  36. virtual ~SceneBaker();
  37. bool Light(const GlowLightMode lightMode);
  38. void LightFinishCycle();
  39. bool LoadScene(const String& filename);
  40. bool GenerateLightmaps();
  41. const VectorBuffer& GetBakeData() const { return bakeData_; }
  42. GlowLightMode GetCurrentLightMode() const { return currentLightMode_; }
  43. void QueryLights(const BoundingBox& bbox, PODVector<BakeLight*>& lights);
  44. void TraceRay(LightRay* lightRay, const PODVector<AtomicGlow::BakeLight *>& bakeLights_);
  45. Scene* GetScene() const { return scene_; }
  46. EmbreeScene* GetEmbreeScene() const { return embreeScene_; }
  47. int GetCurrentGIBounce() const {return currentGIPass_; }
  48. bool WriteBakeData(VectorBuffer& buffer);
  49. bool GetStandaloneMode() const { return standaloneMode_; }
  50. void SetStandaloneMode(bool standaloneMode) { standaloneMode_ = standaloneMode; }
  51. private:
  52. //void FilterLightmap(Image* lightmap);
  53. //void EmitLightmap(int lightMapIndex);
  54. //bool TryAddStaticModelBaker(StaticModelBaker *bakeModel);
  55. bool Preprocess();
  56. /// process direct (and ao/ambient) lighting, returns true if there is work to be done
  57. bool LightDirect();
  58. void LightDirectFinish();
  59. /// process a GI cycle, returns true if there is work to be done
  60. bool LightGI();
  61. void LightGIFinish();
  62. bool SaveLitScene();
  63. SharedPtr<Scene> scene_;
  64. SharedPtr<EmbreeScene> embreeScene_;
  65. Vector<SharedPtr<BakeMesh>> bakeMeshes_;
  66. Vector<SharedPtr<BakeLight>> bakeLights_;
  67. VectorBuffer bakeData_;
  68. GlowLightMode currentLightMode_;
  69. int currentGIPass_;
  70. String projectPath_;
  71. bool standaloneMode_;
  72. };
  73. }