TerraMonkey to create terrain textures

Using TerraMonkey terrian editor, is it possible to import only the texture for the terrain (alpha, diffuse, normal maps)? Can you make a flat terrain, texture it, then import only the texture to use for a different terrain?

Sure. There are two ways to go about doing it.

The alpha maps are saved out to assets/Textures/terrain-alpha. There will be 3 alpha maps for your scene. You can use those directly and set the textures manually on the material when you load in the terrain. Just like the terrain example test files, just load in the alpha maps from the editor instead.



As for getting the actual material object itself, you have to do a little hackery. First, read in the scene.j3o file, find the terrain in it, and call terrain.getMaterial(). You now have the material and you can save out that material to disk, then use it later on for your other terrains. You only have to do this once, unless you change what textures the material has, or their order or scale or any other material settings.

thanks I’ll give it a try

one more problem, when I use “Common/MatDefs/Terrain/TerrainLighting.j3md” instead of “Common/MatDefs/Terrain/Terrain.j3md” it gives me the error “java.lang.IllegalArgumentException: Material parameter is not defined: Alpha” on the line I define my alpha map. I have defined it as “Alpha”, “m_Alpha”, and “Alpha1” to no avail.

They are different materials with different parameters. Look at their definition files (.j3md) to see what the parameters are. The lighting one supports more alpha maps and diffuse textures, so it has more alpha parameters.

I have done the above, and compiled and tried to run it, and I get the error “No material is set for Geometry: my terrainQuad1Quad1Quad3Quad3Patch1”, and it seems to be trying to generate endless terrainQuads. What am I doing wrong, and how do I fix it. (This is my first attempt with terrain lighting.) Just because I think that it would help to see the code :



[java]

package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.texture.Texture;

import com.jme3.texture.Texture.WrapMode;

import com.jme3.terrain.geomipmap.TerrainQuad;

import com.jme3.light.AmbientLight;

import com.jme3.light.DirectionalLight;



public class Main extends SimpleApplication {



public static void main(String[] args) {

Main app = new Main();

app.start();

}



//float array used as heightmap

public float[] map = new float [4096];



@Override

public void simpleInitApp() {

//code where the heightmap is generated

Map Map = new Map();

map = Map.Spawn(map);



//turn the heightmap into the terrain

initMap();

}



@Override

public void simpleUpdate(float tpf) {

//blank for now

}



Material mat_terrain;

TerrainQuad terrain;



public void initMap() {

//use terrian lighting

mat_terrain = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);



//define the alphamap

mat_terrain.setTexture(“AlphaMap”, assetManager.loadTexture(“Textures/alphaMap.png”));



//define the grass texture

Texture grass = assetManager.loadTexture(“Textures/grass.jpg”);

grass.setWrap(WrapMode.Repeat);

mat_terrain.setTexture(“DiffuseMap”, grass);

mat_terrain.setFloat(“DiffuseMap_0_scale”, 1f);



//turn into the terrain

terrain = new TerrainQuad(“my terrain”, 17, 513, map);

rootNode.attachChild(terrain);



//setup the light

initSun();

}



public void initSun() {

//init the ambient light

AmbientLight al = new AmbientLight();

al.setColor(ColorRGBA.White.mult(1.3f));

rootNode.addLight(al);



//init the directional light

DirectionalLight dl = new DirectionalLight();

dl.setColor(ColorRGBA.White);

dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());

rootNode.addLight(dl);

}

}



[/java]

Just tried making the map smaller, and scaling up the terrain. It now tells me that I have no material set for Geometry terrainQuad1 Patch1

I FOUND THE PROBLEM :slight_smile: ALL BY MY SELF :slight_smile:

I setup the terrainQuad after the material defs. For some reason when I setup the defs after the terrainQuad it works.

Glad you found the problem. You will be a master monkey in no time :slight_smile: