Terrain(Block|Page) + car troubles

Probably there’s something wrong with your ODE parameters, like CFM and ERP. Did you try changing them? I did this example from my experiences developing Dirty Racers (http://www.jmonkeyengine.com/jmeforum/index.php?topic=5850.0) and I actually use a TerrainPage there… Generating the triangle accurate physics geometries directly from this TerrainPage.



I had this kind of problems when adjusting the number of contacts per near callback. Try looking at this threads:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4863.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4889.0



I’ll advise you to read ALL the posts, since there’s a lot of useful information on them. I think this is everything that’s been posted here about car simulations. Try looking at Kine’s topics as well. The test you based your car on is the compilation of all these discussions so far.

I just tried to change them, but it doesn't help. Also tried adjusting Odejava.setMaxContactGeomsPerNearcallback(200000);, nothing.



I think there's a problem with TerrainBlock/Page and BoundingSphere/Capsul. If i change the wheels of the car, giving them a BoundingBox with wheel.createBlock("something");, it seems to work fine (obviously the car doesn't drive anymore :slight_smile: ).



if i replace the createFloor function in TestAdvancedVehicle with


       FaultFractalHeightMap ib = new FaultFractalHeightMap( 257, 32, 0, 255, 0.75f, 3 );
       
       TerrainPage tb = new TerrainPage( "Terrain", 128, ib.getSize(), new Vector3f(10f,.1f, 10f), ib.getHeightMap(), false );
       tb.setModelBound(new BoundingBox());
       tb.updateModelBound();
       
        StaticPhysicsNode floor = getPhysicsSpace().createStaticNode();
        floor.attachChild( tb );
        floor.generatePhysicsGeometry();
        floor.setMaterial( Material.CONCRETE );
        floor.setLocalTranslation( new Vector3f( 0, -0.1f, 0 ) );
        rootNode.attachChild( floor );


it crashes.

If i replace the terrain with the terrain from TestGenerateTerrain (and use an unmodified Car), it doesn't crash, but there's no grip at all, the car just drifts over the surface and somtimes it looks like one of the wheels get stuck in the ground.


edit:
i'm not sure why, but for some reason it just suddenly works :? I think it has something to do with the heightscale of the terrain

Hi there,



I am having the exact same problem with my program. Could you tell me what did you change in your terrain? I think this is general problem using physics with terrains generated from imagebasedheightmaps? I generate my terrain as follows:




private void buildTerrain()
    {
       
        display.getRenderer().setBackgroundColor(ColorRGBA.blue);

        URL grayscale = Ares.class.getClassLoader().getResource("jmetest/data/texture/image.png");

        URL waterImage=Ares.class.getClassLoader().getResource("jmetest/data/texture/wall.jpg");
        URL baserock =Ares.class.getClassLoader().getResource("jmetest/data/texture/cloud_land.jpg");
        URL highest=Ares.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg");

        ImageBasedHeightMap ib=new ImageBasedHeightMap(new ImageIcon(grayscale).getImage());

        TerrainBlock tb=new TerrainBlock("image icon",ib.getSize(),new Vector3f(2f,.05f,2f),ib.getHeightMap(),
            new Vector3f(0,0,0),false);

        ProceduralTextureGenerator pg=new ProceduralTextureGenerator(ib);      
        pg.addTexture(new ImageIcon(highest), -128, 0, 10);
        pg.addTexture(new ImageIcon(waterImage), 40,80,128);     
        pg.addTexture(new ImageIcon(highest), 110,180,256);
        pg.createTexture(128);                       

        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));
        terrainNode.attachChild(tb);
        terrainNode.generatePhysicsGeometry();
        scene.attachChild(tb);
    }



Its standard code for terrain generation from imagebasedheightmaps - like in tutorials(HelloTerrain.java).

Many Thanks,

Dev

I really don't know why it suddenly works, but it isn't the heightscale.

I did notice alot of random crashes are caused by a "physics overload" on the first update. Inserting a call to update(0), at the last line of the initGame() function seems to improve stability.

From my experience, the problematic line is:



generatePhysicsGeometry(  );



My own code also crashes at the start of the game if I use generatePhysicsGeometry(true) on a given node  :?.




It

Same for me !



… the same program works under linux buts fails with the ntdll.dll error under Xp …

If I recall correctly, I also got an EXCEPTION_ACCESS_VIOLATION when generating triangle accurate physics on a node that was actually flat (this is, it extended only for two axis, being all the Z coordinates 0). I think ODE didn't like that, which anyway makes some kind of sense, although ODE should drop a clean exception instead if that's the problem.