Problem using the jMonkey terrain editor (solved)

Hi.

In my actual demo level I decided to use the terrain editor from jMonkey because it is easier to handle than Blender. Both ways blender vs. jMonkey have their advantages. But right now I am experiencing some problem with my terrain. I added textures, collision detection, a skymap and stuff and I can walk in my area. But on some places my player (3rd person game) gets stuck in front of some invsible wall. I have to walk around those places and keep on moving some other way. I keep asking why and how to avoid it. The places are reproducable always at the same places, even after game restart. But the terrain editor doesnt show anything there. How could I go on with error handling / debugging here?

Thanks in advance for tipps.

here is a screenshot



http://www.pic-upload.de/view-10472896/screen.jpg.html

Ah. So you are generating a MeshCollisionShape in this case. Make sure you supply the base Terrain spatial to the createMeshShape method, then a HeightMapCollisionShape is generated that suits terrain better. Theres actually invisible mesh data on terrain. Or just generate it in the editor right away:



http://www.youtube.com/watch?v=-kRz4bOV3wo



Then you just have to add the rigidbody to the physics space after loading:

[java]Spatial model=assetManager.loadModel(name);

physicsSpace.addAll(model);[/java]

Probably you edited the terrain and did not update the collision shape? Just regenerate the RigidBodyControl for that terrainquad.

i am adding the rigidbody control programmaticaly, didnt add it within the scene in the editor.



[java]

sceneModel = assetManager.loadModel("Scenes/levels/testlevel/testLevel.j3o");

sceneModel.setLocalTranslation(0, 0, 0);

sceneModel.scale(20);

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);

RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);

sceneModel.addControl(landscape);

rootNode.attachChild(sceneModel);

bulletAppState.getPhysicsSpace().add(landscape);

[/java]

first of all thanks for your anwer. unfortunatelly that solution just made collision detection for my player model worse. i added physicscontrol just like in the video (my terrain has testlevelpatches instead of sub - terrains , that is a difference between my screenshot above and your video. dont know if that matters). and i made the following code changes:

[java]

sceneModel = assetManager.loadModel("Scenes/levels/testlevel/testLevel.j3o");

sceneModel.setLocalTranslation(0, 0, 0);

sceneModel.scale(20);

//CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);

//RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);

//sceneModel.addControl(landscape);

rootNode.attachChild(sceneModel);

//bulletAppState.getPhysicsSpace().add(landscape);

bulletAppState.getPhysicsSpace().addAll(sceneModel);

[/java]

i was able to walk some meters, but then fell through the floor :frowning: i am trying to get this HeightMapCollisionShape stuff to work programmatically, maybe that changes things.



update: hm CollisionShapeFactory cant create heightmapcollisionshapes…

tashtego said:
update: hm CollisionShapeFactory cant create heightmapcollisionshapes...

Yes it can.

So you are using grid terrain or what? for that this is a known issue..

sorry i dont know what a grid terrain is. i simply said “new scene” … added a flat in the terrain editor and edited it in the editor. how can i find out wether it is a grid terrain and what different kinds of terrains there can be?



when i do CollisionShapeFactory.create… and do autocomplete, netbeans shows me only the methods

  • createBoxShape
  • createDynamicMeshShape
  • createMeshShape
  • shiftCompund…



    no heightmapcollision there.

ok now my terrain is completely destroyed… .did a revert changes on subversion, did clean and build, nothing helps, now i can throw away the whole file and start again… :frowning: whyever… maybe there are data files that are not being versioned in subversion (for example j3odata isnt shown in jmonkey sdk, but its in the filesystem. deleting and regenerating this one didnt help either). :((…



attaching it if you like to take a look.

http://www.file-upload.net/download-3539690/testlevel.scene.html

http://www.file-upload.net/download-3539691/testLevel.j3o.html

Not possible if you really had everything in svn. The project manages itself when commiting (e.g. what files to omit and what not)

ok i found at least this problem :frowning: i changed the order in the addScene method for the method calls. the bulletappstate call must be the last one, after translation, scale and other stuff (see above). now i at least am back at my old state with the collision problem. but can you tell me plz more about heightmapcollisionshapes, grid terrain and why i cant use the factory for that? thank you very much normen!!!

Because you are using a feature that has just been added and is tested right now, please refer to the existing threads.

i cant know what features are new and which are not :frowning: as good as everything i used so far stood in some of your tutorials :frowning: heightmapcollision… not. so i didnt yet use it. tried searching for that in the forum and read the heightmap tutorial again, didnt really help me.

but i found out why your example doesnt work for me. as soon as i call the scale method on the sceneModel it makes problems. the addAll method for bulletAppState does what it should do, but it is ignoring scale. and it doesnt matter if i scale before or after the bulletAppState call.

update:

http://hub.jmonkeyengine.org/groups/physics/forum/topic/physics-control-scale/

ok at least here searching helped. trying to check that out

update2:…whatever :frowning:



update3: … checked it finally … solved! the properties let the developer change scale in the terrain editor too. so i dont have to call the scale method. and now the collision detection works like a charme!! sorry that it took me so long!

I have this same problem and haven’t done any scaling. I simply made a flat 256 size terrain in terrain editor (with raise, lower and smooth tools), followed the video to add RigidBodyControl and used:

[java]Spatial terrain = assetManager.loadModel(“Terrain/myScene.j3o”);

rootNode.attachChild(terrain);

physicsSpace.addAll(terrain);[/java]

(After trying the usual programmed way)




There is nothing particularly nasty about the terrain either, just a few hills, but at random places there are invisible hills, if you get what I mean. perhaps the smoothing tool (at a guess) is a bit buggy.

Any ideas?

What problem?

Sorry for late reply, haven’t been checking my email. I was referring to the “invisible walls” in some places on a terrain I created. These seem to have gone now that I’ve tried using a flatter terrain - not as hilly.