mesh2ply: export mesh objects to disk

View source: R/mesh2ply.r

mesh2objR Documentation

export mesh objects to disk

Description

export mesh objects to disk.

Usage

mesh2obj(x, filename = dataname, writeNormals = TRUE)

mesh2ply(x, filename = dataname, col = NULL, writeNormals = FALSE)

Arguments

x

object of class mesh3d - see rgl documentation for further details or a matrix containing vertices, this can either be a k x 3 or a 3 x k matrix, with rows or columns containing vertex coordinates.

filename

character: Path/name of the requested output - extension will be added atuomatically. If not specified, the file will be named as the exported object.

writeNormals

logical: if TRUE, existing normals of a mesh are written to file - can slow things down for very large meshes.

col

Writes color information to ply file. Can be either a single color value or a vector containing a color value for each vertex of the mesh.

Details

export an object of class mesh3d or a set of coordinates to a common mesh file.

Note

meshes containing quadrangular faces will be converted to triangular meshes by splitting the faces. Additionally, mesh2obj is now simply a wrapper of Rvcg::vcgObjWrite.

Author(s)

Stefan Schlager

See Also

ply2mesh, quad2trimesh

Examples


require(rgl)
vb <- c(-1.8,-1.8,-1.8,1.0,1.8,-1.8,-1.8,1.0,-1.8,1.8,-1.8,1.0,1.8,
1.8,-1.8,1.0,-1.8,-1.8,1.8,1.0,1.8,
-1.8,1.8,1.0,-1.8,1.8,1.8,1.0,1.8,1.8,1.8,1.0)
it <- c(2,1,3,3,4,2,3,1,5,5,7,3,5,1,2,2,6,5,6,8,7,7,5,6,7,8,4,4,3,7,4,8,6,6,2,4)
vb <- matrix(vb,4,8) ##create vertex matrix
it <- matrix(it,3,12) ## create face matrix
cube<-list(vb=vb,it=it)
class(cube) <- "mesh3d"
## Not run: 
shade3d(cube,col=3) ## view the green cube

## End(Not run)
mesh2ply(cube,filename="cube") # write cube to a file called cube.ply
unlink("cube.ply")

Morpho documentation built on Feb. 16, 2023, 10:51 p.m.