This may be a noobie question, but I can’t seem to find an answer (either here or by figuring it out myself).
I want to import a mesh in OptiX (which I do thanks to the samples), but I want my camera to be at a fixed point in world space (i.e. the world’s origin at (0.0f, 0.0f, 0.0f)) and the mesh to appear in front of the camera.
In the MeshViewer sample the opposite happens, i.e. the object is imported at the world’s origin and the camera position is relative to the object’s bbox extent, if I understood it right.
As far as I tried to make this happen, it seems that the mesh always get’s imported at the world’s origin.
I tried to translate the vertex positions during importing (host-side), but it didn’t seem to work.
Do I have to translate the geometry group’s Transform node immediately at context launch, so that the object gets translated in front of the camera?
Is there an elegant way of doing this?
To move your mesh around, you can use an OptiX transform node, if you want. Take a look at the optixInstancing sample, specifically in the createNodeGraph() function, to see an example of creating and using a transform node.
You can translate your mesh at any time, just be aware that if you do it after the first launch, you need to mark the transform’s parent acceleration structure dirty to make it aware of the transform change.
The optixMeshViewer sample isn’t importing a mesh at the world origin per-se, it is simply reading the mesh without modification directly into world space. The camera in the sample code is setup to look at the center of the mesh bounding box, wherever that may be.
You can instead translate your mesh in advance, if you prefer, during import or before import by saving a translated version of the mesh file and importing that. If you used the OptiX mesh import functionality and tried to translate the vertex positions after import, it’s possible the mesh was already sent to the GPU by the time you modified the host side data, which may explain why it didn’t work for you.