SceneEditor3D.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 <TurboBadger/tb_widgets_common.h>
  24. #include "../ResourceEditor.h"
  25. #include "SceneView3D.h"
  26. #include "Gizmo3D.h"
  27. using namespace Atomic;
  28. using namespace tb;
  29. namespace Atomic
  30. {
  31. class Scene;
  32. class Node;
  33. class View3D;
  34. class Camera;
  35. class DebugRenderer;
  36. class Octree;
  37. }
  38. namespace ToolCore
  39. {
  40. class ProjectUserPrefs;
  41. class SceneImporter;
  42. }
  43. using namespace ToolCore;
  44. namespace AtomicEditor
  45. {
  46. class SceneSelection;
  47. class SceneEditHistory;
  48. class SceneEditor3D: public ResourceEditor
  49. {
  50. ATOMIC_OBJECT(SceneEditor3D, ResourceEditor);
  51. public:
  52. SceneEditor3D(Context* context, const String& fullpath, UITabContainer* container);
  53. virtual ~SceneEditor3D();
  54. bool OnEvent(const TBWidgetEvent &ev);
  55. SceneSelection* GetSelection() { return selection_; }
  56. SceneEditHistory* GetEditHistory() { return editHistory_; }
  57. SceneView3D* GetSceneView3D() { return sceneView_; }
  58. void RegisterNode(Node* node);
  59. void RegisterNodes(const PODVector<Node*>& nodes);
  60. void ReparentNode(Node* node, Node* newParent);
  61. Scene* GetScene() { return scene_; }
  62. Gizmo3D* GetGizmo() { return gizmo3D_; }
  63. void SetFocus();
  64. virtual bool RequiresInspector() { return true; }
  65. void Close(bool navigateToAvailableResource = true);
  66. bool Save();
  67. void Undo();
  68. void Redo();
  69. void Cut();
  70. void Copy();
  71. void Paste();
  72. ProjectUserPrefs* GetUserPrefs();
  73. void InvokeShortcut(const String& shortcut);
  74. static SceneEditor3D* GetSceneEditor(Scene* scene);
  75. private:
  76. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  77. void HandlePlayStarted(StringHash eventType, VariantMap& eventData);
  78. void HandlePlayStopped(StringHash eventType, VariantMap& eventData);
  79. void HandleGizmoEditModeChanged(StringHash eventType, VariantMap& eventData);
  80. void HandleGizmoAxisModeChanged(StringHash eventType, VariantMap& eventData);
  81. void HandleUserPrefSaved(StringHash eventType, VariantMap& eventData);
  82. void HandleSceneEditSceneModified(StringHash eventType, VariantMap& eventData);
  83. void HandleSceneEditNodeCreated(StringHash eventType, VariantMap& eventData);
  84. void HandleCubemapRenderBegin(StringHash eventType, VariantMap& eventData);
  85. void HandleCubemapRenderEnd(StringHash eventType, VariantMap& eventData);
  86. void UpdateGizmoSnapSettings();
  87. SharedPtr<Scene> scene_;
  88. // TODO: multiple views
  89. SharedPtr<SceneView3D> sceneView_;
  90. SharedPtr<Gizmo3D> gizmo3D_;
  91. SharedPtr<SceneSelection> selection_;
  92. SharedPtr<SceneEditHistory> editHistory_;
  93. SharedPtr<SceneImporter> sceneImporter_;
  94. SharedPtr<Node> clipboardNode_;
  95. WeakPtr<ProjectUserPrefs> userPrefs_;
  96. void RegisterSceneEditor();
  97. static Vector<WeakPtr<SceneEditor3D>> sceneEditors_;
  98. int cubemapRenderCount_;
  99. };
  100. }