2
0

hello_collision.html 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>jMonkeyEngine 3 Tutorial (9) - Hello Collision :: jMonkeyEngine Docs</title>
  7. <link rel="canonical" href="https://wiki.jmonkeyengine.org/docs/3.8/tutorials/beginner/hello_collision.html">
  8. <link rel="prev" href="hello_picking.html">
  9. <link rel="next" href="hello_terrain.html">
  10. <meta name="keywords" content="beginner, collision, control, intro, documentation, model, physics">
  11. <meta name="generator" content="Antora 3.0.1">
  12. <link rel="stylesheet" href="../../../../_/css/site.css">
  13. <meta property="og:image" content="https://wiki.jmonkeyengine.org/_/img/iconx128.png">
  14. <meta property="og:description" content="jMonkeyEngine 3 Tutorial (9) - Hello Collision">
  15. <meta property="og:title" content="jMonkeyEngine Docs">
  16. <link rel="stylesheet" href="../../../../_/css/site-extra.css">
  17. <link rel="stylesheet" href="../../../../_/css/vendor/docsearch.min.css">
  18. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css -->
  19. <link rel="icon" href="../../../../_/img/favicon.ico" type="image/x-icon">
  20. </head>
  21. <body class="article">
  22. <header class="header">
  23. <nav class="navbar">
  24. <div class="navbar-brand">
  25. <a class="navbar-item" href="https://wiki.jmonkeyengine.org">
  26. <img alt="" src="../../../../_/img/jme-logo.png" height="32" type="image/x-icon">
  27. </a>
  28. <div class="navbar-item hide-for-print">
  29. <input id="search-input" type="text" placeholder="Search docs">
  30. </div>
  31. <button class="navbar-burger" data-target="topbar-nav">
  32. <span></span>
  33. <span></span>
  34. <span></span>
  35. </button>
  36. </div>
  37. <div id="topbar-nav" class="navbar-menu">
  38. <div class="navbar-end">
  39. <div class="navbar-item theme-switch-wrapper">
  40. <label class="theme-switch" for="checkbox">
  41. <input type="checkbox" id="checkbox" />
  42. <div class="slider round"></div>
  43. </label>
  44. </div>
  45. <a class="navbar-item" href="https://github.com/jmonkeyengine/wiki">Github</a>
  46. </div>
  47. </div>
  48. </nav>
  49. </header>
  50. <div class="body">
  51. <div class="nav-container" data-component="docs" data-version="3.8">
  52. <aside class="nav">
  53. <div class="panels">
  54. <div class="nav-panel-menu is-active" data-panel="menu">
  55. <nav class="nav-menu">
  56. <h3 class="title"><a href="../../documentation.html">JME</a></h3>
  57. <ul class="nav-list">
  58. <li class="nav-item" data-depth="0">
  59. <ul class="nav-list">
  60. <li class="nav-item" data-depth="1">
  61. <a class="nav-link" href="../../documentation.html">Getting Started</a>
  62. </li>
  63. <li class="nav-item" data-depth="1">
  64. <a class="nav-link" href="https://javadoc.jmonkeyengine.org/v3.4.1-stable">JavaDoc</a>
  65. </li>
  66. <li class="nav-item" data-depth="1">
  67. <a class="nav-link" href="../../release.html">Release Guide</a>
  68. </li>
  69. </ul>
  70. </li>
  71. <li class="nav-item" data-depth="0">
  72. <ul class="nav-list">
  73. <li class="nav-item" data-depth="1">
  74. <button class="nav-item-toggle"></button>
  75. <a class="nav-link" href="beginner.html">Beginner Tutorials</a>
  76. <ul class="nav-list">
  77. <li class="nav-item" data-depth="2">
  78. <a class="nav-link" href="hello_simpleapplication.html">Hello SimpleApplication</a>
  79. </li>
  80. <li class="nav-item" data-depth="2">
  81. <a class="nav-link" href="hello_node.html">Hello Node</a>
  82. </li>
  83. <li class="nav-item" data-depth="2">
  84. <a class="nav-link" href="hello_asset.html">Hello Asset</a>
  85. </li>
  86. <li class="nav-item" data-depth="2">
  87. <a class="nav-link" href="hello_main_event_loop.html">Hello Update Loop</a>
  88. </li>
  89. <li class="nav-item" data-depth="2">
  90. <a class="nav-link" href="hello_input_system.html">Hello Input System</a>
  91. </li>
  92. <li class="nav-item" data-depth="2">
  93. <a class="nav-link" href="hello_material.html">Hello Material</a>
  94. </li>
  95. <li class="nav-item" data-depth="2">
  96. <a class="nav-link" href="hello_animation.html">Hello Animation</a>
  97. </li>
  98. <li class="nav-item" data-depth="2">
  99. <a class="nav-link" href="hello_picking.html">Hello Picking</a>
  100. </li>
  101. <li class="nav-item is-current-page" data-depth="2">
  102. <a class="nav-link" href="hello_collision.html">Hello Collision</a>
  103. </li>
  104. <li class="nav-item" data-depth="2">
  105. <a class="nav-link" href="hello_terrain.html">Hello Terrain</a>
  106. </li>
  107. <li class="nav-item" data-depth="2">
  108. <a class="nav-link" href="hello_audio.html">Hello Audio</a>
  109. </li>
  110. <li class="nav-item" data-depth="2">
  111. <a class="nav-link" href="hello_effects.html">Hello Effects</a>
  112. </li>
  113. <li class="nav-item" data-depth="2">
  114. <a class="nav-link" href="hello_physics.html">Hello Physics</a>
  115. </li>
  116. </ul>
  117. </li>
  118. <li class="nav-item" data-depth="1">
  119. <button class="nav-item-toggle"></button>
  120. <span class="nav-text">Key Concepts</span>
  121. <ul class="nav-list">
  122. <li class="nav-item" data-depth="2">
  123. <a class="nav-link" href="../concepts/best_practices.html">Best Practices</a>
  124. </li>
  125. <li class="nav-item" data-depth="2">
  126. <a class="nav-link" href="../concepts/optimization.html">Optimization</a>
  127. </li>
  128. <li class="nav-item" data-depth="2">
  129. <a class="nav-link" href="../concepts/faq.html">Frequently Asked Questions</a>
  130. </li>
  131. <li class="nav-item" data-depth="2">
  132. <a class="nav-link" href="../concepts/math_for_dummies.html">Math for Dummies</a>
  133. </li>
  134. <li class="nav-item" data-depth="2">
  135. <a class="nav-link" href="../concepts/math.html">Math overview</a>
  136. </li>
  137. <li class="nav-item" data-depth="2">
  138. <a class="nav-link" href="../concepts/math_cheet_sheet.html">3D math "cheat sheet"</a>
  139. </li>
  140. <li class="nav-item" data-depth="2">
  141. <a class="nav-link" href="../concepts/rotate.html">3-D Rotation</a>
  142. </li>
  143. <li class="nav-item" data-depth="2">
  144. <a class="nav-link" href="../concepts/math_video_tutorials.html">Math video tutorial series</a>
  145. </li>
  146. <li class="nav-item" data-depth="2">
  147. <a class="nav-link" href="../concepts/multi-media_asset_pipeline.html">Multi-Media Asset Pipeline</a>
  148. </li>
  149. <li class="nav-item" data-depth="2">
  150. <a class="nav-link" href="../concepts/the_scene_graph.html">The Scene Graph</a>
  151. </li>
  152. <li class="nav-item" data-depth="2">
  153. <a class="nav-link" href="../concepts/scenegraph_for_dummies.html">Scene Graph for Dummies</a>
  154. </li>
  155. <li class="nav-item" data-depth="2">
  156. <a class="nav-link" href="../concepts/terminology.html">3D Graphics Terminology</a>
  157. </li>
  158. <li class="nav-item" data-depth="2">
  159. <a class="nav-link" href="../concepts/transparency_sorting.html">Transparency Sorting</a>
  160. </li>
  161. </ul>
  162. </li>
  163. <li class="nav-item" data-depth="1">
  164. <button class="nav-item-toggle"></button>
  165. <span class="nav-text">Articles and How-to&#8217;s</span>
  166. <ul class="nav-list">
  167. <li class="nav-item" data-depth="2">
  168. <button class="nav-item-toggle"></button>
  169. <span class="nav-text">How to Model</span>
  170. <ul class="nav-list">
  171. <li class="nav-item" data-depth="3">
  172. <a class="nav-link" href="../how-to/modeling/3dsmax/3dsmax.html">3dsmax</a>
  173. </li>
  174. <li class="nav-item" data-depth="3">
  175. <button class="nav-item-toggle"></button>
  176. <a class="nav-link" href="../how-to/modeling/blender/blender.html">Blender</a>
  177. <ul class="nav-list">
  178. <li class="nav-item" data-depth="4">
  179. <a class="nav-link" href="../how-to/modeling/blender/blender_buffer_clearing.html">Buffer Clearing</a>
  180. </li>
  181. <li class="nav-item" data-depth="4">
  182. <a class="nav-link" href="../how-to/modeling/blender/blender_gltf.html">Export as GlTF</a>
  183. </li>
  184. <li class="nav-item" data-depth="4">
  185. <a class="nav-link" href="../how-to/modeling/blender/blender_ogre_export.html">Export as Ogre XML</a>
  186. </li>
  187. <li class="nav-item" data-depth="4">
  188. <a class="nav-link" href="../how-to/modeling/blender/blender_ogre_compatibility.html">Ogre Compatibility</a>
  189. </li>
  190. <li class="nav-item" data-depth="4">
  191. <a class="nav-link" href="../how-to/modeling/blender/makehuman.html">MakeHuman</a>
  192. </li>
  193. <li class="nav-item" data-depth="4">
  194. <a class="nav-link" href="../how-to/modeling/blender/makehuman_blender_ogrexml_toolchain.html">MakeHuman toolchain</a>
  195. </li>
  196. </ul>
  197. </li>
  198. </ul>
  199. </li>
  200. <li class="nav-item" data-depth="2">
  201. <button class="nav-item-toggle"></button>
  202. <span class="nav-text">How to Animate</span>
  203. <ul class="nav-list">
  204. <li class="nav-item" data-depth="3">
  205. <button class="nav-item-toggle"></button>
  206. <span class="nav-text">Mixamo</span>
  207. <ul class="nav-list">
  208. <li class="nav-item" data-depth="4">
  209. <a class="nav-link" href="../how-to/modeling/blender/mixamo.html">Blender Models</a>
  210. </li>
  211. </ul>
  212. </li>
  213. </ul>
  214. </li>
  215. <li class="nav-item" data-depth="2">
  216. <a class="nav-link" href="../how-to/debugging.html">Debugging with Wireframes</a>
  217. </li>
  218. <li class="nav-item" data-depth="2">
  219. <a class="nav-link" href="../how-to/util/free_skymaps.html">How to create free skymaps</a>
  220. </li>
  221. <li class="nav-item" data-depth="2">
  222. <button class="nav-item-toggle"></button>
  223. <span class="nav-text">Java Tips</span>
  224. <ul class="nav-list">
  225. <li class="nav-item" data-depth="3">
  226. <a class="nav-link" href="../how-to/java/localization.html">Localization</a>
  227. </li>
  228. <li class="nav-item" data-depth="3">
  229. <a class="nav-link" href="../how-to/java/swing_canvas.html">Swing Canvas</a>
  230. </li>
  231. <li class="nav-item" data-depth="3">
  232. <a class="nav-link" href="../how-to/java/logging.html">Logging</a>
  233. </li>
  234. <li class="nav-item" data-depth="3">
  235. <a class="nav-link" href="../how-to/java/read_graphic_card_capabilites.html">Read Graphics Capabilities</a>
  236. </li>
  237. </ul>
  238. </li>
  239. <li class="nav-item" data-depth="2">
  240. <button class="nav-item-toggle"></button>
  241. <span class="nav-text">Articles</span>
  242. <ul class="nav-list">
  243. <li class="nav-item" data-depth="3">
  244. <button class="nav-item-toggle"></button>
  245. <span class="nav-text">Physically Based Rendering</span>
  246. <ul class="nav-list">
  247. <li class="nav-item" data-depth="4">
  248. <a class="nav-link" href="../how-to/articles/pbr/pbr_part1.html">PBR – Part one</a>
  249. </li>
  250. <li class="nav-item" data-depth="4">
  251. <a class="nav-link" href="../how-to/articles/pbr/pbr_part2.html">PBR – Part two</a>
  252. </li>
  253. <li class="nav-item" data-depth="4">
  254. <a class="nav-link" href="../how-to/articles/pbr/pbr_part3.html">PBR – Part three</a>
  255. </li>
  256. </ul>
  257. </li>
  258. </ul>
  259. </li>
  260. </ul>
  261. </li>
  262. </ul>
  263. </li>
  264. <li class="nav-item" data-depth="0">
  265. <ul class="nav-list">
  266. <li class="nav-item" data-depth="1">
  267. <button class="nav-item-toggle"></button>
  268. <span class="nav-text">Core Engine</span>
  269. <ul class="nav-list">
  270. <li class="nav-item" data-depth="2">
  271. <a class="nav-link" href="../../core/app/simpleapplication.html">SimpleApplication</a>
  272. </li>
  273. <li class="nav-item" data-depth="2">
  274. <a class="nav-link" href="../../core/system/appsettings.html">AppSettings</a>
  275. </li>
  276. </ul>
  277. </li>
  278. <li class="nav-item" data-depth="1">
  279. <button class="nav-item-toggle"></button>
  280. <span class="nav-text">Controlling Game Logic</span>
  281. <ul class="nav-list">
  282. <li class="nav-item" data-depth="2">
  283. <a class="nav-link" href="../../core/app/update_loop.html">Update Loop</a>
  284. </li>
  285. <li class="nav-item" data-depth="2">
  286. <a class="nav-link" href="../../core/app/state/application_states.html">Application States</a>
  287. </li>
  288. <li class="nav-item" data-depth="2">
  289. <button class="nav-item-toggle"></button>
  290. <a class="nav-link" href="../../core/scene/control/custom_controls.html">Custom Controls</a>
  291. <ul class="nav-list">
  292. <li class="nav-item" data-depth="3">
  293. <button class="nav-item-toggle"></button>
  294. <span class="nav-text">Video</span>
  295. <ul class="nav-list">
  296. <li class="nav-item" data-depth="4">
  297. <a class="nav-link" href="https://www.youtube.com/watch?v=MNDiZ9YHIpM">Control any scene node</a>
  298. </li>
  299. <li class="nav-item" data-depth="4">
  300. <a class="nav-link" href="https://www.youtube.com/watch?v=-OzRZscLlHY">Control a character</a>
  301. </li>
  302. <li class="nav-item" data-depth="4">
  303. <a class="nav-link" href="https://wiki.jmonkeyengine.org/Scenes/SDK-UsecaseDemo_1.zip">Video Source Code</a>
  304. </li>
  305. </ul>
  306. </li>
  307. </ul>
  308. </li>
  309. <li class="nav-item" data-depth="2">
  310. <a class="nav-link" href="../../core/app/multithreading.html">Multithreading</a>
  311. </li>
  312. </ul>
  313. </li>
  314. <li class="nav-item" data-depth="1">
  315. <button class="nav-item-toggle"></button>
  316. <span class="nav-text">Scene Graph</span>
  317. <ul class="nav-list">
  318. <li class="nav-item" data-depth="2">
  319. <a class="nav-link" href="../../core/scene/traverse_scenegraph.html">Traverse SceneGraph</a>
  320. </li>
  321. <li class="nav-item" data-depth="2">
  322. <a class="nav-link" href="../../core/scene/spatial.html">Spatial: Node vs Geometry</a>
  323. </li>
  324. <li class="nav-item" data-depth="2">
  325. <button class="nav-item-toggle"></button>
  326. <a class="nav-link" href="../../core/scene/mesh.html">Mesh</a>
  327. <ul class="nav-list">
  328. <li class="nav-item" data-depth="3">
  329. <a class="nav-link" href="../../core/scene/custom_meshes.html">Custom Meshes</a>
  330. </li>
  331. <li class="nav-item" data-depth="3">
  332. <a class="nav-link" href="../../core/scene/shape/shape.html">Shape</a>
  333. </li>
  334. <li class="nav-item" data-depth="3">
  335. <a class="nav-link" href="../../core/scene/3d_models.html">3D Models</a>
  336. </li>
  337. </ul>
  338. </li>
  339. <li class="nav-item" data-depth="2">
  340. <a class="nav-link" href="../../core/asset/asset_manager.html">Asset Manager</a>
  341. </li>
  342. <li class="nav-item" data-depth="2">
  343. <a class="nav-link" href="../../core/export/save_and_load.html">Saving and Loading Nodes</a>
  344. </li>
  345. <li class="nav-item" data-depth="2">
  346. <a class="nav-link" href="../../core/collision/collision_and_intersection.html">Collision and Intersection</a>
  347. </li>
  348. <li class="nav-item" data-depth="2">
  349. <a class="nav-link" href="../../core/scene/control/level_of_detail.html">Level of Detail</a>
  350. </li>
  351. </ul>
  352. </li>
  353. <li class="nav-item" data-depth="1">
  354. <button class="nav-item-toggle"></button>
  355. <span class="nav-text">Animation, Scene</span>
  356. <ul class="nav-list">
  357. <li class="nav-item" data-depth="2">
  358. <a class="nav-link" href="../../core/animation/animation_new.html">Animation with AnimComposer</a>
  359. </li>
  360. <li class="nav-item" data-depth="2">
  361. <a class="nav-link" href="../../core/animation/animation.html">Animation-Old (AnimControl)</a>
  362. </li>
  363. <li class="nav-item" data-depth="2">
  364. <a class="nav-link" href="../../core/cinematic/cinematics.html">Cinematics (cutscenes, fake destruction physics)</a>
  365. </li>
  366. <li class="nav-item" data-depth="2">
  367. <a class="nav-link" href="../../core/cinematic/motionpath.html">MotionPaths and Waypoints</a>
  368. </li>
  369. </ul>
  370. </li>
  371. <li class="nav-item" data-depth="1">
  372. <button class="nav-item-toggle"></button>
  373. <span class="nav-text">Material, Light, Shadow</span>
  374. <ul class="nav-list">
  375. <li class="nav-item" data-depth="2">
  376. <a class="nav-link" href="../../core/material/how_to_use_materials.html">How to use Materials</a>
  377. </li>
  378. <li class="nav-item" data-depth="2">
  379. <a class="nav-link" href="../../core/material/j3m_material_files.html">.j3m Material Files</a>
  380. </li>
  381. <li class="nav-item" data-depth="2">
  382. <a class="nav-link" href="../../core/material/material_definitions.html">.j3md Material Definitions</a>
  383. </li>
  384. <li class="nav-item" data-depth="2">
  385. <a class="nav-link" href="../../core/material/materials_overview.html">.j3md Properties</a>
  386. </li>
  387. <li class="nav-item" data-depth="2">
  388. <a class="nav-link" href="../../core/shader/jme3_shaders.html">Shaders and JME3</a>
  389. </li>
  390. <li class="nav-item" data-depth="2">
  391. <a class="nav-link" href="../../core/shader/jme3_shadernodes.html">Shader Node System</a>
  392. </li>
  393. <li class="nav-item" data-depth="2">
  394. <a class="nav-link" href="../../core/shader/shader_video_tutorials.html">Shader Video Tutorials</a>
  395. </li>
  396. <li class="nav-item" data-depth="2">
  397. <a class="nav-link" href="../../core/light/light_and_shadow.html">Light and Shadow</a>
  398. </li>
  399. <li class="nav-item" data-depth="2">
  400. <a class="nav-link" href="../../core/texture/anisotropic_filtering.html">Anisotropic Filtering</a>
  401. </li>
  402. <li class="nav-item" data-depth="2">
  403. <a class="nav-link" href="../../core/system/jme3_srgbpipeline.html">Gamma Correction</a>
  404. </li>
  405. <li class="nav-item" data-depth="2">
  406. <a class="nav-link" href="../../core/material/normal_types.html">Normal Map Conventions</a>
  407. </li>
  408. </ul>
  409. </li>
  410. <li class="nav-item" data-depth="1">
  411. <button class="nav-item-toggle"></button>
  412. <span class="nav-text">Audio, Video</span>
  413. <ul class="nav-list">
  414. <li class="nav-item" data-depth="2">
  415. <a class="nav-link" href="../../core/audio/audio.html">Playing Sounds</a>
  416. </li>
  417. <li class="nav-item" data-depth="2">
  418. <a class="nav-link" href="../../core/audio/audio_environment_presets.html">Audio Environment Presets</a>
  419. </li>
  420. <li class="nav-item" data-depth="2">
  421. <a class="nav-link" href="../../core/app/state/screenshots.html">Capture Screenshots</a>
  422. </li>
  423. <li class="nav-item" data-depth="2">
  424. <a class="nav-link" href="../../core/app/state/capture_audio_video_to_a_file.html">Capture Audio/Video</a>
  425. </li>
  426. </ul>
  427. </li>
  428. <li class="nav-item" data-depth="1">
  429. <button class="nav-item-toggle"></button>
  430. <span class="nav-text">Filter, Effect</span>
  431. <ul class="nav-list">
  432. <li class="nav-item" data-depth="2">
  433. <a class="nav-link" href="../../core/effect/effects_overview.html">Overview</a>
  434. </li>
  435. <li class="nav-item" data-depth="2">
  436. <a class="nav-link" href="../../core/effect/bloom_and_glow.html">Bloom and Glow</a>
  437. </li>
  438. <li class="nav-item" data-depth="2">
  439. <a class="nav-link" href="../../core/effect/particle_emitters.html">Particle Emitters</a>
  440. </li>
  441. </ul>
  442. </li>
  443. <li class="nav-item" data-depth="1">
  444. <button class="nav-item-toggle"></button>
  445. <span class="nav-text">Landscapes</span>
  446. <ul class="nav-list">
  447. <li class="nav-item" data-depth="2">
  448. <a class="nav-link" href="../../core/util/sky.html">Sky</a>
  449. </li>
  450. <li class="nav-item" data-depth="2">
  451. <a class="nav-link" href="../../core/terrain/terrain.html">Terrain (TerraMonkey)</a>
  452. </li>
  453. <li class="nav-item" data-depth="2">
  454. <a class="nav-link" href="../../core/collision/terrain_collision.html">Terrain Collision</a>
  455. </li>
  456. <li class="nav-item" data-depth="2">
  457. <a class="nav-link" href="../../core/effect/water.html">Simple Water</a>
  458. </li>
  459. <li class="nav-item" data-depth="2">
  460. <a class="nav-link" href="../../core/effect/post-processor_water.html">Post-Processor Water</a>
  461. </li>
  462. </ul>
  463. </li>
  464. <li class="nav-item" data-depth="1">
  465. <button class="nav-item-toggle"></button>
  466. <span class="nav-text">Camera</span>
  467. <ul class="nav-list">
  468. <li class="nav-item" data-depth="2">
  469. <a class="nav-link" href="../../core/renderer/camera.html">Camera</a>
  470. </li>
  471. <li class="nav-item" data-depth="2">
  472. <a class="nav-link" href="../../core/renderer/making_the_camera_follow_a_character.html">Follow a Character</a>
  473. </li>
  474. <li class="nav-item" data-depth="2">
  475. <a class="nav-link" href="../../core/renderer/remote-controlling_the_camera.html">Remote-Controlling</a>
  476. </li>
  477. <li class="nav-item" data-depth="2">
  478. <a class="nav-link" href="../../core/renderer/multiple_camera_views.html">Multiple Camera Views</a>
  479. </li>
  480. <li class="nav-item" data-depth="2">
  481. <a class="nav-link" href="../../core/renderer/jme3_renderbuckets.html">Render Buckets</a>
  482. </li>
  483. </ul>
  484. </li>
  485. <li class="nav-item" data-depth="1">
  486. <button class="nav-item-toggle"></button>
  487. <span class="nav-text">Rendering</span>
  488. <ul class="nav-list">
  489. <li class="nav-item" data-depth="2">
  490. <a class="nav-link" href="../../core/renderer/render_pipeline.html">Render Pipelines</a>
  491. </li>
  492. </ul>
  493. </li>
  494. <li class="nav-item" data-depth="1">
  495. <button class="nav-item-toggle"></button>
  496. <span class="nav-text">User Interaction</span>
  497. <ul class="nav-list">
  498. <li class="nav-item" data-depth="2">
  499. <a class="nav-link" href="../../core/input/input_handling.html">Input Handling</a>
  500. </li>
  501. <li class="nav-item" data-depth="2">
  502. <a class="nav-link" href="../../core/input/combo_moves.html">Combo Moves</a>
  503. </li>
  504. <li class="nav-item" data-depth="2">
  505. <a class="nav-link" href="../../core/input/mouse_picking.html">Mouse Picking</a>
  506. </li>
  507. </ul>
  508. </li>
  509. <li class="nav-item" data-depth="1">
  510. <button class="nav-item-toggle"></button>
  511. <a class="nav-link" href="../../core/gui/topic_gui.html">Graphical User Interface</a>
  512. <ul class="nav-list">
  513. <li class="nav-item" data-depth="2">
  514. <button class="nav-item-toggle"></button>
  515. <span class="nav-text">Nifty GUI</span>
  516. <ul class="nav-list">
  517. <li class="nav-item" data-depth="3">
  518. <a class="nav-link" href="../../core/gui/nifty_gui.html">Integration Tutorial</a>
  519. </li>
  520. <li class="nav-item" data-depth="3">
  521. <a class="nav-link" href="../../core/gui/nifty_gui_best_practices.html">Best Practices</a>
  522. </li>
  523. <li class="nav-item" data-depth="3">
  524. <a class="nav-link" href="../../core/gui/nifty_gui_scenarios.html">Scenarios</a>
  525. </li>
  526. </ul>
  527. </li>
  528. <li class="nav-item" data-depth="2">
  529. <a class="nav-link" href="../../core/ui/hud.html">Head-Up Display (HUD)</a>
  530. </li>
  531. </ul>
  532. </li>
  533. <li class="nav-item" data-depth="1">
  534. <button class="nav-item-toggle"></button>
  535. <span class="nav-text">Virtual Reality</span>
  536. <ul class="nav-list">
  537. <li class="nav-item" data-depth="2">
  538. <a class="nav-link" href="../../core/vr/virtualreality.html">Virtual Reality</a>
  539. </li>
  540. <li class="nav-item" data-depth="2">
  541. <a class="nav-link" href="../../core/vr/legacyOpenVr.html">Virtual Reality Legacy Support</a>
  542. </li>
  543. <li class="nav-item" data-depth="2">
  544. <a class="nav-link" href="../../core/vr/virtualrealitycontrollers.html">Virtual Reality Legacy Controller Support</a>
  545. </li>
  546. </ul>
  547. </li>
  548. </ul>
  549. </li>
  550. <li class="nav-item" data-depth="0">
  551. <ul class="nav-list">
  552. <li class="nav-item" data-depth="1">
  553. <button class="nav-item-toggle"></button>
  554. <a class="nav-link" href="../../physics/physics.html">Physics</a>
  555. <ul class="nav-list">
  556. <li class="nav-item" data-depth="2">
  557. <a class="nav-link" href="../../physics/bullet_multithreading.html">Multi-Threaded Physics</a>
  558. </li>
  559. <li class="nav-item" data-depth="2">
  560. <a class="nav-link" href="../../physics/collision/physics_listeners.html">Collision Detection</a>
  561. </li>
  562. <li class="nav-item" data-depth="2">
  563. <a class="nav-link" href="../../physics/joint/hinges_and_joints.html">Hinges and Joints</a>
  564. </li>
  565. <li class="nav-item" data-depth="2">
  566. <a class="nav-link" href="../../physics/control/walking_character.html">Walking Character</a>
  567. </li>
  568. <li class="nav-item" data-depth="2">
  569. <a class="nav-link" href="../../physics/control/ragdoll.html">Ragdoll</a>
  570. </li>
  571. <li class="nav-item" data-depth="2">
  572. <a class="nav-link" href="../../physics/control/vehicles.html">Vehicles</a>
  573. </li>
  574. <li class="nav-item" data-depth="2">
  575. <a class="nav-link" href="../../physics/control/softbody.html">Softbody</a>
  576. </li>
  577. <li class="nav-item" data-depth="2">
  578. <a class="nav-link" href="../../physics/bullet_pitfalls.html">Bullet Physics Pitfalls</a>
  579. </li>
  580. </ul>
  581. </li>
  582. </ul>
  583. </li>
  584. <li class="nav-item" data-depth="0">
  585. <ul class="nav-list">
  586. <li class="nav-item" data-depth="1">
  587. <button class="nav-item-toggle"></button>
  588. <span class="nav-text">Networking</span>
  589. <ul class="nav-list">
  590. <li class="nav-item" data-depth="2">
  591. <a class="nav-link" href="../../networking/networking.html">Networking (SpiderMonkey)</a>
  592. </li>
  593. <li class="nav-item" data-depth="2">
  594. <a class="nav-link" href="../../networking/headless_server.html">Headless Server</a>
  595. </li>
  596. <li class="nav-item" data-depth="2">
  597. <a class="nav-link" href="../../networking/monkey_zone.html">Multi-Player Demo Code</a>
  598. </li>
  599. <li class="nav-item" data-depth="2">
  600. <a class="nav-link" href="../../networking/networking_video_tutorials.html">Networking Video Tutorials</a>
  601. </li>
  602. </ul>
  603. </li>
  604. </ul>
  605. </li>
  606. <li class="nav-item" data-depth="0">
  607. <ul class="nav-list">
  608. <li class="nav-item" data-depth="1">
  609. <button class="nav-item-toggle"></button>
  610. <span class="nav-text">User Contributions</span>
  611. <ul class="nav-list">
  612. <li class="nav-item" data-depth="2">
  613. <a class="nav-link" href="../../contributions/contributions.html">User Made Utilities</a>
  614. </li>
  615. <li class="nav-item" data-depth="2">
  616. <button class="nav-item-toggle"></button>
  617. <span class="nav-text">Shader</span>
  618. <ul class="nav-list">
  619. <li class="nav-item" data-depth="3">
  620. <a class="nav-link" href="../../contributions/shader/shaderblow_project.html">ShaderBlow Project</a>
  621. </li>
  622. </ul>
  623. </li>
  624. <li class="nav-item" data-depth="2">
  625. <button class="nav-item-toggle"></button>
  626. <span class="nav-text">Landscapes</span>
  627. <ul class="nav-list">
  628. <li class="nav-item" data-depth="3">
  629. <a class="nav-link" href="../../contributions/lanscapes/vegetationsystem/vegetationsystem.html">Vegetation System</a>
  630. </li>
  631. </ul>
  632. </li>
  633. <li class="nav-item" data-depth="2">
  634. <button class="nav-item-toggle"></button>
  635. <span class="nav-text">Networking</span>
  636. <ul class="nav-list">
  637. <li class="nav-item" data-depth="3">
  638. <a class="nav-link" href="../../contributions/networking/open_game_finder.html">Open Game Finder</a>
  639. </li>
  640. </ul>
  641. </li>
  642. <li class="nav-item" data-depth="2">
  643. <button class="nav-item-toggle"></button>
  644. <span class="nav-text">Entity System</span>
  645. <ul class="nav-list">
  646. <li class="nav-item" data-depth="3">
  647. <a class="nav-link" href="#es/entitysystem.adoc">The Zay-ES Entity System</a>
  648. </li>
  649. </ul>
  650. </li>
  651. <li class="nav-item" data-depth="2">
  652. <button class="nav-item-toggle"></button>
  653. <span class="nav-text">Artificial Intelligence</span>
  654. <ul class="nav-list">
  655. <li class="nav-item" data-depth="3">
  656. <a class="nav-link" href="../../contributions/ai/recast.html">Recast Navigation</a>
  657. </li>
  658. <li class="nav-item" data-depth="3">
  659. <a class="nav-link" href="../../contributions/ai/building_recast.html">Updating and building Recast Native Bindings</a>
  660. </li>
  661. <li class="nav-item" data-depth="3">
  662. <a class="nav-link" href="../../contributions/ai/monkey_brains.html">Monkey Brains</a>
  663. </li>
  664. <li class="nav-item" data-depth="3">
  665. <a class="nav-link" href="../../contributions/ai/steer_behaviours.html">Steer Behaviours</a>
  666. </li>
  667. <li class="nav-item" data-depth="3">
  668. <a class="nav-link" href="../../contributions/ai/jme3_ai.html">jME3 Artificial Intelligence</a>
  669. </li>
  670. </ul>
  671. </li>
  672. <li class="nav-item" data-depth="2">
  673. <button class="nav-item-toggle"></button>
  674. <a class="nav-link" href="../../contributions/gui/topic_contributions_gui.html">GUI</a>
  675. <ul class="nav-list">
  676. <li class="nav-item" data-depth="3">
  677. <a class="nav-link" href="../../contributions/contributions.html#lemur-gui-library">Lemur - a native jME3 GUI library with scene graph tools</a>
  678. </li>
  679. <li class="nav-item" data-depth="3">
  680. <a class="nav-link" href="../../contributions/contributions.html#tonegodgui">tonegodGUI - a native jME3 GUI library</a>
  681. </li>
  682. <li class="nav-item" data-depth="3">
  683. <a class="nav-link" href="../../contributions/contributions.html#immediate-graphical-user-interface">Immediate graphical user interface</a>
  684. </li>
  685. </ul>
  686. </li>
  687. <li class="nav-item" data-depth="2">
  688. <button class="nav-item-toggle"></button>
  689. <span class="nav-text">Tools</span>
  690. <ul class="nav-list">
  691. <li class="nav-item" data-depth="3">
  692. <a class="nav-link" href="../../contributions/tools/navigation.html">Mercator Projection Tool (Marine Navigation)</a>
  693. </li>
  694. <li class="nav-item" data-depth="3">
  695. <a class="nav-link" href="../../contributions/tools/charts.html">Visualizing Maps in JME3 (Marine Charts)</a>
  696. </li>
  697. </ul>
  698. </li>
  699. <li class="nav-item" data-depth="2">
  700. <button class="nav-item-toggle"></button>
  701. <a class="nav-link" href="../../contributions/vr/topic_contributions_vr.html">Virtual Reality (And augmented reality)</a>
  702. <ul class="nav-list">
  703. <li class="nav-item" data-depth="3">
  704. <a class="nav-link" href="../../contributions/contributions.html#tamarin-openxr">Tamarin OpenXR</a>
  705. </li>
  706. </ul>
  707. </li>
  708. <li class="nav-item" data-depth="2">
  709. <button class="nav-item-toggle"></button>
  710. <span class="nav-text">Projects</span>
  711. <ul class="nav-list">
  712. <li class="nav-item" data-depth="3">
  713. <a class="nav-link" href="../../contributions/projects/rise_of_mutants_project.html">Rise of Mutants Project</a>
  714. </li>
  715. </ul>
  716. </li>
  717. </ul>
  718. </li>
  719. </ul>
  720. </li>
  721. <li class="nav-item" data-depth="0">
  722. <ul class="nav-list">
  723. <li class="nav-item" data-depth="1">
  724. <button class="nav-item-toggle"></button>
  725. <a class="nav-link" href="../../sdk/sdk.html">SDK</a>
  726. <ul class="nav-list">
  727. <li class="nav-item" data-depth="2">
  728. <button class="nav-item-toggle"></button>
  729. <span class="nav-text">Video Tutorials</span>
  730. <ul class="nav-list">
  731. <li class="nav-item" data-depth="3">
  732. <button class="nav-item-toggle"></button>
  733. <span class="nav-text">SDK Use Case Tutorials</span>
  734. <ul class="nav-list">
  735. <li class="nav-item" data-depth="4">
  736. <a class="nav-link" href="http://www.youtube.com/watch?v=-OzRZscLlHY">Demo 1 (Quixote demo)</a>
  737. </li>
  738. <li class="nav-item" data-depth="4">
  739. <a class="nav-link" href="http://www.youtube.com/watch?v=6-YWxD3JByE">Demo 2 (Models and Materials)</a>
  740. </li>
  741. </ul>
  742. </li>
  743. <li class="nav-item" data-depth="3">
  744. <button class="nav-item-toggle"></button>
  745. <span class="nav-text">SDK Tutorials</span>
  746. <ul class="nav-list">
  747. <li class="nav-item" data-depth="4">
  748. <a class="nav-link" href="http://www.youtube.com/watch?v=M1_0pbeyJzI">Basics</a>
  749. </li>
  750. <li class="nav-item" data-depth="4">
  751. <a class="nav-link" href="http://www.youtube.com/watch?v=nL7woH40i5c">Importing Models</a>
  752. </li>
  753. <li class="nav-item" data-depth="4">
  754. <a class="nav-link" href="http://www.youtube.com/watch?v=DUmgAjiNzhY">Dragging&amp;Dropping Nodes</a>
  755. </li>
  756. <li class="nav-item" data-depth="4">
  757. <a class="nav-link" href="http://www.youtube.com/watch?v=ntPAmtsQ6eM">Scene Composing</a>
  758. </li>
  759. <li class="nav-item" data-depth="4">
  760. <a class="nav-link" href="http://www.youtube.com/watch?v=zgPV3W6dD4s">Terrain with Collision Shape</a>
  761. </li>
  762. <li class="nav-item" data-depth="4">
  763. <a class="nav-link" href="http://www.youtube.com/watch?v=Feu3-mrpolc">Working with Materials</a>
  764. </li>
  765. <li class="nav-item" data-depth="4">
  766. <a class="nav-link" href="http://www.youtube.com/watch?v=MNDiZ9YHIpM">Custom Controls</a>
  767. </li>
  768. <li class="nav-item" data-depth="4">
  769. <a class="nav-link" href="http://www.youtube.com/watch?v=oZnssg8TBWQ">WebStart Deployment</a>
  770. </li>
  771. <li class="nav-item" data-depth="4">
  772. <a class="nav-link" href="http://www.youtube.com/watch?v=D7JM4VMKqPc">Animation and Effect TrackEditing</a>
  773. </li>
  774. </ul>
  775. </li>
  776. </ul>
  777. </li>
  778. <li class="nav-item" data-depth="2">
  779. <button class="nav-item-toggle"></button>
  780. <span class="nav-text">Getting Started</span>
  781. <ul class="nav-list">
  782. <li class="nav-item" data-depth="3">
  783. <a class="nav-link" href="../../sdk/update_center.html">Updating jMonkeyEngine SDK</a>
  784. </li>
  785. <li class="nav-item" data-depth="3">
  786. <a class="nav-link" href="../../sdk/troubleshooting.html">Troubleshooting</a>
  787. </li>
  788. </ul>
  789. </li>
  790. <li class="nav-item" data-depth="2">
  791. <button class="nav-item-toggle"></button>
  792. <span class="nav-text">Java Development Features</span>
  793. <ul class="nav-list">
  794. <li class="nav-item" data-depth="3">
  795. <a class="nav-link" href="../../sdk/project_creation.html">Project Creation</a>
  796. </li>
  797. <li class="nav-item" data-depth="3">
  798. <a class="nav-link" href="../../sdk/code_editor.html">Code Editor and Palette</a>
  799. </li>
  800. <li class="nav-item" data-depth="3">
  801. <a class="nav-link" href="../../sdk/version_control.html">File Version Control</a>
  802. </li>
  803. <li class="nav-item" data-depth="3">
  804. <a class="nav-link" href="../../sdk/debugging_profiling_testing.html">Debug, Profile, Test</a>
  805. </li>
  806. <li class="nav-item" data-depth="3">
  807. <button class="nav-item-toggle"></button>
  808. <a class="nav-link" href="../../sdk/application_deployment.html">Application Deployment</a>
  809. <ul class="nav-list">
  810. <li class="nav-item" data-depth="4">
  811. <a class="nav-link" href="../../sdk/default_build_script.html">Default Build Script</a>
  812. </li>
  813. <li class="nav-item" data-depth="4">
  814. <a class="nav-link" href="../../sdk/android.html">Android</a>
  815. </li>
  816. <li class="nav-item" data-depth="4">
  817. <a class="nav-link" href="../../sdk/android_cheat_sheet.html">Android Cheat Sheet</a>
  818. </li>
  819. <li class="nav-item" data-depth="4">
  820. <a class="nav-link" href="../../sdk/ios.html">iOS</a>
  821. </li>
  822. </ul>
  823. </li>
  824. </ul>
  825. </li>
  826. <li class="nav-item" data-depth="2">
  827. <button class="nav-item-toggle"></button>
  828. <span class="nav-text">Unique Features</span>
  829. <ul class="nav-list">
  830. <li class="nav-item" data-depth="3">
  831. <button class="nav-item-toggle"></button>
  832. <a class="nav-link" href="../../sdk/model_loader_and_viewer.html">Import, View, Convert Models</a>
  833. <ul class="nav-list">
  834. <li class="nav-item" data-depth="4">
  835. <a class="nav-link" href="../../sdk/asset_packs.html">Asset Packs</a>
  836. </li>
  837. </ul>
  838. </li>
  839. <li class="nav-item" data-depth="3">
  840. <a class="nav-link" href="../../sdk/scene_explorer.html">The SceneExplorer</a>
  841. </li>
  842. <li class="nav-item" data-depth="3">
  843. <a class="nav-link" href="../../sdk/scene_composer.html">Composing a Scene</a>
  844. </li>
  845. <li class="nav-item" data-depth="3">
  846. <a class="nav-link" href="../../sdk/terrain_editor.html">Terrain Editor</a>
  847. </li>
  848. <li class="nav-item" data-depth="3">
  849. <a class="nav-link" href="../../sdk/sample_code.html">Sample Code</a>
  850. </li>
  851. <li class="nav-item" data-depth="3">
  852. <a class="nav-link" href="../../sdk/material_editing.html">Material Editing</a>
  853. </li>
  854. <li class="nav-item" data-depth="3">
  855. <a class="nav-link" href="../../sdk/font_creation.html">Creating Bitmap Fonts</a>
  856. </li>
  857. <li class="nav-item" data-depth="3">
  858. <button class="nav-item-toggle"></button>
  859. <a class="nav-link" href="https://hub.jmonkeyengine.org/t/effecttrack-and-audiotrack-editing-in-the-sdk/23378">Audio and Effect Track Editing</a>
  860. <ul class="nav-list">
  861. <li class="nav-item" data-depth="4">
  862. <a class="nav-link" href="https://www.youtube.com/watch?v=D7JM4VMKqPc">Video: Effect and AudioTrack editing in jMonkeyEngine 3 sdk</a>
  863. </li>
  864. </ul>
  865. </li>
  866. <li class="nav-item" data-depth="3">
  867. <a class="nav-link" href="../../sdk/filters.html">Post-Processor Filter Editor and Viewer</a>
  868. </li>
  869. <li class="nav-item" data-depth="3">
  870. <a class="nav-link" href="../../core/app/state/application_states.html">Application States</a>
  871. </li>
  872. <li class="nav-item" data-depth="3">
  873. <a class="nav-link" href="../../core/scene/control/custom_controls.html">Custom Controls</a>
  874. </li>
  875. <li class="nav-item" data-depth="3">
  876. <a class="nav-link" href="../../sdk/vehicle_creator.html">Vehicle Creator</a>
  877. </li>
  878. <li class="nav-item" data-depth="3">
  879. <a class="nav-link" href="../../sdk/assetbrowser.html">Asset Browser</a>
  880. </li>
  881. <li class="nav-item" data-depth="3">
  882. <a class="nav-link" href="../../sdk/animations.html">Animations</a>
  883. </li>
  884. </ul>
  885. </li>
  886. <li class="nav-item" data-depth="2">
  887. <button class="nav-item-toggle"></button>
  888. <span class="nav-text">Advanced Usage</span>
  889. <ul class="nav-list">
  890. <li class="nav-item" data-depth="3">
  891. <a class="nav-link" href="../../sdk/build_platform.html">Building jMonkeyEngine SDK</a>
  892. </li>
  893. <li class="nav-item" data-depth="3">
  894. <a class="nav-link" href="../../sdk/use_own_jme.html#.adoc">Using your own (modified) version of jME3 in jMonkeyEngine SDK</a>
  895. </li>
  896. <li class="nav-item" data-depth="3">
  897. <a class="nav-link" href="../../sdk/increasing_heap_memory.html">Increasing Heap Memory</a>
  898. </li>
  899. <li class="nav-item" data-depth="3">
  900. <a class="nav-link" href="../../sdk/log_files.html">Log Files</a>
  901. </li>
  902. </ul>
  903. </li>
  904. <li class="nav-item" data-depth="2">
  905. <button class="nav-item-toggle"></button>
  906. <span class="nav-text">Available external plugins</span>
  907. <ul class="nav-list">
  908. <li class="nav-item" data-depth="3">
  909. <a class="nav-link" href="../../contributions/contributions.html">Contributions</a>
  910. </li>
  911. <li class="nav-item" data-depth="3">
  912. <a class="nav-link" href="../../sdk/neotexture.html">Neo Texture Editor for procedural textures</a>
  913. </li>
  914. <li class="nav-item" data-depth="3">
  915. <a class="nav-link" href="http://www.youtube.com/watch?v=yS9a9o4WzL8">Video: Mesh Tool &amp; Physics Editor</a>
  916. </li>
  917. </ul>
  918. </li>
  919. <li class="nav-item" data-depth="2">
  920. <button class="nav-item-toggle"></button>
  921. <a class="nav-link" href="../../sdk/development.html">Developing plugins for jMonkeyEngine SDK</a>
  922. <ul class="nav-list">
  923. <li class="nav-item" data-depth="3">
  924. <a class="nav-link" href="../../sdk/development/setup.html">Creating a plugin</a>
  925. </li>
  926. <li class="nav-item" data-depth="3">
  927. <a class="nav-link" href="../../sdk/development/general.html">Creating components</a>
  928. </li>
  929. <li class="nav-item" data-depth="3">
  930. <a class="nav-link" href="../../sdk/development/scene.html">The Main Scene</a>
  931. </li>
  932. <li class="nav-item" data-depth="3">
  933. <a class="nav-link" href="../../sdk/development/sceneexplorer.html">The Scene Explorer</a>
  934. </li>
  935. <li class="nav-item" data-depth="3">
  936. <a class="nav-link" href="../../sdk/development/projects_assets.html">Projects and Assets</a>
  937. </li>
  938. <li class="nav-item" data-depth="3">
  939. <a class="nav-link" href="../../sdk/development/extension_library.html">Create a library plugin from a jar file</a>
  940. </li>
  941. <li class="nav-item" data-depth="3">
  942. <a class="nav-link" href="../../sdk/development/model_loader.html">Create a new or custom model filetype and loader</a>
  943. </li>
  944. </ul>
  945. </li>
  946. </ul>
  947. </li>
  948. </ul>
  949. </li>
  950. </ul>
  951. </nav>
  952. </div>
  953. <div class="nav-panel-explore" data-panel="explore">
  954. <div class="context">
  955. <span class="title">JME</span>
  956. <span class="version">3.8</span>
  957. </div>
  958. <ul class="components">
  959. <li class="component is-current">
  960. <span class="title">JME</span>
  961. <ul class="versions">
  962. <li class="version is-current">
  963. <a href="../../documentation.html">3.8</a>
  964. </li>
  965. <li class="version">
  966. <a href="../../../3.4/documentation.html">3.4</a>
  967. </li>
  968. <li class="version">
  969. <a href="../../../3.3/documentation.html">3.3</a>
  970. </li>
  971. <li class="version">
  972. <a href="../../../3.2/documentation.html">3.2</a>
  973. </li>
  974. </ul>
  975. </li>
  976. <li class="component">
  977. <span class="title">Wiki Contribution</span>
  978. <ul class="versions">
  979. <li class="version">
  980. <a href="../../../../docs-wiki/3.8/wiki_contributor.html">3.8</a>
  981. </li>
  982. </ul>
  983. </li>
  984. <li class="component">
  985. <span class="title">Wiki UI</span>
  986. <ul class="versions">
  987. <li class="version">
  988. <a href="../../../../wiki-ui/index.html">master</a>
  989. </li>
  990. </ul>
  991. </li>
  992. </ul>
  993. </div>
  994. </div>
  995. </aside>
  996. </div>
  997. <main class="article">
  998. <div class="toolbar" role="navigation">
  999. <button class="nav-toggle"></button>
  1000. <nav class="breadcrumbs" aria-label="breadcrumbs">
  1001. <ul>
  1002. <li><a href="../../documentation.html">JME</a></li>
  1003. <li><a href="beginner.html">Beginner Tutorials</a></li>
  1004. <li><a href="hello_collision.html">Hello Collision</a></li>
  1005. </ul>
  1006. </nav>
  1007. <div class="page-versions">
  1008. <button class="version-menu-toggle" title="Show other versions of page">3.8</button>
  1009. <div class="version-menu">
  1010. <a class="version is-current" href="hello_collision.html">3.8</a>
  1011. <a class="version" href="../../../3.4/tutorials/beginner/hello_collision.html">3.4</a>
  1012. <a class="version" href="../../../3.3/tutorials/beginner/hello_collision.html">3.3</a>
  1013. <a class="version" href="../../../3.2/tutorials/beginner/hello_collision.html">3.2</a>
  1014. </div>
  1015. </div>
  1016. <div class="edit-this-page"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/docs/modules/tutorials/pages/beginner/hello_collision.adoc">Edit this Page</a></div>
  1017. </div>
  1018. <div class="content">
  1019. <article class="doc">
  1020. <h1 class="page">jMonkeyEngine 3 Tutorial (9) - Hello Collision</h1>
  1021. <div id="preamble">
  1022. <div class="sectionbody">
  1023. <div class="paragraph">
  1024. <p>This tutorial demonstrates how you load a scene model and give it solid walls and floors for a character to walk around.
  1025. You use a <code>RigidBodyControl</code> for the static collidable scene, and a <code>CharacterControl</code> for the mobile first-person character. You also learn how to set up the default first-person camera to work with physics-controlled navigation.
  1026. You can use the solution shown here for first-person shooters, mazes, and similar games.</p>
  1027. </div>
  1028. <div class="imageblock text-center">
  1029. <div class="content">
  1030. <img src="../_images/beginner/beginner-scene.png" alt="beginner-scene.png" width="360" height="281">
  1031. </div>
  1032. </div>
  1033. </div>
  1034. </div>
  1035. <div class="sect1">
  1036. <h2 id="sample-code"><a class="anchor" href="#sample-code"></a>Sample Code</h2>
  1037. <div class="sectionbody">
  1038. <div class="paragraph">
  1039. <p>If you don&#8217;t have it yet, <a href="https://wiki.jmonkeyengine.org/Scenes/Town/town.zip">Download the town.zip</a> sample scene.</p>
  1040. </div>
  1041. <div class="listingblock">
  1042. <div class="content">
  1043. <pre class="highlightjs highlight"><code class="language-none hljs">jMonkeyProjects$ ls -1 BasicGame
  1044. assets/
  1045. build.xml
  1046. town.zip
  1047. src/</code></pre>
  1048. </div>
  1049. </div>
  1050. <div class="paragraph">
  1051. <p>Place town.zip in the root directory of your JME3 project. Here is the code:</p>
  1052. </div>
  1053. <div class="listingblock">
  1054. <div class="content">
  1055. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">package jme3test.helloworld;
  1056. import com.jme3.app.SimpleApplication;
  1057. import com.jme3.asset.plugins.HttpZipLocator;
  1058. import com.jme3.bullet.BulletAppState;
  1059. import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
  1060. import com.jme3.bullet.collision.shapes.CollisionShape;
  1061. import com.jme3.bullet.control.CharacterControl;
  1062. import com.jme3.bullet.control.RigidBodyControl;
  1063. import com.jme3.bullet.util.CollisionShapeFactory;
  1064. import com.jme3.input.KeyInput;
  1065. import com.jme3.input.controls.ActionListener;
  1066. import com.jme3.input.controls.KeyTrigger;
  1067. import com.jme3.light.AmbientLight;
  1068. import com.jme3.light.DirectionalLight;
  1069. import com.jme3.math.ColorRGBA;
  1070. import com.jme3.math.Vector3f;
  1071. import com.jme3.scene.Spatial;
  1072. /**
  1073. * Example 9 - How to make walls and floors solid.
  1074. * This collision code uses Physics and a custom Action Listener.
  1075. * @author normen, with edits by Zathras
  1076. */
  1077. public class HelloCollision extends SimpleApplication
  1078. implements ActionListener {
  1079. private CharacterControl player;
  1080. final private Vector3f walkDirection = new Vector3f();
  1081. private boolean left = false, right = false, up = false, down = false;
  1082. //Temporary vectors used on each frame.
  1083. //They here to avoid instantiating new vectors on each frame
  1084. final private Vector3f camDir = new Vector3f();
  1085. final private Vector3f camLeft = new Vector3f();
  1086. public static void main(String[] args) {
  1087. HelloCollision app = new HelloCollision();
  1088. app.start();
  1089. }
  1090. @Override
  1091. public void simpleInitApp() {
  1092. /** Set up Physics */
  1093. BulletAppState bulletAppState = new BulletAppState();
  1094. stateManager.attach(bulletAppState);
  1095. // We re-use the flyby camera for rotation, while positioning is handled by physics
  1096. viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));
  1097. flyCam.setMoveSpeed(100);
  1098. setUpKeys();
  1099. setUpLight();
  1100. // We load the scene from the zip file and adjust its size.
  1101. assetManager.registerLocator(
  1102. "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/town.zip",
  1103. HttpZipLocator.class);
  1104. Spatial sceneModel = assetManager.loadModel("main.scene");
  1105. sceneModel.setLocalScale(2f);
  1106. // We set up collision detection for the scene by creating a
  1107. // compound collision shape and a static RigidBodyControl with mass zero.
  1108. CollisionShape sceneShape =
  1109. CollisionShapeFactory.createMeshShape(sceneModel);
  1110. RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);
  1111. sceneModel.addControl(landscape);
  1112. // We set up collision detection for the player by creating
  1113. // a capsule collision shape and a CharacterControl.
  1114. // The CharacterControl offers extra settings for
  1115. // size, step height, jumping, falling, and gravity.
  1116. // We also put the player in its starting position.
  1117. CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
  1118. player = new CharacterControl(capsuleShape, 0.05f);
  1119. player.setJumpSpeed(20);
  1120. player.setFallSpeed(30);
  1121. player.setGravity(30);
  1122. player.setPhysicsLocation(new Vector3f(0, 10, 0));
  1123. // We attach the scene and the player to the rootnode and the physics space,
  1124. // to make them appear in the game world.
  1125. rootNode.attachChild(sceneModel);
  1126. bulletAppState.getPhysicsSpace().add(landscape);
  1127. bulletAppState.getPhysicsSpace().add(player);
  1128. }
  1129. private void setUpLight() {
  1130. // We add light so we see the scene
  1131. AmbientLight al = new AmbientLight();
  1132. al.setColor(ColorRGBA.White.mult(1.3f));
  1133. rootNode.addLight(al);
  1134. DirectionalLight dl = new DirectionalLight();
  1135. dl.setColor(ColorRGBA.White);
  1136. dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
  1137. rootNode.addLight(dl);
  1138. }
  1139. /** We over-write some navigational key mappings here, so we can
  1140. * add physics-controlled walking and jumping: */
  1141. private void setUpKeys() {
  1142. inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
  1143. inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
  1144. inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
  1145. inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
  1146. inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
  1147. inputManager.addListener(this, "Left");
  1148. inputManager.addListener(this, "Right");
  1149. inputManager.addListener(this, "Up");
  1150. inputManager.addListener(this, "Down");
  1151. inputManager.addListener(this, "Jump");
  1152. }
  1153. /** These are our custom actions triggered by key presses.
  1154. * We do not walk yet, we just keep track of the direction the user pressed. */
  1155. @Override
  1156. public void onAction(String binding, boolean value, float tpf) {
  1157. if (binding.equals("Left")) {
  1158. if (value) { left = true; } else { left = false; }
  1159. } else if (binding.equals("Right")) {
  1160. if (value) { right = true; } else { right = false; }
  1161. } else if (binding.equals("Up")) {
  1162. if (value) { up = true; } else { up = false; }
  1163. } else if (binding.equals("Down")) {
  1164. if (value) { down = true; } else { down = false; }
  1165. } else if (binding.equals("Jump")) {
  1166. player.jump();
  1167. }
  1168. }
  1169. /**
  1170. * This is the main event loop--walking happens here.
  1171. * We check in which direction the player is walking by interpreting
  1172. * the camera direction forward (camDir) and to the side (camLeft).
  1173. * The setWalkDirection() command is what lets a physics-controlled player walk.
  1174. * We also make sure here that the camera moves with player.
  1175. */
  1176. @Override
  1177. public void simpleUpdate(float tpf) {
  1178. camDir.set(cam.getDirection()).multLocal(0.6f);
  1179. camLeft.set(cam.getLeft()).multLocal(0.4f);
  1180. walkDirection.set(0, 0, 0);
  1181. if (left) {
  1182. walkDirection.addLocal(camLeft);
  1183. }
  1184. if (right) {
  1185. walkDirection.addLocal(camLeft.negate());
  1186. }
  1187. if (up) {
  1188. walkDirection.addLocal(camDir);
  1189. }
  1190. if (down) {
  1191. walkDirection.addLocal(camDir.negate());
  1192. }
  1193. player.setWalkDirection(walkDirection);
  1194. cam.setLocation(player.getPhysicsLocation());
  1195. }
  1196. }</code></pre>
  1197. </div>
  1198. </div>
  1199. <div class="paragraph">
  1200. <p>Run the sample. You should see a town square with houses and a monument. Use the WASD keys and the mouse to navigate around with a first-person perspective. Run forward and jump by pressing W and Space. Note how you step over the sidewalk, and up the steps to the monument. You can walk in the alleys between the houses, but the walls are solid. Don&#8217;t walk over the edge of the world! <img class="emoji" draggable="false" height="24px" width="24px" src="https://twemoji.maxcdn.com/2/svg/1f603.svg" /></p>
  1201. </div>
  1202. </div>
  1203. </div>
  1204. <div class="sect1">
  1205. <h2 id="understanding-the-code"><a class="anchor" href="#understanding-the-code"></a>Understanding the Code</h2>
  1206. <div class="sectionbody">
  1207. <div class="paragraph">
  1208. <p>Let&#8217;s start with the class declaration:</p>
  1209. </div>
  1210. <div class="listingblock">
  1211. <div class="content">
  1212. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public class HelloCollision extends SimpleApplication
  1213. implements ActionListener { ... }</code></pre>
  1214. </div>
  1215. </div>
  1216. <div class="paragraph">
  1217. <p>You already know that SimpleApplication is the base class for all jME3 games. You make this class implement the <code>ActionListener</code> interface because you want to customize the navigational inputs later.</p>
  1218. </div>
  1219. <div class="listingblock">
  1220. <div class="content">
  1221. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> private CharacterControl player;
  1222. final private Vector3f walkDirection = new Vector3f();
  1223. private boolean left = false, right = false, up = false, down = false;
  1224. //Temporary vectors used on each frame.
  1225. //They here to avoid instantiating new vectors on each frame
  1226. final private Vector3f camDir = new Vector3f();
  1227. final private Vector3f camLeft = new Vector3f();</code></pre>
  1228. </div>
  1229. </div>
  1230. <div class="paragraph">
  1231. <p>You initialize a few private fields:</p>
  1232. </div>
  1233. <div class="ulist">
  1234. <ul>
  1235. <li>
  1236. <p>The (invisible) first-person player is represented by a CharacterControl object.</p>
  1237. </li>
  1238. <li>
  1239. <p>The fields <code>walkDirection</code> and the four Booleans are used for physics-controlled navigation.</p>
  1240. </li>
  1241. <li>
  1242. <p>camDir and camLeft are temporary vectors used later when computing the walkingDirection from the cam position and rotation</p>
  1243. </li>
  1244. </ul>
  1245. </div>
  1246. <div class="paragraph">
  1247. <p>Let&#8217;s have a look at all the details:</p>
  1248. </div>
  1249. </div>
  1250. </div>
  1251. <div class="sect1">
  1252. <h2 id="initializing-the-game"><a class="anchor" href="#initializing-the-game"></a>Initializing the Game</h2>
  1253. <div class="sectionbody">
  1254. <div class="paragraph">
  1255. <p>As usual, you initialize the game in the <code>simpleInitApp()</code> method.</p>
  1256. </div>
  1257. <div class="listingblock">
  1258. <div class="content">
  1259. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));
  1260. flyCam.setMoveSpeed(100);
  1261. setUpKeys();
  1262. setUpLight();</code></pre>
  1263. </div>
  1264. </div>
  1265. <div class="olist arabic">
  1266. <ol class="arabic">
  1267. <li>
  1268. <p>You set the background color to light blue, since this is a scene with a sky.</p>
  1269. </li>
  1270. <li>
  1271. <p>You repurpose the default camera control &#8220;flyCam&#8221; as first-person camera and set its speed.</p>
  1272. </li>
  1273. <li>
  1274. <p>The auxiliary method <code>setUpLights()</code> adds your light sources.</p>
  1275. </li>
  1276. <li>
  1277. <p>The auxiliary method <code>setUpKeys()</code> configures input mappings–we will look at it later.</p>
  1278. </li>
  1279. </ol>
  1280. </div>
  1281. <div class="sect2">
  1282. <h3 id="the-physics-controlled-scene"><a class="anchor" href="#the-physics-controlled-scene"></a>The Physics-Controlled Scene</h3>
  1283. <div class="paragraph">
  1284. <p>Currently, jMonkeyEngine has two versions of <a href="https://pybullet.org/wordpress/">Bullet Physics</a>. A java port, <a href="http://jbullet.advel.cz/">jBullet</a>, and <a href="https://en.wikipedia.org/wiki/Java_Native_Interface">JNI</a> (native) implementation. Although both accomplish the same goal of adding physics to your game, how you interact with each is quite different. This tutorial and it&#8217;s examples use the JNI (native) implementation of physics. Which you choose is up to you.</p>
  1285. </div>
  1286. <div class="paragraph">
  1287. <p>For a detailed description of the separate jar files see <a href="../../getting-started/jme3_source_structure.html#structure-of-jmonkeyengine3-jars" class="xref page">this list</a>.</p>
  1288. </div>
  1289. <div class="paragraph">
  1290. <p>How you initialize each is the same, only the methods used for manipulating objects is different. The first thing you do in every physics game is create a BulletAppState object. It gives your Simple Application access to the jME3 Bullet integration which handles physical forces and collisions.</p>
  1291. </div>
  1292. <div class="listingblock">
  1293. <div class="content">
  1294. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> BulletAppState bulletAppState = new BulletAppState();
  1295. stateManager.attach(bulletAppState);</code></pre>
  1296. </div>
  1297. </div>
  1298. <div class="paragraph">
  1299. <p>For the scene, you load the Spatial <code>sceneModel</code> from a zip file, and adjust the size.</p>
  1300. </div>
  1301. <div class="listingblock">
  1302. <div class="content">
  1303. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> assetManager.registerLocator(
  1304. "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/town.zip",
  1305. HttpZipLocator.class);
  1306. Spatial sceneModel = assetManager.loadModel("main.scene");
  1307. sceneModel.setLocalScale(2f);</code></pre>
  1308. </div>
  1309. </div>
  1310. <div class="paragraph">
  1311. <p>The file <code>town.zip</code> is an OgreXML model of a town and is included as a sample model in the JME3 sources – you can <a href="https://wiki.jmonkeyengine.org/Scenes/Town/town.zip">Download the town.zip</a>. (Optionally, use any OgreXML scene of your own.) For this sample, place the zip file in the application&#8217;s top level directory (that is, next to src/, assets/, build.xml).</p>
  1312. </div>
  1313. <div class="listingblock">
  1314. <div class="content">
  1315. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> CollisionShape sceneShape =
  1316. CollisionShapeFactory.createMeshShape((Node) sceneModel);
  1317. RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);
  1318. sceneModel.addControl(landscape);
  1319. rootNode.attachChild(sceneModel);</code></pre>
  1320. </div>
  1321. </div>
  1322. <div class="paragraph">
  1323. <p>To make the town model solid and use collision detection, you add a RigidBodyControl to the <code>sceneModel</code> Spatial. The RigidBodyControl for a complex model takes two arguments: A Collision Shape, and the object&#8217;s mass.</p>
  1324. </div>
  1325. <div class="ulist">
  1326. <ul>
  1327. <li>
  1328. <p>JME3 offers a <code>CollisionShapeFactory</code> that precalculates a mesh-accurate collision shape for a Spatial. You choose to generate a <code>CompoundCollisionShape</code> (which has MeshCollisionShapes as its children) because this type of collision shape is optimal for immobile objects, such as terrain, houses, and whole shooter levels.</p>
  1329. </li>
  1330. <li>
  1331. <p>You set the mass to zero since a scene is static and its mass is irrelevant.</p>
  1332. </li>
  1333. <li>
  1334. <p>Add the control to the Spatial to give it physical properties.</p>
  1335. </li>
  1336. <li>
  1337. <p>As always, attach the sceneModel to the rootNode to make it visible.</p>
  1338. </li>
  1339. </ul>
  1340. </div>
  1341. <div class="admonitionblock tip">
  1342. <table>
  1343. <tr>
  1344. <td class="icon">
  1345. <i class="fa icon-tip" title="Tip"></i>
  1346. </td>
  1347. <td class="content">
  1348. <div class="paragraph">
  1349. <p>Remember to add a light source so you can see the scene.</p>
  1350. </div>
  1351. </td>
  1352. </tr>
  1353. </table>
  1354. </div>
  1355. </div>
  1356. <div class="sect2">
  1357. <h3 id="the-physics-controlled-player"><a class="anchor" href="#the-physics-controlled-player"></a>The Physics-Controlled Player</h3>
  1358. <div class="paragraph">
  1359. <p>A first-person player is typically invisible. When you use the default flyCam as first-person cam, it does not even test for collisions and runs through walls. This is because the flyCam control does not have any physical shape assigned. In this code sample, you represent the first-person player as an (invisible) physical shape. You use the WASD keys to steer this physical shape around, while the physics engine manages for you how it walks along solid walls and on solid floors and jumps over solid obstacles. Then you simply make the camera follow the walking shape&#8217;s location – and you get the illusion of being a physical body in a solid environment seeing through the camera.</p>
  1360. </div>
  1361. <div class="paragraph">
  1362. <p>So let&#8217;s set up collision detection for the first-person player.</p>
  1363. </div>
  1364. <div class="listingblock">
  1365. <div class="content">
  1366. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);</code></pre>
  1367. </div>
  1368. </div>
  1369. <div class="paragraph">
  1370. <p>Again, you create a CollisionShape: This time you choose a CapsuleCollisionShape, a cylinder with a rounded top and bottom. This shape is optimal for a person: It&#8217;s tall and the roundness helps to get stuck less often on obstacles.</p>
  1371. </div>
  1372. <div class="ulist">
  1373. <ul>
  1374. <li>
  1375. <p>Supply the CapsuleCollisionShape constructor with the desired radius and height of the bounding capsule to fit the shape of your character. In this example the character is 1.5f units wide, and 6f units tall.</p>
  1376. </li>
  1377. <li>
  1378. <p>The final integer argument specifies the orientation of the cylinder: 1 is the Y-axis, which fits an upright person. For animals which are longer than high you would use 0 or 2 (depending on how it is rotated).</p>
  1379. </li>
  1380. </ul>
  1381. </div>
  1382. <div class="listingblock">
  1383. <div class="content">
  1384. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> player = new CharacterControl(capsuleShape, 0.05f);</code></pre>
  1385. </div>
  1386. </div>
  1387. <div class="admonitionblock tip">
  1388. <table>
  1389. <tr>
  1390. <td class="icon">
  1391. <i class="fa icon-tip" title="Tip"></i>
  1392. </td>
  1393. <td class="content">
  1394. <div class="paragraph">
  1395. <p>&#8220;Does that CollisionShape make me look fat?&#8221; If you ever get confusing physics behaviour, remember to have a look at the collision shapes. Add the following line after the bulletAppState initialization to make the shapes visible:</p>
  1396. </div>
  1397. <div class="listingblock">
  1398. <div class="content">
  1399. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">bulletAppState.setDebugEnabled(true);</code></pre>
  1400. </div>
  1401. </div>
  1402. </td>
  1403. </tr>
  1404. </table>
  1405. </div>
  1406. <div class="paragraph">
  1407. <p>Now you use the CollisionShape to create a <code>CharacterControl</code> that represents the first-person player. The last argument of the CharacterControl constructor (here <code>.05f</code>) is the size of a step that the character should be able to surmount.</p>
  1408. </div>
  1409. <div class="listingblock">
  1410. <div class="content">
  1411. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> player.setJumpSpeed(20);
  1412. player.setFallSpeed(30);
  1413. player.setGravity(30);</code></pre>
  1414. </div>
  1415. </div>
  1416. <div class="paragraph">
  1417. <p>Apart from step height and character size, the <code>CharacterControl</code> lets you configure jumping, falling, and gravity speeds. Adjust the values to fit your game situation. There are some important nuances when setting these variable that are explained in greater detail in the <a href="#2-onaction()">onAction()</a> topic later.</p>
  1418. </div>
  1419. <div class="listingblock">
  1420. <div class="content">
  1421. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> player.setPhysicsLocation(new Vector3f(0, 10, 0));</code></pre>
  1422. </div>
  1423. </div>
  1424. <div class="paragraph">
  1425. <p>Finally we put the player in its starting position and update its state – remember to use <code>setPhysicsLocation()</code> instead of <code>setLocalTranslation()</code> now, since you are dealing with a physical object.</p>
  1426. </div>
  1427. <div class="admonitionblock important">
  1428. <table>
  1429. <tr>
  1430. <td class="icon">
  1431. <i class="fa icon-important" title="Important"></i>
  1432. </td>
  1433. <td class="content">
  1434. <div class="paragraph">
  1435. <p>You can set the gravity before or after adding the object to the physics space,
  1436. but gravity must be set BEFORE moving the physics location.</p>
  1437. </div>
  1438. <div class="listingblock">
  1439. <div class="content">
  1440. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">player.setGravity(30);
  1441. player.setPhysicsLocation(new Vector3f(0, 10, 0));</code></pre>
  1442. </div>
  1443. </div>
  1444. </td>
  1445. </tr>
  1446. </table>
  1447. </div>
  1448. </div>
  1449. <div class="sect2">
  1450. <h3 id="physicsspace"><a class="anchor" href="#physicsspace"></a>PhysicsSpace</h3>
  1451. <div class="paragraph">
  1452. <p>Remember, in physical games, you must register all solid objects (usually the characters and the scene) to the PhysicsSpace!</p>
  1453. </div>
  1454. <div class="listingblock">
  1455. <div class="content">
  1456. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> bulletAppState.getPhysicsSpace().add(landscape);
  1457. bulletAppState.getPhysicsSpace().add(player);</code></pre>
  1458. </div>
  1459. </div>
  1460. <div class="paragraph">
  1461. <p>The invisible body of the character just sits there on the physical floor. It cannot walk yet – you will deal with that next.</p>
  1462. </div>
  1463. </div>
  1464. </div>
  1465. </div>
  1466. <div class="sect1">
  1467. <h2 id="navigation"><a class="anchor" href="#navigation"></a>Navigation</h2>
  1468. <div class="sectionbody">
  1469. <div class="paragraph">
  1470. <p>The default camera controller <code>cam</code> is a third-person camera. JME3 also offers a first-person controller, <code>flyCam</code>, which we use here to handle camera rotation. The <code>flyCam</code> control moves the camera using <code>setLocation()</code>.</p>
  1471. </div>
  1472. <div class="paragraph">
  1473. <p>However, you must redefine how walking (camera movement) is handled for physics-controlled objects: When you navigate a non-physical node (e.g. the default flyCam), you simply specify the <em>target location</em>. There are no tests that prevent the flyCam from getting stuck in a wall! When you move a PhysicsControl, you want to specify a <em>walk direction</em> instead. Then the PhysicsSpace can calculate for you how far the character can actually move in the desired direction – or whether an obstacle prevents it from going any further.</p>
  1474. </div>
  1475. <div class="paragraph">
  1476. <p>In short, you must re-define the flyCam&#8217;s navigational key mappings to use <code>setWalkDirection()</code> instead of <code>setLocalTranslation()</code>. Here are the steps:</p>
  1477. </div>
  1478. <div class="sect2">
  1479. <h3 id="1-inputmanager"><a class="anchor" href="#1-inputmanager"></a>1. inputManager</h3>
  1480. <div class="paragraph">
  1481. <p>In the <code>simpleInitApp()</code> method, you re-configure the familiar WASD inputs for walking, and Space for jumping.</p>
  1482. </div>
  1483. <div class="listingblock">
  1484. <div class="content">
  1485. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">private void setUpKeys() {
  1486. inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
  1487. inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
  1488. inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
  1489. inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
  1490. inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
  1491. inputManager.addListener(this, "Left");
  1492. inputManager.addListener(this, "Right");
  1493. inputManager.addListener(this, "Up");
  1494. inputManager.addListener(this, "Down");
  1495. inputManager.addListener(this, "Jump");
  1496. }</code></pre>
  1497. </div>
  1498. </div>
  1499. <div class="paragraph">
  1500. <p>You can move this block of code into an auxiliary method <code>setupKeys()</code> and call this method from <code>simpleInitApp()</code>– to keep the code more readable.</p>
  1501. </div>
  1502. </div>
  1503. <div class="sect2">
  1504. <h3 id="2-onaction"><a class="anchor" href="#2-onaction"></a>2. onAction()</h3>
  1505. <div class="paragraph">
  1506. <p>Remember that this class implements the <code>ActionListener</code> interface, so you can customize the flyCam inputs. The <code>ActionListener</code> interface requires you to implement the <code>onAction()</code> method: You re-define the actions triggered by navigation key presses to work with physics.</p>
  1507. </div>
  1508. <div class="listingblock">
  1509. <div class="content">
  1510. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Override
  1511. public void onAction(String binding, boolean value, float tpf) {
  1512. if (binding.equals("Left")) {
  1513. if (value) { left = true; } else { left = false; }
  1514. } else if (binding.equals("Right")) {
  1515. if (value) { right = true; } else { right = false; }
  1516. } else if (binding.equals("Up")) {
  1517. if (value) { up = true; } else { up = false; }
  1518. } else if (binding.equals("Down")) {
  1519. if (value) { down = true; } else { down = false; }
  1520. } else if (binding.equals("Jump")) {
  1521. player.jump();
  1522. }
  1523. }</code></pre>
  1524. </div>
  1525. </div>
  1526. <div class="paragraph">
  1527. <p>The only movement that you do not have to implement yourself is the jumping action. The call <code>player.jump(new Vector3f(0,20f,0))</code> is a special method that handles a correct jumping motion for your <code>PhysicsCharacterNode</code>.</p>
  1528. </div>
  1529. <div class="paragraph">
  1530. <p>Remember when we set this variable earlier?</p>
  1531. </div>
  1532. <div class="listingblock">
  1533. <div class="content">
  1534. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">player.setJumpSpeed(20);</code></pre>
  1535. </div>
  1536. </div>
  1537. <div class="paragraph">
  1538. <p>Here, <code>player.setJumpSpeed(20)</code> has no visible effect because its value is overridden when <code>jump(new Vector3f(0,20f,0)</code> is invoked in the onAction(). If you were to replace <code>jump(new Vector3f(0,20f,0)</code> with <code>jump(new Vector3f(0f,60f,0f))</code>, then the player jumps faster and higher, as would be expected.</p>
  1539. </div>
  1540. <div class="paragraph">
  1541. <p>If you were using the &#8220;jBullet&#8221; library for physics, you would manipulate the jump speed and calling jump would have the same effect.</p>
  1542. </div>
  1543. <div class="listingblock">
  1544. <div class="content">
  1545. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">player.setJumpSpeed(60);
  1546. player.jump();</code></pre>
  1547. </div>
  1548. </div>
  1549. <div class="paragraph">
  1550. <p>This is just one of the differences you see when using &#8220;jBullet&#8221; vs the &#8220;Native&#8221; bullet implementations.</p>
  1551. </div>
  1552. <div class="paragraph">
  1553. <p>Another is when using the <code>setFallSpeed()</code> method. This sets the maximum fall speed, what’s sometimes called the terminal velocity. In the town setting, the easiest way to fall faster while jumping is to supply larger values to both setFallSpeed() and jump(). For instance, with <code>setFallSpeed(300f)</code> and <code>jump(new Vector3f(0,200f,0))</code>, the player reaches a speed of 200 wu/second just before landing. Using jBullet, just setting the fall speed accomplishes the same effect.</p>
  1554. </div>
  1555. <div class="paragraph">
  1556. <p>For all other directions: Every time the user presses one of the WASD keys, you <em>keep track</em> of the direction the user wants to go, by storing this info in four directional Booleans. No actual walking happens here yet. The update loop is what acts out the directional info stored in the booleans, and makes the player move, as shown in the next topic, &#8220;setWalkDirection()&#8221;.</p>
  1557. </div>
  1558. </div>
  1559. <div class="sect2">
  1560. <h3 id="3-setwalkdirection"><a class="anchor" href="#3-setwalkdirection"></a>3. setWalkDirection()</h3>
  1561. <div class="paragraph">
  1562. <p>Previously in the <code>onAction()</code> method, you have collected the info in which direction the user wants to go in terms of &#8220;forward&#8221; or &#8220;left&#8221;. In the update loop, you repeatedly poll the current rotation of the camera. You calculate the actual vectors to which &#8220;forward&#8221; or &#8220;left&#8221; corresponds in the coordinate system.</p>
  1563. </div>
  1564. <div class="paragraph">
  1565. <p>This last and most important code snippet goes into the <code>simpleUpdate()</code> method.</p>
  1566. </div>
  1567. <div class="listingblock">
  1568. <div class="content">
  1569. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> public void simpleUpdate(float tpf) {
  1570. camDir.set(cam.getDirection()).multLocal(0.6f);
  1571. camLeft.set(cam.getLeft()).multLocal(0.4f);
  1572. walkDirection.set(0, 0, 0);
  1573. if (left) {
  1574. walkDirection.addLocal(camLeft);
  1575. }
  1576. if (right) {
  1577. walkDirection.addLocal(camLeft.negate());
  1578. }
  1579. if (up) {
  1580. walkDirection.addLocal(camDir);
  1581. }
  1582. if (down) {
  1583. walkDirection.addLocal(camDir.negate());
  1584. }
  1585. player.setWalkDirection(walkDirection);
  1586. cam.setLocation(player.getPhysicsLocation());
  1587. }</code></pre>
  1588. </div>
  1589. </div>
  1590. <div class="paragraph">
  1591. <p>This is how the walking is triggered:</p>
  1592. </div>
  1593. <div class="olist arabic">
  1594. <ol class="arabic">
  1595. <li>
  1596. <p>Initialize the vector <code>walkDirection</code> to zero. This is where you want to store the calculated walk direction.</p>
  1597. <div class="olist loweralpha">
  1598. <ol class="loweralpha" type="a">
  1599. <li>
  1600. <p>Add to <code>walkDirection</code> the recent motion vectors that you polled from the camera. This way it is possible for a character to move forward and to the left simultaneously, for example!</p>
  1601. </li>
  1602. <li>
  1603. <p>This one last line does the &#8220;walking&#8221; magic:</p>
  1604. <div class="listingblock">
  1605. <div class="content">
  1606. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">player.setWalkDirection(walkDirection);</code></pre>
  1607. </div>
  1608. </div>
  1609. <div class="paragraph">
  1610. <p>Always use <code>setWalkDirection()</code> to make a physics-controlled object move continuously, and the physics engine handles collision detection for you.</p>
  1611. </div>
  1612. </li>
  1613. <li>
  1614. <p>Make the first-person camera object follow along with the physics-controlled player:</p>
  1615. <div class="listingblock">
  1616. <div class="content">
  1617. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">cam.setLocation(player.getPhysicsLocation());</code></pre>
  1618. </div>
  1619. </div>
  1620. </li>
  1621. </ol>
  1622. </div>
  1623. </li>
  1624. </ol>
  1625. </div>
  1626. <div class="admonitionblock important">
  1627. <table>
  1628. <tr>
  1629. <td class="icon">
  1630. <i class="fa icon-important" title="Important"></i>
  1631. </td>
  1632. <td class="content">
  1633. <div class="paragraph">
  1634. <p>Again, do not use <code>setLocalTranslation()</code> to walk the player around. You will get it stuck by overlapping with another physical object. You can put the player in a start position with <code>setPhysicalLocation()</code> if you make sure to place it a bit above the floor and away from obstacles.</p>
  1635. </div>
  1636. </td>
  1637. </tr>
  1638. </table>
  1639. </div>
  1640. </div>
  1641. </div>
  1642. </div>
  1643. <div class="sect1">
  1644. <h2 id="conclusion"><a class="anchor" href="#conclusion"></a>Conclusion</h2>
  1645. <div class="sectionbody">
  1646. <div class="paragraph">
  1647. <p>You have learned how to load a &#8220;solid&#8221; physical scene model and walk around in it with a first-person perspective.
  1648. You learned to speed up the physics calculations by using the CollisionShapeFactory to create efficient CollisionShapes for complex Geometries. You know how to add PhysicsControls to your collidable geometries and you register them to the PhysicsSpace. You also learned to use <code>player.setWalkDirection(walkDirection)</code> to move collision-aware characters around, and not <code>setLocalTranslation()</code>.</p>
  1649. </div>
  1650. <div class="paragraph">
  1651. <p><strong>See also:</strong></p>
  1652. </div>
  1653. <div class="ulist">
  1654. <ul>
  1655. <li>
  1656. <p>How to load models and scenes: <a href="hello_asset.html" class="xref page">Hello Asset</a>, <a href="../../sdk/scene_explorer.html" class="xref page">Scene Explorer</a>, <a href="../../sdk/scene_composer.html" class="xref page">Scene Composer</a>.</p>
  1657. </li>
  1658. <li>
  1659. <p><a href="../../core/collision/terrain_collision.html" class="xref page">Terrain Collision</a></p>
  1660. </li>
  1661. <li>
  1662. <p>To learn more about complex physics scenes, where several mobile physical objects bump into each other, read <a href="hello_physics.html" class="xref page">Hello Physics</a>.</p>
  1663. </li>
  1664. <li>
  1665. <p>FYI, there are simpler collision detection solutions without physics, too. Have a look at <a href="https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/collision/TestTriangleCollision.java">jme3test.collision.TestTriangleCollision.java</a>.</p>
  1666. </li>
  1667. </ul>
  1668. </div>
  1669. </div>
  1670. </div>
  1671. <nav class="pagination">
  1672. <span class="prev"><a href="hello_picking.html">Hello Picking</a></span>
  1673. <span class="next"><a href="hello_terrain.html">Hello Terrain</a></span>
  1674. </nav>
  1675. </article>
  1676. <aside class="toc sidebar" data-title="Contents" data-levels="2">
  1677. <div class="toc-menu"></div>
  1678. </aside>
  1679. </div>
  1680. </main>
  1681. </div>
  1682. <footer class="footer">
  1683. <p>Copyright 2020 jMonkeyEngine Wiki Contributors. Licensed BSD-3.</p>
  1684. </footer>
  1685. <script src="../../../../_/js/vendor/docsearch.min.js"></script>
  1686. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js -->
  1687. <script>
  1688. var search = docsearch({
  1689. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  1690. indexName: 'jmonkeyengine',
  1691. inputSelector: '#search-input',
  1692. autocompleteOptions: { hint: false, keyboardShortcuts: ['s'] },
  1693. algoliaOptions: { hitsPerPage: 10 }
  1694. }).autocomplete
  1695. search.on('autocomplete:closed', function () { search.autocomplete.setVal() })
  1696. function focusSearchInput () { document.querySelector('#search-input').focus() }
  1697. if (document.querySelector('.home-link.is-current')) window.addEventListener('load', focusSearchInput)
  1698. </script>
  1699. <script src="../../../../_/js/site.js"></script>
  1700. <script async src="../../../../_/js/vendor/highlight.js"></script>
  1701. </body>
  1702. </html>