官术网_书友最值得收藏!

Using Scene Composer

Here, we'll go through the basics of using Scene Composer in the SDK. Scene Composer is a place where we can preview objects, prepare them for in-game usage, and combine them to form scenes. Further usage includes viewing a model's skeleton and bones setup or playing animations. You can also apply materials, lighting, and set some basic geometry data.

Getting ready

Having some models to play around with will be useful if you want to create an interesting scene. We will use the Jaime model from the test-data library. You can find it in the Jaime folder inside Models and copy it to your project.

How to do it…

Let's start by creating a scene we can use to test our recipes later.

  1. Right-click on the Scenes folder inside Project Assets, select New, and then select Empty jME3 Scene. The scene will open automatically in the SceneComposer window.
  2. A scene is just an empty node, and needs to be populated to be useful. To have something to look at, let's add the Jaime model to the scene. Find it in the folder structure, right-click on Jaime.j3o, and select Link in SceneComposer. The SceneComposer window looks as follows:
  3. Now, most likely, all we can see is a blue, wire-frame box. This is because there are no lights in the scene. At the top-left part of the screen, there is a button with a light bulb on it.
  4. By clicking on it, we should get PointLight following the camera; it is not part of the scene, however.

    Tip

    Linking versus adding

    Adding means you add an instance of the object itself to the scene. This can then be modified separately to the original object.

    Linking means you add a reference to the object in the scene. Apart from making the scene smaller, any modifications to the original object will also affect the objects in the scene.

  5. Basic camera orientation in the scene includes dragging with the left mouse button to rotate the camera. Dragging with the right mouse button pressed moves the camera sideways, up, and down. The mouse wheel zooms in and out.
  6. The second icon in the top bar of the SceneComposer window is the Move icon. By clicking on it, you will see three different colored planes by Jaime. These will be highlighted as you move your mouse over them. If you press the left mouse button while they're highlighted, you will move the object in the dimensions of that plane.
  7. The same rules apply to the next icon, Rotation. Note, though, that scaling is uniform across all the axes.

Tip

If you want to have total control over your transformations, you can use the Properties window to set the exact values for translation, rotation, and scale.

If you'd like to have an in-depth knowledge of the SDK, have a look at the videos on http://hub.jmonkeyengine.org.

How it works...

Scene Composer runs an instance of a jME application and what you see is very much what you will get when watching the scene in the game (minus the camera light). Use it to preview and tweak your assets before bringing them inside your application.

There's more…

Now that we have a scene, what's needed to load it into an application? Just the following lines of code are needed, really:

Spatial scene = assetManager.loadModel("Scenes/TestScene.j3o");
rootNode.attachChild(scene);

Add the preceding code in the simpleInitApp() method of Main.java.

主站蜘蛛池模板: 玛沁县| 琼结县| 肃宁县| 于田县| 微博| 连南| 公主岭市| 牙克石市| 谢通门县| 麻城市| 光泽县| 建德市| 西城区| 双柏县| 巫山县| 余庆县| 广水市| 普兰店市| 开远市| 济阳县| 洛扎县| 德阳市| 瓦房店市| 南投县| 梧州市| 永平县| 泰安市| 谢通门县| 大宁县| 泉州市| 中山市| 广南县| 文成县| 蛟河市| 威海市| 新乡县| 且末县| 浮山县| 张北县| 朝阳县| 甘洛县|