As the title says above, I have a terrain like in the “HelloTerrain” tutorial and I would like to have it dark, because it should be night in the game.
I have removed all light sources defined, but that changed nothing!
For testing, I added a light to the game, but nothing has changed. Now I think that my game isn’t working correctly, I think that it can’t handle light. But why?!
Here’s my code:
[java]…
generateTerrain();
…
private void generateTerrain() {
mat_terrain = new Material(assetManager,
“Common/MatDefs/Terrain/Terrain.j3md”);
AbstractHeightMap heightmap = null;
Texture heightMapImage = assetManager.loadTexture(
“assets/terrain/height1024.png”);
heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
heightmap.load();
mat_terrain.setTexture(“Alpha”, assetManager.loadTexture(
“assets/terrain/alpha1024.png”));
Texture grass = assetManager.loadTexture(
“Textures/Terrain/splat/grass.jpg”);
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture(“Tex1”, grass);
mat_terrain.setFloat(“Tex1Scale”, 64f);
Texture dirt = assetManager.loadTexture(
“Textures/Terrain/splat/dirt.jpg”);
dirt.setWrap(WrapMode.Repeat);
mat_terrain.setTexture(“Tex2”, dirt);
mat_terrain.setFloat(“Tex2Scale”, 32f);
Texture rock = assetManager.loadTexture(
“Textures/Terrain/splat/road.jpg”);
rock.setWrap(WrapMode.Repeat);
mat_terrain.setTexture(“Tex3”, rock);
mat_terrain.setFloat(“Tex3Scale”, 128f);
int patchSize = 65;
terrain = new TerrainQuad(“sosTerrain”, patchSize, 1025, heightmap.getHeightMap());
terrain.setMaterial(mat_terrain);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(2.0f, 1.0f, 2.0f);
//terrain.setShadowMode(ShadowMode.Receive);
terrain.setUserData(“type”, “terrain”);
rootNode.attachChild(terrain);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
control.setLodCalculator(new DistanceLodCalculator(65, 2.7f));
terrain.addControl(control);
CollisionShape terrainShape =
CollisionShapeFactory.createMeshShape((Node) terrain);
landscape = new RigidBodyControl(terrainShape, 0);
terrain.addControl(landscape);
}[/java]
P.S.: I use jME in eclipse, so don’t wonder about the paths
Remove jMonkeyEngine3.jar from the classpath.
@normen said:
Remove jMonkeyEngine3.jar from the classpath.
Hmm, I would, but there's no jMonkeyEngine3.jar on the classpath. Do you mean "Java Build Path", or what?
But thanks for your very fast answer :/
Note: Here's the list of libs I have in the build path:
- eventbus.jar
- j-ogg-oggd.jar
- j-ogg-vorbisd.jar
- jbullet.jar
- jinput.jar
- jME3-blender.jar
- jME3-core.jar
- jME3-desktop.jar
- jME3-effects.jar
- jME3-jbullet.jar
- jME3-jogg.jar
- jME3-lwjgl-natives.jar
- jME3-lwjgl.jar
- jME3-networking.jar
- jME3-niftygui.jar
- jME3-plugins.jar
- jME3-terrain.jar
- jME3-testdata.jar
- lwjgl.jar
- nifty-default-controls.jar
- nifty-examples.jar
- nifty-style-black.jar
- nifty.jar
- stack-alloc.jar
- vecmath.jar
- xmlpull-xpp3.jar
you use the unshaded terrain material. So lights don’t affect the terrain at all.
use
[java]
mat_terrain = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);
[/java]
instead of
[java]
mat_terrain = new Material(assetManager, “Common/MatDefs/Terrain/Terrain.j3md”);
[/java]
3 Likes
@nehon said:
you use the unshaded terrain material. So lights don't affect the terrain at all.
use
[java]
mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
[/java]
instead of
[java]
mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
[/java]
WOW! Thanks! Got it working!
...next time, I search a little bit more...
1 Like