   Intersection \ Is Point Visible
  Hello,I been searching how to check if PointB is visible for PointA.All i find is intersection check with mesh and thats now what im rlly searching.How i can check if PointB is visible for PointA VS a terrain map ? (Vertex and Indices).Thanks alot for any help.   
  There should be an example of mesh picking in the SDK. If you check intersections between PointA and all your meshes, and keep track of the minimum distance for any hits, you can compare that minimum distance to the distance between PointA and PointB.Is that what you're asking?;  I forgot to mention it, i need check if PointA can see PointB and check them against Vertex and Incdices (terrain map).I dont have any mesh here.   ;  If I understand you correctly, you have an indexed vertex buffer for the terrain. You're trying to determine if a line from point A to point B intersects the terrain before it reaches B. Is that correct?If that's correct, testing may be somewhat expensive computationally.Basically:1. Determine the equation of the line from A to B.2. For every triangle in the terrain, determine the equation for a plane containing that triangle.3. Test whether the line intersects the plane. If so, determine the point of intersection.4. If the line intersects the plane, test whether the point of intersection with the plane lies within the triangle.There are two tests you can make to determine if the point lies within the triangle:a. a crossproduct test - simple to understand but requires more calculationsb. a Barycentric test - faster calculationsWhen you find an intersecting point, test whether the distance from point A to the intersection is less than the distance from A to B. If it's closer, you're done and point B can't be seen. If not, you'll have to continue the testing until all triangles have been tested.To find techniques for doing all that, you can google for "line intersects triangle" and "point within triangle." There are a lot of references for both subjects.   ;  Yes, thats correct.So you actually saying that i have to make a line from A to B and check each point of the line if the lie in one of the triangle of the terrian, i need to do it each frame. thats going to kill the cpu for sure isnt it ?   ;Quote:Original post by yoni1993Yes, thats correct.So you actually saying that i have to make a line from A to B and check each point of the line if the lie in one of the triangle of the terrian, i need to do it each frame. thats going to kill the cpu for sure isnt it ?What do you mean by "check each point of the line"?  You need to check each triangle in your terrain, and see if the line intersects it.  You should use an octree, kD tree, or some other structure to accelerate these tests.;  A line is an array on points. It's what i mean.   ;Quote:A line is an array on points.For intersection testing as described above, no. A line is an equation.Quote:thats going to kill the cpu for sure isnt it ?It certainly depends on the size of the terrain and how much data you prepare ahead of time.For instance, plane parameters for each triangle can be calculated ahead of time and stored.You may also be able to derive some culling methods to reduce the number of tests. You could divide the terrain up into sections and determine if the direction of the line intersects a particular section. If it doesn't, you don't need to test any triangles in that section.You can calculate ahead of time the maximum elevation for a section of terrain. If point A and point B are both above the maximum elevation for a section, you know the line won't intersect any triangles in that section.As smitty mentioned, you may be able to use an octree or other method for dividing up the terrain to use to cull sections from the testing of individual triangles tests. E.g., store the maximum elevation for various sections of terrain in an octree. Progress through the octree (which itself eliminates sections of terrain not in the direction of the line), testing the minimum elevation of the line (from one side of that section to the other side) against the maximum elevation of a section of the terrain.   