Hi Alien,
Well, I went through your source a little bit more. Your method is different enough from mine that it didn't really help solve my problem.
I was however able to solve the problem with mine. Two variables: height and width, were just a little short - so everytime through the loop, the matrix size got a little smaller. The error doesn't really show up until the terrain gets bigger and bigger by which time the little errors have added up into BIG errors.
I've included an updated demo.
Well, it's fixed - and now any size bitmap will generate a terrain. I have to modify and add a few things:
1. Texturing
2. Using non square matrix dimensions
3. Applying the technique to objects so instead of matrices I can use shapes that can be saved
4. Finish my dirext x exporter function to add the ability to save a terrain as an x file
I hadn't even thought about a bump map progran until you wrote this thread. I always pictured it as a complicated and unfriendly process, but it's actually pretty easy! It's just the fine tuning that's tough.
Anyway back to your source: there seems to be a lot of redundancy - the same thing keeps being done over and over again. Why does it seem that you reposition the player every time a new matrix is crossed? Then the matrix is updated...
Doesn't the player just move in 3d space, not really relative to the matrix, so it's position would always be in relation to the 3d world?
I suppose to get the y height of the car, you need to get the ground height of the matrix underneath the car but that could be solved with something like the following if your first matrix started at 0,0,0:
rem psuedo code
matrix across = int(current player position/matrix x size)
if (current player position/matrix x size) > matrix across
inc matrix across,1
endif
matrix updown = int(current player position/matrix z size)
if (current player position/matrix z size) > matrix updown
inc matrix updown,1
endif
what matrix are we on = matrix updown * matrix across
Then multiply updown*matrix z dimension and subtract that from the world z coordinates to get you matrix z position.
Do the same with the x and you've got your matrix x position. Now you'd have your matrix number, your x and z to solve for y ground height.
[Edit]
Once again I'm getting uploading error messages. I'll have to try again later.
Enjoy your day.