Terrain following and collision detection

Hi again,

dunno whether this is the right place to ask, but I simply try.

I’m still trying to find out, how I can solve all those things coming up in my mind which could be obstacles in my way towards the game, that I’d finally like to implement. My current issue is as the heading says.

I will have a tile based map. That means, that a map will consist, seen from the y axis, of square tiles of the same size. Seen from the x-z plane, some could be flat, others could rise like a ramp by fixed values in one direction. Additionally I will have vertical walls. My cam is set up in 3rd person view, following the players avatar using a cam node.

Now I need two things. I don’t want to run into walls → collision detection and I want to follow the ramps or fall down at a ledge → terrain following. In reaction to movement action from the keyboard I will first predict, where the avatar is going, then do a collision detection, adjusting the movement so I don’t bump into walls and after that I will do terrain following by picking the tiles from the corner points of the avatars bounding box and adjusting the height. Sounds reasonable to me up to this point.

Now comes the question: would it be a good idea to arrange the scenegraph in a way, that all vertical walls are beneath one node and all tiles beneath a different one in order to minimize calculations? I’m planning to write some test prog anyway, but if you have experiences already, I would appreciate if you share it with me. Thanks in advance for any answers.

This is sort of what I’m trying to do. Have a camera follow my Milkshape model and then register collisions with particular objects to produce different things e.g. a particle explosion or a GUI dialog.

At the moment jme has no phyiscs so proper collisions won’t happen unless you figure out how to use ODE with jme.

To cheat a bit I used TerrainBlock.getHeight(X,Z)+offSet to place my camera on my terrain & then to keep my camera from going through my terrain I put the following in my update() method:

if(cam.getLocation().y < TerrainBlock.getHeight(cam.getLocation().x, cam.getLocation().z) + 15)

cam.getLocation().y = TerrainBlock.getHeight(cam.getLocation().x, cam.getLocation().z) + 15;

I’m not having much joy with the collision at the moment & Dark Prophet is very knidly helping me (see total noob app #2 thread).

After I have this sorted I was going to go on the the trackingcontroller type behaviour for my Milkshape model, mojo gave me some hints (see total noob app#4).

Hopefully we can figure this out together.

Well, actually I do not plan to use the Terrain classes but create the map from my own structures. This may be giving me some limitations, but I do not plan to write some general stuff anyway. I just want to optimize the code for the type of game I’d like to implement.

2nite I will start implementing a test prog for a replacement of the KeyNodeXXX classes, as I need a place to plug in my movement prediction/collision detection code. Once I got this working, I’ll start looking into the collision detection stuff and maybe then I’ll begin to understand the issues in the thread that you have mentioned. XD