I have just upgrades to JME 3.1, and have tried t run my projects in the 3.1 sdk. However, I found that there were two major differences in two of my projects: in the first, lighting did not work as it had before. In the second, the canvas I use to display my game did not work, which I believe is due to incompatibility with how I use the Material class.
For my first project:
I have uploaded a picture of the in-game view before and after the upgrade
Before:
After:
.
This is my lighting code (which is identical for both, found in simpleInitApp:
//Lighting
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(1f, 1f, 1f));
rootNode.addLight(dl);
DirectionalLight dl1 = new DirectionalLight();
dl1.setDirection(new Vector3f(-1f, -1f, -1f));
rootNode.addLight(dl1);
In my second game, once again I did not change my code. However, I always get the following stacktrace:
run:
mar 05, 2017 10:19:51 AM com.jme3.system.JmeDesktopSystem initialize
INFORMACIÓN: Running on jMonkeyEngine 3.1-stable
* Branch: HEAD
* Git Hash: af04bf9
* Build Date: 2017-02-19
1
mar 05, 2017 10:19:53 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFORMACIÓN: OpenGL Renderer Information
* Vendor: NVIDIA Corporation
* Renderer: GeForce GTX 1070/PCIe/SSE2
* OpenGL Version: 4.5.0 NVIDIA 378.57
* GLSL Version: 4.50 NVIDIA
* Profile: Compatibility
mar 05, 2017 10:19:53 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFORMACIÓN: LWJGL 2.9.3 context running on thread jME3 Main
* Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvd3dumx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx
* Driver Version: 21.21.13.7857
* Scaling Factor: 1
mar 05, 2017 10:19:53 AM com.jme3.asset.AssetConfig loadText
ADVERTENCIA: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
mar 05, 2017 10:19:53 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio Renderer Information
* Device: OpenAL Soft
* Vendor: OpenAL Community
* Renderer: OpenAL Soft
* Version: 1.1 ALSOFT 1.15.1
* Supported channels: 64
* ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
* AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
mar 05, 2017 10:19:53 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
ADVERTENCIA: Pausing audio device not supported.
mar 05, 2017 10:19:53 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio effect extension version: 1.0
mar 05, 2017 10:19:53 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio max auxiliary sends: 4
Bullet-Native: Initializing java classes
mar 05, 2017 10:19:53 AM com.jme3.material.plugins.J3MLoader readDefine
ADVERTENCIA: In technique 'GBuf':
Define 'VERTEX_COLOR' mapped to non-existent material parameter 'UseVertexColor', ignoring.
mar 05, 2017 10:19:53 AM com.jme3.material.plugins.J3MLoader readDefine
ADVERTENCIA: In technique 'GBuf':
Define 'MATERIAL_COLORS' mapped to non-existent material parameter 'UseMaterialColors', ignoring.
mar 05, 2017 10:19:53 AM com.jme3.material.plugins.J3MLoader readDefine
ADVERTENCIA: In technique 'GBuf':
Define 'V_TANGENT' mapped to non-existent material parameter 'VTangent', ignoring.
mar 05, 2017 10:19:53 AM com.jme3.material.plugins.J3MLoader readDefine
ADVERTENCIA: In technique 'GBuf':
Define 'MINNAERT' mapped to non-existent material parameter 'Minnaert', ignoring.
mar 05, 2017 10:19:53 AM com.jme3.material.plugins.J3MLoader readDefine
ADVERTENCIA: In technique 'GBuf':
Define 'PARALLAXMAP' mapped to non-existent material parameter 'ParallaxMap', ignoring.
mar 05, 2017 10:19:54 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:19:54 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
mar 05, 2017 10:19:54 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:19:54 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
initEND
up 0.0
upEND 2.2513494
C:\Users\jeffr\AppData\Roaming\.jmonkeyplatform\3.1.0-stable-FINAL\var\cache\executor-snippets\run.xml:53: Java returned: -1073741819
BUILD FAILED (total time: 16 seconds)
Note that
“initEND
up 0.0
upEND 2.2513494”
are printed from simpleInitApp (at the end) and simpleUpdate (at the start and end) with the associated times.
Through experimenting, I have found that if I do not add the canvas to my JFrame display, everything loads, except, of course, for the game world. I use the code
inMainMenu = false;
prepareForContainer();
initContainer();
frame.remove(menu);
frame.add(container);
APP.runCanvas();
to display the frame (APP.runCanvas() just tells my main class to call startCanvas()).
Could anyone point me in the right direction to fix these errors?
Thanks!!
EDIT:
I feel like it would be of use for me to show my world generation code, as I believe the materials / textures in it are part of the problem. Neither work.
Strategy 1: use heightmaps to create the world (note that the mathod name, buildEndlessMap, is not what I intend to do. I plan to make the map endelss eventually, but it is not so right now).
private void buildEndlessMap(int scale)
{
Texture heightMapImage = assetManager.loadTexture("Textures/Height.png");
Material mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
mat_terrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Alpha.png"));
//Red layer in alphamap
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("DiffuseMap", grass);
mat_terrain.setFloat("DiffuseMap_0_scale", 64f);
//Green layer in alphamap
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("DiffuseMap_1", dirt);
mat_terrain.setFloat("DiffuseMap_1_scale", 32f);
//Blue layer in alphamap
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("DiffuseMap_2", rock);
mat_terrain.setFloat("DiffuseMap_2_scale", 128f);
AbstractHeightMap heightmap = null;
heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
heightmap.load();
TerrainQuad terrain;
int patchSize = 65;
terrain = new TerrainQuad("my terrain", patchSize, 1025, heightmap.getHeightMap());
terrain.setMaterial(mat_terrain);
terrain.setLocalTranslation(0, -70, 0);
terrain.setLocalScale(2f, 1f, 2f);
rootNode.attachChild(terrain);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
terrain.addControl(control);
//------------------------------Endless(broken)------------------------------
/*ImageTileLoader itm = new ImageTileLoader(assetManager, new Namer()
{
public String getName(int x, int y) {
//return "Textures/heightmap.png";
return "assets/Scenes/Height" + x + "" + y + ".png";
}
});
TerrainGrid terrain = new TerrainGrid("terrain", 65, 1025, itm);
terrain.setMaterial(mat_terrain);
terrain.setLocalTranslation(0, 10, 0);
terrain.setLocalScale(2f, 2f, 2f);
rootNode.attachChild(terrain);
TerrainLodControl control = new TerrainGridLodControl(terrain, getCamera());
terrain.addControl(control);
//-----------------------------END----------------------------*/
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) terrain);
RigidBodyControl mapBody = new RigidBodyControl(sceneShape, 0);
terrain.addControl(mapBody);
bulletAppState.getPhysicsSpace().add(mapBody);
}
Strategy 2: use blender models to create a tiled world
private void buildRandomMap(int num)
{
//all maps are 800 x 800 squares
int mapsOnSide = 0; //increment as maps are placed
int sideLen = (int) (FastMath.sqrt(num) + .5); //Number of maps on one larger map side.
Vector3f nextLoc = new Vector3f(0, 0, 0);
for(int i = 0; i < num; i++)
{
RigidBodyControl mapBody = new RigidBodyControl();
int rand = gen.nextInt(6);
rand = rand == 2 ? 1 : rand; //Be sure tyhe volcane does not spawn first
switch(rand)
{
case 0:
{
Spatial map_grassland = assetManager.loadModel("Models/map_alt_valleyv1/map_alt_valleyv1.j3o");
map_grassland.setName("Map");
map_grassland.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_grassland);
mapBody = new RigidBodyControl(sceneShape, 0);
map_grassland.addControl(mapBody);
rootNode.attachChild(map_grassland);
mapBody.setPhysicsLocation(nextLoc);
break;
}
case 1:
{
Spatial map_forest = assetManager.loadModel("Models/map_forestv2/map_forestv2.j3o");
map_forest.setName("Map");
map_forest.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_forest);
mapBody = new RigidBodyControl(sceneShape, 0);
map_forest.addControl(mapBody);
rootNode.attachChild(map_forest);
mapBody.setPhysicsLocation(nextLoc);
break;
}
case 2:
{
Spatial map_mountainRange = assetManager.loadModel("Models/map_volcano/map_volcano.j3o");
map_mountainRange.setName("Map");
map_mountainRange.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_mountainRange);
mapBody = new RigidBodyControl(sceneShape, 0);
map_mountainRange.addControl(mapBody);
rootNode.attachChild(map_mountainRange);
mapBody.setPhysicsLocation(nextLoc);
break;
}
case 3:
{
Spatial map_pits = assetManager.loadModel("Models/map_pits/map_pits.j3o");
map_pits.setName("Map");
map_pits.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_pits);
mapBody = new RigidBodyControl(sceneShape, 0);
map_pits.addControl(mapBody);
rootNode.attachChild(map_pits);
mapBody.setPhysicsLocation(nextLoc);
break;
}
case 4:
{
Spatial map_stonefield = assetManager.loadModel("Models/map_stonefieldv2/map_stonefieldv2.j3o");
map_stonefield.setName("Map");
map_stonefield.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_stonefield);
mapBody = new RigidBodyControl(sceneShape, 0);
map_stonefield.addControl(mapBody);
rootNode.attachChild(map_stonefield);
mapBody.setPhysicsLocation(nextLoc);
break;
}
case 5:
{
Spatial map_valleyv1 = assetManager.loadModel("Models/map_valleyv1/map_valleyv1.j3o");
map_valleyv1.setName("Map");
map_valleyv1.setLocalScale(50f, 50f, 50f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) map_valleyv1);
mapBody = new RigidBodyControl(sceneShape, 0);
map_valleyv1.addControl(mapBody);
rootNode.attachChild(map_valleyv1);
mapBody.setPhysicsLocation(nextLoc);
break;
}
}
bulletAppState.getPhysicsSpace().add(mapBody);
//Put more maps on this side
if(mapsOnSide < sideLen - 1)
{
nextLoc.set(new Vector3f(nextLoc.getX() + EXTENT, 0, nextLoc.getZ()));
mapsOnSide++;
}
else
{
mapsOnSide = 0;
nextLoc.set(new Vector3f(0, 0, nextLoc.getZ() + EXTENT));
}
}
}
If I use this alternate method, I get this error log:
run:
mar 05, 2017 10:33:51 AM com.jme3.system.JmeDesktopSystem initialize
INFORMACIÓN: Running on jMonkeyEngine 3.1-stable
* Branch: HEAD
* Git Hash: af04bf9
* Build Date: 2017-02-19
1
mar 05, 2017 10:33:54 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFORMACIÓN: OpenGL Renderer Information
* Vendor: NVIDIA Corporation
* Renderer: GeForce GTX 1070/PCIe/SSE2
* OpenGL Version: 4.5.0 NVIDIA 378.57
* GLSL Version: 4.50 NVIDIA
* Profile: Compatibility
mar 05, 2017 10:33:54 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFORMACIÓN: LWJGL 2.9.3 context running on thread jME3 Main
* Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvd3dumx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx,C:\WINDOWS\System32\DriverStore\FileRepository\nvami.inf_amd64_dc9c3a170a19f645\nvwgf2umx
* Driver Version: 21.21.13.7857
* Scaling Factor: 1
mar 05, 2017 10:33:55 AM com.jme3.asset.AssetConfig loadText
ADVERTENCIA: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
mar 05, 2017 10:33:55 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio Renderer Information
* Device: OpenAL Soft
* Vendor: OpenAL Community
* Renderer: OpenAL Soft
* Version: 1.1 ALSOFT 1.15.1
* Supported channels: 64
* ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
* AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
mar 05, 2017 10:33:55 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
ADVERTENCIA: Pausing audio device not supported.
mar 05, 2017 10:33:55 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio effect extension version: 1.0
mar 05, 2017 10:33:55 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMACIÓN: Audio max auxiliary sends: 4
Bullet-Native: Initializing java classes
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: WardIso. Ignoring..
mar 05, 2017 10:33:55 AM com.jme3.material.Material read
ADVERTENCIA: The material parameter is not defined: Minnaert. Ignoring..
initEND
up 0.0
upEND 1.8230565
C:\Users\jeffr\AppData\Roaming\.jmonkeyplatform\3.1.0-stable-FINAL\var\cache\executor-snippets\run.xml:53: Java returned: -1073741819
BUILD FAILED (total time: 6 seconds)