= Frequently Asked Questions
:revnumber: 2.1
:revdate: 2020/07/23
:keywords: documentation, faq



== I want to create and configure a jME3 Application


=== How do I start writing a preconfigured jME game?

Write a Java class that extends link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java[com.jme3.app.SimpleApplication].

*Learn more:*

* xref:beginner/hello_simpleapplication.adoc[Hello SimpleApplication]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java[TestAppStateLifeCycle].


=== How do I change the background color?

[source,java]
----
viewPort.setBackgroundColor(ColorRGBA.Blue);
----


=== Can I customize the SimpleApplication class?

Yes! Actually, you MUST customize it! For your own games, you always create a custom base class that extends link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java[com.jme3.app.SimpleApplication] class. From now on it's no longer a `simple application` – it's now your game. Configure your xref:core:system/appsettings.adoc[application settings], implement methods, and customize away!

*Learn more:*

* xref:core:app/simpleapplication.adoc[SimpleApplication]
* xref:core:system/appsettings.adoc[AppSettings]


=== How can I switch between screens or states?

You should break down your application logic into components by spreading it out over individual AppStates. AppStates can be attached to and detached from the game. AppStates have access to all objects (rootNode, PhysicsSpace, inputManager, etc) and methods in your main application. So each AppState can bring its own subset of input handlers, +++<abbr title="Graphical User Interface">GUI</abbr>+++ nodes, spatial nodes, and even its own subset of game mechanics in the update() loop.

*Learn more:*

* xref:core:app/state/application_states.adoc[Application States]


=== How do I pause/unpause a game?

You split up your application into several AppStates and implement the setEnabled() methods for each state. Then you create, for example, a GameRunningAppState and a GamePausedAppState. GamePausedAppState's job is to attach all your AppStates that contain the logic and +++<abbr title="Graphical User Interface">GUI</abbr>+++ of the pause screen, and to detach all the AppStates that contain logic and +++<abbr title="Graphical User Interface">GUI</abbr>+++ of the running game. GameRunningAppState does the opposite. By attaching one or the other to the game, you switch between the paused and unpaused states.

*Learn more:*

* xref:core:app/state/application_states.adoc[Application States]


=== How do I disable logger output to the console?

During development, you can switch the severity level of the default logger to no longer print FINE warnings, but only WARNINGs.

[source,java]
----
java.util.logging.Logger.getLogger("").setLevel(Level.WARNING);
----

For the release, switch the severity level of the default logger to print only SEVERE errors.

[source,java]
----
java.util.logging.Logger.getLogger("").setLevel(Level.SEVERE);
----

*Learn more:*

* xref:how-to/java/logging.adoc[Logging]


=== Why does the executable crash with "Cannot locate resource"?

Make sure to only load() models converted to .j3o binary format, not the original Ogre or Wavefront formats. If you load assets from zip files, make sure to ammend the build script to copy them to the build directory.

*Learn more:*

* xref:core:asset/asset_manager.adoc[Asset Manager]


=== What is java.lang.LinkageError: Version mismatch?

This rare exception shows a message similar to the following: `Exception in thread "LWJGL" Renderer Thread java.lang.LinkageError: Version mismatch: jar version is (number), native library version is (another number)`. jME3 needs native libraries (.dll, .jnilib, lib*.so files) to run LWJGL and jBullet. The correct versions of these libraries are included when you install the SDK or download the binaries. However there are circumstances where jME3 cannot determine which copy of the native library it should use:

.Possible Causes
* If you install another application that needs a different version of a native library, and this app globally installs its version over jME3's.
* If an old copy of a native library is in your project directory, your home directory, or Java library path, or in the classpath.
* If you permanently linked an old copy in your IDE's settings.

Java then assumes you prefer these native libraries over the bundled ones, and your jME3 application ends up running with the wrong version.

To fix this, search for .dll (Windows), .jnilib (Mac), and .so (Linux) files for jBullet and LWJGL on your harddrive and in your path and IDE settings, and verify they don't interfere. (If you have other jME  versions installed and linked somehow, the outdated natives may also be in a lwjgl.jar or jbullet.jar file!)


== I want to load my scene


=== How do I make objects appear / disappear in the 3D scene?

To make a spatial appear in the scene, you attach it to the rootNode (or to a node that is attached to the rootnode). To remove a spatial, you detach it from its parent node.

[source,java]
----
rootNode.attachChild(spatial); // appear in scene
----

[source,java]
----
rootNode.detachChild(spatial); // remove from scene
----

*Learn more:*

* xref:concepts/the_scene_graph.adoc[The Scene Graph]
* xref:beginner/hello_node.adoc[Hello Node]
* xref:beginner/hello_asset.adoc[Hello Asset]
* xref:core:scene/spatial.adoc[Spatial]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/Node.java[com.jme3.scene.Node]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/Geometry.java[com.jme3.scene.Geometry]


=== Why do I get AssetNotFoundException when loading X ?

First check whether the file path of the asset is correct. By default it is relative to your project's assets directory:

[source,java]
----
// To load .../jMonkeyProjects/MyGame/assets/Models/Ninja/Ninja.j3o
Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.j3o");
----

If you are not using the default `assets` directory, verify that you have registered a locator to the AssetManager. link:{link-javadoc}/com/jme3/asset/plugins/package-summary.html[Different Locator types] are available.

[source,java]
----

this.assetManager.registerLocator("assets/", FileLocator.class); // default
this.assetManager.registerLocator("c:/jme3User/JMEisSoCool/myAwesomeFolder/", FileLocator.class);
this.assetManager.registerLocator("town.zip", ZipLocator.class);

----

Note that you should not register every single folder containing a texture as the assetmanager will not be able to discern between images with the same name anymore.

*Learn more:* xref:core:asset/asset_manager.adoc[Asset Manager]


=== How do I Create 3-D models, textures, sounds?

Follow our best practices for the xref:concepts/multi-media_asset_pipeline.adoc[multi-media asset pipeline]. +
You create 3-D models in a 3-D mesh editor, for example Blender, and export it in one of the 3D model <<ROOT:jme3/features.adoc#supported-external-file-types,Supported External File Types>> such as GLTF (animated objects, scenes) or Wavefront OBJ format (static objects, scenes).
You create textures in a graphic editor, for example Gimp, and export them as PNG or JPG.
You create sounds in an audio editor, for example, Audacity, and export them as WAVE or OGG.

*Learn more:*

* xref:core:scene/3d_models.adoc[3D Models]
* xref:concepts/multi-media_asset_pipeline.adoc[multi-media asset pipeline]
* xref:how-to/modeling/blender/blender.adoc[Creating assets in Blender3D]
* link:https://www.blender.org[Download Blender]
* link:http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro[Blender intro tutorial]
* link:http://en.wikipedia.org/wiki/Comparison_of_3D_computer_graphics_software#Features[Comparison of 3D graphic software features (Wikipedia)].


=== How do I load a 3-D model into the scene?

Export your model using one of the <<ROOT:jme3/features.adoc#supported-external-file-types,Supported External File Types>> for 3D models. Convert to .j3o binary format. Load the .j3o file using the AssetManager.

[source,java]
----
// To load .../jMonkeyProjects/MyGame/assets/Models/Ninja/Ninja.j3o
Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.j3o");
----

*Learn more:*

* xref:beginner/hello_asset.adoc[Hello Asset]
* xref:core:asset/asset_manager.adoc[Asset Manager]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/asset/AssetManager.java[com.jme3.assets.AssetManager]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/scene/Geometry.java[com.jme3.scene.Geometry]
* xref:sdk:model_loader_and_viewer.adoc[jMonkeyEngine SDK j3o converter]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/model/TestOgreLoading.java[TestOgreLoading.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/export/TestOgreConvert.java[TestOgreConvert.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/2124e3e86bf898d6c7a7bc90a191cf639e39bacb/jme3-examples/src/main/java/jme3test/model/TestGltfLoading.java[TestGltfLoading.java]


=== How to initialize the scene?

Use the simpleInitApp() method in SimpleApplication (or initApp() in Application).

*Learn more:*

* xref:beginner/hello_simpleapplication.adoc[Hello SimpleApplication]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java[SimpleApplication.java]


== I want to transform objects in the scene


=== How do I move or turn or resize a spatial?

To move or turn or resize a spatial you use transformations. You can concatenate transformations (e.g. perform rotations around several axes in one step using a xref:concepts/rotate.adoc[Quaternion] with `slerp()` or a com.jme3.math.Transform with interpolateTransforms().

[source,java]
----
spatial.setLocalTranslation(1,-3,2.5f); spatial.rotate(0,3.14f,0); spatial.scale(2,2,2);
----

*Learn more:*

* xref:beginner/hello_node.adoc[Hello Node]
* xref:core:scene/spatial.adoc[Spatial]
* xref:concepts/math_for_dummies.adoc[Math For Dummies]


=== How do I make a spatial move by itself?

Change the geometry's translation (position) live in the update loop using setLocalTranslation() for non-physical and applyForce() or setWalkDirection() for physical objects. You can also define and remote-control a spatial's motion using xref:core:cinematic/cinematics.adoc[Cinematics], e.g. to record cutscenes, or to implement mobile platforms, elevators, airships, etc.

*Learn more:*

* xref:beginner/hello_main_event_loop.adoc[Hello Loop]
* xref:core:app/update_loop.adoc[Update Loop]>
* xref:core:scene/control/custom_controls.adoc[Custom Controls]
* xref:core:cinematic/cinematics.adoc[Cinematics]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/material/TestBumpModel.java[TestBumpModel.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/model/TestOgreLoading.java[TestOgreLoading.java]


=== How do I access a named sub-mesh in Model?

[source,java]
----
Geometry submesh = (Geometry) model.getChild("door 12");
----

*Learn more:*

* xref:core:scene/spatial.adoc[Spatial]


=== How do I make procedural or custom shapes?

You can programmatically create com.jme3.scene.Mesh'es.

*Learn more:*

* xref:core:scene/custom_meshes.adoc[Custom Meshes]


== I want to change the surface of objects in the scene


=== Why is my UV wrapping / texture appearance all wrong?

The most likely reason is the flipping of textures. You may be using the following default method:

[source,java]
----
material.setTexture("ColorMap", assetManager.loadTexture("myTexture.jpg"));
----

You can set the boolean value in the constructor of TextureKey to flipped or not flipped. Toggle the boolean to see if it fixes your UV wrapping/texture problem:

[source,java]
----
material.setTexture("ColorMap", this.assetManager.loadTexture(new TextureKey("myTexture.jpg", false)));
----


=== How do I scale, mirror, or wrap a texture?

You cannot scale a texture, but you scale the texture coordinates of the mesh the texture is applied to:

[source,java]
----
mesh.scaleTextureCoordinates(new Vector2f(2,2));
----

You can choose among various ``com.jme3.texture.Texture.WrapMode``s for individual texture maps of a material: BorderClamp, EdgeClamp, Clamp; MirrorBorderClamp, MirrorEdgeClamp, MirrorClamp; Repeat, MirroredRepeat.

[source,java]
----
material.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
----


=== How do I change color or shininess of an material?

Use the AssetManager to load Materials, and change material settings.

*Learn more:*

* xref:beginner/hello_material.adoc[Hello Material]
* xref:core:material/how_to_use_materials.adoc[How To Use Materials]
* xref:core:material/materials_overview.adoc[Materials Overview], xref:core:asset/asset_manager.adoc[Asset Manager]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/material/TestNormalMapping.java[TestNormalMapping.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/model/shape/TestSphere.java[TestSphere.java].


=== How do I make a surface wood, stone, metal, etc?

Create Textures as image files. Use the AssetManager to load a Material and use texture mapping for improved looks.

*Learn more:*

* xref:beginner/hello_material.adoc[Hello Material]
* xref:core:material/how_to_use_materials.adoc[How To Use Materials]
* xref:core:material/materials_overview.adoc[Materials Overview]
* xref:core:asset/asset_manager.adoc[Asset Manager]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/asset/AssetManager.java[com.jme3.assets.AssetManager]
* link:https://archive.blender.org/wiki/index.php/Doc:Manual/Textures/Maps/Bump_and_Normal_Maps/[Blender: Creating Bump Maps and Normal Maps]

*Code sample:*

link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/material/TestSimpleBumps.java[TestSimpleBumps.java]


=== Why are materials too bright, too dark, or flickering?

If you use a lit material (based on Lighting.j3md) then you must attach a light source to the rootNode, otherwise you see nothing. If you use lit material colors, make sure you have specified an Ambient color (can be the same as the Diffuse color) if you use an AmbientLight. If you see objects, but they are gray or too dark, set the light color to white, or make it brighter (you can multiply the color value with a scalar), or add a global white light source (AmbientLight). Similarly, if everything is too white, tune down the lights. If materials flicker under a directional light, change the light direction vector. Change the background color (which is independent of light sources) to get a better contrast while debugging a light problem.


=== How do I make geometries cast a shadow?

Use com.jme3.shadow.BasicShadowRenderer together with com.jme3.light.DirectionalLight, and setShadowMode().

*Learn more:*

* xref:core:light/light_and_shadow.adoc[Light and Shadow]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/effect/TestEverything.java[TestEverything.java]
//* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/light/TestShadow.java[TestShadow.java]


=== How do I make materials transparent?

Assign a texture with an alpha channel to a Material and set the Material's blend mode to alpha. Use this to create transparent or translucent materials such as glass, window panes, water, tree leaves, etc.

[source,java]
----
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
----

*Learn more:*

* xref:beginner/hello_material.adoc[Hello Material]
* xref:core:material/how_to_use_materials.adoc[How To Use Materials]


=== How do I force or disable culling?

While debugging custom meshes, you can switch the `com.jme3.material.RenderState.FaceCullMode` off to see the inside and outside of the mesh.

[source,java]
----
someMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
----

You can also deactivate the `com.jme3.scene.Spatial.CullHint` of a whole spatial to force jme to calculate it even if it is behind the camera and outside of view.

[source,java]
----
someNode.setCullHint(CullHint.Never);
----

*Learn more:*

* xref:core:scene/spatial.adoc[Spatial]


=== Can I draw only an outline of the scene?

Add a renders state to the material's and activate `Wireframe`.

[source,java]
----
material.getAdditionalRenderState().setWireframe(true);
----

*Learn more:*

* xref:how-to/debugging.adoc[Debugging]


== I want to control the camera

The default camera `cam` is an instance of the `Camera` class.

*Learn more:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/renderer/Camera.java[com.jme3.renderer.Camera]


=== How do I keep the camera from moving?

SimpleApplication activates `flyCam` (an instance of `FlyByCamera`) by default. `flyCam` causes the camera to move with the mouse and the WASD keys. You can disable flyCam as follows:

[source,java]
----
flyCam.setEnabled(false);
----

=== How do I switch between third-person and first-person view ?

You can activate the FlyBy Cam as a first-person camera.

[source,java]
----
flyCam.setEnabled(true);
----

*Learn more:*

* xref:beginner/hello_collision.adoc[Hello Collision]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/input/FlyByCamera.java[com.jme3.input.FlyByCamera]

You can also create a third-person chase cam.

[source,java]
----
flyCam.setEnabled(false);
chaseCam = new ChaseCamera(cam, spatial, inputManager);
----

*Learn more:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java[com.jme3.input.ChaseCamera]

*Code sample:*

link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/input/TestChaseCamera.java[jme3test/input/TestChaseCamera.java]


=== How do I increase camera speed?

[source,java]
----
flyCam.setMoveSpeed(50f);
----


== Actions, Interactions, Physics


=== How do I implement game logic / game mechanics?

Use Controls to define the behaviour of types of Spatials. Use Application States to implement global behaviour, to group subsets of input handlers or +++<abbr title="Graphical User Interface">GUI</abbr>+++ screens, etc. Use the `simpleUpdate()` and `update()` loops for tests and interactions. Use Cinematics to remote-control objects in scenes.

*Learn more:*

* xref:beginner/hello_main_event_loop.adoc[Hello Loop]
* xref:core:app/update_loop.adoc[Update Loop]
* xref:core:scene/control/custom_controls.adoc[Custom Controls]
* xref:core:app/state/application_states.adoc[Application States]
* xref:core:cinematic/cinematics.adoc[Cinematics]


=== How do I let players interact via keyboard?

Use com.jme3.input.KeyInput and a Input Listener.

*Learn more:*

* xref:beginner/hello_input_system.adoc[Hello Input]
* xref:core:input/input_handling.adoc[Input Handling]


=== How do I let players interact by clicking?

Players typically click the mouse to pick up objects, to open doors, to shoot a weapon, etc. Use an Input Listener to respond to mouse clicks, then cast a ray from the player; if it intersects with the bounding volume of a spatial, this is the selected target. The links below contain code samples for both `fixed` crosshair picking and `free` mouse pointer picking.

*Learn more:*

* xref:beginner/hello_picking.adoc[Hello Picking]
* xref:core:input/mouse_picking.adoc[Mouse Picking]
* xref:core:collision/collision_and_intersection.adoc[Collision and Intersection]
* xref:core:input/input_handling.adoc[Input Handling]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-core/src/main/java/com/jme3/bounding[com.jme3.bounding.]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/math/Ray.java[com.jme3.math.Ray.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/math/Ray.java[com.jme3.collision.CollisionResults.java]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bounding/TestRayCollision.java[TestRayCollision.java]


=== How do I animate characters?

Create an animated OgreMesh model with bones in a 3-D mesh editor (e.g. Blender).

*Learn more:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-core/src/main/java/com/jme3/animation[com.jme3.animation.]
* xref:beginner/hello_animation.adoc[Hello Animation]
* xref:core:animation/animation.adoc[Animation]
* link:https://archive.blender.org/wiki/index.php/Doc:Tutorials/Animation/BSoD/Character_Animation/[Blender animation tutorial]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-examples/src/main/java/jme3test/model/anim[animation]


=== How do I keep players from falling through walls and floors?

Use collision detection. The most common solution is to use jme's physics integration, jBullet.

*Learn more:*

* xref:beginner/hello_collision.adoc[Hello Collision]
* xref:physics:physics.adoc[Physics]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-bullet/src/common/java/com/jme3/bullet[com.jme3.bullet.]
* CapsuleCollisionShape versus CompoundCollisionShape, CharacterControl versus RigidBodyControl.


=== How do I make balls/wheels/etc bounce and roll?

Add physics controls to Spatials and give them spherical or cylindrical bounding volumes.

*Learn more:*

* xref:beginner/hello_physics.adoc[Hello Physics]
* xref:physics:physics.adoc[Physics]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-core/src/main/java/com/jme3/bounding[com.jme3.bounding.]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-bullet/src/main/java/com/jme3/bullet/collision[com.jme3.bullet.collisions]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java[com.jme3.bullet.control.RigidBodyControl.java]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bullet/TestSimplePhysics.java[TestSimplePhysics.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-examples/src/main/java/jme3test/bullet[more physics samples]


=== How do I debug weird Physics behaviour?

Maybe your collision shapes overlap – or they are not where you think they are. Make the collision shapes visible by adding the following line after the bulletAppState initialization:

[source,java]
----
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
----


=== How do I make a walking character?

You can use jBullet's CharacterControl that locks a physical object upright, so it does not tip over when moving/walking (as tall physical objects are typically wanted to).

*Learn more:*

* <<physics:control/walking_character.adoc#bettercharactercontrol,BetterCharacterControl>>

*Code Sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bullet/TestQ3.java[TestQ3.java] (first-person)
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java[TestPhysicsCharacter.java] (third-person)


=== How do I steer vehicles?

Use a VehicleControl that supports suspension behavior.

*Learn more:*

* xref:physics:control/vehicles.adoc[Vehicles]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-bullet/src/common/java/com/jme3/bullet/control/[com.jme3.bullet.control.VehicleControl]

*Code Sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java[TestFancyCar.java] (Press HUJK keys to steer, spacebar to jump.)


=== Can objects swing like a pendulums, chains, ropebridges?

Use a PhysicsControl's hinges and joints.

*Learn more:*

* xref:physics:joint/hinges_and_joints.adoc[Hinges and Joints]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsHingeJoint.java[TestPhysicsHingeJoint.java] (Press HK keys to turn, spacebar to swing.)


== Default GUI Display


=== What are these FPS/Objects/Vertices/Triangles statistics?

At the bottom left of every default SimpleGame, you see the xref:core:app/statsview.adoc[StatsView] and the FPS (frames per seconds) view. These views provide you with extra information during the development phase. For example, if you notice the object count is increasing and the FPS is decreasing, then you know that your code attaches too many objects and does not detach enough of them again (maybe a loop gone wild?).


=== How do I get rid of the FPS/Objects statistics?

In the application's simpleInitApp() method, call:

[source]
----
setDisplayFps(false); // to hide the FPS
setDisplayStatView(false); // to hide the statistics
----


=== How do I display score, health, mini-maps, status icons?

Attach text and pictures to the orthogonal `guiNode` to create a heads-up display (link:http://en.wikipedia.org/wiki/HUD_%28video_gaming%29[HUD]).

*Learn more:*

* xref:core:ui/hud.adoc[HUD]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-core/src/main/java/com/jme3/font[com.jme3.font.]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/ui/Picture.java[com.jme3.ui.Picture] guiNode.attachChild()

*Code Sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/gui/TestOrtho.java[TestOrtho.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/gui/TestBitmapFont.java[TestBitmapFont.java]


=== How do I display buttons and UI controls?

You may want to display buttons to let the player switch between the game, settings screen, and score screens. For buttons and other more advanced UI controls, jME supports the Nifty +++<abbr title="Graphical User Interface">GUI</abbr>+++ library.

*Learn more:*

* xref:core:gui/nifty_gui.adoc[Nifty GUI]

*Code Sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyGui.java[TestNiftyGui.java]


=== How do i display a loading screen?

Instead of having a frozen frame while your games loads, you can have a loading screen while it loads.

*Learn more:*

* xref:core:gui/loading_screen.adoc[Loading screen]


== Nifty GUI


=== I get NoSuchElementException when adding controls (buttons etc)!

Verify that you include a controls definition file link in your XML: This is the default:

[source,xml]
----
<useControls filename="nifty-default-controls.xml"/>
----


=== Where can I find example code of Nifty GUI's XML and Java classes?

link:https://github.com/nifty-gui/nifty-gui[https://github.com/nifty-gui/nifty-gui]


=== Is there Java Doc for Nifty GUI?

<<core:gui/nifty_gui_java_interaction.adoc#useful_links,Nifty GUI 1.3 Java docs>>


== I want to create an environment with sounds, effects, and landscapes


=== How do I play sounds and noises?

Use AudioRenderer, Listener, and AudioNode from com.jme3.audio..

*Learn more:*

* xref:beginner/hello_audio.adoc[Hello Audio]
* xref:core:audio/audio.adoc[Audio]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-examples/src/main/java/jme3test/audio[audio]


=== How do I make fire, smoke, explosions, swarms, magic spells?

For swarm like effects you use particle emitters.

*Learn more:*

* xref:beginner/hello_effects.adoc[Hello Effects]
* xref:core:effect/particle_emitters.adoc[Particle Emitters]
* xref:core:effect/bloom_and_glow.adoc[Bloom and Glow]
* xref:core:effect/effects_overview.adoc[Effects Overview]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterSphereShape.java[com.jme3.effect.EmitterSphereShape.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java[com.jme3.effect.ParticleEmitter.java]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/effect/TestExplosionEffect.java[TestExplosionEffect.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/effect/TestMovingParticle.java[TestMovingParticle.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/effect/TestSoftParticles.java[TestSoftParticle.java]


=== How do I make water, waves, reflections?

Use a special post-processor renderer from com.jme3.water..

*Learn more:*

* xref:core:effect/water.adoc[Water]
* xref:core:effect/post-processor_water.adoc[Post-Processor Water]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/water/TestSimpleWater.java[TestSimpleWater.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/water/TestSceneWater.java[TestSceneWater.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/water/TestPostWaterLake.java[TestPostWaterLake.java]
* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/water/TestPostWater.java[TestPostWater.java]


=== How do I make fog, bloom, blur, light scattering?

Use special post-processor renderers from com.jme3.post..

*Learn more:*

* xref:core:effect/effects_overview.adoc[Effects Overview]


=== How do I generate a terrain?

Use com.jme3.terrain.. The JMonkeyEngine also provides you with a Terrain Editor plugin.

*Learn more:*

* xref:beginner/hello_terrain.adoc[Hello Terrain]
* xref:core:terrain/terrain.adoc[Terrain]
* xref:sdk:terrain_editor.adoc[Terrain Editor]

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/terrain/TerrainTest.java[TerrainTest.java]


=== How do I make a sky?

*Code sample:*

* link:https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-examples/src/main/java/jme3test/texture/TestSkyLoading.java[TestSkyLoading.java]

[source,java]
----
rootNode.attachChild(SkyFactory.createSky( assetManager,
       "Textures/Sky/Bright/BrightSky.dds", false));
skyGeo.setQueueBucket(Bucket.Sky)
----

*Learn more:*

* xref:core:util/sky.adoc[Sky]


== I want to access to back-end properties


=== How do I read out graphic card capabilities?

If your game is heavily using features that older cards do not support, you can xref:how-to/java/read_graphic_card_capabilites.adoc[Read Graphic Card Capabilites] in the beginning before starting the app, and then decide how to proceed.

[source,java]
----
Collection<com.jme3.renderer.Caps> caps = renderer.getCaps();
Logger.getLogger(HelloJME3.class.getName()).log(Level.INFO, "Capabilities: {0}", caps.toString());
----


=== How do I Run jMonkeyEngine 3 with OpenGL1?

In your game, add

[source,java]
----
settings.setRenderer(AppSettings.LWJGL_OPENGL1)
----

to the xref:core:system/appsettings.adoc[AppSettings] (see details there). +
For the jMonkeyEngine SDK itself, choose Options &gt; OpenGL, and check OpenGL1.


=== How do I optimize the heck out of the Scene Graph?

You can batch all Geometries in a scene (or a subnode) that remains static.

[source,java]
----
jme3tools.optimize.GeometryBatchFactory.optimize(rootNode);
----

Batching means that all Geometries with the same Material are combined into one mesh. This optimization only has an effect if you use only few (roughly up to 32) Materials total. The pay-off is that batching takes extra time when the game is initialized.


=== How do I prevent users from unzipping my JAR?

Add an https://github.com/Guardsquare/proguard[obfuscator to the Ant script]. The SDK comes with a basic obfuscation script that you can enable in the project settings.


== I want to do maths


=== What does addLocal() / multLocal() etc mean?

Many maths functions (mult(), add(), subtract(), etc) come as local and a non-local variant (multLocal(), addLocal(), subtractLocal(), etc).

.  Non-local means a new independent object is created (similar to clone()) as a return value. Use non-local methods if you want to keep using the old value of the object calling the method.
**  Example 1:  `Quaternion q1 = q2.mult(q3);`
***  Returns the result as a new xref:concepts/rotate.adoc[Quaternion] q1.
***  The involved objects q2 and q3 stay as they are and can be reused.

**  Example 2: `v.mult(b).add(b);`
***  *Watch out:* This calculates the expected result, but unless you actually use the return value, it is discarded!


.  Local means that no new objects are created, instead, the calling object is modified. Use this if you are sure you no longer need the old value of the calling object.
**  Example 1: `q2.multLocal(q3)`
***  Calculates q2*q3 without creating temp objects.
***  The result is stored in the calling object q2. The old value of q2 is gone.
***  Object q3 stays as it was.

**  Example 2: `v.multLocal(a).addLocal(b);`
***  Calculates the expected result without creating temp objects.
***  The result is stored in the calling object v. The old value of v is gone.
***  The objects a and b stay as they were.




=== What is the difference between World and Local coordinates?

World coordinates of a Spatial are its absolute coordinates in the 3D scene (this is like giving GPS coordinates). Local coordinates are relative to the Spatial's parent Spatial (this is like saying, `I'm ten meters left of the entrance`).


=== How do I convert Degrees to Radians?

Multiply degree value by FastMath.DEG_TO_RAD to convert it to radians.
