39_CrowdNavigation.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. -- CrowdNavigation example.
  2. -- This sample demonstrates:
  3. -- - Generating a dynamic navigation mesh into the scene
  4. -- - Performing path queries to the navigation mesh
  5. -- - Adding and removing obstacles/agents at runtime
  6. -- - Raycasting drawable components
  7. -- - Crowd movement management
  8. -- - Accessing crowd agents with the crowd manager
  9. -- - Using off-mesh connections to make boxes climbable
  10. -- - Using agents to simulate moving obstacles
  11. require "LuaScripts/Utilities/Sample"
  12. local INSTRUCTION = "instructionText"
  13. function Start()
  14. -- Execute the common startup for samples
  15. SampleStart()
  16. -- Create the scene content
  17. CreateScene()
  18. -- Create the UI content
  19. CreateUI()
  20. -- Setup the viewport for displaying the scene
  21. SetupViewport()
  22. -- Hook up to the frame update and render post-update events
  23. SubscribeToEvents()
  24. end
  25. function CreateScene()
  26. scene_ = Scene()
  27. -- Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
  28. -- Also create a DebugRenderer component so that we can draw debug geometry
  29. scene_:CreateComponent("Octree")
  30. scene_:CreateComponent("DebugRenderer")
  31. -- Create scene node & StaticModel component for showing a static plane
  32. local planeNode = scene_:CreateChild("Plane")
  33. planeNode.scale = Vector3(100.0, 1.0, 100.0)
  34. local planeObject = planeNode:CreateComponent("StaticModel")
  35. planeObject.model = cache:GetResource("Model", "Models/Plane.mdl")
  36. planeObject.material = cache:GetResource("Material", "Materials/StoneTiled.xml")
  37. -- Create a Zone component for ambient lighting & fog control
  38. local zoneNode = scene_:CreateChild("Zone")
  39. local zone = zoneNode:CreateComponent("Zone")
  40. zone.boundingBox = BoundingBox(-1000.0, 1000.0)
  41. zone.ambientColor = Color(0.15, 0.15, 0.15)
  42. zone.fogColor = Color(0.5, 0.5, 0.7)
  43. zone.fogStart = 100.0
  44. zone.fogEnd = 300.0
  45. -- Create a directional light to the world. Enable cascaded shadows on it
  46. local lightNode = scene_:CreateChild("DirectionalLight")
  47. lightNode.direction = Vector3(0.6, -1.0, 0.8)
  48. local light = lightNode:CreateComponent("Light")
  49. light.lightType = LIGHT_DIRECTIONAL
  50. light.castShadows = true
  51. light.shadowBias = BiasParameters(0.00025, 0.5)
  52. -- Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
  53. light.shadowCascade = CascadeParameters(10.0, 50.0, 200.0, 0.0, 0.8)
  54. -- Create randomly sized boxes. If boxes are big enough, make them occluders. Occluders will be software rasterized before
  55. -- rendering to a low-resolution depth-only buffer to test the objects in the view frustum for visibility
  56. local boxGroup = scene_:CreateChild("Boxes")
  57. for i = 1, 20 do
  58. local boxNode = boxGroup:CreateChild("Box")
  59. local size = 1.0 + Random(10.0)
  60. boxNode.position = Vector3(Random(80.0) - 40.0, size * 0.5, Random(80.0) - 40.0)
  61. boxNode:SetScale(size)
  62. local boxObject = boxNode:CreateComponent("StaticModel")
  63. boxObject.model = cache:GetResource("Model", "Models/Box.mdl")
  64. boxObject.material = cache:GetResource("Material", "Materials/Stone.xml")
  65. boxObject.castShadows = true
  66. if size >= 3.0 then
  67. boxObject.occluder = true
  68. end
  69. end
  70. -- Create a DynamicNavigationMesh component to the scene root
  71. local navMesh = scene_:CreateComponent("DynamicNavigationMesh")
  72. -- Enable drawing debug geometry for obstacles and off-mesh connections
  73. navMesh.drawObstacles = true
  74. navMesh.drawOffMeshConnections = true
  75. -- Set the agent height large enough to exclude the layers under boxes
  76. navMesh.agentHeight = 10
  77. -- Set nav mesh cell height to minimum (allows agents to be grounded)
  78. navMesh.cellHeight = 0.05
  79. -- Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
  80. -- navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
  81. scene_:CreateComponent("Navigable")
  82. -- Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
  83. -- in the scene and still update the mesh correctly
  84. navMesh.padding = Vector3(0.0, 10.0, 0.0)
  85. -- Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
  86. -- physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
  87. -- it will use renderable geometry instead
  88. navMesh:Build()
  89. -- Create an off-mesh connection for each box to make it climbable (tiny boxes are skipped).
  90. -- Note that OffMeshConnections must be added before building the navMesh, but as we are adding Obstacles next, tiles will be automatically rebuilt.
  91. -- Creating connections post-build here allows us to use FindNearestPoint() to procedurally set accurate positions for the connection
  92. CreateBoxOffMeshConnections(navMesh, boxGroup)
  93. -- Create some mushrooms as obstacles. Note that obstacles are non-walkable areas
  94. for i = 1, 100 do
  95. CreateMushroom(Vector3(Random(90.0) - 45.0, 0.0, Random(90.0) - 45.0))
  96. end
  97. -- Create a CrowdManager component to the scene root (mandatory for crowd agents)
  98. local crowdManager = scene_:CreateComponent("CrowdManager")
  99. local params = crowdManager:GetObstacleAvoidanceParams(0)
  100. -- Set the params to "High (66)" setting
  101. params.velBias = 0.5
  102. params.adaptiveDivs = 7
  103. params.adaptiveRings = 3
  104. params.adaptiveDepth = 3
  105. crowdManager:SetObstacleAvoidanceParams(0, params)
  106. -- Create some movable barrels. We create them as crowd agents, as for moving entities it is less expensive and more convenient than using obstacles
  107. CreateMovingBarrels(navMesh)
  108. -- Create Jack node as crowd agent
  109. SpawnJack(Vector3(-5, 0, 20), scene_:CreateChild("Jacks"))
  110. -- Create the camera. Limit far clip distance to match the fog. Note: now we actually create the camera node outside
  111. -- the scene, because we want it to be unaffected by scene load / save
  112. cameraNode = Node()
  113. local camera = cameraNode:CreateComponent("Camera")
  114. camera.farClip = 300.0
  115. -- Set an initial position for the camera scene node above the plane and looking down
  116. cameraNode.position = Vector3(0.0, 50.0, 0.0)
  117. pitch = 80.0
  118. cameraNode.rotation = Quaternion(pitch, yaw, 0.0)
  119. end
  120. function CreateUI()
  121. -- Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
  122. -- control the camera, and when visible, it will point the raycast target
  123. local style = cache:GetResource("XMLFile", "UI/DefaultStyle.xml")
  124. local cursor = Cursor:new()
  125. cursor:SetStyleAuto(style)
  126. ui.cursor = cursor
  127. -- Set starting position of the cursor at the rendering window center
  128. cursor:SetPosition(graphics.width / 2, graphics.height / 2)
  129. -- Construct new Text object, set string to display and font to use
  130. local instructionText = ui.root:CreateChild("Text", INSTRUCTION)
  131. instructionText.text = "Use WASD keys to move, RMB to rotate view\n"..
  132. "LMB to set destination, SHIFT+LMB to spawn a Jack\n"..
  133. "MMB or O key to add obstacles or remove obstacles/agents\n"..
  134. "F5 to save scene, F7 to load\n"..
  135. "Space to toggle debug geometry\n"..
  136. "F12 to toggle this instruction text"
  137. instructionText:SetFont(cache:GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15)
  138. -- The text has multiple rows. Center them in relation to each other
  139. instructionText.textAlignment = HA_CENTER
  140. -- Position the text relative to the screen center
  141. instructionText.horizontalAlignment = HA_CENTER
  142. instructionText.verticalAlignment = VA_CENTER
  143. instructionText:SetPosition(0, ui.root.height / 4)
  144. end
  145. function SetupViewport()
  146. -- Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
  147. local viewport = Viewport:new(scene_, cameraNode:GetComponent("Camera"))
  148. renderer:SetViewport(0, viewport)
  149. end
  150. function SubscribeToEvents()
  151. -- Subscribe HandleUpdate() function for processing update events
  152. SubscribeToEvent("Update", "HandleUpdate")
  153. -- Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request debug geometry
  154. SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate")
  155. -- Subscribe HandleCrowdAgentFailure() function for resolving invalidation issues with agents, during which we
  156. -- use a larger extents for finding a point on the navmesh to fix the agent's position
  157. SubscribeToEvent("CrowdAgentFailure", "HandleCrowdAgentFailure")
  158. -- Subscribe HandleCrowdAgentReposition() function for controlling the animation
  159. SubscribeToEvent("CrowdAgentReposition", "HandleCrowdAgentReposition")
  160. -- Subscribe HandleCrowdAgentFormation() function for positioning agent into a formation
  161. SubscribeToEvent("CrowdAgentFormation", "HandleCrowdAgentFormation")
  162. end
  163. function SpawnJack(pos, jackGroup)
  164. local jackNode = jackGroup:CreateChild("Jack")
  165. jackNode.position = pos
  166. local modelObject = jackNode:CreateComponent("AnimatedModel")
  167. modelObject.model = cache:GetResource("Model", "Models/Jack.mdl")
  168. modelObject.material = cache:GetResource("Material", "Materials/Jack.xml")
  169. modelObject.castShadows = true
  170. jackNode:CreateComponent("AnimationController")
  171. -- Create a CrowdAgent component and set its height and realistic max speed/acceleration. Use default radius
  172. local agent = jackNode:CreateComponent("CrowdAgent")
  173. agent.height = 2.0
  174. agent.maxSpeed = 3.0
  175. agent.maxAccel = 3.0
  176. end
  177. function CreateMushroom(pos)
  178. local mushroomNode = scene_:CreateChild("Mushroom")
  179. mushroomNode.position = pos
  180. mushroomNode.rotation = Quaternion(0.0, Random(360.0), 0.0)
  181. mushroomNode:SetScale(2.0 + Random(0.5))
  182. local mushroomObject = mushroomNode:CreateComponent("StaticModel")
  183. mushroomObject.model = cache:GetResource("Model", "Models/Mushroom.mdl")
  184. mushroomObject.material = cache:GetResource("Material", "Materials/Mushroom.xml")
  185. mushroomObject.castShadows = true
  186. -- Create the navigation Obstacle component and set its height & radius proportional to scale
  187. local obstacle = mushroomNode:CreateComponent("Obstacle")
  188. obstacle.radius = mushroomNode.scale.x
  189. obstacle.height = mushroomNode.scale.y
  190. end
  191. function CreateBoxOffMeshConnections(navMesh, boxGroup)
  192. boxes = boxGroup:GetChildren()
  193. for i, box in ipairs(boxes) do
  194. local boxPos = box.position
  195. local boxHalfSize = box.scale.x / 2
  196. -- Create 2 empty nodes for the start & end points of the connection. Note that order matters only when using one-way/unidirectional connection.
  197. local connectionStart = box:CreateChild("ConnectionStart")
  198. connectionStart.worldPosition = navMesh:FindNearestPoint(boxPos + Vector3(boxHalfSize, -boxHalfSize, 0)) -- Base of box
  199. local connectionEnd = connectionStart:CreateChild("ConnectionEnd")
  200. connectionEnd.worldPosition = navMesh:FindNearestPoint(boxPos + Vector3(boxHalfSize, boxHalfSize, 0)) -- Top of box
  201. -- Create the OffMeshConnection component to one node and link the other node
  202. local connection = connectionStart:CreateComponent("OffMeshConnection")
  203. connection.endPoint = connectionEnd
  204. end
  205. end
  206. function CreateMovingBarrels(navMesh)
  207. local barrel = scene_:CreateChild("Barrel")
  208. local model = barrel:CreateComponent("StaticModel")
  209. model.model = cache:GetResource("Model", "Models/Cylinder.mdl")
  210. model.material = cache:GetResource("Material", "Materials/StoneTiled.xml")
  211. model.material:SetTexture(TU_DIFFUSE, cache:GetResource("Texture2D", "Textures/TerrainDetail2.dds"))
  212. model.castShadows = true
  213. for i = 1, 20 do
  214. local clone = barrel:Clone()
  215. local size = 0.5 + Random(1)
  216. clone.scale = Vector3(size / 1.5, size * 2, size / 1.5)
  217. clone.position = navMesh:FindNearestPoint(Vector3(Random(80.0) - 40.0, size * 0.5 , Random(80.0) - 40.0))
  218. local agent = clone:CreateComponent("CrowdAgent")
  219. agent.radius = clone.scale.x * 0.5
  220. agent.height = size
  221. agent.navigationQuality = NAVIGATIONQUALITY_LOW
  222. end
  223. barrel:Remove()
  224. end
  225. function SetPathPoint(spawning)
  226. local hitPos, hitDrawable = Raycast(250.0)
  227. if hitDrawable then
  228. local navMesh = scene_:GetComponent("DynamicNavigationMesh")
  229. local pathPos = navMesh:FindNearestPoint(hitPos, Vector3.ONE)
  230. local jackGroup = scene_:GetChild("Jacks")
  231. if spawning then
  232. -- Spawn a jack at the target position
  233. SpawnJack(pathPos, jackGroup)
  234. else
  235. -- Set crowd agents target position
  236. scene_:GetComponent("CrowdManager"):SetCrowdTarget(pathPos, jackGroup)
  237. end
  238. end
  239. end
  240. function AddOrRemoveObject()
  241. -- Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
  242. local hitPos, hitDrawable = Raycast(250.0)
  243. if hitDrawable then
  244. local hitNode = hitDrawable.node
  245. if hitNode.name == "Mushroom" then
  246. hitNode:Remove()
  247. elseif hitNode.name == "Jack" then
  248. hitNode:Remove()
  249. else
  250. CreateMushroom(hitPos)
  251. end
  252. end
  253. end
  254. function Raycast(maxDistance)
  255. local pos = ui.cursorPosition
  256. -- Check the cursor is visible and there is no UI element in front of the cursor
  257. if (not ui.cursor.visible) or (ui:GetElementAt(pos, true) ~= nil) then
  258. return nil, nil
  259. end
  260. local camera = cameraNode:GetComponent("Camera")
  261. local cameraRay = camera:GetScreenRay(pos.x / graphics.width, pos.y / graphics.height)
  262. -- Pick only geometry objects, not eg. zones or lights, only get the first (closest) hit
  263. local octree = scene_:GetComponent("Octree")
  264. local result = octree:RaycastSingle(cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY)
  265. if result.drawable ~= nil then
  266. return result.position, result.drawable
  267. end
  268. return nil, nil
  269. end
  270. function MoveCamera(timeStep)
  271. -- Right mouse button controls mouse cursor visibility: hide when pressed
  272. ui.cursor.visible = not input:GetMouseButtonDown(MOUSEB_RIGHT)
  273. -- Do not move if the UI has a focused element (the console)
  274. if ui.focusElement ~= nil then
  275. return
  276. end
  277. -- Movement speed as world units per second
  278. local MOVE_SPEED = 20.0
  279. -- Mouse sensitivity as degrees per pixel
  280. local MOUSE_SENSITIVITY = 0.1
  281. -- Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  282. -- Only move the camera when the cursor is hidden
  283. if not ui.cursor.visible then
  284. local mouseMove = input.mouseMove
  285. yaw = yaw + MOUSE_SENSITIVITY * mouseMove.x
  286. pitch = pitch + MOUSE_SENSITIVITY * mouseMove.y
  287. pitch = Clamp(pitch, -90.0, 90.0)
  288. -- Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  289. cameraNode.rotation = Quaternion(pitch, yaw, 0.0)
  290. end
  291. -- Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  292. if input:GetKeyDown(KEY_W) then
  293. cameraNode:Translate(Vector3(0.0, 0.0, 1.0) * MOVE_SPEED * timeStep)
  294. end
  295. if input:GetKeyDown(KEY_S) then
  296. cameraNode:Translate(Vector3(0.0, 0.0, -1.0) * MOVE_SPEED * timeStep)
  297. end
  298. if input:GetKeyDown(KEY_A) then
  299. cameraNode:Translate(Vector3(-1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
  300. end
  301. if input:GetKeyDown(KEY_D) then
  302. cameraNode:Translate(Vector3(1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
  303. end
  304. -- Set destination or spawn a jack with left mouse button
  305. if input:GetMouseButtonPress(MOUSEB_LEFT) then
  306. SetPathPoint(input:GetQualifierDown(QUAL_SHIFT))
  307. -- Add new obstacle or remove existing obstacle/agent with middle mouse button
  308. elseif input:GetMouseButtonPress(MOUSEB_MIDDLE) or input:GetKeyPress(KEY_O) then
  309. AddOrRemoveObject()
  310. end
  311. -- Check for loading/saving the scene from/to the file Data/Scenes/CrowdNavigation.xml relative to the executable directory
  312. if input:GetKeyPress(KEY_F5) then
  313. scene_:SaveXML(fileSystem:GetProgramDir().."Data/Scenes/CrowdNavigation.xml")
  314. elseif input:GetKeyPress(KEY_F7) then
  315. scene_:LoadXML(fileSystem:GetProgramDir().."Data/Scenes/CrowdNavigation.xml")
  316. -- Toggle debug geometry with space
  317. elseif input:GetKeyPress(KEY_SPACE) then
  318. drawDebug = not drawDebug
  319. -- Toggle instruction text with F12
  320. elseif input:GetKeyPress(KEY_F12) then
  321. instruction = ui.root:GetChild(INSTRUCTION)
  322. instruction.visible = not instruction.visible
  323. end
  324. end
  325. function HandleUpdate(eventType, eventData)
  326. -- Take the frame time step, which is stored as a float
  327. local timeStep = eventData["TimeStep"]:GetFloat()
  328. -- Move the camera, scale movement with time step
  329. MoveCamera(timeStep)
  330. end
  331. function HandlePostRenderUpdate(eventType, eventData)
  332. if drawDebug then
  333. -- Visualize navigation mesh, obstacles and off-mesh connections
  334. scene_:GetComponent("DynamicNavigationMesh"):DrawDebugGeometry(true)
  335. -- Visualize agents' path and position to reach
  336. scene_:GetComponent("CrowdManager"):DrawDebugGeometry(true)
  337. end
  338. end
  339. function HandleCrowdAgentFailure(eventType, eventData)
  340. local node = eventData["Node"]:GetPtr("Node")
  341. local agentState = eventData["CrowdAgentState"]:GetInt()
  342. -- If the agent's state is invalid, likely from spawning on the side of a box, find a point in a larger area
  343. if agentState == CA_STATE_INVALID then
  344. -- Get a point on the navmesh using more generous extents
  345. local newPos = scene_:GetComponent("DynamicNavigationMesh"):FindNearestPoint(node.position, Vector3(5, 5, 5))
  346. -- Set the new node position, CrowdAgent component will automatically reset the state of the agent
  347. node.position = newPos
  348. end
  349. end
  350. function HandleCrowdAgentReposition(eventType, eventData)
  351. local WALKING_ANI = "Models/Jack_Walk.ani"
  352. local node = eventData["Node"]:GetPtr("Node")
  353. local agent = eventData["CrowdAgent"]:GetPtr("CrowdAgent")
  354. local velocity = eventData["Velocity"]:GetVector3()
  355. local timeStep = eventData["TimeStep"]:GetFloat()
  356. -- Only Jack agent has animation controller
  357. local animCtrl = node:GetComponent("AnimationController")
  358. if animCtrl ~= nil then
  359. local speed = velocity:Length()
  360. if animCtrl:IsPlaying(WALKING_ANI) then
  361. local speedRatio = speed / agent.maxSpeed
  362. -- Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
  363. node.rotation = node.rotation:Slerp(Quaternion(Vector3.FORWARD, velocity), 10.0 * timeStep * speedRatio)
  364. -- Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
  365. animCtrl:SetSpeed(WALKING_ANI, speedRatio)
  366. else
  367. animCtrl:Play(WALKING_ANI, 0, true, 0.1)
  368. end
  369. -- If speed is too low then stopping the animation
  370. if speed < agent.radius then
  371. animCtrl:Stop(WALKING_ANI, 0.8)
  372. end
  373. end
  374. end
  375. function HandleCrowdAgentFormation(eventType, eventData)
  376. local index = eventData["Index"]:GetUInt()
  377. local size = eventData["Size"]:GetUInt()
  378. local position = eventData["Position"]:GetVector3()
  379. -- The first agent will always move to the exact position, all other agents will select a random point nearby
  380. if index > 0 then
  381. local crowdManager = GetEventSender()
  382. local agent = eventData["CrowdAgent"]:GetPtr("CrowdAgent")
  383. eventData["Position"] = crowdManager:GetRandomPointInCircle(position, agent.radius, agent.queryFilterType)
  384. end
  385. end
  386. -- Create XML patch instructions for screen joystick layout specific to this sample app
  387. function GetScreenJoystickPatchString()
  388. return
  389. "<patch>" ..
  390. " <add sel=\"/element\">" ..
  391. " <element type=\"Button\">" ..
  392. " <attribute name=\"Name\" value=\"Button3\" />" ..
  393. " <attribute name=\"Position\" value=\"-120 -120\" />" ..
  394. " <attribute name=\"Size\" value=\"96 96\" />" ..
  395. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" ..
  396. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" ..
  397. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" ..
  398. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" ..
  399. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" ..
  400. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" ..
  401. " <element type=\"Text\">" ..
  402. " <attribute name=\"Name\" value=\"Label\" />" ..
  403. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" ..
  404. " <attribute name=\"Vert Alignment\" value=\"Center\" />" ..
  405. " <attribute name=\"Color\" value=\"0 0 0 1\" />" ..
  406. " <attribute name=\"Text\" value=\"Spawn\" />" ..
  407. " </element>" ..
  408. " <element type=\"Text\">" ..
  409. " <attribute name=\"Name\" value=\"KeyBinding\" />" ..
  410. " <attribute name=\"Text\" value=\"LSHIFT\" />" ..
  411. " </element>" ..
  412. " <element type=\"Text\">" ..
  413. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  414. " <attribute name=\"Text\" value=\"LEFT\" />" ..
  415. " </element>" ..
  416. " </element>" ..
  417. " <element type=\"Button\">" ..
  418. " <attribute name=\"Name\" value=\"Button4\" />" ..
  419. " <attribute name=\"Position\" value=\"-120 -12\" />" ..
  420. " <attribute name=\"Size\" value=\"96 96\" />" ..
  421. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" ..
  422. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" ..
  423. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" ..
  424. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" ..
  425. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" ..
  426. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" ..
  427. " <element type=\"Text\">" ..
  428. " <attribute name=\"Name\" value=\"Label\" />" ..
  429. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" ..
  430. " <attribute name=\"Vert Alignment\" value=\"Center\" />" ..
  431. " <attribute name=\"Color\" value=\"0 0 0 1\" />" ..
  432. " <attribute name=\"Text\" value=\"Obstacles\" />" ..
  433. " </element>" ..
  434. " <element type=\"Text\">" ..
  435. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  436. " <attribute name=\"Text\" value=\"MIDDLE\" />" ..
  437. " </element>" ..
  438. " </element>" ..
  439. " </add>" ..
  440. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" ..
  441. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Set</replace>" ..
  442. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" ..
  443. " <element type=\"Text\">" ..
  444. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  445. " <attribute name=\"Text\" value=\"LEFT\" />" ..
  446. " </element>" ..
  447. " </add>" ..
  448. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" ..
  449. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" ..
  450. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" ..
  451. " <element type=\"Text\">" ..
  452. " <attribute name=\"Name\" value=\"KeyBinding\" />" ..
  453. " <attribute name=\"Text\" value=\"SPACE\" />" ..
  454. " </element>" ..
  455. " </add>" ..
  456. "</patch>"
  457. end