The jMonkeyEngine uses a special Material format, which comes in .j3m files. You use .j3m files to store sets of material properties that you use repeatedly. This enables you write one short line of code that simply loads the presets from a custom j3m file. Without a .j3m file you need to write several lines of material property setters every time when you want to use a non-default material.
To create new .j3m files,
assets/Materials
directory and choose New… > Other.mat_wall
for a wall material.mat_wall.j3m
is created in the Materials directory and opens in the Material Editor.You can edit the source of the material, or use the user-friendly visual editor to set the properties of the material. Set the properties to the same values as you would otherwise specify with setters on a Material object in Java code:
Material mat_wall = new Material( assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat_wall.setTexture("DiffuseMap", assetManager.loadTexture("Textures/wall.png")); mat_wall.setTexture("NormalMap", assetManager.loadTexture("Textures/wall-normals.png")); mat_wall.setFloat("Shininess", 5f);
The source code of the j3m file is always accessible and can be modified in the "source" tab of the editor.
When the material is ready and saved into your projects assets directory, you can assign the .j3m to a Geometry.
In the jMonkeyPlatform
Or in your Java code
mywall.setMaterial(assetManager.loadAsset( "Materials/mat_wall.j3m"));
See also