   terrain engine problem
  Say the player is standing on a given field on my terrain. I want to be able to check wether he can see a given other field of the terrain or if its blocked by a mountain. So basically a function that takes in the terrain coordiantes of two tiles and returns if theres a clean line of sight. Any ideas how this could easily be done?-CProgrammer 
quote:Original post by CProgrammer  Any ideas how this could easily be done?You can start by reading some of the N topics on the same subject. Or even searching on google. You should never let your fears become the boundaries of your dreams. ;  not real sure but a a guess would be something likecalculate the equation for a line between where you are and what you are trying to look atnot mathmatically advance in increments from your current location to that location (the increments cant be too large or it might miss something and they cant be too small or this would run way too slow)anyways...each step along the way see if the height of the terrain at that location is higher then your "seeing height" and if it is then you cant see what is behind it "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  It''s called occlusion culling. ;  Yes its similar to occlusion culling but it must be precise. I dont want to find as many non visible tiles as posible. No just find out if a specific tile is visible from another tile. Its not for culling or shadows, but for gameplay.-CProgrammer ;  Is ray casting an option ? ;  Well I dont want to invest to much time into this part, so if theres an easy and fast solution i''ll take it. If theres a good raycasting way to do it please share it with me. Till now I could make a line between the tiles and then go through all tiles in between with some line algorithm and see if the height is greate than the line height at that position. But I cant seem to get a grasp on this method.-CProgrammer ;  Sorry, but I''ve no magic method that could easily solve the problem of visibility There should be methods that speed-up raycasting if your terrain is based on a heightmap, but it will still involve a lot of tiedous intersection tests and the use of a spatial partionning structure. Your line-based approach is probably better (though, after all, it IS a form of raycasting). ;  i will try to explain what i was saying but in 2d because i can draw ascii 2d *|   ***    *| ******* ***=======================  the thing on the left is your character and the top of it is his "eye height"the next object is a hill/mountain/something you cant see throughthe next object is a hill/mountain/something you cant see throughnow compute the equation of the line from your "eye height" to the top of the second "hill" as a parametric equationfor (float t = 0; t <= 1; t += small_amount)now each time through this loop plug t into the equation....and also get the height of the terrain at that locationnow if the height of the terrain is greater than your solution for height in the parametric equation then that terrain blocks your view of the hill behind iti am not going to explain parametric equations here if you dont know what they aresomeone else can or google it   "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA   [edited by - ncsu121978 on February 6, 2004 7:12:01 AM];  Yeah that sounds like a good solution, that way I dont have to use a line algo. I''ll do that, thanks.-CProgrammer 