Collision with terrain

Hi,



I want my DynamicPhysicsNode collide with the terrain. Should I use I PhysicsMesh as collider for the terrain ?



I thought I saw a utility class in jME Physics 0.4 for making a tri-mesh collider from a terrain. It seems like it's gone in jME Physics 2. Are you going to implement it again for jME Physics 2 ?



jME Physics is working nicely. So far no problems.  :slight_smile:



Thanks in advance.

Yes, PhysicsMesh is what you need. It's the equivalent to the trimesh stuff in 0.4. Create a PhysicsMesh and call copyFrom( yourTriMesh ).

@irrisor: could You please add a convenience method to add Node's (eg. TerrainPages) to the Physics system (like it was in jmephysics1)?

what do you mean?

@irrisor: sorry nodes work of course (nice design that btw :wink: )  i meant if i add a TerrainBlock or TerrainPage to a PhysicsNode then i get the physics representation computed from the bounds of the object if i call generatePyhsicsGeometry().

In case of Terrain or other irregular meshes however i want PhysicsMeshes as representation and need to get to the TerrainBlocks or TriMeshes myself to call a copyFrom() as You mentioned earlier.

So if i haven't overlooked something here i meant a way to get generatePhysicsGeometry() to make PhysicMeshes instead of PhysicsBoxes in my case.

hmm, that could be done easily, yes. The question is when to generate a PhysicsMesh and when to chose approximation by boundings - it's hard to guess what the application want's there.

At least choosing PhysicsMesh for TerrainPage and TerrainBlock sounds reasonable…

That would be helpful :slight_smile:

how about a generatePhysicsGeometryFromMesh() or make PhysicsMesh.copyFrom() accept Nodes to allow the user to choose ?



edit: and is there a way to get a PhysicsMesh from cloned / shared Geometry ?

Works fine with terrain blocks for me but not with terrain pages - It seems that when generatingPhysicsGeometry from a terrain Page with 4 blocks, only 1 block gets a physical representation ???

I'm busy with this stuff again.  :slight_smile:



I have this now:

        terrainNode = physicsSpace.createStaticNode();

        PhysicsMesh physicsMesh = physicsSpace.createMesh("terrain", terrainNode );

        physicsMesh.copyFrom( terrain );



How can I get a TriMesh from the terrain ? Terrain is a TerrainPage. Should I create the TriMesh manually or is there an easier way to get the TriMesh ?



Thanks in advance.

as far as i know that's an addon contrib made by the ogre community…it's quite easy to make your own geometries with callbacks etc and plug into jme…might be able to get that in if someone has the guts to add it into the odejava wrapper or something



…and yes, that's alot faster and more robust than treating the terrain as a poygon soup…

using the heightfield collider (also a contrib) would be good (I don't know if it uses a callback, though)



If I ever manage to get to it I want to switch to ODE 0.6 and probably add such contribs (and intel-mac support). Adding the native bindings is not the problem. But I guess support for those contribs in the API and testing would require some time…

TriMesh support for TerrainPage is in cvs (including test).



I will take a look into the heightfield stuff now.

doesn't look too complicated but I think I'll do other things first (e.g. design tut)