Learn R Programming

rgl (version 0.111.6)

mesh3d: Construct 3D mesh objects

Description

Creates meshes containing points, segments, triangles and quads.

Usage

mesh3d( x, y = NULL, z = NULL, vertices,
                    material = NULL,
                    normals = NULL, texcoords = NULL,
                    points = NULL, segments = NULL,
                    triangles = NULL, quads = NULL,
                    meshColor = c("vertices", "edges", "faces", "legacy"))
  qmesh3d(vertices, indices, homogeneous = TRUE, material = NULL, 
         normals = NULL, texcoords = NULL,
         meshColor = c("vertices", "edges", "faces", "legacy"))
  tmesh3d(vertices, indices, homogeneous = TRUE, material = NULL, 
         normals = NULL, texcoords = NULL,
         meshColor = c("vertices", "edges", "faces", "legacy"))

Value

Objects of class c("mesh3d", "shape3d").

See points3d for a discussion of texture coordinates.

Arguments

x, y, z

coordinates. Any reasonable way of defining the coordinates is acceptable. See the function xyz.coords for details.

vertices

A 4 row matrix of homogeneous coordinates; takes precedence over x, y, z.

material

material properties for later rendering

normals

normals at each vertex

texcoords

texture coordinates at each vertex

points

vector of indices of vertices to draw as points

segments

2 x n matrix of indices of vertices to draw as segments

triangles

3 x n matrix of indices of vertices to draw as triangles

quads

4 x n matrix of indices of vertices to draw as quads

indices

(obsolete) 3 or 4 x n matrix of vertex indices

homogeneous

(obsolete) should tmesh3d and qmesh3d vertices be assumed to be homogeneous?

meshColor

how should colours be interpreted? See details in shade3d.

Details

These functions create mesh3d objects, which consist of a matrix of vertex coordinates together with a matrices of indices indicating how the vertices should be displayed, and material properties.

The "shape3d" class is a general class for shapes that can be plotted by dot3d, wire3d or shade3d.

The "mesh3d" class is a class of objects that form meshes: the vertices are in member vb, as a 4 by n matrix using homogeneous coordinates. Indices of these vertices are contained in optional components ip for points, is for line segments, it for triangles, and ib for quads. Individual meshes may have any combination of these.

The functions tmesh3d and qmesh3d are included for back-compatibility; they produce meshes of triangles and quads respectively.

See Also

shade3d, shapelist3d for multiple shapes

Examples

Run this code

  # generate a quad mesh object

  vertices <- c( 
     -1.0, -1.0, 0,
      1.0, -1.0, 0,
      1.0,  1.0, 0,
     -1.0,  1.0, 0
  )
  indices <- c( 1, 2, 3, 4 )
  
  open3d()  
  wire3d( mesh3d(vertices = vertices, quads = indices) )
  

Run the code above in your browser using DataLab