I've got a problem that completely baffles me.
I use JME 0.10, and i didn't compile it myself, i just downloaded the compiled code for it.
I just started working with JME and made this program to test out terrain and skybox stuff:
package jmetest;
import java.net.URL;
import javax.swing.ImageIcon;
import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.util.TextureManager;
import com.jme.scene.Skybox;
import com.jme.scene.state.*;
import com.jme.system.*;
import com.jmex.terrain.TerrainBlock;
import com.jmex.terrain.util.MidPointHeightMap;
import com.jmex.terrain.util.ImageBasedHeightMap;
import com.jmex.terrain.util.ProceduralTextureGenerator;
public class SkyTerrainTest extends SimpleGame {
Skybox skybox;
public static void main(String[] args) {
SkyTerrainTest app = new SkyTerrainTest();
app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
protected void simpleInitGame() {
// Create the sky & the ground
Terrain();
Skybox();
}
private void Skybox() {
skybox = new Skybox("skybox", 200, 200, 200);
Texture north = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/north.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
Texture south = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/south.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
Texture east = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/east.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
Texture west = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/west.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
Texture up = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/top.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
Texture down = TextureManager.loadTexture(
SkyTerrainTest.class.getClassLoader().getResource(
"jmetest/bottom.jpg"),
Texture.MM_LINEAR,
Texture.FM_LINEAR);
skybox.setTexture(Skybox.NORTH, north);
skybox.setTexture(Skybox.WEST, west);
skybox.setTexture(Skybox.SOUTH, south);
skybox.setTexture(Skybox.EAST, east);
skybox.setTexture(Skybox.UP, up);
skybox.setTexture(Skybox.DOWN, down);
skybox.preloadTextures();
skybox.getSide(Skybox.NORTH).setLightCombineMode(LightState.OFF);
skybox.getSide(Skybox.SOUTH).setLightCombineMode(LightState.OFF);
skybox.getSide(Skybox.WEST).setLightCombineMode(LightState.OFF);
skybox.getSide(Skybox.EAST).setLightCombineMode(LightState.OFF);
skybox.getSide(Skybox.UP).setLightCombineMode(LightState.OFF);
skybox.getSide(Skybox.DOWN).setLightCombineMode(LightState.OFF);
rootNode.attachChild(skybox);
}
private void Terrain() {
MidPointHeightMap mph=new MidPointHeightMap(64,1.5f);
// Create a terrain block from the created terrain map.
TerrainBlock tb=new TerrainBlock("terrain",mph.getSize(),
new Vector3f(1,.11f,1),
mph.getHeightMap(),
new Vector3f(0,-25,0),true);
// These will be the textures of our terrain.
URL waterImage=SkyTerrainTest.class.getClassLoader().
getResource("jmetest/water.png");
URL dirtImage=SkyTerrainTest.class.getClassLoader().
getResource("jmetest/grassb.jpg");
URL highest=SkyTerrainTest.class.getClassLoader().
getResource("jmetest/highest.jpg");
ProceduralTextureGenerator pg=new ProceduralTextureGenerator(mph);
pg.addTexture(new ImageIcon(waterImage),0,30,60);
pg.addTexture(new ImageIcon(dirtImage),40,80,120);
pg.addTexture(new ImageIcon(highest),110,130,256);
pg.createTexture(256);
TextureState ts=display.getRenderer().createTextureState();
ts.setTexture(TextureManager.loadTexture(
pg.getImageIcon().getImage(),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR,
true));
tb.setRenderState(ts);
tb.setModelBound(new BoundingBox());
tb.updateModelBound();
tb.setLocalTranslation(new Vector3f(0,0,-50));
rootNode.attachChild(tb);
}
protected void simpleUpdate () {
skybox.setLocalTranslation(cam.getLocation());
}
}
It compiles fine, but the only way i can get the skybox to render at all is if i comment out the call to Terrain(), and the skybox responds to lighting if i don't individually set the quads it's made up of to not do that. So, getting the lighting thing out of the way, i either have terrain and no sky or an empty skybox.
I also just noticed, my username was meant to be rootbeerbandit348, not the way it is now with the t and i transposed, how could i fix that?