Learn R Programming

PolygonSoup (version 1.0.1)

readMeshFile: Read a mesh file

Description

Read mesh vertices and faces from a file.

Usage

readMeshFile(filepath)

Value

A list with two fields: vertices, a numeric matrix with three columns, and faces, either a list of integer vectors or, in the case if all faces have the same number of sides, an integer matrix.

Arguments

filepath

path to the mesh file; supported formats are stl, ply, obj and off

Examples

Run this code
library(PolygonSoup)
library(rgl)
vf <- readMeshFile(
  system.file("extdata", "beethoven.ply", package = "PolygonSoup")
)
mesh <- Mesh(
  vf[["vertices"]], vf[["faces"]], normals = TRUE
)
rglmesh <- toRGL(mesh)
open3d(windowRect = c(50, 50, 562, 562))
view3d(0, 0, zoom = 0.8)
shade3d(rglmesh, color = "palevioletred")

Run the code above in your browser using DataLab