JME Physics 2 Sphere / Terrain Access Violation

Hello everyone - longtime lurker here.

I'm currently using jME as part of my game development class final, and I've hit a rather irritating wall. That is, every time I try to assign physics properties to a sphere (com.jme.scene.shape.Sphere), the game crashes whenever that sphere hits my terrain. It loads just fine, I can turn around, watch it fall, but as soon as it would strike the ground, I get an access violation and java tips over. It doesn't happen with boxes, only spheres.

Java 1.6.0 release 3, jME checkout from CVS from a week or two ago.

The error:


An unexpected error has been detected by Java Runtime Environment:


#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77272121, pid=2296, tid=2920


Java VM: Java HotSpot™ Client VM (1.6.0_03-b05 mixed mode, sharing)

Problematic frame:

C  [ntdll.dll+0x62121]


An error report file with more information is saved as hs_err_pid2296.log


If you would like to submit a bug report, please visit:


[error occurred during error reporting, step 270, id 0xc0000005]

I can post source code if needed.

My comp:

  • Vista Ultimate 64 bit
  • Core 2 Duo E6700 2.66 (Overclocked to 3.0, but it tests as stable under various full-load multihour processing tasks)
  • 8800 Ultra
  • 4GB system ram

It seems your terrain mesh confuses ODE. Check that TestGenerateTerrain works fine. If yes, your terrain probably contains degenerated triangles (zero size) or other anomalies ODE cannot handle (bad numbered indices etc.).

TestGenerateTerrain works fine, the ball hits the box and rolls down the hill. I tried a different terrain, and it worked fine. I also tried replacing the terrain with a giant flat box - no crash. I then added a pile (50 or so) boxes with physics that fell on / around the sphere. No crash. So the problem lies somewhere in the interaction between my terrain and the sphere, and most likely in my code. But I don't see any notable differences in how I implement the physics… odd.

Ok, more testing has narrowed it down to some problem with my TerrainBlock that I generate from the heightmap - if I make my own (with an int[]) I don't have the crash.

The relevant code:

URL heightmap_grayscale = loader.loadMap("test2.png"); // loader is my URL loader class. It's confirmed to work just fine.
ImageBasedHeightMap heightmap_heightmap = new ImageBasedHeightMap(new ImageIcon(heightmap_grayscale).getImage());
TerrainBlock terrainblock = new TerrainBlock("terrain", heightmap_heightmap.getSize(), new Vector3f(1f, .1f, 1f), heightmap_heightmap.getHeightMap(), new Vector3f(0, 0, 0), false);

Ok, so after doing the last test, I found out that it just seemed to hold some kind of arbitrary hate for my large (256x256) terrain. I made 32x32 one, which didn't crash. shrug I can still do my final in with a smaller terrain.


codes like an insane person for the next 5 hours to turn in final on time


I am having exactly the same problem. Just to be clear, 256 x 256 is the size of your "test2.png" from which you generate the terrain right??

i.e. making change at the following point in the code:

TerrainBlock tb=new TerrainBlock("terrain",ib.getSize(), new Vector3f(2f,.05f,2f),ib.getHeightMap(),

            new Vector3f(0,0,0),false);

instead of ib.getSize() you put 32(in your case) right?

Even after doing that in my case on collision the box spins wildly and goes in the air and everything flickers… From the current couple of posts on this subject it seems the problem is generating the terrain with imagebasedheightmaps and then trying to use the physics on it…Surely your terrain worked and the others somehow seem to work so would very much like to know what you did exactly!



Exactly same problem here, JRE crashes when a dynamicphysicsnode with a model lands on my terrain. If anyone has any clue please feel ree to share, otherwise I'll keep experimenting around.  :slight_smile:

Ok, so I found a solution for myself, which was kind of obvious  :// , and so I thought I’d share it in case someone else has problems with terrain and models colliding.

The issue at hand was that I was adding my model straight to the dynamic node, and thus I was forced (not sure why, I guess since I didn’t provide model bound settings I was left in the cold by ODE) to use triangle based collision in order for it to actually collide with my terrain ( my terrain was based on a FluidSimHeightmap). This crashed the JRE and was also a real performance killer. Solution was found in the excellent beginner’s faq found here by zathra.

Basically I just made sure to set bounding volumes for the loaded model node, and setting mass attributes for the physics node to which I attached the model. This is the sample part of my code that did the trick:

modelNode = getPhysicsSpace().createDynamicNode();
r1.setModelBound(new BoundingBox());
modelNode.setCenterOfMass(new Vector3f(0.0f, 0.0f, 0.0f));

Set/Update model bound being the key function calls here.
Now I get nice bounding boxes applied to my model, performance is very good, and no further crashes.
Hope it can help some other clueless newbies.  :P