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

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.

主站蜘蛛池模板: 怀仁县| 和林格尔县| 武强县| 阳高县| 格尔木市| 伊通| 菏泽市| 汉沽区| 蚌埠市| 常德市| 册亨县| 高清| 名山县| 仪征市| 韶关市| 申扎县| 刚察县| 屯留县| 阿拉尔市| 沁水县| 武威市| 宣威市| 兴业县| 莲花县| 建瓯市| 凌源市| 肇源县| 巴青县| 会昌县| 福鼎市| 万荣县| 雷波县| 汝州市| 乌兰察布市| 阿克苏市| 孝感市| 离岛区| 青岛市| 弥渡县| 清水河县| 临城县|