SceneView3D.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Portions Copyright (c) 2008-2015 the Urho3D project.
  2. //
  3. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include <Atomic/Core/Object.h>
  25. #include <Atomic/UI/UISceneView.h>
  26. using namespace Atomic;
  27. namespace Atomic
  28. {
  29. class Scene;
  30. class Node;
  31. class Camera;
  32. class DebugRenderer;
  33. class Octree;
  34. }
  35. namespace AtomicEditor
  36. {
  37. class SceneEditor3D;
  38. class SceneView3D: public UISceneView
  39. {
  40. OBJECT(SceneView3D);
  41. public:
  42. SceneView3D(Context* context, SceneEditor3D* sceneEditor);
  43. virtual ~SceneView3D();
  44. Ray GetCameraRay();
  45. bool OnEvent(const TBWidgetEvent &ev);
  46. void SetPitch(float pitch) { pitch_ = pitch; }
  47. void SetYaw(float yaw) { yaw_ = yaw; }
  48. void FrameSelection();
  49. void Enable();
  50. void Disable();
  51. bool IsEnabled() { return enabled_; }
  52. DebugRenderer* GetDebugRenderer() { return debugRenderer_; }
  53. SceneEditor3D* GetSceneEditor3D() { return sceneEditor_; }
  54. private:
  55. bool MouseInView();
  56. bool GetOrbitting();
  57. bool GetZooming();
  58. void HandleMouseMove(StringHash eventType, VariantMap& eventData);
  59. void UpdateDragNode(int mouseX, int mouseY);
  60. void HandleDragEnded(StringHash eventType, VariantMap& eventData);
  61. void HandleDragExitWidget(StringHash eventType, VariantMap& eventData);
  62. void HandleDragEnterWidget(StringHash eventType, VariantMap& eventData);
  63. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  64. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
  65. void HandleUIWidgetFocusEscaped(StringHash eventType, VariantMap& eventData);
  66. void HandleUIUnhandledShortcut(StringHash eventType, VariantMap& eventData);
  67. void MoveCamera(float timeStep);
  68. WeakPtr<SceneEditor3D> sceneEditor_;
  69. float yaw_;
  70. float pitch_;
  71. bool mouseLeftDown_;
  72. bool mouseMoved_;
  73. bool enabled_;
  74. bool cameraMove_;
  75. float cameraMoveTime_;
  76. Vector3 cameraMoveStart_;
  77. Vector3 cameraMoveTarget_;
  78. SharedPtr<Camera> camera_;
  79. SharedPtr<DebugRenderer> debugRenderer_;
  80. SharedPtr<Octree> octree_;
  81. BoundingBox framedBBox_;
  82. SharedPtr<Scene> preloadResourceScene_;
  83. String dragAssetGUID_;
  84. SharedPtr<Node> dragNode_;
  85. };
  86. }