[Edit]
Obese87 reminded me of a much simpler way than what I wrote previously. I've left it in the post so you can look at it if you want, but here's a very easy way:
Your obejct or the camera has an initial height above the terrain. Create a PLAIN object whose y value is twice the height of the camera (in first person) or twice the height of your object that will traverse the terrain. So if your objects y position was 30, you'd create a plain like this:
MAKE OBJECT PLAIN <num>,.1,60
set object collision on <num>
set object collision to boxes <num>
Next, set your terrain to polygon collision:
SET OBJECT COLLISION ON <terrain>
set object collision to polygons
Now, set the plain to the same position as the object. When ever the object rotates, rotate the plain. When you are going to move the object, move the plain first. Test for collision where the plain is. In a loop, move the plain up until there is no collision. As an ELSE clause, move the plain down until there is collision. This will be the ground height (depending on your increments). After the loop, position the object where the plain is and stop all collision detecting until you are going to move again.
[Original Post]
Quote: "With that, how do I decide which vertex I want? I looked on these forums and on google, but came up empty handed..."
Now that is the trick! If you've created your landscape out of a grid in a 3d model program, how does one know the order of the vertices? Is vertex number one in the lower left hand corner or is somewhere else completely? When going through a memblock, the vertices are ordered, of course, but their order doesn't necessarily correspond to the actual position in 3d space relative to the objects size.
I've been working on this problem and have a couple of possible solutions.
1) Get the size of your object in the x and z direction. Divide each direction by the number of tiles you want to store in your array. For example, a terrain that is 10000 x 5000 units, you might divide it up into 25 x 10 tiles. So that means there are 400 units per tile in the x direction, and 500 units per tile in the z direction.
1b) At each tile intersection (every z units by x units) use a small box (like .1 x .1 x .1) or some other small object (a plain rotated 90 degress flat would be best) and move it up or down in the y direction until you detect collision. This is the height at that position. Record the position and the height in your array.
2) Memblock - even if you don't know the order of the vertices, a standard terrain generally runs in the x and z directions with the height in the y direction. If you go through all of the vertices in the memblock, you can create your own order in the array based on the x and z value.
For example, just looking at a terrain, if the coordinates of the first 4 vertices were in this order in the memblock:
(2,1,2)
(1,10,2)
(3,2,0)
(3,2,1)
We can make a couple of determinations. The lowest x is 1, the highest x is 3, the lowewst z is 0 and the highest z is 2. The scale between x and z values seems to be 1. There are only 3 different x values and 3 different z values. This suggests that terrain size is 2 x 2 (the vertices are always 1 more than the cell size so the vertice dimensions would be 3x3)
The idea would be to go through all of the vertices in the memblock and put them in order according to lowest to highest in our array, and at those coordinates use the y height. Since the indexes of an array are not allowed to be floats, you'd convert that later using the scale between values to match against a legitimate x and z position.
So the array (based on this example) might look like:
dim array#(3,3) : rem assuming z is first then x
and the values from our small sample:
array#(0,3)=2
array#(1,3)=2
array#(2,1)=10
array#(2,2)=1
In short, you have to establish the order of vertices based on world positions and store them in an array. That way you can match your position to the array indexes and return a height.
3) You can also use the face information from the memblock. However, you'd still have to figure out which face you are over, calculate the face normal, then using the dot product, you can calculate the height of your position. A bit more complicated but it would be accurate if done properly. It would also eat resources and is better left up to a dll.
Enjoy your day.