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

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.

主站蜘蛛池模板: 巴塘县| 婺源县| 泾阳县| 盐山县| 景东| 镇坪县| 汾阳市| 大同市| 车致| 萨迦县| 周至县| 淮安市| 静海县| 洱源县| 高安市| 仙游县| 长武县| 辽宁省| 屏山县| 曲周县| 贵溪市| 六盘水市| 漠河县| 石门县| 东光县| 雷州市| 英山县| 若尔盖县| 北辰区| 兴和县| 浦江县| 进贤县| 濮阳县| 黔江区| 柳江县| 琼结县| 类乌齐县| 象州县| 武冈市| 安溪县| 大丰市|