Hello guys
I am new to jmonkey and I try to create a game with two scenes
The first one is the default town. For the second one I have created a custom terrain using heightmap and alphamap together with a java class.
I tried to import it to the main java class but I could find it anywhere in the map. My aim is to have the two terrains adjucent with each other.
What could I do wrong?
Can I convert the custom created terrain to j3o mesh format in order to call it using the same method that I call the town?
No I dont have any light attached to the custom scenery. I only have a light on the main code where I have attached the town.scene
In the class that I have only the custom terrain I can see the terrain correctly.
If I delete the town scene and have only the custom terrain I can see the terrain but when the character lands on the terrain, the character falls immediately under the terrain.
If I have both the default town in as one terrain and the custom terrain as a second terrain I see only the first one, even if the two terrains are one the same position on x and z axis and just +2 on y axis
What could I be missing?
The code for the custom terrain is:
public void simpleInitApp() {
flyCam.setMoveSpeed(50);
/** 1. Create terrain material and load four textures into it. */
mat_terrain = new Material(assetManager,
"Common/MatDefs/Terrain/Terrain.j3md");
/** 1.1) Add ALPHA map (for red-blue-green coded splat textures) */
mat_terrain.setTexture("Alpha", assetManager.loadTexture(
"Textures/Terrain/splat/alphamap.png"));
/** 1.2) Add GRASS texture into the red layer (Tex1). */
Texture grass = assetManager.loadTexture(
"Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("Tex1", grass);
mat_terrain.setFloat("Tex1Scale", 32);
Texture dust = assetManager.loadTexture(
"Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("Tex2", grass);
mat_terrain.setFloat("Tex2Scale", 32);
/** 1.4) Add ROAD texture into the blue layer (Tex3) */
Texture rock = assetManager.loadTexture(
"Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("Tex3", rock);
mat_terrain.setFloat("Tex3Scale", 16);
/** 2. Create the height map */
Texture heightMapImage = assetManager.loadTexture(
"Textures/Terrain/heightmap.png");
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(
heightMapImage.getImage(), 0.5f );
heightmap.load();
} catch (Exception e) { e.printStackTrace(); }
TerrainQuad terrain = new TerrainQuad(
"terrain", 65, 513, heightmap.getHeightMap() );
/** 4. We give the terrain its material, position & scale it, and attach it. */
terrain.setMaterial(mat_terrain);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(2f, 1f, 2f);
rootNode.attachChild(terrain);
/** 5. The LOD (level of detail) depends on were the camera is: */
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
terrain.addControl(control);