tylermorganwall / rayrender

A pathtracer for R. Build and render complex scenes and 3D data visualizations directly from R
http://www.rayrender.net
622 stars 42 forks source link

support for directly loading shape3d objects #18

Closed gdagstn closed 3 years ago

gdagstn commented 4 years ago

Hi, I'm having a lot of fun with rayrender. However, since I am creating my meshes in R using a combination of rgl and Rvcg, I was wondering if there was a way to bypass writing an .OBJ file to disk to subsequently have rayrender load it in the scene. Sort of what mesh2ray does, but not just rendering cubes, rather the whole mesh and its faces. I know that you can easily get vertex coordinates, faces and normals from a shape3d object, but if I understand correctly non-primitive shapes are only loaded in the scene through Rcpp via TinyObjLoader. The only alternative I could think of was, in the spirit of mesh2ray, loading every triangle as a separate object via add_object(triangle()), using vertices and normals from the shade3d object. But this is horribly slow using a for loop - so much that it makes no sense as an alternative to writing and reading a big .OBJ file - and, since it has to call add_object() every time, I'm not sure whether it can be vectorised. Do you have any other suggestions?

tylermorganwall commented 3 years ago

mesh3d and shapelist3d objects are now supported by rayrender