| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <!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, asset"><title>Blender importer for jMonkeyEngine 3</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/blender.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"><i class="fa fa-sort-down" aria-hidden="true"></i></div><h1>Blender importer for jMonkeyEngine 3</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="#introduction">Introduction</a></li><li><a href="#usage">Usage</a></li><li><a href="#currently-supported-features">Currently supported features</a></li><li><a href="#planned-features">Planned features.</a></li><li><a href="#known-bugs-problems">Known bugs/problems.</a></li><li><a href="#using-blenderloader-instead-of-blendermodelloader">Using BlenderLoader instead of BlenderModelLoader</a></li><li><a href="#how-does-it-work">How does it work?</a></li><li><a href="#notes">Notes</a></li></ul></div></div><div id="content"><div class="sect1"><h2 id="introduction">Introduction</h2><div class="sectionbody"><div class="paragraph"><p>Importing models to any game engine is as important as using them. The quality of the models depends on the abilities of the people who create it and on the tools they use.
- Blender is one of the best free tools for creating 3D enviroments. Its high amount of features attract many model designers.
- So far jMonkeyEngine used Ogre mesh files to import 3D data. These files were created by the python script that exported data from blender.
- It was important to have always the lates version of the script that is compatible with the version of blender and to use it before importing data to jme.
- Now we have an opportunity to simplify the import process by loading data directly from blender binary files: *.blend.</p></div>
- <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>Before you try to import models, make sure you <a href="../jme3/external/blender.html">created them properly</a>.</p></div></td></tr></table></div></div></div>
- <div class="sect1"><h2 id="usage">Usage</h2><div class="sectionbody"><div class="paragraph"><p>To use it in your game or the SDK you should follow the standard asset loading instructions.
- By default a BlenderModelLoader is registered with your assetManager to load blend files. This means you can load and convert .blend model files to .j3o format, just like any other supported model format.</p></div></div></div>
- <div class="sect1"><h2 id="currently-supported-features">Currently supported features</h2><div class="sectionbody"><div class="olist arabic"><ol class="arabic"><li><p>Loading scene (only the current scene is loaded and imported as a node)</p></li><li><p>Loading mesh objects.</p><div class="ulist"><ul><li><p>Meshes are split into several geometries when they have several materials applied.</p></li><li><p>All faces are stored as triangles (even if blender uses quads).</p></li><li><p>The mesh is 'Smooth' aware.</p></li><li><p>User defined UV coordinates are read.</p></li><li><p>Loading BMesh is supported.</p></li></ul></div></li><li><p>Loading textures.</p><div class="ulist"><ul><li><p>Both image and generated textures are imported.</p></li><li><p>Textures influence is supported ('Influence' tab in blender 2.5+ and 'Map to' in 2.49).</p></li><li><p>Map input is not yet fully supported (currently working on it ;) ) so please use UV-mapping for all kinds of textures.</p></li></ul></div></li><li><p>Image textures.</p><div class="ulist"><ul><li><p>Textures can be loaded from: png, jpg, bmp, dds and tga.</p></li><li><p>Both textures stored in the blender file and the outside are loaded (the outside textures need a valid path).</p></li><li><p>Image textures are stored as Texture2D.</p></li></ul></div></li><li><p>Generated textures.</p><div class="ulist"><ul><li><p>All generated textures can be loaded except: VoxelData, EnviromentMap and PointDensity.</p></li><li><p>Feel free to use colorbands.</p></li><li><p>Generated textures are 'baked' into 2D textures and merged to create one flat texture. They can be freely merged with image textures.</p></li><li><p>Generated textures can be used as normal maps (but this looks poor when large amount of small triangles is used; incleasing generated texture ppu in blender key might help a little)</p></li></ul></div></li><li><p>Loading materials.</p><div class="ulist"><ul><li><p>Materials are loaded and attached to geometries.</p></li><li><p>Because jMonkeyEngine supports only one material for each Mesh, if you apply several materials to one object – it will be split into several meshes (but still in one node).</p></li><li><p>Several kinds of input mapping is supported: UV maps, Orco and Nor; all projection types for 2D textures, XYZ coordinates mapping.</p></li></ul></div></li><li><p>Loading animations.</p><div class="ulist"><ul><li><p>Bone animations and object animations are supported.</p></li><li><p>Armatures are imported as Skeleton. Constraint loading is not fully supported so use it carefully.</p></li><li><p>Only assigning vertices to bones is at the moment supported so do not use bones' envelopes.</p></li></ul></div></li><li><p>Loading modifiers.</p><div class="olist loweralpha"><ol class="loweralpha" type="a"><li><p>Array modifier</p></li><li><p>Mirror modifier</p></li><li><p>Armature modifier (see loading animations)</p></li><li><p>Particles modifier (see loading particles)</p><div class="ulist"><ul><li><p>More will come with time.</p></li></ul></div></li></ol></div></li><li><p>Constraints loading</p><div class="ulist"><ul><li><p>Constraints are basicly supported but they do not work the way I’d like it. So feel free to experiment with it. I will create another post when I get it to work properly.</p></li></ul></div></li><li><p>Particles loading.</p><div class="ulist"><ul><li><p>Some features of particles loading is supported. You can use only particle emitters at the moment.</p></li><li><p>You can choose to emit particles from vertices, faces or the geometry’s convex hull (instead of volume).</p></li><li><p>Currently Newtonian Physics is only supported.</p></li><li><p>It was mostly tested for blender 2.49 (so I’m not 100% sure about its use in blender 2.5+).</p></li></ul></div></li><li><p>Using sculpting.</p><div class="ulist"><ul><li><p>This should work quite well for now :).</p></li></ul></div></li><li><p>Importing curves.</p><div class="ulist"><ul><li><p>Both bezier and NURBS curves are supproted.</p></li><li><p>Feel free to use bevel and taper objects as well ;)</p></li></ul></div></li><li><p>Importing surfaces</p><div class="ulist"><ul><li><p>NURBS surface and sphere can be imported.</p></li></ul></div></li><li><p>Importing sky</p><div class="ulist"><ul><li><p>loading world’s horizon color as a background color if no sky type is used</p></li><li><p>loading sky without the texture</p></li><li><p>loading textured sky (including both generated and normal textures)</p></li></ul></div></li></ol></div></div></div>
- <div class="sect1"><h2 id="planned-features">Planned features.</h2><div class="sectionbody"><div class="olist arabic"><ol class="arabic"><li><p>Full support for scale and offset in texture input mapping.</p></li><li><p>Full support for bone and object constraints.</p></li><li><p>More modifiers loaded.</p></li><li><p>Loading texts.</p></li><li><p>Loading meta objects (if jme will support it ;) ).</p></li></ol></div></div></div>
- <div class="sect1"><h2 id="known-bugs-problems">Known bugs/problems.</h2><div class="sectionbody"><div class="olist arabic"><ol class="arabic"><li><p>RGB10 and RGB9E5 texture types are not supported in texture merging operations (which means that you can use this as a single texture on the model, but you should not combine it with other images or generated textures).</p></li><li><p>If an armature is attached to a mesh that has more than one material the vertices of the mesh might be strongly displaced. Hope to fix that soon.</p></li></ol></div></div></div>
- <div class="sect1"><h2 id="using-blenderloader-instead-of-blendermodelloader">Using BlenderLoader instead of BlenderModelLoader</h2><div class="sectionbody"><div class="paragraph"><p>You have two loaders available.</p></div>
- <div class="ulist"><ul><li><p>BlenderLoader that loads the whole scene. It returns an instance of LoadingResults that contains all the data loaded from the scene.</p><div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><span class="directive">public</span> <span class="directive">static</span> <span class="type">class</span> <span class="class">LoadingResults</span> <span class="directive">extends</span> Spatial {
- <span class="comment">/** Bitwise mask of features that are to be loaded. */</span>
- <span class="directive">private</span> <span class="directive">final</span> <span class="type">int</span> featuresToLoad;
- <span class="comment">/** The scenes from the file. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Node> scenes;
- <span class="comment">/** Objects from all scenes. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Node> objects;
- <span class="comment">/** Materials from all objects. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Material> materials;
- <span class="comment">/** Textures from all objects. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Texture> textures;
- <span class="comment">/** Animations of all objects. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><AnimData> animations;
- <span class="comment">/** All cameras from the file. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Camera> cameras;
- <span class="comment">/** All lights from the file. */</span>
- <span class="directive">private</span> <span class="predefined-type">List</span><Light> lights;
- <span class="comment">/** Access Methods goes here. */</span>
- }</code></pre></div></div></li><li><p>BlenderModelLoader loads only the model node and should be used if you have a single model in a file.</p></li></ul></div>
- <div class="paragraph"><p>To register the model do the following:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">assetManager.registerLoader(BlenderLoader.class, <span class="string"><span class="delimiter">"</span><span class="content">blend</span><span class="delimiter">"</span></span>);</code></pre></div></div>
- <div class="paragraph"><p>or</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">assetManager.registerLoader(BlenderModelLoader.class, <span class="string"><span class="delimiter">"</span><span class="content">blend</span><span class="delimiter">"</span></span>);</code></pre></div></div>
- <div class="paragraph"><p>The last thing to do is to create a proper key.</p></div>
- <div class="paragraph"><p>You can use com.jme3.asset.BlenderKey for that.
- The simplest use is to create the key with the asset’s name.
- It has many differens settings descibing the blender file more precisely, but all of them have default values so you do not need to worry about it at the beggining.
- You can use ModelKey as well. This will give the same result as using default BlenderKey.</p></div></div></div>
- <div class="sect1"><h2 id="how-does-it-work">How does it work?</h2><div class="sectionbody"><div class="paragraph"><p>BlenderLoader (as well as BlenderModelLoader) is looking for all kinds of known assets to load.
- It’s primary use is of course to load the models withon the files.
- Each blender object is imported as scene Node. The node should have applied textures and materials as well.
- If you define animations in your BlenderKey the animations will as well be imported and attached to the model.</p></div>
- <div class="paragraph"><p>Here is the list of how blender features are mapped into jme.</p></div>
- <table class="tableblock frame-all grid-all spread"><colgroup><col style="width: 33.3333%;"><col style="width: 33.3333%;"><col style="width: 33.3334%;"></colgroup><thead><tr><th class="tableblock halign-left valign-top">Blender</th><th class="tableblock halign-left valign-top">jMonkeyEngine3</th><th class="tableblock halign-left valign-top">Note</th></tr></thead><tbody><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Scene</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Node</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Object</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Node</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Mesh</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>List<Geometry></p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>One mesh can have several materials so that is why a list is needed here.</p></div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Lamp</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Light</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Camera</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Camera</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Material</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Material</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Texture</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Texture</p></div></div></td><td class="tableblock halign-left valign-top"><div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Curve</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Node</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Node with Curve as its mesh</p></div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Surface</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Node</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>The surface is transformed to the proper mesh</p></div></div></td></tr></tbody></table>
- <div class="paragraph"><p>Using BlenderLoader can allow you to use blend file as your local assets repository.
- You can store your textures, materials or meshes there and simply import it when needed.
- Currently blender 2.49 and 2.5+ are supported (only the stable versions).
- Probably versions before 2.49 will work pretty well too, but I never checked that :)</p></div></div></div>
- <div class="sect1"><h2 id="notes">Notes</h2><div class="sectionbody"><div class="paragraph"><p>I know that the current version of loader is not yet fully functional, but belive me – Blender is a very large issue ;)
- Hope I will meet your expectations.</p></div>
- <div class="paragraph"><p>Be mindful of the result model vertices amount. The best results are achieved when the model is smooth and has no texture. Then the vertex amount is equal to the vertex amount in blender. If the model is not smooth or has a generated texture applied then the amount of vertices is 3 times larger than mesh’s triangles amount. If a 2d texture is applied with UV mapping then the vertex count will vary depending on how much the UV map is fragmented.</p></div>
- <div class="paragraph"><p>When using polygon meshes in blender 2.5 and newer, better add and apply the triangulation modifier (if available in your version) or save the file with convertion from polygons to triangles.
- Even though the importer supports loading of polygons as the mesh faces, if your face isn’t convex, the results might contain errors.</p></div>
- <div class="paragraph"><p>Not all modifiers are supported. If your model has modifiers and looks not the way you want in the jme scene - try to apply them and load again.</p></div>
- <div class="paragraph"><p>Cheers,
- Marcin Roguski (Kaelthas)</p></div>
- <div class="paragraph"><p>P.S.
- This text might be edited in a meantime if I forgot about something ;)</p></div>
- <hr>
- <div class="paragraph"><p>See also:</p></div>
- <div class="ulist"><ul><li><p><a href="../sdk/3ds_to_blender_to_jmp.html">3DS to Blender to j3o</a></p></li></ul></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-10-25 21:59:24 +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>
|