StaticPhysicsObject constructor for Spatial

What is the intended method of creating a PhysicsObject for TerrainPage right now ?

I think StaticPhysicsObject should have a Constructor that takes a Node (TerrainPage) and use it to create the StaticPhysicsObjects of the TerrainBlocks ?

Well, we had this feature since 0.3 for terrain pages:

ArrayList staticGeoms = com.jmex.physics.util.PhysicsUtilities.createStaticPhysicsObjects(page);

Iterator it = staticGeoms.iterator();
while (it.hasNext()) {
  Geometry geo = (Geometry);
  StaticPhysicsObject obj = new StaticPhysicsObject(geo);

But i do agree with you, if we are having DynamicPhysicsObject take a spatial, then StaticPhysicsObject should too. Consider it done for next release.


Thanks, then i’ll go playing with the iterator in the meantime :slight_smile:

Ok, i played a bit and it seems as i can’t get Physics to work correct with a terrain page.

Near the center of the page all seems well but as i get off the center, objects beginn to pass through the terrain. (seem to happen at boundaries of terrain blocks)

The same image based terrain works well as a terrain block.

I do the same in both cases except to create model bounds for each block of the terrain page as i already get them from the util as an ArrayList of StaticPhysicsObject

(and it doesn’t help too) :?

I know this is going to sound alot and stuff. But could you perhaps make us a test case? That would be appreciated.


sure thing, but could take a little while

Ok, i took jmextest.physics.TerrainTest as a starting point and simply changed the following lines in initTerrain:

        Vector3f terrainScale = new Vector3f(10f, 1f, 10f);
        // Create a terrain block from the image's grey scale
        //      TerrainBlock tb = new TerrainBlock("image icon", ib.getSize(),
        //            terrainScale, ib.getHeightMap(),
        //            new Vector3f(0, 0, 0), false);
        //      tb.setModelBound(new BoundingBox());
        //      tb.updateModelBound();
        TerrainPage tb = new TerrainPage("Terrain", 16, ib.getSize(), terrainScale,
                ib.getHeightMap(), false);


        //        world.addObject(new StaticPhysicsObject(tb));
        ArrayList staticGeoms = PhysicsUtilities.createStaticPhysicsObjects(tb);
        Iterator it = staticGeoms.iterator();
            StaticPhysicsObject sto = (StaticPhysicsObject);
            Geometry geo = (Geometry)sto.getSpatial();
            geo.setModelBound(new BoundingBox());

it also doesn't work if i don't set new ModesBound's on the blocks
i also changed the grayscale image used to be 2^n+1 (65x65 in this case)
I am running on linux and have the from the sourceforge page (could you please put it in cvs ?) and jme and lwjgl lib's from current jme cvs

The image builds a terrain page with 8x8 terrain blocks and shows a large crater in the middle and flat land surroundign it.
The created objects (balls and boxes) come down and pass straight through the surface.
When i experiment with the ballthrower however i note that balls go through the surface on all terrain blocks with the exception of the middle 2x2 terrain blocks.
And moreover if i shoot through the crater wall at the inner blocks the balls also get reflected back through them.
If You give me a location i can provide the image but i really dont think it's the culprit as it works when used with a single terrain block.
... and did a quick test ... wenn i build a page with only 4 blocks then 3 of them reflect and one (right, near to viewer) does not 8-O
If You need more information just ask !

edit: ok found another oddity - there are some triangles in the otherwise correctly behaving terrain blocks that let also pass balls ? mostly long thin ones (steep sloope) but not all eg the neighboring triangles that are equally stretched reflect correctly

I think this is happening because we extract the TerrainBlocks from that TerrainPage, and then tell ODE that their position == their local translation, which might not always be the case due to that TerrainPages can contain other TerrainPages. We should really be using the world translation…

The reason we’re not doing this is because the world translation gets computed only if updateGeometricState has been called on the Node (the TerrainPage), which might not always be the case.

We need to come up with something clever here, e.g. call updateGeometricState on all incoming Spatials, and then use the world translation!

All this is very strange though, since a while back I was using TerrainPages with no problem… :?

Anyhow, this should be working soon - I have no time atm.

ok found another oddity - there are some triangles in the otherwise correctly behaving terrain blocks that let also pass balls ? mostly long thin ones (steep sloope) but not all eg the neighboring triangles that are equally stretched reflect correctly

Yup - I've seen this in the TerrainTest as well... very strange! Might have something to do with the step function that is being used. Maybe worth to investigate...

Thanks, looking forward to the fix :slight_smile:

I’ll play a bit with the step function when i get to it…

Ok, can i suggest that you supply ODE with a bigger triangle version of your terrain? I.e. a smaller image file that has been scaled up to be the same size as the terrain. Then render the terrain page instead of the terrain block. ODE is really strange, it can’t have triangles that are too big, and it can’t have triangles that are really small…

Anyways, i think i know how to solve this, i’l see if i can implement it soon.


ok, i played around with stepSize a bit and it seem to solve the passing through triangle issue if set small enough.

But then the simulation slows down heavily.

I managed to find a value (1.5f/100f in my case) where i was able to sometimes shoot balls through a triangle and sometimes not.

This doesn’t solve the terrain blocks missing in phys world issue of course.

ok, back on topic…added Spatial constructor.

Took a while ://