4

I'm looking for a library that will let me cast a ray into a scene model (it happens to be a terrain model in our case) and return the point of intersection in the scene. It does not have to be super-efficient (although I'd rather it not be super-inefficient). Ideally it would not have dependencies on other libraries (like OpenGL). I'm really looking for something that has just the functionality I need and no more.

Does anyone have any suggestions?

Alton Patrick
  • 235
  • 1
  • 4
  • 10
  • 2
    "simple" and "ray casting" are two things that probably together cannot coexist! You just need something like this? http://stackoverflow.com/questions/3085096/simple-c-c-library-for-triangle-intersection-acceleration-structure – Salvatore Previti Oct 25 '11 at 21:03
  • 3
    @Salvatore Preveti why not? Raycasting is simple, it ain't rocket science. –  Oct 25 '11 at 21:06
  • 4
    If you want to obtain decent performances you need a kd-tree, at least. – Salvatore Previti Oct 25 '11 at 21:07
  • 1
    @WTP "So simple" that entire upperclassmen college courses are devoted to it... ;-) –  Oct 25 '11 at 22:51

1 Answers1

3

Unless there are other requirements you haven't revealed, use CGAL's AABB tree's support for ray intersections (example).

(Please, don't even think about using this if you're actually trying to do terrain rendering though... there are far more efficient algorithms for ray-casting height fields for the purpose of producing images e.g so-called voxel algorithms).

timday
  • 24,582
  • 12
  • 83
  • 135
  • 1
    I looked at CGAL and I really like it. Looks like it has a very straight-forward, well-documented interface. Unfortunately, to do with it what we want I think we'd have to buy a commercial license. I found that IPP, which we already use and have licenses for, has some ray casting functionality. It doesn't appear to be as easy to use as CGAL, but since we're already using IPP in our project, I figure it is worth a try with that. – Alton Patrick Oct 27 '11 at 13:43