Original Post
🔒 Locked
Terrain Picking
Advertisement
There are different ways of doing this, most of which will break down to a narrow phase and a broad phase. The broad phase involves identifying the candidate triangles, and the narrow phase involves finding the exact point of intersection.
If these topics are new to you, you might just start with a brute-force broad phase so that you can focus on getting your triangle picking function working. If your terrain is large it may be painfully slow, so you might try experimenting using a smaller data set.
There are lots of references on triangle raytracing online, although many ignore certain numerical pitfalls which can result in missed intersections when a ray fall between two triangles.
Feel free to ask if you need further details on any of these topics.
If these topics are new to you, you might just start with a brute-force broad phase so that you can focus on getting your triangle picking function working. If your terrain is large it may be painfully slow, so you might try experimenting using a smaller data set.
There are lots of references on triangle raytracing online, although many ignore certain numerical pitfalls which can result in missed intersections when a ray fall between two triangles.
Feel free to ask if you need further details on any of these topics.
jyk, he mentioned that he just has a 2d grid, so there is no need for the broad phase if he plans on keeping the terrain always a 2d grid. Though, Tauqeer, if you do plan to eventually make this into a height map representation then you'll need to re-evaluate how you'll want to solve this.
For finding out which cell a ray intersects in a 2d grid what you can do is first calculate a ray to plane intersection. Then, if it intersects the plane, calculate point inside AABB. If it is inside the AABB, then take the offest into the AABB and hash that into a 2d array coordinate.
If you have any questions on any of these steps then ask and I'll go into further detail.
- Dave
For finding out which cell a ray intersects in a 2d grid what you can do is first calculate a ray to plane intersection. Then, if it intersects the plane, calculate point inside AABB. If it is inside the AABB, then take the offest into the AABB and hash that into a 2d array coordinate.
If you have any questions on any of these steps then ask and I'll go into further detail.
- Dave
Quote:I read 'just a 2d grid' as 'just a heightmap aligned to a 2d grid'. If it really is just a 'flat' grid of cells, then of course no broad phase is necessary (or rather, the broad phase is trivial).
Original post by ph33r
jyk, he mentioned that he just has a 2d grid, so there is no need for the broad phase if he plans on keeping the terrain always a 2d grid.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement