39_CrowdNavigation.lua 25 KB

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