i tried to implement a few codes in my game… and i am having problems with 3 of them…
the first two errors are in SkyBox…
skybox.preloadTextures();
skybox().lockMeshes();
and in Terrain with
terrainNode.lock();
why this happens? did i forgot to do something?
all libs are in correct place… and no "red lines" are showing in my Eclipse IDE…
if i comment all those error lines, it all works perfect…
but i know those commands would improve my FPS… so i want to fix them…
thanks !
FIRST ERROR
skybox = new Skybox("skybox", 1000, 1000, 1000);
String dir = "jmetest/data/texture/";
Texture north = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "north.jpg"),Texture.MM_LINEAR, Texture.FM_LINEAR);
Texture south = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "south.jpg"),Texture.MM_LINEAR, Texture.FM_LINEAR);
Texture east = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "east.jpg"),Texture.MM_LINEAR, Texture.FM_LINEAR);
Texture west = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "west.jpg"),Texture.MM_LINEAR, Texture.FM_LINEAR);
Texture up = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "top.jpg"),Texture.MM_LINEAR, Texture.FM_LINEAR);
Texture down = TextureManager.loadTexture(TestQuadWater.class.getClassLoader().getResource(dir + "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(); <---- ERROR HERE !!!
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1348)
at com.jme.scene.state.lwjgl.LWJGLTextureState.load(LWJGLTextureState.java:273)
at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(LWJGLTextureState.java:464)
at com.jme.scene.Skybox.preloadTextures(Skybox.java:271)
#######################
SECOND ERROR
skybox.setLightCombineMode(LightState.OFF);
skybox.setCullMode(SceneElement.CULL_NEVER);
skybox.setTextureCombineMode(TextureState.REPLACE);
skybox.updateRenderState();
skybox.lockBounds();
skybox.lockMeshes(); <---- ERROR HERE !!!
rootNode.attachChild(skybox);
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenLists(GL11.java:1359)
at com.jme.renderer.lwjgl.LWJGLRenderer.createDisplayList(LWJGLRenderer.java:1480)
at com.jme.scene.batch.GeomBatch.lockMeshes(GeomBatch.java:537)
at com.jme.scene.Geometry.lockMeshes(Geometry.java:750)
at com.jme.scene.Node.lockMeshes(Node.java:439)
at com.jme.scene.SceneElement.lockMeshes(SceneElement.java:336)
at gamestates.InGameState.criaSkyBox(InGameState.java:270)
######
THIRD ERROR
Node terrainNode = new Node();
rootNode.attachChild(terrainNode);
FaultFractalHeightMap heightMap = new FaultFractalHeightMap(257, 1, 0, 0, 0.75f);
Vector3f terrainScale = new Vector3f(10,1,10);
heightMap.setHeightScale(0.001f);
terrain = new TerrainPage("Terrain", 33,heightMap.getSize(), terrainScale,heightMap.getHeightMap(), false);
terrain.setDetailTexture(1, 16);
terrainNode.attachChild(terrain);
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
pt.addTexture(new ImageIcon(InGameState.class.getClassLoader().getResource("jmetest/data/texture/terrain/nicegrass.jpg")), -128, 0, 128);
//pt.addTexture(new ImageIcon(InGameState.class.getClassLoader().getResource("jmetest/data/texture/grassb.png")), -128, 0, 128);
//pt.addTexture(new ImageIcon(InGameState.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg")), 0, 128, 255);
//pt.addTexture(new ImageIcon(InGameState.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg")), 128, 255, 384);
pt.createTexture(512);
TextureState ts = Main.disp.getRenderer().createTextureState();
ts.setEnabled(true);
Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),Texture.MM_LINEAR_LINEAR,Texture.FM_LINEAR,true);
ts.setTexture(t1, 0);
Texture t2 = TextureManager.loadTexture(InGameState.class.getClassLoader().getResource("jmetest/data/texture/Detail.jpg"),Texture.MM_LINEAR_LINEAR,Texture.FM_LINEAR);
ts.setTexture(t2, 1);
t2.setWrap(Texture.WM_WRAP_S_WRAP_T);
t1.setApply(Texture.AM_COMBINE);
t1.setCombineFuncRGB(Texture.ACF_MODULATE);
t1.setCombineSrc0RGB(Texture.ACS_TEXTURE);
t1.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
t1.setCombineSrc1RGB(Texture.ACS_PRIMARY_COLOR);
t1.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
t1.setCombineScaleRGB(1.0f);
t2.setApply(Texture.AM_COMBINE);
t2.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
t2.setCombineSrc0RGB(Texture.ACS_TEXTURE);
t2.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
t2.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
t2.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
t2.setCombineScaleRGB(1.0f);
terrainNode.setRenderState(ts);
FogState fs = Main.disp.getRenderer().createFogState();
fs.setDensity(0.0015f);
fs.setEnabled(true);
fs.setColor(new ColorRGBA(0.8f, 0.8f, 0.5f, 0.5f));
fs.setDensityFunction(FogState.DF_EXP);
fs.setApplyFunction(FogState.AF_PER_VERTEX);
terrainNode.setRenderState(fs);
terrainNode.lock(); <---- HERE IS THE ERROR
terrainNode.lockBranch(); <--- AND HERE TOO !!!
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenLists(GL11.java:1359)
at com.jme.renderer.lwjgl.LWJGLRenderer.createDisplayList(LWJGLRenderer.java:1480)
at com.jme.scene.batch.GeomBatch.lockMeshes(GeomBatch.java:537)
at com.jme.scene.Geometry.lockMeshes(Geometry.java:750)
at com.jme.scene.Node.lockMeshes(Node.java:439)
at com.jme.scene.Node.lockMeshes(Node.java:439)
at com.jme.scene.Node.lockMeshes(Node.java:439)
at com.jme.scene.Node.lockMeshes(Node.java:439)
at com.jme.scene.SceneElement.lockMeshes(SceneElement.java:336)
at com.jme.scene.SceneElement.lock(SceneElement.java:367)
at gamestates.InGameState.criaTerreno(InGameState.java:427)