Thank you for quick answer.
I have to inform you that the only available functions in the package
misc3d
are:
contour3d Draw an Isosurface, a Three Dimension Contour
Plot
drawScene Rendering of Triangular Mesh Surface Data
image3d Draw Points on a 3D Grid
kde3d Compute a Three Dimension Kernel Density
Estimate
makeTriangles Triangle Mesh Functions
parametric3d Draw a 3D Parametric Plot
perspLighting Lighting Functions
phongLighting Lighting Functions
pointsTetrahedra Create a Set of Tetrahetra Centered at Data Points
scaleTriangles Triangle Mesh Functions
slices3d Interactive Image Slices of 3D or 4D Volume
Data
surfaceTriangles Create a Triangle Mesh Representing a Surface
teapot Utah Teapot
translateTriangles Triangle Mesh Functions
updateTriangles Triangle Mesh Functions
None of them does read/write a PLY file.
You will find below a simple code for drawing a 3D image. The displayed
image is stored in the package misc3d (not read from a file).
library(misc3d)
data(teapot)
haveRGL <- suppressWarnings(require(rgl,quietly=TRUE))
ttri <- makeTriangles(teapot$vertices, teapot$edges, color = "red",
color2 =
"green")
## draw the teapot
drawScene(ttri,screen=list(y=-30,x=40), scale = FALSE)
str(teapot)
# > str(teapot)
# List of 2
# $ vertices: num [1:3, 1:1976] -3,00 1,65 0,00 -2,99 1,65 ...
# $ edges : int [1:3, 1:3751] 1455 1469 1459 1449 1455 1459 1462 1449
1459
1469 ...
# My images (PLY images) have vertices and edges like the teapot image in
the example. If PLY images are read by R, I will be able to manipulate
them.
Okay, I understand now. Yes, R can display 3D images based on lines and
polygons using the rgl package or scatterplot3d or grid graphics, but
those have nothing to do with PLY files. As far as I know there is no
existing code to read or write a PLY file, but from the look of it, it's
a simple format and it wouldn't be hard to write input/output routines.
The likely problems are:
- it's an open ended format, with each application allowed to define
its own record types. If your files come from an application that did
that you may have trouble working out what was intended and reading it in.
- some of the recommended elements are not supported in rgl or other
3D renderers in R. In particular, polygons with more than 4 vertices
need to be decomposed into triangles or quads, and rgl knows nothing
about refraction index: you'd probably need a ray-tracing renderer for
that.
- rgl scenes contain text, and as far as I can see, there's no way to
include that in a standard PLY file, so you'd need to invent your own
record type for it. Text is always hard to describe graphically, so
this wouldn't be easy.
Duncan Murdoch