blender.adoc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. = Creating assets in Blender3D
  2. :revnumber: 2.1
  3. :revdate: 2020/07/23
  4. This section discusses how to create and import models from Blender3D (2.78+, see bottom of page for Blender 2.49 and before) to jME3. Furthermore, it explains how you can create various typical game-related assets like "`Normal`" maps of high-poly models and "`Baked Lighting`" maps.
  5. == Asset Management
  6. For the managing of assets in general, be sure to read the xref:tutorials:concepts/multi-media_asset_pipeline.adoc[Asset Pipeline Documentation]. It contains vital information on how to manage your asset files.
  7. == Creating Models
  8. Game-compatible models are models that basically only consist of a mesh and UV-mapped textures, in some cases animations. All other material parameters or effects (like particles, etc.) cannot be expected to be transferred properly and probably would not translate to live rendering very well anyway.
  9. === UV Mapped Textures
  10. To successfully import a texture, the texture *has to* be UV-mapped to the model. Here's how to assign "`Diffuse`", "`Normal`" and "`Specular`" maps:
  11. image::how-to/modeling/blender/blender-material-4.png[blender-material-4.png,width="",height=""]
  12. image::how-to/modeling/blender/blender-material-3.png[blender-material-3.png,width="",height=""]
  13. image::how-to/modeling/blender/blender-material-2.png[blender-material-2.png,width="",height=""]
  14. image::how-to/modeling/blender/blender-material-1.png[blender-material-1.png,width="",height=""]
  15. It's important to note that each used texture will create one separate geometry. So it's best to either combine the UV maps or use a pre-made atlas with different texture types from the start and then map the uv coords of the models to the atlas instead of painting on the texture. This works best for large models like cities and space ships.
  16. === Animations
  17. Animations for jME3 have to be bone animations, mesh deformation or other forms of animation are not supported.
  18. To create an animation from scratch do the following:
  19. . Create the model.
  20. .. Make sure your models location, rotation and scale is applied and zero / one (see "`Model Checklist`" below).
  21. +
  22. TIP: Did you know? You can make any model from a box by only using extrusion, this creates very clean meshes.
  23. . Create the armature bones, don't forget to have one root bone!
  24. .. Start by placing the cursor at zero.
  25. .. Go to the `menu:Add[Armature > Single Bone]` menu and create the root bone.
  26. +
  27. image::how-to/modeling/blender/blender-add-bone.png[blender-add-bone.png,width="",height=""]
  28. .. Select the bone and go to edit mode (press kbd:[Tab]).
  29. .. Select the root bone end and press kbd:[E] to extrude the bone, then start rigging your model this way.
  30. +
  31. IMPORTANT: Make sure your armature's location, rotation and scale is applied (see "`Model Checklist`" below) before continuing.
  32. . Make the armature the parent of the model.
  33. .. Make sure you are back in object mode (press kbd:[Tab] again).
  34. .. First select the model object then select the armature object with kbd:[Shift] pressed, then press kbd:[Ctrl] + kbd:[P].
  35. .. When you do this, you can select how the bone groups will be mapped to the model vertices initially. Select btn:[With Automatic Weights].
  36. +
  37. [NOTE]
  38. ====
  39. When you parent your mesh to the armature, Blender automatically adds the `Armature` modifier to the mesh.
  40. image:how-to/modeling/blender/blender-make-armature.png[blender-make-armature.png,width="",height=""]
  41. ====
  42. +
  43. Voila, your model should move when you move the bones in pose mode.
  44. . From the `Info` header, press the btn:[Choose Screen Layout] button and select the `Animation` layout.
  45. . In the `Dope Sheet Editor` window, press the btn:[Context] button and select `Action Editor`.
  46. +
  47. image::how-to/modeling/blender/blender-action-editor.png[blender-action-editor.png,width="",height=""]
  48. . Add an action by pressing the btn:[+] button.
  49. . Set the "`Rotation Mode`" of the bone to `Quaternion` or switch later from your "`Rotation Mode`" to `Quaternion` and make a `Keyframe`.
  50. +
  51. image::how-to/modeling/blender/blender-switch-rotationmode.png[blender-switch-rotationmode.png,width="",height=""]
  52. . Create the ``Keyframe``s (select the model armature and press kbd:[I]) along the timeline.
  53. +
  54. --
  55. image::how-to/modeling/blender/blender-add-keyframes.png[blender-add-keyframes.png,width="",height=""]
  56. Each action will be an animation available via the animation control in jME after the import.
  57. IMPORTANT: Press the btn:[F] button next to the action so it will be saved even if there's no references. The animation would else be deleted if its not the active animation on the armature and the file is saved.
  58. --
  59. === Model Checklist
  60. Sometimes you do not create the model yourself and often models from the web are not really made for OpenGL live rendering or not completely compatible with the bone system in jME.
  61. To export an animated model in Blender make sure the following conditions are met:
  62. TIP: This checklist is interactive for your convenience.
  63. [%interactive]
  64. * [ ] The animation has to be a *bone animation*.
  65. * [ ] Apply Location, Rotation and Scale to the mesh in Blender: In the `3D Viewport` in Blender, select the mesh in `Object Mode`, from the `3D View Editor` header, click `menu:Object[Apply > Location / Rotation / Scale]`.
  66. +
  67. image::how-to/modeling/blender/blender_apply_mesh.png[blender_apply_mesh.png,width="300",height=""]
  68. * [ ] Apply Location, Rotation and Scale to the armature in Blender: In the `3D Viewport` in Blender, select the armature in `Object Mode`, from the `3D View Editor` header, click `menu:Object[Apply > Location / Rotation / Scale]`.
  69. +
  70. image::how-to/modeling/blender/blender_apply_bones.png[blender_apply_bones.png,width="300",height=""]
  71. * [ ] Set the mesh’s origin point in the bottom of the mesh (see the image below).
  72. * [ ] Set the armature’s origin point in the bottom of the armature (see the image below).
  73. * [ ] Armature’s origin point and mesh’s origin point must be in the same location (see the image below).
  74. * [ ] Use a root bone located in the armature’s origin. This root bone must be in vertical position (see the image below) and it is the root bone of the armature. If you rotate the root bone, the entire armature might be rotated when you import the model into jMonkey.
  75. * [ ] Uncheck:
  76. ** [ ] Bone Envelopes
  77. +
  78. --
  79. on the Armature modifier for the mesh (see the image below).
  80. image::how-to/modeling/blender/blender_envelopes.png[blender_envelopes.png,width="300",height=""]
  81. --
  82. * [ ] Under the armature data tab, make sure the bone type is `Octahedral` (see image below).
  83. //* Uncheck "`Envelopes`" checkbox on the armature (see the image below).
  84. +
  85. image::how-to/modeling/blender/blender_rootbone2.png[blender_rootbone2.png,width="",height=""]
  86. You can use `SkeletonDebugger` to show the skeleton on your game in order to check if the mesh and the skeleton are loaded correctly:
  87. [source,java]
  88. ----
  89. final Material soldier2Mat = assetManager.loadMaterial("Materials/soldier2/soldier2.j3m");
  90. final Spatial soldier2 = assetManager.loadModel("Models/soldier2/soldier2.j3o");
  91. TangentBinormalGenerator.generate(soldier2);
  92. soldier2.setMaterial(soldier2Mat);
  93. final Node soldier2Node = new Node("Soldier2 Node");
  94. soldier2Node.attachChild(soldier2);
  95. rootNode.attachChild(soldier2Node);
  96. final AnimControl animControl = soldier2.getControl(AnimControl.class);
  97. animControl.addListener(this);
  98. final AnimChannel animChannel = animControl.createChannel();
  99. final SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", animControl.getSkeleton());
  100. final Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  101. mat.setColor("Color", ColorRGBA.Green);
  102. mat.getAdditionalRenderState().setDepthTest(false);
  103. skeletonDebug.setMaterial(mat);
  104. soldier2Node.attachChild(skeletonDebug);
  105. ----
  106. image::how-to/modeling/blender/blender_finished.png[blender_finished.png,width="500",height=""]
  107. Also check out these videos and resources:
  108. * link:https://hub.jmonkeyengine.org/t/importing-animations-from-blender-2-62-using-ogre-xml-things-to-check-if-you-are-getting-problems/22234[Forum: How to import animated models from Blender 2.6 correctly] (link:https://www.youtube.com/watch?v=QiLCs4AKh28[Video])
  109. * link:http://www.youtube.com/watch?v=NdjC9sCRV0s[Video tutorial for animated models from Blender 2.6]
  110. * link:https://docs.google.com/fileview?id=0B9hhZie2D-fENDBlZDU5MzgtNzlkYi00YmQzLTliNTQtNzZhYTJhYjEzNWNk&hl=en[Exporting OgreXML scenes from Blender 2.49 to jME]
  111. == Action Baking
  112. There are many 3D model <<ROOT:getting-started/features.adoc#supported-external-file-types,Supported External File Types>> for jMonkeyEngine. Some of them bake your actions automatically on export, others don't. Baking is a destructive process so it is recommended that you test the animation in-game first. If your animations are all messed up, try baking them or use a different exporter.
  113. If you find yourself in need of baking, the process is as follows.
  114. . From the Blender `Info` header, select `menu:File[Save Copy]`.
  115. . Save the file somewhere other than the current folder. This will save you the effort of re-creating the animation file if you need it at some other time.
  116. . In the `Info` header, change the `Default` screen layout to `Animation`.
  117. . In the `Dope Sheet Editor`, change the `Dope Sheet` mode/context to `Action Editor`.
  118. . Click the btn:[Action to be linked] button and select your action.
  119. . In the `3d Viewport` header, select the armature.
  120. * Depending on the mode selected choose:
  121. .. Object Mode: `menu:Object[Animation > Bake Action]`.
  122. .. Pose Mode: `menu:Pose[Animation > Bake Action]`.
  123. . In the `Bake Action` dialog, deselect and set the settings as follows:
  124. Bake Action::
  125. - [ ] Selected Only
  126. - [x] Visual Keying
  127. - [x] Clear Constraints
  128. - [ ] Clear Parents
  129. - [ ] Overwrite Current
  130. -  Bake Data = Pose
  131. . When ready click btn:[OK].
  132. . The `Linked Action` in the `Dope Sheet Editor` will change to the newly baked action and is named `Action`. Rename this to the name of the imported animation.
  133. . Select the btn:[F] button to save the action.
  134. . Save your file.
  135. . Clear the old action from the `Linked Action` buffer. See xref:how-to/modeling/blender/blender_buffer_clearing.adoc[Blender Buffer Clearing] for more information.
  136. == Normal Map baking
  137. Models for live rendering should have a low polygon count. To increase the perceived detail of a model, Normal maps are commonly used in games. This tutorial will show how to create a Normal map from a "`HighPoly`" version of your model that you can apply to a "`LowPoly`" version of the model in your game.
  138. === Blender Modeling LowPoly & HighPoly
  139. .Method 1
  140. If you use the `Multiresolution` modifier you only need one object. Let's look at this example, the Blender object Monkey, with an applied `Triangulate` modifier:
  141. image::how-to/modeling/blender/monkey.png[monkey.png,width="50%",height=""]
  142. . Add a "`Monkey`" object by selecting the btn:[Monkey] button located on the "`Create Tab`".
  143. .. While in `Object Mode`, in the `Properties` panel under the `Modifiers` tab, add a `Triangulate` modifier and apply it:
  144. .. While in `Object Mode`, in the `Properties` panel under the `Modifiers` tab, add a `Multiresolution` modifier:
  145. +
  146. --
  147. image::how-to/modeling/blender/3.1.gif[3.1.gif,width="300",height=""]
  148. There are two types of modifiers: Catmull-Clark and Simple.
  149. * Simple is better for things like walls or floors.
  150. * Catmull-Clark is better for objects like spheres.
  151. When using Catmull-Clark with a higher "`subdivide`" value (more than 3), it's good to have the "`Preview`" value above 0 and less than the subdivide level. This is because Catmull-Clark smooths the vertices, so the Normal map is not so precise.
  152. Regardless of the choice, the larger the difference is between "`Render`" and "`Preview`", the deeper the detail is on the Normal map.
  153. * Here is an example of `Preview 1`, it's more smooth than the original mesh:
  154. image::how-to/modeling/blender/monkeyprev1.png[monkkeyprev1.png,width="50%",height=""]
  155. --
  156. . From the `File` header at the top of the 3d View, click the btn:[Choose Screen layout] button and select "`UV Editing`".
  157. . In the `3d View`, select the Monkey and kbd:[Tab] into "`Edit Mode`".
  158. . If the Monkey vertices are not already highlighted, press the kbd:[A] key until all vertices are highlighted.
  159. . From the `3d View` header, select `menu:Mesh[UV Unwrap>Smart UV Project]`.
  160. .. Click the btn:[Island Margin] button once to advance the value to .03.
  161. .. Click btn:[OK] when ready.
  162. . In the `UV Image Editor`, click the btn:[New] button.
  163. .. Change the name to something like "`monkey_bump`".
  164. .. Optionally, change the `Generated Type` to "`UV Grid`".
  165. .. Uncheck:
  166. ** [ ] 32 Bit
  167. .. Click btn:[OK] when ready.
  168. . From the `File` header at the top of the `UV Image Editor`, click the btn:[Choose Screen layout] button and select "`Default`".
  169. . With your mouse inside the `3D View`, tab into `Object Mode`.
  170. . Now go into the `Render` tab, and bake a `Normal` map using the same configuration as here:
  171. +
  172. --
  173. image::how-to/modeling/blender/4.gif[4.gif,width="300",height=""]
  174. IMPORTANT: Remember! The actual preview affects the baking output and mesh export!
  175. --
  176. . Navigate back to the `UV Editing` layout and save your image by selecting `menu:Image*[Save As]` from the `UV Image Editor` header.
  177. TIP: The asterisk kbd:[*] next to the `Image` menu item means the image has not yet been saved.
  178. .Normal map from Method 1
  179. image::how-to/modeling/blender/monkey_bump.png[monkey_bump.png,width="50%",height=""]
  180. This second method produces the best results by far:
  181. .Method 2
  182. . Follow the steps for "`Method 1`" but before baking, uncheck:
  183. ** [ ] Bake from Multires
  184. . Make a copy of your mesh (kbd:[SHIFT]+kbd:[D]).
  185. . Remove the Multires modifier from the copied model.
  186. . Remove any materials from the copied model.
  187. . Remove the armature modifier from the copied model.
  188. . Select the original (HighPoly) model.
  189. . Go into pose mode, clear any pose transformations.
  190. . The "`HighPoly`" and "`LowPoly`" models should be on top of each other now.
  191. . Select the original (HighPoly) model.
  192. . Hold kbd:[SHIFT] and select the copied (LowPoly) model.
  193. . In the `Properties` panel, in the `Render` tab:
  194. .. Bake Mode: `Normal`
  195. .. check:
  196. ** [x] Selected to Active
  197. .. Use a reasonably high value for "`Margin`" (4+ pixels at least for 1024x1024 maps).
  198. . Bake and don't forget to save the Normal map image.
  199. [IMPORTANT]
  200. ====
  201. Keep in mind that when you duplicate the model, you are also duplicating its UV mapping. What this means is your "HiPoly" model and "`LowPoly`" model are both assigned to an image.
  202. If you ever see this error:
  203. "No objects or images found to bake to"
  204. You are either missing the image for the "`LowPoly`" model, or in the Outliner, the camera symbol (Restrict Render) is off (grayed out).
  205. ====
  206. .Normal map from Method 2
  207. image::how-to/modeling/blender/monkey_bump2.png[monkey_bump2.png,width="50%",height=""]
  208. === Fixing the Normal colors in Blender
  209. There are two "`standards`" for Normal maps:
  210. * DirectX
  211. * OpenGL
  212. The difference between them is that the green channel is inverted. One would expect that JME supports the OpenGL way, but actually JME supports the DirectX way because it’s what Blender supports and the developers of JME thought it would be easier in the Blender to JME workflow.
  213. Because of this, you need to fix the colors to prepare the Normal map for using it with the JME Lighting Material. You should only have to invert the green channel, the red and blue channels should stay unchanged. The curve for the red and blue channels should go from bottom left to top right, the green from top left to bottom right.
  214. To do this after baking and saving the original Normal map image:
  215. . In the "`UV Editing`" layout, from the "`UV Image Editor`" header select `menu:Image[Invert>Invert Green Channel]`.
  216. . Save the inverted image to a destination you want and use it with the JME Lighting Material and the "`LowPoly`" version of the model.
  217. .Normal map invert results (Method 2 example)
  218. image::how-to/modeling/blender/monkey_bump2_invert.png[monkey_bump2_invert.png,width="50%",height=""]
  219. [TIP]
  220. .Inverting Tips
  221. ====
  222. If you build the engine from source, the master branch link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md#L39[PBR material] has a NormalType parameter that allows one to handle this in the shader instead of having to edit the Normal map.
  223. You can also use the SDK to invert the channel:
  224. . In the SDK, btn:[RMB] select the image and choose "`Edit Texture`".
  225. . In the window header, press the btn:[Filters] button and choose `menu:Invert[Green]`.
  226. . When satisfied, save the change in the same format as the original image using `menu:File[Save]`.
  227. ====
  228. This is what the final outcome of Normal map baking should produce for you. A "`LowPoly`" model that looks like it's a "`HighPoly`" model.
  229. .Final results (Method 2 example)
  230. image::how-to/modeling/blender/monkey_final.gif[monkey_final.gif,width="",height=""]
  231. == LightMap baking
  232. The goal of this tutorial is to explain briefly how to bake light map in blender with a separate set of texture coordinates and then export a model using this map in jME3.
  233. === Blender modeling + texturing
  234. * create a mesh in blender and unwrap it to create uvs
  235. ** image:how-to/modeling/blender/1.jpg[1.jpg,width="600",height=""]
  236. * In the mesh tab you can see the sets of Uvs, it will create the first one.
  237. ** You can assign w/e texture on it, I used the built in checker of blender for the example.
  238. * In this list, create a new one and click on the camera icon so that baking is made with this set. Name it LightUvMap.
  239. * In the 3D view in edit mode select all your mesh vertices and hit 'U'/LightMap pack then ok it will unfold the mesh for light map.
  240. * Create a new image, go to the render tab an all at the end check the "`Bake`" section and select shadows. Then click bake.
  241. * If all went ok it will create a light map like this.
  242. ** image:how-to/modeling/blender/2.jpg[2.jpg,width="600",height=""]
  243. * Go to the material tab, create a new one for your model and go to the Texture Tab.
  244. * Create 2 textures one for the color map, and one for the light map.
  245. * In the Mapping section be sure to select coordinates : UV and select the good set of coordinates.
  246. ** image:how-to/modeling/blender/3.jpg[3.jpg,width="600",height=""]
  247. * Then the light map
  248. ** image:how-to/modeling/blender/4.jpg[4.jpg,width="600",height=""]
  249. == Importing the model in the SDK and creating the appropriate material
  250. Once this is done, export your model with one of the 3D model <<ROOT:getting-started/features.adoc#supported-external-file-types,Supported External File Types>> and convert it into a `.j3o` with the SDK, or the JME link:{link-javadoc}/com/jme3/export/binary/BinaryExporter.html[BinaryExporter].
  251. * Create material for it using the lighting definition.
  252. * Add the colorMap in the diffuse map slot and the lightMap in the light map slot.
  253. * Make sure you check "`SeparateTexCoords`"
  254. ** image:how-to/modeling/blender/5.jpg[5.jpg,width="600",height=""]
  255. * It should roughly result in something like that :
  256. ** image:how-to/modeling/blender/6.jpg[6.jpg,width="600",height=""]
  257. == Modelling racing tracks and cars
  258. Follow the link below to a pdf tutorial by rhymez where I guide you to modelling a car and importing it to the jMonkeyEngine correctly and edit it in the vehicle editor.Plus how to model a simple racing track.
  259. link:http://www.indiedb.com/games/street-rally-3d/downloads/modelling-in-blender-to-the-jmonkeyengine[http://www.indiedb.com/games/street-rally-3d/downloads/modelling-in-blender-to-the-jmonkeyengine]
  260. == Optimizing Models for 3D games
  261. Follow the link below to a pdf tutorial by rhymez where I guide you on how you can optimize your models for faster rendering.
  262. link:http://www.indiedb.com/games/street-rally-3d/downloads/optimizing-3d-models-for-games[http://www.indiedb.com/games/street-rally-3d/downloads/optimizing-3d-models-for-games]
  263. == SkyBox baking
  264. There are several ways to create static images to use for a sky in your game. This will describe the concepts used in blender and create an ugly sky emoji:smiley[]. Check the links below for other ways and prettier skies.
  265. A sky box is a texture mapped cube, it can also, loosely, be called en EnvMap or a CubeMap. The camera is inside the cube and the clever thing that jME does is to draw the sky so it is always behind whatever else is in your scene. Imagine the monkey is the camera in the picture.
  266. * image:how-to/modeling/blender/skybox-concept.png[skybox-concept.png,width="",height=""]
  267. But a real sky is not a box around our heads, it is more like a sphere. So if we put any old image in the sky it will look strange and might even look like a box. This is not what we want. The trick is to distort the image so that it will _look_ like a sphere even if it in fact is a picture pasted on a box. Luckily blender can do that tricky distortion for us.
  268. The screenshots are from Blender 2.63 but the equivalent operations have been in blender for years so with minor tweaks should work for almost any version.
  269. So let's get started
  270. * Fire up blender and you'll see something like this.
  271. ** image:how-to/modeling/blender/start-screen2.png[start-screen2.png,width="",height=""]
  272. * The cube in the start scene is perfect for us. What we'll do is have Blender render the scene onto that cube. The resulting image is what we'll use for our sky box. So our jME sky will look like we stood inside the blender box and looked out on the scene in blender.
  273. * Start by selecting the box and set its material to shadeless.
  274. ** image:how-to/modeling/blender/shadeless.png[shadeless.png,width="",height=""]
  275. * Now we will create a texture for the box. Make sure the texture is an `Environment Map`, that the `Viewpoint Object` is set to the cube. The resolution is how large the resulting image will be. More pixels makes the sky look better but comes at the cost of texture memory. You'll have to trim the resolution to what works in your application.
  276. ** image:how-to/modeling/blender/texture.png[texture.png,width="",height=""]
  277. * Next up is the fun part, create the sky scene in blender. You can do whatever fits your application, include models for a city landscape, set up a texture mapped sphere in blender with a nice photographed sky, whatever you can think will make a good sky. I am not so creative so I created this scene:
  278. ** image:how-to/modeling/blender/scene.png[scene.png,width="",height=""]
  279. * Now render the scene (press F12). It doesn't actually matter where the camera is in blender but you might see something similar to this:
  280. ** image:how-to/modeling/blender/render.png[render.png,width="",height=""]
  281. * You can see that Blender has actually drawn the scene onto the cube. This is exactly what we want. Now to save the image.
  282. * Select the texture of the cube and select save environment map.
  283. ** image:how-to/modeling/blender/saveenvmap.png[saveenvmap.png,width="",height=""]
  284. * That is it for Blender. Open the saved image in some image editor (I use the Gimp from link:http://www.gimp.org[http://www.gimp.org] here).
  285. [TIP]
  286. ====
  287. The SDK also contains an image editor, right-click the image and select "`edit`" image to open it.
  288. ====
  289. * You will notice that Blender has taken the 6 sides of the cube and pasted together into one image (3x2). So now we need to cut it up again into 6 separate images. In gimp I usually set the guides to where I want to cut and then go into Filters→Web→Slice and let gimp cut it up for me.
  290. ** image:how-to/modeling/blender/post-slice.png[post-slice.png,width="",height=""]
  291. * Next up is to move the image files into your assets directory and create the sky in jME. You can do that in the Scene Composer by right clicking the scene node, select `Add Spatial` and then select `Skybox`.
  292. If you want to do it from code, here is an example:
  293. [source,java]
  294. ----
  295. public void simpleInitApp() {
  296. Texture westTex = assetManager.loadTexture("Textures/west.png");
  297. Texture eastTex = assetManager.loadTexture("Textures/east.png");
  298. Texture northTex = assetManager.loadTexture("Textures/north.png");
  299. Texture southTex = assetManager.loadTexture("Textures/south.png");
  300. Texture upTex = assetManager.loadTexture("Textures/top.png");
  301. Texture downTex = assetManager.loadTexture("Textures/bottom.png");
  302. final Vector3f normalScale = new Vector3f(-1, 1, 1);
  303. Spatial skySpatial = SkyFactory.createSky(
  304. assetManager,
  305. westTex,
  306. eastTex,
  307. northTex,
  308. southTex,
  309. upTex,
  310. downTex,
  311. normalScale);
  312. rootNode.attachChild(skySpatial);
  313. }
  314. ----
  315. [TIP]
  316. ====
  317. This example uses a strange normalScale, this is to flip the image on the X-axis and might not be needed in your case. Hint: the texture is applied on the outside of the cube but we are inside so what do we see?
  318. ====
  319. == Further reading
  320. * xref:core:util/sky.adoc[How to add a Sky to your Scene]
  321. * link:http://hub.jmonkeyengine.org/t/jmonkeyengine-tutorial-how-to-create-skymaps-using-blender/19313[http://hub.jmonkeyengine.org/t/jmonkeyengine-tutorial-how-to-create-skymaps-using-blender/19313]