Sorry John, I couldn’t get it working. It is getting alot of weird results.

From what I could gather from your last post. I came up with this for [a]…[d]:

```
int ha = HeightMap[posX][posZ];
int hb = HeightMap[posX + 1][posZ];
int hc = HeightMap[posX + 1][posZ + 1];
int hd = HeightMap[posX][posZ + 1];
```

Then you came up with your final equation for h and I substituted my numbers into it and it came out like:

```
h = xpos * ((hc-hb) * zpos+hb) - ((xpos-1) * ((hd-ha) * zpos+ha));
```

Where xpos is your x and zpos is your y. I then set the Y of my ‘camera’ to the result of h.

But I am not sure whether you are using [a]…[d] as the height data themselves, or as just the points, eg: [a]=(x,y).

I’ll take a closer look (currently school holidays and haven’t done much maths recently). Hopefully I will get it. But I believe I get what you are on about.

*Just tried it the long way and am getting the exact same results. I must be doing something wrong in the [a]…[d] section. Really not sure at this stage…

**Just tested it in 2D, I have narrowed the problem down to how it is displaying the height. When it does a downward slope (m is a -ive value), the point where the camera is going to be is inverted. So instead of a positive number, it becomes a negative, like a reflection. Also, when I have a slope of 1, everything works fine going up hill, but when it gets higher, the point moves too hight above the needed point. Here is the code I am using for this:

```
float h1;
float h2;
int posX = xpos;
float m;
float c;
h1 = Map[posX];
h2 = Map[posX+1];
m = (h2-h1);
c = h1;
newypos = (m * xpos) + c;
```

Where the Map positions are randomly generated on startup, xpos starts at 0 and is increased at 0.1 intervals.

Then to display it I am using:

```
camera();
enable();
glColor3f(0,1,0);
HeightMap();
glPushMatrix();
glPointSize(3);
glColor3f(1,0,0);
glBegin(GL_POINTS);
glVertex3f(xpos,newypos,0);
glEnd();
glPopMatrix();
```

Where ‘camera’ sets up the newypos.

I am thinking maybe I need a variable that ranges between maybe 0 and 1, that resets everytime I hit a new ‘key height’ to count how far along the selected slope I am.