Learn R Programming

Morpho (version 2.12)

mesh2obj: 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.

Author

Stefan Schlager

Details

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

See Also

ply2mesh, quad2trimesh

Examples

Run this code

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"
if (FALSE) {
shade3d(cube,col=3) ## view the green cube
}
mesh2ply(cube,filename="cube") # write cube to a file called cube.ply
unlink("cube.ply")

Run the code above in your browser using DataLab