Transforms all vertex positions in a mesh by a 4x4 homogeneous
matrix (applied as M * (x, y, z, 1)^T). Vertex colors are
kept as they are; vertex normals (if the mesh has any) are
transformed by the inverse transpose of M, so that shading
stays correct for shearing and non-uniform scaling. Use
compute_vertex_normals() if the mesh has no normals yet.
Arguments
- mesh
A mesh descriptor list with
verticesandtriangles, as returned byrender_mesh()or built byscimesh_generate_multi_spheres()etc.- matrix
A 4x4 numeric matrix.
Examples
mesh <- generate_cuboid(c(0, 0, 0), c(1, 1, 1))
mat <- diag(4)
mat[1:3, 4] <- c(2, 3, 4)
translated <- transform_mesh(mesh, mat)
translated$vertices[1, ]
#> [1] 1 2 5