Zinger August 09, 1999, 11:00 PM 

Seems like an easy solution. Maybe, I am missing something here. If you are using a bitmap to store your heightfield information then the collision calculations are easy.
Let's take a simple case where there are gradual changes in the terrain. Maybe there are a few hills. In this case there are no obstacles that could prevent you from traveling from point A to point B.
void Navigate::cameraPosition( const D3DVECTOR& delta ) { // add delta to current camera position. vectorAdd( &m_cameraPos, &m_cameraPos, &delta );
// calculate your height and set it! hfBitmapHeight basically just indexes into the bitmap // and retrieves the height at position ( x, z ) to give you height ( y ). m_cameraPos.y = Terrain::singleton().hfBitmapHeight( m_cameraPos.x, m_cameraPos.z );
// now you need to add your eye level here. Your eye level is not at ground level. :) m_cameraPos.y += m_viewingHeight; }
Obviously, this last method would allow you to walk over tall walls with sudden abrupt changes in y direction. So now you just need to modify it so that so you can check based on some delta whether you can go in that direction.
void Navigate::cameraPosition( const D3DVECTOR& delta ) { // candidate position D3DVECTOR pos = { m_cameraPos.x + delta.x, m_cameraPos.y + delta.y, m_cameraPos.z + delta.z };
// retrieve current height float currentHeight = Terrain::singleton().hfBitmapHeight( m_cameraPos.x, m_cameraPos.z ); float candidateHeight = Terrain::singleton().hfBitmapHeight( pos.x, pos.z );
float dy = fabs( currentHeight  candidateHeight );
if ( dy > So first I set about calculating my turning angles. When I rotate, I simply Translate the X coordinate by 1.0 or 1.0. I made an angle variable, a float. I find that each rotation of 1.0 (or 1.0) is ~ 90/15.7 But of course this isn't incredibly acurate, because if you turn around enough times you discover that it's not truly a correct value. BTW, this is all out of 360 degrees. Anyway, It works fair enough for me to try what I need, you'd have to turn around about 50 times to see the problems. Well, I have a D3DVECTOR Velocity declared, and I update it each time I move forward by increasing the z value. I also have an X and Y value stored as the coordinates of my viewing point. so each time i update the position, I change them as follows: >> >> x=sin(0.0174532925*angle)*Velocity.z; >> y=cos(0.0174532925*angle)*Velocity.z; >> >>that big float happens to be pi / 180. Now, this seems to work fine, but I decided to test it's accuracy by coloring the triangle I am standing on, and it's not accurate in the least! It's all driving me crazy, and I've decided to scrap that pile of junk and do it the right way. How do i do it the right way! I figure that I'll need to do it realistically, aka instead of incrementing a float each time I rotate, have the angle actually be directly related to the rotation. And I'm pretty sure I need to get those coordinates of the viewing point, so Is there a good way to do this? AHHH! This is all madenning!
