| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <!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, material, file, texture"><title>jMonkeyEngine SDK: Material Editor</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <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/material_editing.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: Material 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="#materials">Materials</a></li><li><a href="#creating-j3m-materials">Creating .j3m Materials</a></li><li><a href="#using-j3m-materials">Using .j3m Materials</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>If you are looking for background information, read about <a href="../jme3/advanced/material_definitions.html">Material Definitions</a> and <a href="../jme3/advanced/j3m_material_files.html">j3M Material Files</a>.
- You can <a href="../jme3/advanced/j3m_material_files.html">write .j3m files in a text editor</a>, or use the jMonkeyEngine SDK to generate them for you as described in this article.</p></div></div></div>
- <div class="sect1"><h2 id="materials">Materials</h2><div class="sectionbody"><div class="paragraph"><p>The jMonkeyEngine uses a special Material format, which comes in .j3m files. You use .j3m files to store sets of material properties that you use repeatedly. This enables you write one short line of code that simply loads the presets from a custom .j3m file. Without a .j3m file you need to write several lines of material property setters every time when you want to use a non-default material.</p></div></div></div>
- <div class="sect1"><h2 id="creating-j3m-materials">Creating .j3m Materials</h2><div class="sectionbody"><div style="text-align: right;" class="imageblock right"><div class="content"><img src="../sdk/material-editor.png" alt="material-editor.png" width="275" height="245"></div></div>
- <div class="paragraph"><p>To create new .j3m files in the jMonkeyEngine SDK:</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p><b class="button">RMB</b> select the <code>assets/Materials</code> directory and choose <code><span class="menuseq"><span class="menu">New</span> ▸ <span class="menuitem">Other</span></span></code>.</p></li><li><p>In the New File Wizard, choose <code><span class="menuseq"><span class="menu">Material</span> ▸ <span class="menuitem">Empty Material File</span></span></code>, and click <b class="button">Next</b>.</p></li><li><p>Give the file a name, for example <code>mat_wall</code> for a wall material.</p></li><li><p>A new file <code>mat_wall.j3m</code> is created in the Materials directory and opens in the Material Editor.</p></li></ol></div>
- <div class="paragraph"><p>You can edit the source of the material, or use the user-friendly visual editor to set the properties of the material. Set the properties to the same values as you would otherwise specify with setters on a Material object in Java code:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">Material mat_wall = <span class="keyword">new</span> Material(
- assetManager, <span class="string"><span class="delimiter">"</span><span class="content">Common/MatDefs/Light/Lighting.j3md</span><span class="delimiter">"</span></span>);
- mat_wall.setTexture(<span class="string"><span class="delimiter">"</span><span class="content">DiffuseMap</span><span class="delimiter">"</span></span>,
- assetManager.loadTexture(<span class="string"><span class="delimiter">"</span><span class="content">Textures/wall_diffuse.png</span><span class="delimiter">"</span></span>));
- mat_wall.setTexture(<span class="string"><span class="delimiter">"</span><span class="content">NormalMap</span><span class="delimiter">"</span></span>,
- assetManager.loadTexture(<span class="string"><span class="delimiter">"</span><span class="content">Textures/wall_normals.png</span><span class="delimiter">"</span></span>));
- mat_wall.setFloat(<span class="string"><span class="delimiter">"</span><span class="content">Shininess</span><span class="delimiter">"</span></span>, <span class="float">5f</span>);</code></pre></div></div>
- <div class="paragraph"><p>This Java code corresponds to the following .j3m file:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="xml">Material my brick wall : Common/MatDefs/Light/Lighting.j3md {
- MaterialParameters {
- DiffuseMap: Repeat Textures/wall_diffuse.png
- NormalMap: Repeat Textures/wall_normals.png
- Shininess: 5.0
- }
- }</code></pre></div></div>
- <div class="paragraph"><p>You can modify the source code of the j3m file in the “source” tab of the Material Editor.</p></div></div></div>
- <div class="sect1"><h2 id="using-j3m-materials">Using .j3m Materials</h2><div class="sectionbody"><div style="text-align: right;" class="imageblock right"><div class="content"><img src="../sdk/applymaterial.jpg" alt="applymaterial.jpg" width="180" height="300"></div></div>
- <div class="paragraph"><p>When the material is ready and saved into your projects assets directory, you can assign the .j3m to a Geometry.</p></div>
- <div class="paragraph"><p>In the jMonkeyEngine SDK</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p><b class="button">RMB</b> select the j3o file and choose <code>Edit in SceneComposer</code>.</p></li><li><p>You can open the SceneExplorer window by selecting <code><span class="menuseq"><span class="menu">Window</span> ▸ <span class="menuitem">SceneExplorer</span></span></code> from the menu bar, if it’s not already open.</p></li><li><p>In the SceneExplorer, click the geometry to which you want to assign the material.</p></li><li><p>Open the Properties window.</p></li><li><p>Assign the .j3m material to the .j3o in the <code><span class="menuseq"><span class="menu">Properties</span> ▸ <span class="submenu">Geometry</span> ▸ <span class="menuitem">Material</span></span></code> section.</p><div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content">If the .j3o file already has a material assigned to it from exporting/importing, you can generate the material by selecting “create j3m file” instead. This will place a .j3m under <code>assets/Materials/Generated</code> and assign it to your .j3o.</td></tr></table></div></li><li><p>Save the j3o and load it into you game.</p></li></ol></div>
- <div class="paragraph"><p>Or in your Java code</p></div>
- <div class="ulist"><ul><li><p>Use a loader and a setter to assign the material to a Geometry.</p></li></ul></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">mywall.setMaterial(assetManager.loadMaterial( <span class="string"><span class="delimiter">"</span><span class="content">Materials/mat_wall.j3m</span><span class="delimiter">"</span></span>));</code></pre></div></div>
- <hr>
- <div class="paragraph"><p><strong>See also:</strong></p></div>
- <div class="ulist"><ul><li><p><a href="../jme3/advanced/material_specification.html">Developer specification of the jME3 material system (.j3md,.j3m)</a></p></li><li><p><a href="../jme3/beginner/hello_material.html">Hello Material</a></p></li><li><p><a href="../jme3/advanced/materials_overview.html">Materials Overview</a></p></li><li><p><a href="../jme3/advanced/material_definitions.html">Material Definitions</a></p></li><li><p><a href="../jme3/advanced/j3m_material_files.html">j3M Material Files</a></p></li><li><p><a href="../sdk/neotexture.html">Neotexture</a> (Procedural textures)</p></li></ul></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({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|