   3D Line of Sight... Sort of
  I'm part of a development team for a turn based strategy game. It is tile based, but it has a 3D engine, so you can turn the map around 360 degrees, and zoom in/out. Units can move around on this map. It tends to be very hilly. I'm doing the LOS code for the engine. However, I don't know how to do this. Any articles that describe how to do a 3D line of sight function that will allow for hills? Did I just make any sense?   
  The LOS problem should be fairly easy to solve, but you'll probably have to provide us with some more information. From your post I'm not sure if it's strictly tile based (one entire tile has a certain elevation) or more arbitrary (the landscape is a heightmap or mesh of some sort). The LOS algorithm will of course depend on all this, so you might go ahead and provide as much detail as you can about the specifics.   ;  Sorry. It is more arbitrary. The map is determined by a heightmap generated by a plasma style fractal. Anything else that you need to know?   ;  Just a couple more questions. Is the heightmap on a regular grid? And how is the landscape represented internally? Is it stored as a 2d array of height values, or simply as a triangle mesh?   ;  Umm... I beleive that the map is stored in an array of height values. Buildings and other units are meshes however.   ;  Here's a quick answer, but feel free to ask for more details if you need them. Basically you want to raytrace a regular heightfield. The fundamental primitive test here is a ray-triangle test, which you'll need to implement if you don't already have it. I'll say right off that most 'naive' ray-tri tests suffer from some robustness problems and could theoretically result in intersections with the terrain being missed. If this is a concern, it can be addressed by using the tetrahedral volume method for ray-tri intersection and sharing calculations between edges.The next problem will be to apply some sort of broad-phase culling to limit the number ray-tri tests. If you already have a spatial partitioning scheme in place (such as an octree or quadtree), you could use that for intersection culling as well. Another effective method is described here; this method involves stepping through the heightfield grid using DDA, and performing any necessary ray-tri tests along the way. This method has the advantage that it processes hits in order and can therefore bail as soon as a hit is registered (good for line of sight of projectile collision).Let me know if you need any other info.   ;  an example in code3DDDA.cppDXInputs.cppDXInputs.h