Using stl file

I’m learning ray tracing from Optix. optixMeshViewer was a very helpful sample to me.
But I hope to load mesh using stl files not obj.
Please inform me if there is any good way to load stl files or any good library to refer to?
Thanks a lot.

The STL file format is really simple.
If you’re not wanting to write your own loader (really, it’s just about 600 lines of C++ code) just search for “STL” on
If you plan to load other formats in the future, maybe have a look at the assimp project.

Thank you for your help.
There is an additional question.
In optixMeshviewer, I want to add a .cu file for a closest hit function associated with mesh.
how can I get a ptx file? I read some documents and tried compile in VS and it didn’t work.
It’s a ridiculous question, but I really can’t figure out.

The OptiX examples use CMake to generate a custom build rule for each *.cu file inside the list of files inside the CMakeLists.txt of each individual example.

If you want to add another *.cu file to that, just add it to your example’s CMakelists.txt and configure and generate the solution with CMake again, then it should appear in your project and gets built.

The logic doing that is inside the OptiX SDK 6.0.0\SDK\CMake\FindCUDA *.cmake scripts.

There are much simpler ways to do this. In the end, translating *.cu files to *.ptx files is just calling the CUDA compiler nvcc.exe with the proper command line options. Find that nvcc.exe in your CUDA installation and run it with nvcc.exe --help to get more information.