Learn R Programming

svgViewR (version 1.4.3)

readOBJ: Reads an OBJ file

Description

Reads a mesh file in the OBJ format and returns an object of class 'obj'

Usage

readOBJ(file, scaling = 1)

# S3 method for obj print(x, ...)

Value

a list of class "obj" with the following elements:

vertices

Mesh vertices.

normals

Normal vectors, at each vertex.

faces

Mesh faces (indices to vertices).

metadata

Mesh metadata.

Arguments

file

A filepath to a file of type '.obj'.

scaling

A scaling factor to be applied to the vertices.

x

an object used to select a method.

...

further arguments passed to or from other methods.

Author

Aaron Olsen

Details

This function convert a Wavefront .obj file or OBJ object into a JSON (JavaScript Object Notation) object and optionally saves this JSON object as a .json file. This function only provides basic functionality, reading only vertices, normals, and faces. It has only been tested on the .obj files returned from the DICOM Medical Image Viewer Horos (formerly Osirix). This function was written in order directly convert CT scan meshes exported from Horos into the JSON format for web visualization, eliminating intermediate conversions in programs such as meshlab and Blender.

See Also

objToJSON

Examples

Run this code
if (FALSE) {
# Read an .obj file
obj <- readOBJ('obj_file.obj')

# Print obj object
print(obj)
}

Run the code above in your browser using DataLab