How to use or download terramonkey?

I was wondering how do you guys use terramonkey.

I m trying to find a link to download the editor and i cant find any.

I tink it is inside Jme3 but i dont get how to creat classe out side my main class to make the terrain show up using the simple code in the tutorial…

I was wondering if some one could make me an exemple of Main with a terrain build out side of it. Like a Main and a Terrain class.

Anyway if some one as a tip for me i would enjoy them i am new to jme3. I m trying to make a small game on my pass time but i dont want to build it the wrong way (like the whole script into my main…)

Just install the TerrainEditor plugin for jMonkeyPlataform.

the SDK has the terrain editor built into it.



Normally you would build your scene in jMP(the SDK), save out the .j3o file, and then load that into your game. Each “level” of your game would load in a different saved scene.

You can start structuring your app that way.

It is hard to give a code example, because everyone’s game will act differently in how it is structured. But once you have the basics, even if it is one major main class, then you can start refactoring out the code into separate classes.

It is also worth looking at AppStates.

1 Like
Sploreg said:
the SDK has the terrain editor built into it.

Normally you would build your scene in jMP(the SDK), save out the .j3o file, and then load that into your game. Each "level" of your game would load in a different saved scene.
You can start structuring your app that way.
It is hard to give a code example, because everyone's game will act differently in how it is structured. But once you have the basics, even if it is one major main class, then you can start refactoring out the code into separate classes.
It is also worth looking at AppStates.


Yeah, i forget the TerraiEditor is now integrated in jmp :D. We don't need install it anymore...
1 Like

alright thank you I had the JmonkeyPlatform…

And about refactoring all into different classes… This is my main problem, I m trying to build out my main like


[java]
package mygame;

import com.jme3.app.SimpleApplication;

import com.jme3.renderer.RenderManager;


/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication {

public static void main(String[] args) {
Main app = new Main();
app.start();
}

@Override
public void simpleInitApp() {
Terrain terrainTest1 = new Terrain();
Cube cube1 = new Cube();
}

@Override
public void simpleUpdate(float tpf) {

}

@Override
public void simpleRender(RenderManager rm) {

}
}
[/java]

And the Terrain class look like

[java]
package mygame;


import com.jme3.material.Material;
import com.jme3.renderer.Camera;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.heightmap.AbstractHeightMap;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.HillHeightMap; // is used in example 2
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
import java.util.ArrayList;
import java.util.List;
import jme3tools.converters.ImageToAwt;

public class Terrain extends Main {

private TerrainQuad terrain;
Material mat_terrain;




public void Terrain() {
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("m_Alpha",
assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));

/** 1.2) Add GRASS texture into the red layer (m_Tex1). */
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_Tex1", grass);
mat_terrain.setFloat("m_Tex1Scale", 64f);

/** 1.3) Add DIRT texture into the green layer (m_Tex2) */
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_Tex2", dirt);
mat_terrain.setFloat("m_Tex2Scale", 32f);

/** 1.4) Add ROAD texture into the blue layer (m_Tex3) */
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_Tex3", rock);
mat_terrain.setFloat("m_Tex3Scale", 128f);

/** 2. Create the height map */
final Texture heightMapImage =
assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
final AbstractHeightMap heightmap =
new ImageBasedHeightMap(
ImageToAwt.convert(
heightMapImage.getImage(), false, true, 0));
heightmap.load();

/** 3. We have prepared material and heightmap. Now we create the actual terrain:
* 3.1) We create a TerrainQuad and name it "my terrain".
* 3.2) A good value for terrain tiles is 64x64 -- so we supply 64+1=65.
* 3.3) We prepared a heightmap of size 512x512 -- so we supply 512+1=513.
* 3.4) As LOD step scale we supply Vector3f(1,1,1).
* 3.5) At last, we supply the prepared heightmap itself.
*/
terrain = new TerrainQuad("my 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: */
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);

}
}

[/java]

this is how i m trying to show up the terrain but it seem i m doing it all wrong.

Don’t have your Terrain class extend Main, that will just lead to confusion. Instead have it extend nothing, and call it something else, like “TerrainGenerator”.

Rename the constructor to “create(Node rootNode)”.



Then in your main class in “public void simpleInitApp() {” do this:

[java]

TerrainGenerator myTerrainGenerator = new TerrainGenerator(rootNode);

[/java]



If you extend your Main class, it will just confuse the issue.



AppStates are a great way to modularize your code, easily allowing you to plug in different features of your game without cluttering your main application class.

1 Like

Alright thank you Sploreg.

I m going to give this a try and i found the Terrain editor inside my Jmp.

I most be doing all this wrong, i get an error when it s time to call the classes



[java]

TerrainGenerator myTerrainGenerator = new TerrainGenerator(rootNode);

[/java]

'>

I m getting an error when i m adding (rootNode);

i was wondering if u could help on this?

Did you create the TerrainGenerator.java file? And if so, is it imported?



It will also need a constructor that takes in a root node:

[java]

class TerrainGenerator {

public TerrainGenerator(Node node, AssetManager manager) {

// create your terrain here, you will need the asset manager to load textures

}

}

[/java]

It will also need the AssetManager that will load textures for you.

I made the TerrainGenerator.java file and imported? do u mean in the same folder?

cause it is if u can see it in the picture i linked.

I add the assetManager and the rootNode and i still have an error.

I think i miss something in my Main.

[java]

package mygame;

import com.jme3.app.SimpleApplication;

import com.jme3.renderer.RenderManager;

public class Main extends SimpleApplication {

public static void main(String[] args) {

Main app = new Main();

app.start();

}

@Override

public void simpleInitApp() {

flyCam.setMoveSpeed(50);

TerrainGenerator myTerrainGenerator = new TerrainGenerator(rootNode , assetManager);

rootNode.attachChild(myTerrainGenerator.getTerrain());

}

@Override

public void simpleUpdate(float tpf) {

}

@Override

public void simpleRender(RenderManager rm) {

}

}

[/java]

Alright i got to run the Terrain and made a 3x3 1024 terrain witch give around 3072x3072

i just dont find how to use the terrain editor if i look into the plug in they say it s installed and if i take a look

at the top menu bar it s unclickable as show on this picture!



Is there something to do to make it active?

http://www.youtube.com/watch?v=zgPV3W6dD4s