From POV-Ray to rgl

两盒软妹~` 提交于 2019-12-11 07:25:55

问题


I've followed this tutorial to export a POV-Ray graphic to a STL file, through Meshlab. I've also tried the export to the OBJ format. Everything seems to work fine from the creation of the POV-Ray graphic to the exporting in Meshlab.

But then I've tried to render the graphic in R with the functions readSTL and readOBJ of the rgl package, and the problem is here.

In fact, the exported STL file is empty:

solid STL generated by MeshLab
endsolid vcg

So, of course, rgl::readSTL renders nothing in R.

The OBJ file is not empty, but it contains no faces (only vertices and vertex normals):

####
#
# OBJ File Generated by Meshlab
#
####
# Object blob.obj
#
# Vertices: 8437
# Faces: 0
#
####
vn -0.900372 -0.267658 -0.343060
v -4.000525 2.600000 -0.833225
......

After running rgl::readOBJ in R the rendering is just a white scene, there's nothing. Even if there's no face, we could expect to get some points.

Maybe I'm mistaken during one step of the procedure. Do you have any idea about:

  • how to export to a non-empty STL file in Meshlab ?

  • how to get the points with readOBJ in R ?

  • how to get the faces in the OBJ file when exporting from Meshlab ?

  • do you know another way to go from POV-Ray to rgl, if possible preserving the colors ?

Update

I've found a way to get the faces in the OBJ file: instead of doing Screened Poisson Surface Reconstruction in Meshlab, as said in the tuto, I do Surface Reconstruction: Ball Pivoting.

But then rgl::readOBJ generates this error:

Error in order(vlinks[[i]][, 2]) : argument 1 is not a vector

The same procedure allows to export a non-empty STL file. But then rgl::readSTL generates this error:

Error in matrix(NA, 3 * n, 3) : invalid 'nrow' value (too large or NA)
In addition: Warning message:
In matrix(NA, 3 * n, 3) : NAs introduced by coercion to integer range

回答1:


Ok, I've found.

  • Follow the linked tuto to create the file blob.asc in POV-Ray

  • In Meshlab, open this file, and do Surface Reconstruction: Ball Pivoting in the menu Filters -> Remeshing, Simplification and Reconstruction. Perhaps one previously needs to do Screened Poisson Surface Reconstruction before, I don't know.

  • Export the file as STL. Check "Binary Encoding" (a default option), because rgl::readSTL reads binary STL files only, not ASCII files.

  • In R, now you can do rgl::readSTL. And this works:



来源:https://stackoverflow.com/questions/49477327/from-pov-ray-to-rgl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!