I've modified the code of the appRaytracer demo
included in the Bullet (2.76) distribution, and I've made this new raytracer demo.WHAT'S IN THE ZIP FILE
The .exe included in the zipped archive has been built with the VC++ 2008 compiler, using the /MD option, and so needs the VC++ 2008 runtime to be installed on your system in order to run.
Compiling the code is very easy, since all the files and project options can be copied from the original appRaytracer demo: the only difference is that the (two) .cpp files are in the folder inside the .zip archive.USAGE:
You might find a similiar raytracer useful if you need to build some kind of collision shape that's not correctly displayed (with enough approximation) by the Bullet default openGL renderer (or by other renderers as well); that's why I thought it was worth sharing it with the Bullet community.KEYS:
-> camera can be moved using the usual camera keys.IMPLEMENTATION NOTES:
-> the raytracer uses a parallel projection
: it's not as good as a perspective projection
, but in this way:
a) the ray direction is the same for all rays and can be calculated once.
b) the rays don't diverge, so even at low resolutions, a lot of them hit the target.
-> the openGL texture is a GL_LUMINANCE texture
, so that the texture buffer is 2/3 smaller.
The code hasn't been written with speed in mind and there are plenty of further optimizations that can be done (like using multiple cores/threads, etc.).SCREENSHOT:
ortho_raytracer_demo.jpg [ 5.94 KiB | Viewed 2821 times ]
RaytracerOrtho.zip [211.37 KiB]
Downloaded 297 times
Hope you like it.
P.S. I've included an experimental btCollisionShapeGarbageCollector class
, but please don't rely too much on it. I made it in ten minutes and so it lacks testing/fixing and must contain several errors for sure.