sample_code.html 9.5 KB

1234567891011121314151617181920212223242526
  1. <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, sdk, asset, project"><title>jMonkeyEngine SDK: Sample Code</title><link rel="stylesheet" href="./twemoji-awesome.css">
  2. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  3. <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"><link rel="stylesheet" href="/home/travis/build/jMonkeyEngine/wiki/build/asciidoc/html5/sdk/twemoji-awesome.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/sdk/sample_code.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/sdk/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"></div><h1>jMonkeyEngine SDK: Sample Code</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#code-palette-and-samples-in-the-sdk">Code Palette and Samples in the SDK</a></li><li><a href="#the-jme3tests-project-template">The JME3Tests Project Template</a></li><li><a href="#jme3testdata-assets">JME3TestData Assets</a></li><li><a href="#assetpacks">AssetPacks</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>You can run example code by opening an included JME3Tests project and included assets. You can also search the built-in documentation or drag and drop code snippets from the Palette in the SDK to get short code sample.</p></div></div></div>
  4. <div class="sect1"><h2 id="code-palette-and-samples-in-the-sdk">Code Palette and Samples in the SDK</h2><div class="sectionbody"><div class="ulist"><ul><li><p>Type a keyword into the search box in the SDK or press <kbd>F1</kbd> to search the built-in help for sample code.</p></li><li><p><a href="../sdk/code_editor.html">SDK code editor and palette</a></p></li></ul></div></div></div>
  5. <div class="sect1"><h2 id="the-jme3tests-project-template">The JME3Tests Project Template</h2><div class="sectionbody"><div class="paragraph"><p>The jMonkeyEngine SDK contains a Test Project with lots of sample code and assets. The Test Project is all set up and ready to run, and it&#8217;s easy to use for beginners (no need to mess with classpaths or libraries).</p></div>
  6. <div class="olist arabic"><ol class="arabic"><li><p>Install and Open the jMonkeyEngine <a href="../sdk.html">SDK</a>.</p></li><li><p>Go to <code><span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="menuitem">New Project</span></span></code>.</p></li><li><p>In the New Project Wizard, select <code>JME3 Tests</code> from the <code>JME3</code> category. Click <code><b class="button">Next</b></code>.</p></li><li><p>Specify a location, e.g. create a jMonkeyProjects directory in your home directory. Click <code><b class="button">Finish</b></code>.</p></li></ol></div>
  7. <div class="paragraph"><p>This default project template creates a project called <code>JmeTests</code>. It contains all test classes and examples from the jme3 source repository. Feel free to modify the code samples and experiment! In the unlikely event that you should break the project, <i class="twa twa-smiley"></i> you can always recreate all packaged samples by creating another project from the New Project wizard&#8217;s <code>JME3 Tests</code> template.</p></div>
  8. <div class="paragraph"><p>If you&#8217;re using the 3.1.0-Stable+ version of the SDK, you will need to set the <code>Source/Binary Format</code> from the <code>Project Properties</code> window to Java 1.7 or later.</p></div>
  9. <div class="ulist"><ul><li><p>To change the source, <code><b class="button">RMB</b></code> select the jmeTestProject and then select <code><span class="menuseq"><span class="menu">Properties</span>&#160;&#9656; <span class="submenu">Sources</span>&#160;&#9656; <span class="menuitem">Source/Binary Format</span></span></code>, or from the File menu, with the jmeTestProject selected, <code><span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="submenu">Project Properties</span>&#160;&#9656; <span class="submenu">Sources</span>&#160;&#9656; <span class="menuitem">Source/Binary Format</span></span></code>.</p></li></ul></div>
  10. <div class="paragraph"><p>You will also need to remove the <code>jme3-jbullet</code> library and add <code>jme3-bullet</code> and <code>jme3-bullet-native</code> libraries.</p></div>
  11. <div class="ulist"><ul><li><p>From the <code>Project Properties</code> window select <code>Libraries</code> and then the <code>Compile</code> tab. Under <code>Compile-time Libraries</code> select <code>jme3-jbullet</code> and press <code><b class="button">Remove</b></code>. Press <code><b class="button">Add Library</b></code>, select the two libraries <code>jme3-bullet</code> and <code>jme3-bullet-native</code> while holding <kbd>Ctrl</kbd> and then press <code><b class="button">Add Library</b></code> and finally <code><b class="button">OK</b></code>.</p></li></ul></div>
  12. <div class="admonitionblock important"><table><tr><td class="icon"><i class="fa icon-important" title="Important"></i></td><td class="content"><div class="paragraph"><p>Press <kbd>Shift</kbd> + <kbd>F6</kbd> to run a class that is open in the editor, or <code><b class="button">RMB</b></code> a class in the Project window and choose <code><b class="button">Run File</b></code>. You can run the <code>TestChooser</code> app by <code><b class="button">RMB</b></code> selecting the project and pressing <code><b class="button">Run</b></code>. The TestChooser app allows you to easily navigate through all the test cases.</p></div></td></tr></table></div></div></div>
  13. <div class="sect1"><h2 id="jme3testdata-assets">JME3TestData Assets</h2><div class="sectionbody"><div class="paragraph"><p>You may want access to some sample assets, such as 3D models or textures, in one of your projects. A common situation for this would be while going through the <a href="../jme3.html#tutorials-for-beginners">beginner tutorials</a>.</p></div>
  14. <div class="olist arabic"><ol class="arabic"><li><p><b class="button">RMB</b> select an existing jME3 project in the <a href="../sdk.html">SDK</a>, and select Properties.</p></li><li><p>In the Properties window, select the <code>Libraries</code> section. Go to the <code>Compile</code> tab, it contains <code>Compile-time Libraries</code>.</p></li><li><p>Click the <b class="button">Add Library</b> button and select the pre-defined <code>jme3-test-data</code>. Click <b class="button">OK</b>.</p></li><li><p>Click <b class="button">OK</b> to save and close the Properties.</p></li></ol></div>
  15. <div class="paragraph"><p>The project&#8217;s assetManager now has access to sample files from the <code>jme3-test-data.jar</code> file. This JAR library contains</p></div>
  16. <div class="ulist"><ul><li><p>Ogre XML Models: Ninja.mesh.xml, Oto.mesh.xml, HoverTank.mesh.xml, Sinbad.mesh.xml, and many more</p></li><li><p>Blender models</p></li><li><p>Materials and Textures</p><div class="ulist"><ul><li><p>Terrain, sky, rock, brick, pond…</p></li><li><p>Particle effect textures</p></li></ul></div></li><li><p>Sounds</p></li><li><p>And more…</p></li></ul></div></div></div>
  17. <div class="sect1"><h2 id="assetpacks">AssetPacks</h2><div class="sectionbody"><div class="imageblock right"><div class="content"><img src="../sdk/assetpackbrowser-300x166.jpg" alt="assetpackbrowser-300x166.jpg" width="" height=""></div></div>
  18. <div class="paragraph"><p>If you need sample 3D models, don&#8217;t miss the opportunity to download our community-provided <a href="../sdk/asset_packs.html">Asset Packs</a>!</p></div>
  19. <div class="paragraph"><p>In the SDK:</p></div>
  20. <div class="ulist"><ul><li><p>Open the AssetPackBrowser from the Windows menu</p></li><li><p>In the AssetPackBrowser, click the Online AssetPacks button</p></li><li><p>Click <b class="button">Install</b> on the AssetPack of your choice. The SDK downloads it and makes the assets accessible in your AssetPack Library.</p></li><li><p>Click the <b class="button">View Library</b> button and open the Assets node.</p></li><li><p><b class="button">RMB</b> select an asset to</p><div class="ulist"><ul><li><p>Preview it</p></li><li><p>Add it to the SceneComposer</p></li><li><p>Add it to a game project&#8217;s assets directory</p></li></ul></div></li></ul></div>
  21. <div class="paragraph"><p>Read more about <a href="../sdk/asset_packs.html">Asset Packs</a> and how you can share your own collection with the community.</p></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2019-12-19 19:32:51 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
  22. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  23. indexName: 'jmonkeyengine',
  24. inputSelector: '#doc-search',
  25. debug: false // Set debug to true if you want to inspect the dropdown
  26. });</script></body></html>