Reputation: 1575
I was wondering if anyone knew of a good resource for ray-box intersection algorithms. I am writing a ray-tracing program and want to include a box-primitive object. To be specific, I need an algorithm that can return a "t value" for a ray parameterized as R = E + t*D where E is the starting point and D is the direction vector. I have already implemented a ray-box intersection that is useful for bounding boxes, but it only returns a boolean value for whether or not the box was hit. This is no good however since I need to be able to calculate the exact point in 3D space that the box was hit in order to be able to render it.
Upvotes: 1
Views: 1930
Reputation: 315
I assume you are interested only in axes aligned boxes. The code is available in LuxRays sources: https://bitbucket.org/luxrender/luxrays/src/ceb10f7963250be95af709f98633907c13da7830/src/luxrays/core/geometry/bbox.cpp?at=default&fileviewer=file-view-default#bbox.cpp-148
Upvotes: 0