Uneven terrain

I have looked through the Roaming Ralph example and I believe I understand how to move on uneven terrain with someone as simple as ralph, but what about with something like a car. I want to tilt the car so that it appears to drive up the hill, not just move the front up and have the back end float in mid air. Any suggestions on how I’d go about doing that? Thanks in advance for any assistance.

You could have four collision rays, one for each tire. From the top-left going clockwise you have collisions A-D. The cross product of the vector AC and BD will give you the vector to orient the car model to. The midpoint of AC or BD will give the position to set the car model, given that the origin of the model is in the center of the tires.

Ok, I have a significant portion of the game worked on, and I have a plane made now. How do I normalize the Actor to the plane? I feel this should be easy, I’m just not sure.

If you have the normal of the plane as a vector you might be able to do carNode.lookAt(carNode.getPos() + vector.forward())

I used self.player.lookAt(self.player.getPos(), v3) , but now it ignores the fact that I am turning the object. when I use self.player.setH(self.player.getH() + elapsed*150) it now ignores that. I tried to get around this by taking the h beforehand and adding it to the h afterwards, but that screws with everything and it no longer tilts in the right direction. Any suggestions?

Is there a way to just tilt the model according to vector, otherwise if you drive straight into a hill, it work fine until you turn and the car keeps it’s rotation angle and just turns round its axis, so you end up with the rear of the car in the hill and the front in the air. Can I just normalize/align the car to the vector?

I really appreciate your help thus far, it has helped immensely on the project, so any further help would be greatly appreciated.

What about using the lookAt method and using this for the H instead:

self.player.setH(self.player, elapsed*150)

You could also use the headsUp() method instead of lookAt(). This method is very similar but has a preference to line up the up vector first, and then brings the forward vector into line as nearly as possible (as opposed to lookAt(), which has the opposite prefence).

Then you just do something like:

self.player.headsUp(self.player, Point3(0, 1, 0), planeNormal)

where planeNormal is a Vec3() that contains the normal (up) vector from your ground plane at the point at which your player is standing.

David

drwr:

That headsUp works great except on some hills/angles it changes the heading for some reason - and I can’t change it by trying to turn the model left or right manually by keyboard; without moving it off the current colliding triangle first.

Do you know what I’m talking about and have a solution?

true, it isnt that tricky. thats a solution, how i figured out solved this problem. i wished i had red your post before, the crossproduct way sounds much faster.

i was doing also for each tire a collision ray (i know i have to spin them in relation to the car orientation, i havnt done this so far, but its for sure not that tricky) and just getting out the radians between. (i know that should be overworked and i will do this soon)

[url]eatMORE]

hope that helps