solved: there were two issues: one should not use null for TexCoords when creating a TriMesh, and one should call the rootNode.update… functions after adding something to them. Sorry to everyone for the inconvenciences.
Hi,
I am almost done with my project and would also like to add a view screenshots to the showcase, but first I need to fix one last but very annoying misunderstanding which I seem to have with jme2.
I generate a mesh during initialization phase of SimpleGame and show it and it works allright, as can be witnessed in the screenshot below. But then I'd like to regenerate it. So, according to the tutorials I do this during simplUpdate():
GameTaskQueueManager.getManager().update( new Callable<Void>()
{
public Void call() throws Exception
{
generateAndAddNewMesh();
chaseCamera.setTarget(targetWord);
return null;
}
} );
But unfortunately, right after successfully finishing the generation of the mesh and even showing exactly one frame, this crashes with this error:
java.lang.NullPointerException
at com.jme.renderer.lwjgl.LWJGLRenderer.predrawGeometry(LWJGLRenderer.java:1479)
at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:999)
at com.jme.scene.TriMesh.draw(TriMesh.java:240)
at com.jme.scene.Spatial.onDraw(Spatial.java:429)
at com.jme.scene.Node.draw(Node.java:518)
at com.jme.scene.Spatial.onDraw(Spatial.java:429)
at com.jme.scene.Node.draw(Node.java:518)
at com.jme.scene.Spatial.onDraw(Spatial.java:429)
at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:1220)
at com.jme.app.SimpleGame.render(SimpleGame.java:81)
at com.jme.app.BaseGame.start(BaseGame.java:87)
I found a fix for this error somewhere to update LWJGLRenderer to read like this:
if (texC != null && texC.coords != null ) {
// make sure only the necessary texture coords are sent
// through on old cards.
oldLimit = texC.coords.limit();
texC.coords.limit(g.getVertexCount() * texC.perVert);
}
this fixes the NullPointerException, but introduces a hard crash in the driver instead:
#
An unexpected error has been detected by Java Runtime Environment:
#
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69295000, pid=5400, tid=5216
#
Java VM: Java HotSpot™ Client VM (10.0-b19 mixed mode windows-x86)
Problematic frame:
C [atioglxx.dll+0x265000]
#
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
#
T H R E A D
Current thread (0x026d9000): JavaThread "main" [_thread_in_native, id=5216, stack(0x00170000,0x001c0000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x11360010, EBX=0xeec9fff0, ECX=0x00000010, EDX=0x001bf640
ESP=0x001bf608, EBP=0x00000002, ESI=0x69c1a2c0, EDI=0x11360020
EIP=0x69295000, EFLAGS=0x00010287
...
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J org.lwjgl.opengl.GL11.nglDrawElements(IIILjava/nio/Buffer;IJ)V
J org.lwjgl.opengl.GL11.glDrawElements(ILjava/nio/IntBuffer;)V
J com.jme.renderer.lwjgl.LWJGLRenderer.draw(Lcom/jme/scene/TriMesh;)V
J com.jme.scene.TriMesh.draw(Lcom/jme/renderer/Renderer;)V
J com.jme.scene.Spatial.onDraw(Lcom/jme/renderer/Renderer;)V
J com.jme.scene.Node.draw(Lcom/jme/renderer/Renderer;)V
J com.jme.scene.Spatial.onDraw(Lcom/jme/renderer/Renderer;)V
J com.jme.scene.Node.draw(Lcom/jme/renderer/Renderer;)V
J com.jme.scene.Spatial.onDraw(Lcom/jme/renderer/Renderer;)V
J com.jme.renderer.lwjgl.LWJGLRenderer.draw(Lcom/jme/scene/Spatial;)V
J com.jme.app.SimpleGame.render(F)V
v ~BufferBlob::Interpreter
v ~BufferBlob::Interpreter
v ~BufferBlob::StubRoutines (1)
Apparently I am doing something bad to some buffer somewhere. Does anyone have any idea what that could possibly be? I am kind of out of options currently... When generating the mesh I am messing around with FloatBuffers a lot. Do I have to clear them manually or something? Or am I completely offtrack?