guiNavEditorCtrl.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2014 Daniel Buckmaster
  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
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell 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
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUINAVEDITORCTRL_H_
  23. #define _GUINAVEDITORCTRL_H_
  24. #include "torqueConfig.h"
  25. #ifdef TORQUE_TOOLS
  26. #ifndef _EDITTSCTRL_H_
  27. #include "gui/worldEditor/editTSCtrl.h"
  28. #endif
  29. #ifndef _UNDO_H_
  30. #include "util/undo.h"
  31. #endif
  32. #ifndef _GIZMO_H_
  33. #include "gui/worldEditor/gizmo.h"
  34. #endif
  35. //#ifndef _NAVMESH_TOOL_H_
  36. //#include "navigation/navMeshTool.h"
  37. //#endif
  38. #include "navMesh.h"
  39. #include "T3D/aiPlayer.h"
  40. struct ObjectRenderInst;
  41. class SceneManager;
  42. class SceneRenderState;
  43. class BaseMatInstance;
  44. class NavMeshTool;
  45. class GuiNavEditorCtrl : public EditTSCtrl
  46. {
  47. typedef EditTSCtrl Parent;
  48. friend class GuiNavEditorUndoAction;
  49. public:
  50. static const String mSelectMode;
  51. static const String mLinkMode;
  52. static const String mCoverMode;
  53. static const String mTestMode;
  54. GuiNavEditorCtrl();
  55. ~GuiNavEditorCtrl();
  56. DECLARE_CONOBJECT(GuiNavEditorCtrl);
  57. /// @name SimObject
  58. /// @{
  59. bool onAdd() override;
  60. static void initPersistFields();
  61. /// @}
  62. /// @name GuiControl
  63. /// @{
  64. void onSleep() override;
  65. void onRender(Point2I offset, const RectI &updateRect) override;
  66. /// @}
  67. /// @name EditTSCtrl
  68. /// @{
  69. void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_) override;
  70. bool get3DCentre(Point3F &pos);
  71. void on3DMouseDown(const Gui3DMouseEvent & event) override;
  72. void on3DMouseUp(const Gui3DMouseEvent & event) override;
  73. void on3DMouseMove(const Gui3DMouseEvent & event) override;
  74. void on3DMouseDragged(const Gui3DMouseEvent & event) override;
  75. void on3DMouseEnter(const Gui3DMouseEvent & event) override;
  76. void on3DMouseLeave(const Gui3DMouseEvent & event) override;
  77. void updateGuiInfo() override;
  78. void renderScene(const RectI & updateRect) override;
  79. /// @}
  80. /// @name GuiNavEditorCtrl
  81. /// @{
  82. bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
  83. void selectMesh(NavMesh *mesh);
  84. S32 getMeshId();
  85. /// @}
  86. void setActiveTool(NavMeshTool* tool);
  87. void setDrawMode(S32 id);
  88. protected:
  89. void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
  90. void submitUndo(const UTF8 *name = "Action");
  91. GFXStateBlockRef mZDisableSB;
  92. GFXStateBlockRef mZEnableSB;
  93. bool mIsDirty;
  94. /// Currently-selected NavMesh.
  95. SimObjectPtr<NavMesh> mMesh;
  96. /// The active tool in used by the editor.
  97. SimObjectPtr<NavMeshTool> mTool;
  98. /// @}
  99. /// @name Tile mode
  100. /// @{
  101. duDebugDrawTorque dd;
  102. /// @}
  103. Gui3DMouseEvent mLastMouseEvent;
  104. #define InvalidMousePoint Point2I(-100,-100)
  105. Point2I mStartDragMousePoint;
  106. };
  107. class GuiNavEditorUndoAction : public UndoAction
  108. {
  109. public:
  110. GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName), mNavEditor(NULL), mObjId(0)
  111. {
  112. }
  113. GuiNavEditorCtrl *mNavEditor;
  114. SimObjectId mObjId;
  115. void undo() override;
  116. void redo() override { undo(); }
  117. };
  118. #endif
  119. #endif