'lo again
i'm getting a nullpointer error from my method that calls updateFromHeightMap, and have been trying to figure out the problem. I think i may have been staring at it too long XD This may or may not be helpful, but i'm using a jframe with an implementor and a canvas for the 3d viewport, and i'm updating the terrain from the heightmap from a method in a jframe, and have already tried putting the method in the implementor.
so here's the code in question:
public void editGrid(Location loc, Renderer display){
TextureManager.clearCache();
//TextureManager.doTextureCleanup();
int resize;
int stepsize;
System.out.println("editing terrain");
System.out.println(grid.isValid(loc));
System.out.println(grid.getTerrain(loc) != null);
if(grid.isValid(loc)&& grid.getTerrain(loc) != null){
ImageIcon ic = hashHeight.get(grid.getTerrain(loc).getClass().getName().
substring(grid.getTerrain(loc).getClass().getName().lastIndexOf(".")+1));
resize = map_icon.getHeight()/grid.getNumCols();
BufferedImage buff= resize(ic, resize);
ImageBasedHeightMap h= new ImageBasedHeightMap(buff);
h.setSize(resize);
Graphics2D edit = map_icon.createGraphics();
edit.drawImage(buff, resize*loc.getRow(),resize*loc.getCol(),null);
grid_map = new ImageBasedHeightMap(map_icon);
System.out.println(grid_gui.getSize());
for(int i = 0; i<resize; i++){
for(int j=0; j<resize;j++){
System.out.println(i+" "+j+" "+h.getTrueHeightAtPoint(i, j));
/*grid_gui.setHeightMapValue(
resize*loc.getRow()+i,
resize*loc.getCol()+j,
h.getTrueHeightAtPoint(i, j));*/
}
}
System.out.println("IS THIS UPDATED??");
colors = compositeAroundOverlayTexture(loc,colors.getIconWidth());
TextureState t= display.createTextureState();
Texture ed= getTerrainTexture();
//rows are columns...columns are rows?
//flip Texture vertically Here!!!!
t.setTexture(ed);
TextureManager.clearCache();
grid_gui.setRenderState(t);
System.out.println(grid_gui);
System.out.println(grid_map.getHeightMap());
//grid_gui.updateModelBound();
//grid_gui.updateGeometricState(0, true);
//grid_gui.updateFromHeightMap();
grid_gui.updateRenderState();
}
}
//makes a terrainPage from terrian entities
public TerrainPage createTerrainPage(int size, boolean b){
int side;
ImageIcon def;
def = hashHeight.get("Default");
map_icon = resize(def, size);
grid_map = new ImageBasedHeightMap(map_icon);
grid_gui = new TerrainPage("master_grid",
size,
size,
new Vector3f(1f,1f,1f),
grid_map.getHeightMap()
,b);
//grid_gui.setLocalScale(2f);
//grid_gui.setDetailTexture(1, 16);
System.out.println("Grid gui size: "+grid_gui.getSize());
return grid_gui;
}
and my lovely error XD
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.lwjgl.opengl.ARBBufferObject.glDeleteBuffersARB(ARBBufferObject.java:50)
at com.jme.renderer.lwjgl.LWJGLRenderer.deleteVBO(Unknown Source)
at com.jme.renderer.lwjgl.LWJGLRenderer.deleteVBO(Unknown Source)
at com.jmex.terrain.TerrainBlock.updateFromHeightMap(Unknown Source)
at com.jmex.terrain.TerrainPage.updateFromHeightMap(Unknown Source)
at World3DFrame.updateTerrain(World3DFrame.java:223)
at JMenuMaker$OccupantConstructorItem.actionPerformed(JMenuMaker.java:324)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1220)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1261)
at java.awt.Component.processMouseEvent(Component.java:6099)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5864)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4296)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2454)
at java.awt.Component.dispatchEvent(Component.java:4296)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:284)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)