15_Navigation.as 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. // Navigation example.
  2. // This sample demonstrates:
  3. // - Generating a navigation mesh into the scene
  4. // - Performing path queries to the navigation mesh
  5. // - Rebuilding the navigation mesh partially when adding or removing objects
  6. // - Visualizing custom debug geometry
  7. // - Raycasting drawable components
  8. // - Making a node follow the Detour path
  9. #include "Scripts/Utilities/Sample.as"
  10. Vector3 endPos;
  11. Array<Vector3> currentPath;
  12. Node@ jackNode;
  13. bool useStreaming = false;
  14. // Used for streaming only
  15. const int STREAMING_DISTANCE = 2;
  16. Array<VectorBuffer> navigationTilesData;
  17. Array<IntVector2> navigationTilesIdx;
  18. Array<IntVector2> addedTiles;
  19. void Start()
  20. {
  21. // Execute the common startup for samples
  22. SampleStart();
  23. // Create the scene content
  24. CreateScene();
  25. // Create the UI content
  26. CreateUI();
  27. // Setup the viewport for displaying the scene
  28. SetupViewport();
  29. // Set the mouse mode to use in the sample
  30. SampleInitMouseMode(MM_RELATIVE);
  31. // Hook up to the frame update and render post-update events
  32. SubscribeToEvents();
  33. }
  34. void CreateScene()
  35. {
  36. scene_ = Scene();
  37. // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
  38. // Also create a DebugRenderer component so that we can draw debug geometry
  39. scene_.CreateComponent("Octree");
  40. scene_.CreateComponent("DebugRenderer");
  41. // Create scene node & StaticModel component for showing a static plane
  42. Node@ planeNode = scene_.CreateChild("Plane");
  43. planeNode.scale = Vector3(100.0f, 1.0f, 100.0f);
  44. StaticModel@ planeObject = planeNode.CreateComponent("StaticModel");
  45. planeObject.model = cache.GetResource("Model", "Models/Plane.mdl");
  46. planeObject.material = cache.GetResource("Material", "Materials/StoneTiled.xml");
  47. // Create a Zone component for ambient lighting & fog control
  48. Node@ zoneNode = scene_.CreateChild("Zone");
  49. Zone@ zone = zoneNode.CreateComponent("Zone");
  50. zone.boundingBox = BoundingBox(-1000.0f, 1000.0f);
  51. zone.ambientColor = Color(0.15f, 0.15f, 0.15f);
  52. zone.fogColor = Color(0.5f, 0.5f, 0.7f);
  53. zone.fogStart = 100.0f;
  54. zone.fogEnd = 300.0f;
  55. // Create a directional light to the world. Enable cascaded shadows on it
  56. Node@ lightNode = scene_.CreateChild("DirectionalLight");
  57. lightNode.direction = Vector3(0.6f, -1.0f, 0.8f);
  58. Light@ light = lightNode.CreateComponent("Light");
  59. light.lightType = LIGHT_DIRECTIONAL;
  60. light.castShadows = true;
  61. light.shadowBias = BiasParameters(0.00025f, 0.5f);
  62. // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
  63. light.shadowCascade = CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);
  64. // Create some mushrooms
  65. const uint NUM_MUSHROOMS = 100;
  66. for (uint i = 0; i < NUM_MUSHROOMS; ++i)
  67. CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
  68. // Create randomly sized boxes. If boxes are big enough, make them occluders. Occluders will be software rasterized before
  69. // rendering to a low-resolution depth-only buffer to test the objects in the view frustum for visibility
  70. const uint NUM_BOXES = 20;
  71. for (uint i = 0; i < NUM_BOXES; ++i)
  72. {
  73. Node@ boxNode = scene_.CreateChild("Box");
  74. float size = 1.0f + Random(10.0f);
  75. boxNode.position = Vector3(Random(80.0f) - 40.0f, size * 0.5f, Random(80.0f) - 40.0f);
  76. boxNode.SetScale(size);
  77. StaticModel@ boxObject = boxNode.CreateComponent("StaticModel");
  78. boxObject.model = cache.GetResource("Model", "Models/Box.mdl");
  79. boxObject.material = cache.GetResource("Material", "Materials/Stone.xml");
  80. boxObject.castShadows = true;
  81. if (size >= 3.0f)
  82. boxObject.occluder = true;
  83. }
  84. // Create Jack node that will follow the path
  85. jackNode = scene_.CreateChild("Jack");
  86. jackNode.position = Vector3(-5.0f, 0.0f, 20.0f);
  87. AnimatedModel@ modelObject = jackNode.CreateComponent("AnimatedModel");
  88. modelObject.model = cache.GetResource("Model", "Models/Jack.mdl");
  89. modelObject.material = cache.GetResource("Material", "Materials/Jack.xml");
  90. modelObject.castShadows = true;
  91. // Create a NavigationMesh component to the scene root
  92. NavigationMesh@ navMesh = scene_.CreateComponent("NavigationMesh");
  93. // Set small tiles to show navigation mesh streaming
  94. navMesh.tileSize = 32;
  95. // Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
  96. // navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
  97. scene_.CreateComponent("Navigable");
  98. // Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
  99. // in the scene and still update the mesh correctly
  100. navMesh.padding = Vector3(0.0f, 10.0f, 0.0f);
  101. // Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
  102. // physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
  103. // it will use renderable geometry instead
  104. navMesh.Build();
  105. // Create the camera. Limit far clip distance to match the fog
  106. cameraNode = scene_.CreateChild("Camera");
  107. Camera@ camera = cameraNode.CreateComponent("Camera");
  108. camera.farClip = 300.0f;
  109. // Set an initial position for the camera scene node above the plane and looking down
  110. cameraNode.position = Vector3(0.0f, 50.0f, 0.0f);
  111. pitch = 80.0f;
  112. cameraNode.rotation = Quaternion(pitch, yaw, 0.0f);
  113. }
  114. void CreateUI()
  115. {
  116. // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
  117. // control the camera, and when visible, it will point the raycast target
  118. XMLFile@ style = cache.GetResource("XMLFile", "UI/DefaultStyle.xml");
  119. Cursor@ cursor = Cursor();
  120. cursor.SetStyleAuto(style);
  121. ui.cursor = cursor;
  122. // Set starting position of the cursor at the rendering window center
  123. cursor.SetPosition(graphics.width / 2, graphics.height / 2);
  124. // Construct new Text object, set string to display and font to use
  125. Text@ instructionText = ui.root.CreateChild("Text");
  126. instructionText.text =
  127. "Use WASD keys to move, RMB to rotate view\n"
  128. "LMB to set destination, SHIFT+LMB to teleport\n"
  129. "MMB or O key to add or remove obstacles\n"
  130. "Tab to toggle navigation mesh streaming\n"
  131. "Space to toggle debug geometry";
  132. instructionText.SetFont(cache.GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15);
  133. // The text has multiple rows. Center them in relation to each other
  134. instructionText.textAlignment = HA_CENTER;
  135. // Position the text relative to the screen center
  136. instructionText.horizontalAlignment = HA_CENTER;
  137. instructionText.verticalAlignment = VA_CENTER;
  138. instructionText.SetPosition(0, ui.root.height / 4);
  139. }
  140. void SetupViewport()
  141. {
  142. // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
  143. Viewport@ viewport = Viewport(scene_, cameraNode.GetComponent("Camera"));
  144. renderer.viewports[0] = viewport;
  145. }
  146. void SubscribeToEvents()
  147. {
  148. // Subscribe HandleUpdate() function for processing update events
  149. SubscribeToEvent("Update", "HandleUpdate");
  150. // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
  151. // debug geometry
  152. SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate");
  153. }
  154. void MoveCamera(float timeStep)
  155. {
  156. input.mouseVisible = input.mouseMode != MM_RELATIVE;
  157. bool mouseDown = input.mouseButtonDown[MOUSEB_RIGHT];
  158. // Override the MM_RELATIVE mouse grabbed settings, to allow interaction with UI
  159. input.mouseGrabbed = mouseDown;
  160. // Right mouse button controls mouse cursor visibility: hide when pressed
  161. ui.cursor.visible = !mouseDown;
  162. // Do not move if the UI has a focused element (the console)
  163. if (ui.focusElement !is null)
  164. return;
  165. // Movement speed as world units per second
  166. const float MOVE_SPEED = 20.0f;
  167. // Mouse sensitivity as degrees per pixel
  168. const float MOUSE_SENSITIVITY = 0.1f;
  169. // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  170. // Only move the camera when the cursor is hidden
  171. if (!ui.cursor.visible)
  172. {
  173. IntVector2 mouseMove = input.mouseMove;
  174. yaw += MOUSE_SENSITIVITY * mouseMove.x;
  175. pitch += MOUSE_SENSITIVITY * mouseMove.y;
  176. pitch = Clamp(pitch, -90.0f, 90.0f);
  177. // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  178. cameraNode.rotation = Quaternion(pitch, yaw, 0.0f);
  179. }
  180. // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  181. if (input.keyDown[KEY_W])
  182. cameraNode.Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
  183. if (input.keyDown[KEY_S])
  184. cameraNode.Translate(Vector3::BACK * MOVE_SPEED * timeStep);
  185. if (input.keyDown[KEY_A])
  186. cameraNode.Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
  187. if (input.keyDown[KEY_D])
  188. cameraNode.Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
  189. // Set destination or teleport with left mouse button
  190. if (input.mouseButtonPress[MOUSEB_LEFT])
  191. SetPathPoint();
  192. // Add or remove objects with middle mouse button, then rebuild navigation mesh partially
  193. if (input.mouseButtonPress[MOUSEB_MIDDLE] || input.keyPress[KEY_O])
  194. AddOrRemoveObject();
  195. // Toggle debug geometry with space
  196. if (input.keyPress[KEY_SPACE])
  197. drawDebug = !drawDebug;
  198. }
  199. void SetPathPoint()
  200. {
  201. Vector3 hitPos;
  202. Drawable@ hitDrawable;
  203. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  204. if (Raycast(250.0f, hitPos, hitDrawable))
  205. {
  206. Vector3 pathPos = navMesh.FindNearestPoint(hitPos, Vector3(1.0f, 1.0f, 1.0f));
  207. if (input.qualifierDown[QUAL_SHIFT])
  208. {
  209. // Teleport
  210. currentPath.Clear();
  211. jackNode.LookAt(Vector3(pathPos.x, jackNode.position.y, pathPos.z), Vector3::UP);
  212. jackNode.position = pathPos;
  213. }
  214. else
  215. {
  216. // Calculate path from Jack's current position to the end point
  217. endPos = pathPos;
  218. currentPath = navMesh.FindPath(jackNode.position, endPos);
  219. }
  220. }
  221. }
  222. void AddOrRemoveObject()
  223. {
  224. // Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
  225. Vector3 hitPos;
  226. Drawable@ hitDrawable;
  227. if (!useStreaming && Raycast(250.0f, hitPos, hitDrawable))
  228. {
  229. // The part of the navigation mesh we must update, which is the world bounding box of the associated
  230. // drawable component
  231. BoundingBox updateBox;
  232. Node@ hitNode = hitDrawable.node;
  233. if (hitNode.name == "Mushroom")
  234. {
  235. updateBox = hitDrawable.worldBoundingBox;
  236. hitNode.Remove();
  237. }
  238. else
  239. {
  240. Node@ newNode = CreateMushroom(hitPos);
  241. StaticModel@ newObject = newNode.GetComponent("StaticModel");
  242. updateBox = newObject.worldBoundingBox;
  243. }
  244. // Rebuild part of the navigation mesh, then rebuild the path if applicable
  245. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  246. navMesh.Build(updateBox);
  247. if (currentPath.length > 0)
  248. currentPath = navMesh.FindPath(jackNode.position, endPos);
  249. }
  250. }
  251. Node@ CreateMushroom(const Vector3& pos)
  252. {
  253. Node@ mushroomNode = scene_.CreateChild("Mushroom");
  254. mushroomNode.position = pos;
  255. mushroomNode.rotation = Quaternion(0.0f, Random(360.0f), 0.0f);
  256. mushroomNode.SetScale(2.0f + Random(0.5f));
  257. StaticModel@ mushroomObject = mushroomNode.CreateComponent("StaticModel");
  258. mushroomObject.model = cache.GetResource("Model", "Models/Mushroom.mdl");
  259. mushroomObject.material = cache.GetResource("Material", "Materials/Mushroom.xml");
  260. mushroomObject.castShadows = true;
  261. return mushroomNode;
  262. }
  263. bool Raycast(float maxDistance, Vector3& hitPos, Drawable@& hitDrawable)
  264. {
  265. hitDrawable = null;
  266. IntVector2 pos = ui.cursorPosition;
  267. // Check the cursor is visible and there is no UI element in front of the cursor
  268. if (!ui.cursor.visible || ui.GetElementAt(pos, true) !is null)
  269. return false;
  270. Camera@ camera = cameraNode.GetComponent("Camera");
  271. Ray cameraRay = camera.GetScreenRay(float(pos.x) / graphics.width, float(pos.y) / graphics.height);
  272. // Pick only geometry objects, not eg. zones or lights, only get the first (closest) hit
  273. // Note the convenience accessor to scene's Octree component
  274. RayQueryResult result = scene_.octree.RaycastSingle(cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY);
  275. if (result.drawable !is null)
  276. {
  277. hitPos = result.position;
  278. hitDrawable = result.drawable;
  279. return true;
  280. }
  281. return false;
  282. }
  283. void FollowPath(float timeStep)
  284. {
  285. if (currentPath.length > 0)
  286. {
  287. Vector3 nextWaypoint = currentPath[0]; // NB: currentPath[0] is the next waypoint in order
  288. // Rotate Jack toward next waypoint to reach and move. Check for not overshooting the target
  289. float move = 5.0f * timeStep;
  290. float distance = (jackNode.position - nextWaypoint).length;
  291. if (move > distance)
  292. move = distance;
  293. jackNode.LookAt(nextWaypoint, Vector3::UP);
  294. jackNode.Translate(Vector3::FORWARD * move);
  295. // Remove waypoint if reached it
  296. if (distance < 0.1)
  297. currentPath.Erase(0);
  298. }
  299. }
  300. void ToggleStreaming(bool enabled)
  301. {
  302. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  303. if (enabled)
  304. {
  305. int maxTiles = (2 * STREAMING_DISTANCE + 1) * (2 * STREAMING_DISTANCE + 1);
  306. BoundingBox boundingBox = navMesh.boundingBox;
  307. SaveNavigationData();
  308. navMesh.Allocate(boundingBox, maxTiles);
  309. }
  310. else
  311. navMesh.Build();
  312. }
  313. void UpdateStreaming()
  314. {
  315. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  316. // Center the navigation mesh at the jack
  317. IntVector2 jackTile = navMesh.GetTileIndex(jackNode.worldPosition);
  318. IntVector2 beginTile = VectorMax(IntVector2(0, 0), jackTile - IntVector2(1, 1) * STREAMING_DISTANCE);
  319. IntVector2 endTile = VectorMin(jackTile + IntVector2(1, 1) * STREAMING_DISTANCE, navMesh.numTiles - IntVector2(1, 1));
  320. // Remove tiles
  321. for (uint i = 0; i < addedTiles.length;)
  322. {
  323. IntVector2 tileIdx = addedTiles[i];
  324. if (beginTile.x <= tileIdx.x && tileIdx.x <= endTile.x && beginTile.y <= tileIdx.y && tileIdx.y <= endTile.y)
  325. ++i;
  326. else
  327. {
  328. addedTiles.Erase(i);
  329. navMesh.RemoveTile(tileIdx);
  330. }
  331. }
  332. // Add tiles
  333. for (int z = beginTile.y; z <= endTile.y; ++z)
  334. for (int x = beginTile.x; x <= endTile.x; ++x)
  335. {
  336. const IntVector2 tileIdx(x, z);
  337. int tileDataIdx = navigationTilesIdx.Find(tileIdx);
  338. if (!navMesh.HasTile(tileIdx) && tileDataIdx != -1)
  339. {
  340. addedTiles.Push(tileIdx);
  341. navMesh.AddTile(navigationTilesData[tileDataIdx]);
  342. }
  343. }
  344. }
  345. void SaveNavigationData()
  346. {
  347. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  348. navigationTilesData.Clear();
  349. navigationTilesIdx.Clear();
  350. addedTiles.Clear();
  351. IntVector2 numTiles = navMesh.numTiles;
  352. for (int z = 0; z < numTiles.y; ++z)
  353. for (int x = 0; x < numTiles.x; ++x)
  354. {
  355. IntVector2 idx(x, z);
  356. navigationTilesData.Push(navMesh.GetTileData(idx));
  357. navigationTilesIdx.Push(idx);
  358. }
  359. }
  360. void HandleUpdate(StringHash eventType, VariantMap& eventData)
  361. {
  362. // Take the frame time step, which is stored as a float
  363. float timeStep = eventData["TimeStep"].GetFloat();
  364. // Move the camera, scale movement with time step
  365. MoveCamera(timeStep);
  366. // Make Jack follow the Detour path
  367. FollowPath(timeStep);
  368. // Update streaming
  369. if (input.keyPress[KEY_TAB])
  370. {
  371. useStreaming = !useStreaming;
  372. ToggleStreaming(useStreaming);
  373. }
  374. if (useStreaming)
  375. UpdateStreaming();
  376. }
  377. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
  378. {
  379. // If draw debug mode is enabled, draw navigation mesh debug geometry
  380. if (drawDebug)
  381. {
  382. NavigationMesh@ navMesh = scene_.GetComponent("NavigationMesh");
  383. navMesh.DrawDebugGeometry(true);
  384. }
  385. if (currentPath.length > 0)
  386. {
  387. // Visualize the current calculated path
  388. // Note the convenience accessor to the DebugRenderer component
  389. DebugRenderer@ debug = scene_.debugRenderer;
  390. debug.AddBoundingBox(BoundingBox(endPos - Vector3(0.1f, 0.1f, 0.1f), endPos + Vector3(0.1f, 0.1f, 0.1f)),
  391. Color(1.0f, 1.0f, 1.0f));
  392. // Draw the path with a small upward bias so that it does not clip into the surfaces
  393. Vector3 bias(0.0f, 0.05f, 0.0f);
  394. debug.AddLine(jackNode.position + bias, currentPath[0] + bias, Color(1.0f, 1.0f, 1.0f));
  395. if (currentPath.length > 1)
  396. {
  397. for (uint i = 0; i < currentPath.length - 1; ++i)
  398. debug.AddLine(currentPath[i] + bias, currentPath[i + 1] + bias, Color(1.0f, 1.0f, 1.0f));
  399. }
  400. }
  401. }
  402. // Create XML patch instructions for screen joystick layout specific to this sample app
  403. String patchInstructions =
  404. "<patch>" +
  405. " <add sel=\"/element\">" +
  406. " <element type=\"Button\">" +
  407. " <attribute name=\"Name\" value=\"Button3\" />" +
  408. " <attribute name=\"Position\" value=\"-120 -120\" />" +
  409. " <attribute name=\"Size\" value=\"96 96\" />" +
  410. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" +
  411. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" +
  412. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" +
  413. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" +
  414. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" +
  415. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" +
  416. " <element type=\"Text\">" +
  417. " <attribute name=\"Name\" value=\"Label\" />" +
  418. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" +
  419. " <attribute name=\"Vert Alignment\" value=\"Center\" />" +
  420. " <attribute name=\"Color\" value=\"0 0 0 1\" />" +
  421. " <attribute name=\"Text\" value=\"Teleport\" />" +
  422. " </element>" +
  423. " <element type=\"Text\">" +
  424. " <attribute name=\"Name\" value=\"KeyBinding\" />" +
  425. " <attribute name=\"Text\" value=\"LSHIFT\" />" +
  426. " </element>" +
  427. " <element type=\"Text\">" +
  428. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  429. " <attribute name=\"Text\" value=\"LEFT\" />" +
  430. " </element>" +
  431. " </element>" +
  432. " <element type=\"Button\">" +
  433. " <attribute name=\"Name\" value=\"Button4\" />" +
  434. " <attribute name=\"Position\" value=\"-120 -12\" />" +
  435. " <attribute name=\"Size\" value=\"96 96\" />" +
  436. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" +
  437. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" +
  438. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" +
  439. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" +
  440. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" +
  441. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" +
  442. " <element type=\"Text\">" +
  443. " <attribute name=\"Name\" value=\"Label\" />" +
  444. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" +
  445. " <attribute name=\"Vert Alignment\" value=\"Center\" />" +
  446. " <attribute name=\"Color\" value=\"0 0 0 1\" />" +
  447. " <attribute name=\"Text\" value=\"Obstacles\" />" +
  448. " </element>" +
  449. " <element type=\"Text\">" +
  450. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  451. " <attribute name=\"Text\" value=\"MIDDLE\" />" +
  452. " </element>" +
  453. " </element>" +
  454. " </add>" +
  455. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" +
  456. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Set</replace>" +
  457. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" +
  458. " <element type=\"Text\">" +
  459. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" +
  460. " <attribute name=\"Text\" value=\"LEFT\" />" +
  461. " </element>" +
  462. " </add>" +
  463. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" +
  464. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" +
  465. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" +
  466. " <element type=\"Text\">" +
  467. " <attribute name=\"Name\" value=\"KeyBinding\" />" +
  468. " <attribute name=\"Text\" value=\"SPACE\" />" +
  469. " </element>" +
  470. " </add>" +
  471. "</patch>";