39_CrowdNavigation.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. "CTRL+LMB to teleport main agent\n"..
  134. "MMB to add obstacles or remove obstacles/agents\n"..
  135. "F5 to save scene, F7 to load\n"..
  136. "Space to toggle debug geometry\n"..
  137. "F12 to toggle this instruction text"
  138. instructionText:SetFont(cache:GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15)
  139. -- The text has multiple rows. Center them in relation to each other
  140. instructionText.textAlignment = HA_CENTER
  141. -- Position the text relative to the screen center
  142. instructionText.horizontalAlignment = HA_CENTER
  143. instructionText.verticalAlignment = VA_CENTER
  144. instructionText:SetPosition(0, ui.root.height / 4)
  145. end
  146. function SetupViewport()
  147. -- Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
  148. local viewport = Viewport:new(scene_, cameraNode:GetComponent("Camera"))
  149. renderer:SetViewport(0, viewport)
  150. end
  151. function SubscribeToEvents()
  152. -- Subscribe HandleUpdate() function for processing update events
  153. SubscribeToEvent("Update", "HandleUpdate")
  154. -- Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request debug geometry
  155. SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate")
  156. -- Subscribe HandleCrowdAgentFailure() function for resolving invalidation issues with agents, during which we
  157. -- use a larger extents for finding a point on the navmesh to fix the agent's position
  158. SubscribeToEvent("CrowdAgentFailure", "HandleCrowdAgentFailure")
  159. -- Subscribe HandleCrowdAgentReposition() function for controlling the animation
  160. SubscribeToEvent("CrowdAgentReposition", "HandleCrowdAgentReposition")
  161. -- Subscribe HandleCrowdAgentFormation() function for positioning agent into a formation
  162. SubscribeToEvent("CrowdAgentFormation", "HandleCrowdAgentFormation")
  163. end
  164. function SpawnJack(pos, jackGroup)
  165. local jackNode = jackGroup:CreateChild("Jack")
  166. jackNode.position = pos
  167. local modelObject = jackNode:CreateComponent("AnimatedModel")
  168. modelObject.model = cache:GetResource("Model", "Models/Jack.mdl")
  169. modelObject.material = cache:GetResource("Material", "Materials/Jack.xml")
  170. modelObject.castShadows = true
  171. jackNode:CreateComponent("AnimationController")
  172. -- Create a CrowdAgent component and set its height and realistic max speed/acceleration. Use default radius
  173. local agent = jackNode:CreateComponent("CrowdAgent")
  174. agent.height = 2.0
  175. agent.maxSpeed = 3.0
  176. agent.maxAccel = 3.0
  177. end
  178. function CreateMushroom(pos)
  179. local mushroomNode = scene_:CreateChild("Mushroom")
  180. mushroomNode.position = pos
  181. mushroomNode.rotation = Quaternion(0.0, Random(360.0), 0.0)
  182. mushroomNode:SetScale(2.0 + Random(0.5))
  183. local mushroomObject = mushroomNode:CreateComponent("StaticModel")
  184. mushroomObject.model = cache:GetResource("Model", "Models/Mushroom.mdl")
  185. mushroomObject.material = cache:GetResource("Material", "Materials/Mushroom.xml")
  186. mushroomObject.castShadows = true
  187. -- Create the navigation Obstacle component and set its height & radius proportional to scale
  188. local obstacle = mushroomNode:CreateComponent("Obstacle")
  189. obstacle.radius = mushroomNode.scale.x
  190. obstacle.height = mushroomNode.scale.y
  191. end
  192. function CreateBoxOffMeshConnections(navMesh, boxGroup)
  193. boxes = boxGroup:GetChildren()
  194. for i, box in ipairs(boxes) do
  195. local boxPos = box.position
  196. local boxHalfSize = box.scale.x / 2
  197. -- Create 2 empty nodes for the start & end points of the connection. Note that order matters only when using one-way/unidirectional connection.
  198. local connectionStart = box:CreateChild("ConnectionStart")
  199. connectionStart.worldPosition = navMesh:FindNearestPoint(boxPos + Vector3(boxHalfSize, -boxHalfSize, 0)) -- Base of box
  200. local connectionEnd = connectionStart:CreateChild("ConnectionEnd")
  201. connectionEnd.worldPosition = navMesh:FindNearestPoint(boxPos + Vector3(boxHalfSize, boxHalfSize, 0)) -- Top of box
  202. -- Create the OffMeshConnection component to one node and link the other node
  203. local connection = connectionStart:CreateComponent("OffMeshConnection")
  204. connection.endPoint = connectionEnd
  205. end
  206. end
  207. function CreateMovingBarrels(navMesh)
  208. local barrel = scene_:CreateChild("Barrel")
  209. local model = barrel:CreateComponent("StaticModel")
  210. model.model = cache:GetResource("Model", "Models/Cylinder.mdl")
  211. model.material = cache:GetResource("Material", "Materials/StoneTiled.xml")
  212. model.material:SetTexture(TU_DIFFUSE, cache:GetResource("Texture2D", "Textures/TerrainDetail2.dds"))
  213. model.castShadows = true
  214. for i = 1, 20 do
  215. local clone = barrel:Clone()
  216. local size = 0.5 + Random(1)
  217. clone.scale = Vector3(size / 1.5, size * 2, size / 1.5)
  218. clone.position = navMesh:FindNearestPoint(Vector3(Random(80.0) - 40.0, size * 0.5 , Random(80.0) - 40.0))
  219. local agent = clone:CreateComponent("CrowdAgent")
  220. agent.radius = clone.scale.x * 0.5
  221. agent.height = size
  222. agent.navigationQuality = NAVIGATIONQUALITY_LOW
  223. end
  224. barrel:Remove()
  225. end
  226. function SetPathPoint(spawning)
  227. local hitPos, hitDrawable = Raycast(250.0)
  228. if hitDrawable then
  229. local navMesh = scene_:GetComponent("DynamicNavigationMesh")
  230. local pathPos = navMesh:FindNearestPoint(hitPos, Vector3.ONE)
  231. local jackGroup = scene_:GetChild("Jacks")
  232. if spawning then
  233. -- Spawn a jack at the target position
  234. SpawnJack(pathPos, jackGroup)
  235. else
  236. -- Set crowd agents target position
  237. scene_:GetComponent("CrowdManager"):SetCrowdTarget(pathPos, jackGroup)
  238. end
  239. end
  240. end
  241. function AddOrRemoveObject()
  242. -- Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
  243. local hitPos, hitDrawable = Raycast(250.0)
  244. if hitDrawable then
  245. local hitNode = hitDrawable.node
  246. if hitNode.name == "Mushroom" then
  247. hitNode:Remove()
  248. elseif hitNode.name == "Jack" then
  249. hitNode:Remove()
  250. else
  251. CreateMushroom(hitPos)
  252. end
  253. end
  254. end
  255. function Raycast(maxDistance)
  256. local pos = ui.cursorPosition
  257. -- Check the cursor is visible and there is no UI element in front of the cursor
  258. if (not ui.cursor.visible) or (ui:GetElementAt(pos, true) ~= nil) then
  259. return nil, nil
  260. end
  261. local camera = cameraNode:GetComponent("Camera")
  262. local cameraRay = camera:GetScreenRay(pos.x / graphics.width, pos.y / graphics.height)
  263. -- Pick only geometry objects, not eg. zones or lights, only get the first (closest) hit
  264. local octree = scene_:GetComponent("Octree")
  265. local result = octree:RaycastSingle(cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY)
  266. if result.drawable ~= nil then
  267. return result.position, result.drawable
  268. end
  269. return nil, nil
  270. end
  271. function MoveCamera(timeStep)
  272. -- Right mouse button controls mouse cursor visibility: hide when pressed
  273. ui.cursor.visible = not input:GetMouseButtonDown(MOUSEB_RIGHT)
  274. -- Do not move if the UI has a focused element (the console)
  275. if ui.focusElement ~= nil then
  276. return
  277. end
  278. -- Movement speed as world units per second
  279. local MOVE_SPEED = 20.0
  280. -- Mouse sensitivity as degrees per pixel
  281. local MOUSE_SENSITIVITY = 0.1
  282. -- Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  283. -- Only move the camera when the cursor is hidden
  284. if not ui.cursor.visible then
  285. local mouseMove = input.mouseMove
  286. yaw = yaw + MOUSE_SENSITIVITY * mouseMove.x
  287. pitch = pitch + MOUSE_SENSITIVITY * mouseMove.y
  288. pitch = Clamp(pitch, -90.0, 90.0)
  289. -- Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  290. cameraNode.rotation = Quaternion(pitch, yaw, 0.0)
  291. end
  292. -- Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  293. if input:GetKeyDown(KEY_W) then
  294. cameraNode:Translate(Vector3(0.0, 0.0, 1.0) * MOVE_SPEED * timeStep)
  295. end
  296. if input:GetKeyDown(KEY_S) then
  297. cameraNode:Translate(Vector3(0.0, 0.0, -1.0) * MOVE_SPEED * timeStep)
  298. end
  299. if input:GetKeyDown(KEY_A) then
  300. cameraNode:Translate(Vector3(-1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
  301. end
  302. if input:GetKeyDown(KEY_D) then
  303. cameraNode:Translate(Vector3(1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
  304. end
  305. -- Set destination or spawn a jack with left mouse button
  306. if input:GetMouseButtonPress(MOUSEB_LEFT) then
  307. SetPathPoint(input:GetQualifierDown(QUAL_SHIFT))
  308. -- Add new obstacle or remove existing obstacle/agent with middle mouse button
  309. elseif input:GetMouseButtonPress(MOUSEB_MIDDLE) then
  310. AddOrRemoveObject()
  311. end
  312. -- Check for loading/saving the scene from/to the file Data/Scenes/CrowdNavigation.xml relative to the executable directory
  313. if input:GetKeyPress(KEY_F5) then
  314. scene_:SaveXML(fileSystem:GetProgramDir().."Data/Scenes/CrowdNavigation.xml")
  315. elseif input:GetKeyPress(KEY_F7) then
  316. scene_:LoadXML(fileSystem:GetProgramDir().."Data/Scenes/CrowdNavigation.xml")
  317. -- Toggle debug geometry with space
  318. elseif input:GetKeyPress(KEY_SPACE) then
  319. drawDebug = not drawDebug
  320. -- Toggle instruction text with F12
  321. elseif input:GetKeyPress(KEY_F12) then
  322. instruction = ui.root:GetChild(INSTRUCTION)
  323. instruction.visible = not instruction.visible
  324. end
  325. end
  326. function HandleUpdate(eventType, eventData)
  327. -- Take the frame time step, which is stored as a float
  328. local timeStep = eventData["TimeStep"]:GetFloat()
  329. -- Move the camera, scale movement with time step
  330. MoveCamera(timeStep)
  331. end
  332. function HandlePostRenderUpdate(eventType, eventData)
  333. if drawDebug then
  334. -- Visualize navigation mesh, obstacles and off-mesh connections
  335. scene_:GetComponent("DynamicNavigationMesh"):DrawDebugGeometry(true)
  336. -- Visualize agents' path and position to reach
  337. scene_:GetComponent("CrowdManager"):DrawDebugGeometry(true)
  338. end
  339. end
  340. function HandleCrowdAgentFailure(eventType, eventData)
  341. local node = eventData["Node"]:GetPtr("Node")
  342. local agentState = eventData["CrowdAgentState"]:GetInt()
  343. -- If the agent's state is invalid, likely from spawning on the side of a box, find a point in a larger area
  344. if agentState == CA_STATE_INVALID then
  345. -- Get a point on the navmesh using more generous extents
  346. local newPos = scene_:GetComponent("DynamicNavigationMesh"):FindNearestPoint(node.position, Vector3(5, 5, 5))
  347. -- Set the new node position, CrowdAgent component will automatically reset the state of the agent
  348. node.position = newPos
  349. end
  350. end
  351. function HandleCrowdAgentReposition(eventType, eventData)
  352. local WALKING_ANI = "Models/Jack_Walk.ani"
  353. local node = eventData["Node"]:GetPtr("Node")
  354. local agent = eventData["CrowdAgent"]:GetPtr("CrowdAgent")
  355. local velocity = eventData["Velocity"]:GetVector3()
  356. local timeStep = eventData["TimeStep"]:GetFloat()
  357. -- Only Jack agent has animation controller
  358. local animCtrl = node:GetComponent("AnimationController")
  359. if animCtrl ~= nil then
  360. local speed = velocity:Length()
  361. if animCtrl:IsPlaying(WALKING_ANI) then
  362. local speedRatio = speed / agent.maxSpeed
  363. -- Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
  364. node.rotation = node.rotation:Slerp(Quaternion(Vector3.FORWARD, velocity), 10.0 * timeStep * speedRatio)
  365. -- Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
  366. animCtrl:SetSpeed(WALKING_ANI, speedRatio)
  367. else
  368. animCtrl:Play(WALKING_ANI, 0, true, 0.1)
  369. end
  370. -- If speed is too low then stopping the animation
  371. if speed < agent.radius then
  372. animCtrl:Stop(WALKING_ANI, 0.8)
  373. end
  374. end
  375. end
  376. function HandleCrowdAgentFormation(eventType, eventData)
  377. local index = eventData["Index"]:GetUInt()
  378. local size = eventData["Size"]:GetUInt()
  379. local position = eventData["Position"]:GetVector3()
  380. -- The first agent will always move to the exact position, all other agents will select a random point nearby
  381. if index > 0 then
  382. local crowdManager = GetEventSender()
  383. local agent = eventData["CrowdAgent"]:GetPtr("CrowdAgent")
  384. eventData["Position"] = crowdManager:GetRandomPointInCircle(position, agent.radius, agent.queryFilterType)
  385. end
  386. end
  387. -- Create XML patch instructions for screen joystick layout specific to this sample app
  388. function GetScreenJoystickPatchString()
  389. return
  390. "<patch>" ..
  391. " <add sel=\"/element\">" ..
  392. " <element type=\"Button\">" ..
  393. " <attribute name=\"Name\" value=\"Button3\" />" ..
  394. " <attribute name=\"Position\" value=\"-120 -120\" />" ..
  395. " <attribute name=\"Size\" value=\"96 96\" />" ..
  396. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" ..
  397. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" ..
  398. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" ..
  399. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" ..
  400. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" ..
  401. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" ..
  402. " <element type=\"Text\">" ..
  403. " <attribute name=\"Name\" value=\"Label\" />" ..
  404. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" ..
  405. " <attribute name=\"Vert Alignment\" value=\"Center\" />" ..
  406. " <attribute name=\"Color\" value=\"0 0 0 1\" />" ..
  407. " <attribute name=\"Text\" value=\"Spawn Jack\" />" ..
  408. " </element>" ..
  409. " <element type=\"Text\">" ..
  410. " <attribute name=\"Name\" value=\"KeyBinding\" />" ..
  411. " <attribute name=\"Text\" value=\"LSHIFT\" />" ..
  412. " </element>" ..
  413. " <element type=\"Text\">" ..
  414. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  415. " <attribute name=\"Text\" value=\"LEFT\" />" ..
  416. " </element>" ..
  417. " </element>" ..
  418. " <element type=\"Button\">" ..
  419. " <attribute name=\"Name\" value=\"Button4\" />" ..
  420. " <attribute name=\"Position\" value=\"-120 -12\" />" ..
  421. " <attribute name=\"Size\" value=\"96 96\" />" ..
  422. " <attribute name=\"Horiz Alignment\" value=\"Right\" />" ..
  423. " <attribute name=\"Vert Alignment\" value=\"Bottom\" />" ..
  424. " <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" ..
  425. " <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" ..
  426. " <attribute name=\"Hover Image Offset\" value=\"0 0\" />" ..
  427. " <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" ..
  428. " <element type=\"Text\">" ..
  429. " <attribute name=\"Name\" value=\"Label\" />" ..
  430. " <attribute name=\"Horiz Alignment\" value=\"Center\" />" ..
  431. " <attribute name=\"Vert Alignment\" value=\"Center\" />" ..
  432. " <attribute name=\"Color\" value=\"0 0 0 1\" />" ..
  433. " <attribute name=\"Text\" value=\"Obstacles\" />" ..
  434. " </element>" ..
  435. " <element type=\"Text\">" ..
  436. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  437. " <attribute name=\"Text\" value=\"MIDDLE\" />" ..
  438. " </element>" ..
  439. " </element>" ..
  440. " </add>" ..
  441. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" ..
  442. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Set</replace>" ..
  443. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" ..
  444. " <element type=\"Text\">" ..
  445. " <attribute name=\"Name\" value=\"MouseButtonBinding\" />" ..
  446. " <attribute name=\"Text\" value=\"LEFT\" />" ..
  447. " </element>" ..
  448. " </add>" ..
  449. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" ..
  450. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" ..
  451. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" ..
  452. " <element type=\"Text\">" ..
  453. " <attribute name=\"Name\" value=\"KeyBinding\" />" ..
  454. " <attribute name=\"Text\" value=\"SPACE\" />" ..
  455. " </element>" ..
  456. " </add>" ..
  457. "</patch>"
  458. end