terrain_editor.html 14 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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, tool, terrain, asset, texture"><title>jMonkeyEngine SDK: Terrain Editor</title><link rel="stylesheet" href="./asciidoctor.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"></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/terrain_editor.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: Terrain Editor</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="#controls">Controls</a></li><li><a href="#creating-terrain">Creating Terrain</a><ul class="sectlevel2"><li><a href="#step-1-terrain-size">Step 1: Terrain Size</a></li><li><a href="#step-2-heightmap">Step 2: Heightmap</a></li><li><a href="#step-3-alpha-image-detail">Step 3: Alpha Image Detail</a></li></ul></li><li><a href="#modifying-terrain">Modifying Terrain</a></li><li><a href="#painting-terrain">Painting Terrain</a><ul class="sectlevel2"><li><a href="#adding-a-new-texture-layer">Adding a new texture layer</a></li><li><a href="#changing-the-diffuse-texture">Changing the diffuse texture</a></li><li><a href="#adding-a-normal-map-to-the-texture-layer">Adding a normal map to the texture layer</a></li><li><a href="#removing-a-normal-map-from-the-texture-layer">Removing a normal map from the texture layer</a></li><li><a href="#changing-the-texture-scale">Changing the texture scale</a></li><li><a href="#tri-planar-texture-mapping">Tri-planar texture mapping</a></li><li><a href="#total-texture-count">Total texture count</a></li></ul></li><li><a href="#generating-terrain-entropies-for-lod">Generating Terrain Entropies for LOD</a></li><li><a href="#loading-terrain-into-your-game">Loading Terrain Into Your Game</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>The terrain editor lets you create, modify, and paint terrain.</p></div></div></div>
  4. <div class="sect1"><h2 id="controls">Controls</h2><div class="sectionbody"><div class="paragraph"><p>Terrain controls are the same as the Scene Composer, you rotate the camera with the left mouse button and pan the camera with the right mouse button. Until you select one of the terrain tools in the toolbar, then the controls change for that tool. Then left mouse button will use that tool: painting, raising/lowering terrain, etc. The right mouse button might do something, depending on the tool.</p></div></div></div>
  5. <div class="sect2"><h3 id="creating-terrain">Creating Terrain</h3><div class="paragraph"><p>To create terrain, first select the <code>Scene</code> directory under your <code>Project Assets</code> folder, right click and select <code><span class="menuseq"><span class="menu">New</span>&#160;&#9656; <span class="submenu">Other</span>&#160;&#9656; <span class="submenu">Scene</span>&#160;&#9656; <span class="menuitem">Empty jme3 Scene</span></span></code>. This will generate an empty scene in that directory. Right click this new file and then select <code>Edit Terrain</code>. This will open the new file in the <code>TerrainEditor</code> and display your scenes file structure in the <code>SceneExplorer</code> located at the bottom left window of the SDK. In the <code>SceneExplorer</code> window, select a node (usually your root node) in your scene.<br>
  6. <span class="image"><img src="../sdk/sdk-terrain-tut-selectnode.png" alt="sdk-terrain-tut-selectnode.png" width="" height=""></span><br>
  7. Then click the add terrain button.<br>
  8. <span class="image"><img src="../sdk/sdk-terrain-tut-addterrain.png" alt="sdk-terrain-tut-addterrain.png" width="" height=""></span><br>
  9. This will pop up the <code>Create Terrain</code> wizard that will walk you through the steps for creating terrain. Make sure you decide now how large you want your terrain to be and how detailed you want the textures to be as you cannot change it later on!</p></div>
  10. <div class="paragraph"><p>In order to see the terrain, you will need to add light to your scene. To do this, right-click the root node in the <code>SceneExplorer</code> window and select <code><span class="menuseq"><span class="menu">Add</span>&#160;&#9656; <span class="submenu">Light</span>&#160;&#9656; <span class="menuitem">Directional Light</span></span></code>. Alternatively, you can create your terrain and press the <b class="button">Toggle cam light</b> button located in the menu at the top of the open terrain window. You will need to add a light to your scene by code in the <code>simpleinitApp()</code> method later so you can see the terrain.</p></div>
  11. <div class="sect2"><h3 id="step-1-terrain-size">Step 1: Terrain Size</h3><div class="paragraph"><p>Here you determine the size of your terrain, the total size and the patch size. You should probably leave the patch size alone. But the total size should be defined; this is how big your terrain is.</p></div></div>
  12. <div class="sect2"><h3 id="step-2-heightmap">Step 2: Heightmap</h3><div class="paragraph"><p>Here you can select a heightmap generation technique to give you a default/random look of the terrain. You can also select a heightmap image to pre-define how your terrain looks.
  13. By default, it will give you a flat terrain.</p></div></div>
  14. <div class="sect2"><h3 id="step-3-alpha-image-detail">Step 3: Alpha Image Detail</h3><div class="paragraph"><p>This step determines how large the alpha blend images are for your terrain. The smaller the alpha image, the less detailed you can paint the terrain. Play around with this to see how big you need it to be. Remember that terrain does not have to be that detailed, and is often covered by vegetation, rocks, and other items. So having a really detailed texture is not always necessary.</p></div></div></div>
  15. <div class="sect1"><h2 id="modifying-terrain">Modifying Terrain</h2><div class="sectionbody"><div class="paragraph"><p>Right now there are two terrain modification tools: raise and lower terrain.<br>
  16. <span class="image"><img src="../sdk/sdk-terrain-raise-lower.png" alt="sdk-terrain-raise-lower.png" width="" height=""></span><br>
  17. There are two sliders that affect how these tools operate:</p></div>
  18. <div class="ulist"><ul><li><p>Radius: how big the brush is</p></li><li><p>Weight/Height: how much impact the brush has</p></li></ul></div>
  19. <div class="paragraph"><p>Once a tool is selected, you will see the tool marker (now an ugly wire sphere) on the map where your mouse is. Click and drag on the terrain to see the tool change the height of the terrain.</p></div></div></div>
  20. <div class="sect2"><h3 id="painting-terrain">Painting Terrain</h3><div class="paragraph"><p>Your terrain comes with one diffuse default texture, and you can have up to 12 total diffuse textures. It also allows you to add normal maps to each texture layer. There can be a maximum of 13 textures, including Diffuse and Normal (3 textures are taken up by alpha maps).</p></div>
  21. <div class="paragraph"><p>All of the textures can be controlled in the Texture Layer table by clicking on the textures.
  22. There are two sliders that affect how the paint tool operates:</p></div>
  23. <div class="ulist"><ul><li><p>Radius: how big the brush is</p></li><li><p>Weight/Height: how much impact the brush has.</p></li></ul></div>
  24. <div class="sect2"><h3 id="adding-a-new-texture-layer">Adding a new texture layer</h3><div class="paragraph"><p>Adds a new texture layer to the terrain. The will be drawn over top of the other texture layers listed above it in the list.</p></div>
  25. <div class="paragraph"><p><span class="image"><img src="../sdk/sdk-terrain-addtexture.png" alt="sdk-terrain-addtexture.png" width="" height=""></span></p></div></div>
  26. <div class="sect2"><h3 id="changing-the-diffuse-texture">Changing the diffuse texture</h3><div class="paragraph"><p>Click on the diffuse texture image in the texture table. This will pop up a window with the available textures in your assets directory.</p></div>
  27. <div class="paragraph"><p><span class="image"><img src="../sdk/sdk-terrain-editdiffuse.png" alt="sdk-terrain-editdiffuse.png" width="" height=""></span></p></div></div>
  28. <div class="sect2"><h3 id="adding-a-normal-map-to-the-texture-layer">Adding a normal map to the texture layer</h3><div class="paragraph"><p>When you add a texture layer, by default it does not add a normal map for you. To add one, click on the button next to the diffuse texture for that texture layer. This will pop up the texture browser. Select a texture and hit Ok, and you are done.<br>
  29. <span class="image"><img src="../sdk/sdk-terrain-addnormaltexture.png" alt="sdk-terrain-addnormaltexture.png" width="" height=""></span></p></div></div>
  30. <div class="sect2"><h3 id="removing-a-normal-map-from-the-texture-layer">Removing a normal map from the texture layer</h3><div class="paragraph"><p>To remove a normal map from the texture layer, hit the normal map button for that texture layer again, and deselect the texture. Then hit Ok and the texture should be removed.</p></div></div>
  31. <div class="sect2"><h3 id="changing-the-texture-scale">Changing the texture scale</h3><div class="paragraph"><p>The field in the table to the right of the diffuse and normal textures for your texture layer is the scale. Changing that value changes the scale of the texture.<br>
  32. <span class="image"><img src="../sdk/sdk-terrain-texturescale.png" alt="sdk-terrain-texturescale.png" width="" height=""></span><br>
  33. You will notice that the scale changes when you switch between Tri-Planar and normal texture mapping. Tri-planar mapping does not use the texture coordinates of the geometry, but real world coordinates. And because of this, in order for the texture to look the same when you switch between the two texture mapping methods, the terrain editor will automatically convert the scales for you.
  34. Essentially if your scale in normal texture coordinates is 16, then for tri-planar gets converted like this: 1/terrainSize/16</p></div></div>
  35. <div class="sect2"><h3 id="tri-planar-texture-mapping">Tri-planar texture mapping</h3><div class="paragraph"><p>Tri-planar texture mapping is recommended if you have lots of near-vertical terrain. With normal texture mapping the textures can look stretched because it is rendered on the one plane: X-Z. Tri-planar mapping renders the textures on three planes: X-Z, X-Y, Z-Y; and blends them together based on what plane the normal of the triangle is facing most on.
  36. This makes the terrain look much better, but it does have a performance hit!
  37. Here is an article on tri-planar mapping: <a href="https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch01.html">https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch01.html</a></p></div></div>
  38. <div class="sect2"><h3 id="total-texture-count">Total texture count</h3><div class="paragraph"><p>Terrain will support a maximum of 12 diffuse texture. And a combined total of 13 diffuse and normal maps.
  39. Most video cards are limited to 16 texture units (textures), and 3 are used behind the scenes of the terrain material for alpha blending of the textures, so you are left with a maximum of 13 textures.</p></div></div></div>
  40. <div class="sect1"><h2 id="generating-terrain-entropies-for-lod">Generating Terrain Entropies for LOD</h2><div class="sectionbody"><div class="paragraph"><p>If you are using the recommended PerspectiveLodCalculator for calculating LOD levels of the terrain, then you will want to pre-generate the entropy levels for the terrain. This is a slow process. If they are not pre-generated, the LOD control will generate them for you, but this will lag the user when they load the scene, and the terrain will flicker.
  41. Use the 'Generate Entropies' button to pre-generate the entropies for the terrain, they will be saved with it.
  42. Note that whenever you modify the height of the terrain, you should re-generate the entropies. Of course, don&#8217;t do this every time, but maybe just before you are ready to send the map out for testing.</p></div></div></div>
  43. <div class="sect1"><h2 id="loading-terrain-into-your-game">Loading Terrain Into Your Game</h2><div class="sectionbody"><div class="paragraph"><p>There are a few things your code needs to do to load the terrain.</p></div>
  44. <div class="ulist"><ul><li><p>You must first use the asset manager to load the scene, see the <a href="../jme3/beginner/hello_asset.html">hello asset tutorial</a>.</p></li><li><p>The terrain (as you can see on the left in the editor) is a sub-node of the scene, so you have to write code to investigate the child nodes of the scene until you find the node that is the terrain, see <a href="../jme3/the_scene_graph.html">this tutorial for scene graph concepts</a>.</p></li><li><p>You also have to set the camera on the LOD control in order for it to work correctly:</p></li></ul></div>
  45. <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">TerrainLodControl lodControl = ((Node)terrain).getControl(TerrainLodControl.class);
  46. <span class="keyword">if</span> (lodControl != <span class="predefined-constant">null</span>)
  47. lodControl.setCamera(getCamera());</code></pre></div></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2018-02-28 16:23:40 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
  48. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  49. indexName: 'jmonkeyengine',
  50. inputSelector: '#doc-search',
  51. debug: false // Set debug to true if you want to inspect the dropdown
  52. });</script></body></html>