JSONSceneProcess.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/Container/HashMap.h>
  24. #include <Atomic/Container/List.h>
  25. #include <Atomic/Resource/ResourceCache.h>
  26. #include <Atomic/Graphics/Technique.h>
  27. #include <Atomic/Graphics/Texture2D.h>
  28. #include <Atomic/Graphics/Material.h>
  29. #include <Atomic/Graphics/Model.h>
  30. #include <Atomic/Scene/Scene.h>
  31. using namespace Atomic;
  32. namespace ToolCore
  33. {
  34. class JSONSceneImporter;
  35. class JSONNode;
  36. class JSONTransform;
  37. class JSONMeshRenderer;
  38. class JSONSkinnedMeshRenderer;
  39. class JSONAnimation;
  40. class JSONTerrain;
  41. class JSONBoxCollider;
  42. class JSONMeshCollider;
  43. class JSONRigidBody;
  44. class JSONLight;
  45. class JSONTimeOfDay;
  46. class JSONSceneProcess : public Object
  47. {
  48. ATOMIC_OBJECT(JSONSceneProcess, Object);
  49. public:
  50. JSONSceneProcess(Context* context, JSONSceneImporter* importer) : Object(context)
  51. {
  52. importer_ = importer;
  53. }
  54. bool Process(const String& resourcePath);
  55. bool Write();
  56. private:
  57. String resourcePath_;
  58. HashMap<String, SharedPtr<Material> > materials_;
  59. HashMap<String, SharedPtr<Model> > models_;
  60. SharedPtr<Scene> scene_ ;
  61. List<SharedPtr<Node> > hierarchy_;
  62. bool WriteMaterials();
  63. bool WriteModels();
  64. bool WriteHierarchy(Scene *scene);
  65. bool ProcessTextures();
  66. bool ProcessLightmaps();
  67. bool ProcessMaterials();
  68. bool ProcessModels();
  69. bool ProcessComponent(Node* node, const JSONTransform* jtransform );
  70. bool ProcessComponent(Node* node, const JSONMeshRenderer* jmeshrenderer );
  71. bool ProcessComponent(Node* node, const JSONSkinnedMeshRenderer* jmeshrenderer );
  72. bool ProcessComponent(Node* node, const JSONAnimation* janim );
  73. bool ProcessComponent(Node* node, const JSONTerrain* jterrain );
  74. bool ProcessComponent(Node* node, const JSONBoxCollider* jbox );
  75. bool ProcessComponent(Node* node, const JSONMeshCollider* jmesh );
  76. bool ProcessComponent(Node* node, const JSONLight* jlight );
  77. bool ProcessComponent(Node* node, const JSONRigidBody* jbody );
  78. bool ProcessComponent(Node* node, const JSONTimeOfDay* jtime );
  79. Node* ProcessNode(const JSONNode* jnode, Node *parent);
  80. bool ProcessHierarchy(Scene *scene);
  81. SharedPtr<JSONSceneImporter> importer_;
  82. };
  83. }