guiNavEditorCtrl.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. #include "torqueConfig.h"
  23. #ifdef TORQUE_TOOLS
  24. #include "platform/platform.h"
  25. #include "guiNavEditorCtrl.h"
  26. #include "duDebugDrawTorque.h"
  27. #include "console/engineAPI.h"
  28. #include "console/consoleTypes.h"
  29. #include "math/util/frustum.h"
  30. #include "math/mathUtils.h"
  31. #include "gfx/primBuilder.h"
  32. #include "gfx/gfxDrawUtil.h"
  33. #include "scene/sceneRenderState.h"
  34. #include "scene/sceneManager.h"
  35. #include "gui/core/guiCanvas.h"
  36. #include "gui/buttons/guiButtonCtrl.h"
  37. #include "gui/worldEditor/undoActions.h"
  38. #include "T3D/gameBase/gameConnection.h"
  39. #include "T3D/AI/AIController.h"
  40. IMPLEMENT_CONOBJECT(GuiNavEditorCtrl);
  41. ConsoleDocClass(GuiNavEditorCtrl,
  42. "@brief GUI tool that makes up the Navigation Editor\n\n"
  43. "Editor use only.\n\n"
  44. "@internal"
  45. );
  46. // Each of the mode names directly correlates with the Nav Editor's tool palette.
  47. const String GuiNavEditorCtrl::mSelectMode = "SelectMode";
  48. const String GuiNavEditorCtrl::mLinkMode = "LinkMode";
  49. const String GuiNavEditorCtrl::mCoverMode = "CoverMode";
  50. const String GuiNavEditorCtrl::mTestMode = "TestMode";
  51. GuiNavEditorCtrl::GuiNavEditorCtrl()
  52. {
  53. mMode = mSelectMode;
  54. mIsDirty = false;
  55. mStartDragMousePoint = InvalidMousePoint;
  56. mMesh = NULL;
  57. mPlayer = mCurPlayer = NULL;
  58. mSpawnClass = mSpawnDatablock = "";
  59. mLinkStart = Point3F::Max;
  60. mLink = mCurLink = -1;
  61. }
  62. GuiNavEditorCtrl::~GuiNavEditorCtrl()
  63. {
  64. }
  65. void GuiNavEditorUndoAction::undo()
  66. {
  67. }
  68. bool GuiNavEditorCtrl::onAdd()
  69. {
  70. if(!Parent::onAdd())
  71. return false;
  72. GFXStateBlockDesc desc;
  73. desc.fillMode = GFXFillSolid;
  74. desc.setBlend(false);
  75. desc.setZReadWrite(false, false);
  76. desc.setCullMode(GFXCullNone);
  77. mZDisableSB = GFX->createStateBlock(desc);
  78. desc.setZReadWrite(true, true);
  79. mZEnableSB = GFX->createStateBlock(desc);
  80. SceneManager::getPreRenderSignal().notify(this, &GuiNavEditorCtrl::_prepRenderImage);
  81. return true;
  82. }
  83. void GuiNavEditorCtrl::initPersistFields()
  84. {
  85. docsURL;
  86. addField("isDirty", TypeBool, Offset(mIsDirty, GuiNavEditorCtrl));
  87. addField("spawnClass", TypeRealString, Offset(mSpawnClass, GuiNavEditorCtrl),
  88. "Class of object to spawn in test mode.");
  89. addField("spawnDatablock", TypeRealString, Offset(mSpawnDatablock, GuiNavEditorCtrl),
  90. "Datablock to give new objects in test mode.");
  91. Parent::initPersistFields();
  92. }
  93. void GuiNavEditorCtrl::onSleep()
  94. {
  95. Parent::onSleep();
  96. //mMode = mSelectMode;
  97. }
  98. void GuiNavEditorCtrl::selectMesh(NavMesh *mesh)
  99. {
  100. mesh->setSelected(true);
  101. mMesh = mesh;
  102. }
  103. DefineEngineMethod(GuiNavEditorCtrl, selectMesh, void, (S32 id),,
  104. "@brief Select a NavMesh object.")
  105. {
  106. NavMesh *obj;
  107. if(Sim::findObject(id, obj))
  108. object->selectMesh(obj);
  109. }
  110. S32 GuiNavEditorCtrl::getMeshId()
  111. {
  112. return mMesh.isNull() ? 0 : mMesh->getId();
  113. }
  114. DefineEngineMethod(GuiNavEditorCtrl, getMesh, S32, (),,
  115. "@brief Select a NavMesh object.")
  116. {
  117. return object->getMeshId();
  118. }
  119. S32 GuiNavEditorCtrl::getPlayerId()
  120. {
  121. return mPlayer.isNull() ? 0 : mPlayer->getId();
  122. }
  123. DefineEngineMethod(GuiNavEditorCtrl, getPlayer, S32, (),,
  124. "@brief Select a NavMesh object.")
  125. {
  126. return object->getPlayerId();
  127. }
  128. void GuiNavEditorCtrl::deselect()
  129. {
  130. if(!mMesh.isNull())
  131. mMesh->setSelected(false);
  132. mMesh = NULL;
  133. mPlayer = mCurPlayer = NULL;
  134. mLinkStart = Point3F::Max;
  135. mLink = mCurLink = -1;
  136. }
  137. DefineEngineMethod(GuiNavEditorCtrl, deselect, void, (),,
  138. "@brief Deselect whatever is currently selected in the editor.")
  139. {
  140. object->deselect();
  141. }
  142. void GuiNavEditorCtrl::deleteLink()
  143. {
  144. if(!mMesh.isNull() && mLink != -1)
  145. {
  146. mMesh->selectLink(mLink, false);
  147. mMesh->deleteLink(mLink);
  148. mLink = -1;
  149. Con::executef(this, "onLinkDeselected");
  150. }
  151. }
  152. DefineEngineMethod(GuiNavEditorCtrl, deleteLink, void, (),,
  153. "@brief Delete the currently selected link.")
  154. {
  155. object->deleteLink();
  156. }
  157. void GuiNavEditorCtrl::setLinkFlags(const LinkData &d)
  158. {
  159. if(mMode == mLinkMode && !mMesh.isNull() && mLink != -1)
  160. {
  161. mMesh->setLinkFlags(mLink, d);
  162. }
  163. }
  164. DefineEngineMethod(GuiNavEditorCtrl, setLinkFlags, void, (U32 flags),,
  165. "@Brief Set jump and drop properties of the selected link.")
  166. {
  167. object->setLinkFlags(LinkData(flags));
  168. }
  169. void GuiNavEditorCtrl::spawnPlayer(const Point3F &pos)
  170. {
  171. SceneObject *obj = (SceneObject*)Sim::spawnObject(mSpawnClass, mSpawnDatablock);
  172. if(obj)
  173. {
  174. MatrixF mat(true);
  175. mat.setPosition(pos);
  176. obj->setTransform(mat);
  177. SimObject* cleanup = Sim::findObject("MissionCleanup");
  178. if(cleanup)
  179. {
  180. SimGroup* missionCleanup = dynamic_cast<SimGroup*>(cleanup);
  181. missionCleanup->addObject(obj);
  182. }
  183. mPlayer = obj;
  184. #ifdef TORQUE_NAVIGATION_ENABLED
  185. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(obj);
  186. if (asAIPlayer) //try direct
  187. {
  188. Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
  189. }
  190. else
  191. {
  192. ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj);
  193. if (sbo->getAIController())
  194. {
  195. if (sbo->getAIController()->mControllerData)
  196. Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
  197. }
  198. else
  199. {
  200. #endif
  201. Con::executef(this, "onPlayerSelected");
  202. #ifdef TORQUE_NAVIGATION_ENABLED
  203. }
  204. }
  205. #endif
  206. }
  207. }
  208. DefineEngineMethod(GuiNavEditorCtrl, spawnPlayer, void, (),,
  209. "@brief Spawn an AIPlayer at the centre of the screen.")
  210. {
  211. Point3F c;
  212. if(object->get3DCentre(c))
  213. object->spawnPlayer(c);
  214. }
  215. void GuiNavEditorCtrl::get3DCursor(GuiCursor *&cursor,
  216. bool &visible,
  217. const Gui3DMouseEvent &event_)
  218. {
  219. //cursor = mAddNodeCursor;
  220. //visible = false;
  221. cursor = NULL;
  222. visible = false;
  223. GuiCanvas *root = getRoot();
  224. if(!root)
  225. return;
  226. S32 currCursor = PlatformCursorController::curArrow;
  227. if(root->mCursorChanged == currCursor)
  228. return;
  229. PlatformWindow *window = root->getPlatformWindow();
  230. PlatformCursorController *controller = window->getCursorController();
  231. // We've already changed the cursor,
  232. // so set it back before we change it again.
  233. if(root->mCursorChanged != -1)
  234. controller->popCursor();
  235. // Now change the cursor shape
  236. controller->pushCursor(currCursor);
  237. root->mCursorChanged = currCursor;
  238. }
  239. bool GuiNavEditorCtrl::get3DCentre(Point3F &pos)
  240. {
  241. Point3F screen, start, end;
  242. screen.set(getExtent().x / 2, getExtent().y / 2, 0);
  243. unproject(screen, &start);
  244. screen.z = 1.0f;
  245. unproject(screen, &end);
  246. RayInfo ri;
  247. if(gServerContainer.castRay(start, end, StaticObjectType, &ri))
  248. {
  249. pos = ri.point;
  250. return true;
  251. }
  252. return false;
  253. }
  254. void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
  255. {
  256. if (!mMesh)
  257. return;
  258. mGizmo->on3DMouseDown(event);
  259. if (mTool)
  260. mTool->on3DMouseDown(event);
  261. mouseLock();
  262. return;
  263. // Construct a LineSegment from the camera position to 1000 meters away in
  264. // the direction clicked.
  265. // If that segment hits the terrain, truncate the ray to only be that length.
  266. Point3F startPnt = event.pos;
  267. Point3F endPnt = event.pos + event.vec * 1000.0f;
  268. RayInfo ri;
  269. U8 keys = Input::getModifierKeys();
  270. bool shift = keys & SI_LSHIFT;
  271. bool ctrl = keys & SI_LCTRL;
  272. if(mMode == mLinkMode && !mMesh.isNull())
  273. {
  274. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  275. {
  276. U32 link = mMesh->getLink(ri.point);
  277. if(link != -1)
  278. {
  279. if(mLink != -1)
  280. mMesh->selectLink(mLink, false);
  281. mMesh->selectLink(link, true, false);
  282. mLink = link;
  283. LinkData d = mMesh->getLinkFlags(mLink);
  284. Con::executef(this, "onLinkSelected", Con::getIntArg(d.getFlags()));
  285. }
  286. else
  287. {
  288. if(mLink != -1)
  289. {
  290. mMesh->selectLink(mLink, false);
  291. mLink = -1;
  292. Con::executef(this, "onLinkDeselected");
  293. }
  294. else
  295. {
  296. if(mLinkStart != Point3F::Max)
  297. {
  298. mMesh->addLink(mLinkStart, ri.point);
  299. if(!shift)
  300. mLinkStart = Point3F::Max;
  301. }
  302. else
  303. {
  304. mLinkStart = ri.point;
  305. }
  306. }
  307. }
  308. }
  309. else
  310. {
  311. mMesh->selectLink(mLink, false);
  312. mLink = -1;
  313. Con::executef(this, "onLinkDeselected");
  314. }
  315. }
  316. if(mMode == mTestMode)
  317. {
  318. // Spawn new character
  319. if(ctrl)
  320. {
  321. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  322. spawnPlayer(ri.point);
  323. }
  324. // Deselect character
  325. else if(shift)
  326. {
  327. mPlayer = NULL;
  328. Con::executef(this, "onPlayerDeselected");
  329. }
  330. // Select/move character
  331. else
  332. {
  333. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  334. {
  335. if(ri.object)
  336. {
  337. mPlayer = ri.object;
  338. #ifdef TORQUE_NAVIGATION_ENABLED
  339. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  340. if (asAIPlayer) //try direct
  341. {
  342. Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
  343. }
  344. else
  345. {
  346. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  347. if (sbo->getAIController())
  348. {
  349. if (sbo->getAIController()->mControllerData)
  350. Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
  351. }
  352. else
  353. {
  354. #endif
  355. Con::executef(this, "onPlayerSelected");
  356. }
  357. #ifdef TORQUE_NAVIGATION_ENABLED
  358. }
  359. }
  360. #endif
  361. }
  362. else if (!mPlayer.isNull() && gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  363. {
  364. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  365. if (asAIPlayer) //try direct
  366. {
  367. #ifdef TORQUE_NAVIGATION_ENABLED
  368. asAIPlayer->setPathDestination(ri.point);
  369. #else
  370. asAIPlayer->setMoveDestination(ri.point,false);
  371. #endif
  372. }
  373. else
  374. {
  375. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  376. if (sbo->getAIController())
  377. {
  378. if (sbo->getAIController()->mControllerData)
  379. sbo->getAIController()->getNav()->setPathDestination(ri.point, true);
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. void GuiNavEditorCtrl::on3DMouseUp(const Gui3DMouseEvent & event)
  387. {
  388. if (!mMesh)
  389. return;
  390. // Keep the Gizmo up to date.
  391. mGizmo->on3DMouseUp(event);
  392. if (mTool)
  393. mTool->on3DMouseUp(event);
  394. mouseUnlock();
  395. }
  396. void GuiNavEditorCtrl::on3DMouseMove(const Gui3DMouseEvent & event)
  397. {
  398. if (!mMesh)
  399. return;
  400. if (mTool)
  401. mTool->on3DMouseMove(event);
  402. return;
  403. //if(mSelRiver != NULL && mSelNode != -1)
  404. //mGizmo->on3DMouseMove(event);
  405. Point3F startPnt = event.pos;
  406. Point3F endPnt = event.pos + event.vec * 1000.0f;
  407. RayInfo ri;
  408. if(mMode == mLinkMode && !mMesh.isNull())
  409. {
  410. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  411. {
  412. U32 link = mMesh->getLink(ri.point);
  413. if(link != -1)
  414. {
  415. if(link != mLink)
  416. {
  417. if(mCurLink != -1)
  418. mMesh->selectLink(mCurLink, false);
  419. mMesh->selectLink(link, true, true);
  420. }
  421. mCurLink = link;
  422. }
  423. else
  424. {
  425. if(mCurLink != mLink)
  426. mMesh->selectLink(mCurLink, false);
  427. mCurLink = -1;
  428. }
  429. }
  430. else
  431. {
  432. mMesh->selectLink(mCurLink, false);
  433. mCurLink = -1;
  434. }
  435. }
  436. if(mMode == mTestMode)
  437. {
  438. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  439. mCurPlayer = ri.object;
  440. else
  441. mCurPlayer = NULL;
  442. }
  443. }
  444. void GuiNavEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
  445. {
  446. mGizmo->on3DMouseDragged(event);
  447. if(mGizmo->isDirty())
  448. {
  449. Point3F scale = mGizmo->getScale();
  450. const MatrixF &mat = mGizmo->getTransform();
  451. VectorF normal;
  452. mat.getColumn(2, &normal);
  453. //mSelRiver->setNode(pos, scale.x, scale.z, normal, mSelNode);
  454. mIsDirty = true;
  455. }
  456. }
  457. void GuiNavEditorCtrl::on3DMouseEnter(const Gui3DMouseEvent & event)
  458. {
  459. }
  460. void GuiNavEditorCtrl::on3DMouseLeave(const Gui3DMouseEvent & event)
  461. {
  462. }
  463. void GuiNavEditorCtrl::updateGuiInfo()
  464. {
  465. if (mTool)
  466. {
  467. if (mTool->updateGuiInfo())
  468. return;
  469. }
  470. }
  471. void GuiNavEditorCtrl::onRender(Point2I offset, const RectI &updateRect)
  472. {
  473. PROFILE_SCOPE(GuiNavEditorCtrl_OnRender);
  474. Parent::onRender(offset, updateRect);
  475. return;
  476. }
  477. static void renderBoxOutline(const Box3F &box, const ColorI &col)
  478. {
  479. if(box != Box3F::Invalid)
  480. {
  481. GFXStateBlockDesc desc;
  482. desc.setCullMode(GFXCullNone);
  483. desc.setFillModeSolid();
  484. desc.setZReadWrite(true, false);
  485. desc.setBlend(true);
  486. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 20));
  487. desc.setFillModeWireframe();
  488. desc.setBlend(false);
  489. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 255));
  490. }
  491. }
  492. void GuiNavEditorCtrl::renderScene(const RectI & updateRect)
  493. {
  494. GFX->setStateBlock(mZDisableSB);
  495. // get the projected size...
  496. GameConnection* connection = GameConnection::getConnectionToServer();
  497. if(!connection)
  498. return;
  499. // Grab the camera's transform
  500. MatrixF mat;
  501. connection->getControlCameraTransform(0, &mat);
  502. // Get the camera position
  503. Point3F camPos;
  504. mat.getColumn(3,&camPos);
  505. if (mTool)
  506. mTool->onRender3D();
  507. if(mMode == mLinkMode)
  508. {
  509. if(mLinkStart != Point3F::Max)
  510. {
  511. GFXStateBlockDesc desc;
  512. desc.setBlend(false);
  513. desc.setZReadWrite(true ,true);
  514. MatrixF linkMat(true);
  515. linkMat.setPosition(mLinkStart);
  516. Point3F scale(0.8f, 0.8f, 0.8f);
  517. GFX->getDrawUtil()->drawTransform(desc, linkMat, &scale);
  518. }
  519. }
  520. if(mMode == mTestMode)
  521. {
  522. if(!mCurPlayer.isNull())
  523. renderBoxOutline(mCurPlayer->getWorldBox(), ColorI::BLUE);
  524. if(!mPlayer.isNull())
  525. renderBoxOutline(mPlayer->getWorldBox(), ColorI::GREEN);
  526. }
  527. duDebugDrawTorque d;
  528. if(!mMesh.isNull())
  529. mMesh->renderLinks(d);
  530. // Now draw all the 2d stuff!
  531. GFX->setClipRect(updateRect);
  532. }
  533. bool GuiNavEditorCtrl::getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos)
  534. {
  535. // Find clicked point on the terrain
  536. Point3F startPnt = event.pos;
  537. Point3F endPnt = event.pos + event.vec * 1000.0f;
  538. RayInfo ri;
  539. bool hit;
  540. hit = gServerContainer.castRay(startPnt, endPnt, StaticShapeObjectType, &ri);
  541. tpos = ri.point;
  542. return hit;
  543. }
  544. void GuiNavEditorCtrl::setMode(String mode, bool sourceShortcut = false)
  545. {
  546. mMode = mode;
  547. Con::executef(this, "onModeSet", mode);
  548. if(sourceShortcut)
  549. Con::executef(this, "paletteSync", mode);
  550. }
  551. void GuiNavEditorCtrl::submitUndo(const UTF8 *name)
  552. {
  553. // Grab the mission editor undo manager.
  554. UndoManager *undoMan = NULL;
  555. if(!Sim::findObject("EUndoManager", undoMan))
  556. {
  557. Con::errorf("GuiNavEditorCtrl::submitUndo() - EUndoManager not found!");
  558. return;
  559. }
  560. // Setup the action.
  561. GuiNavEditorUndoAction *action = new GuiNavEditorUndoAction(name);
  562. action->mNavEditor = this;
  563. undoMan->addAction(action);
  564. }
  565. void GuiNavEditorCtrl::_prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* state)
  566. {
  567. /*if(isAwake() && River::smEditorOpen && mSelRiver)
  568. {
  569. ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
  570. ri->type = RenderPassManager::RIT_Editor;
  571. ri->renderDelegate.bind(this, &GuiNavEditorCtrl::_renderSelectedRiver);
  572. ri->defaultKey = 100;
  573. state->getRenderPass()->addInst(ri);
  574. }*/
  575. }
  576. void GuiNavEditorCtrl::setActiveTool(NavMeshTool* tool)
  577. {
  578. if (mTool)
  579. {
  580. mTool->onDeactivated();
  581. }
  582. mTool = tool;
  583. if (mTool)
  584. {
  585. mTool->setActiveNavMesh(mMesh);
  586. mTool->onActivated(mLastEvent);
  587. }
  588. }
  589. DefineEngineMethod(GuiNavEditorCtrl, setActiveTool, void, (const char* toolName), , "( NavMeshTool tool )")
  590. {
  591. NavMeshTool* tool = dynamic_cast<NavMeshTool*>(Sim::findObject(toolName));
  592. object->setActiveTool(tool);
  593. }
  594. DefineEngineMethod(GuiNavEditorCtrl, getMode, const char*, (), , "")
  595. {
  596. return object->getMode();
  597. }
  598. DefineEngineMethod(GuiNavEditorCtrl, setMode, void, (String mode),, "setMode(String mode)")
  599. {
  600. object->setMode(mode);
  601. }
  602. #endif