This function takes a mesh and validates it. The mesh should be a list with "shapes", "materials", "vertices", "texcoords", "normals", and "material_hashes" entries.

validate_mesh(mesh, validate_materials = TRUE)

Arguments

mesh

List. A mesh is a list as described above.

validate_materials

Default TRUE. Whether or not to validate "materials".

Value

A mesh.

Shapes

Each "shapes" entry should be a list with "mesh", "name", and "material" entries. Each "mesh" entry should have "indices", "tex_indices", "norm_indices", "material_ids", "has_vertex_tex", and "has_vertex_normals". The indices should not exceed the number of rows in their corresponding vertex/normal/texcoord data. There should be no NA/NaN values in the vertex/normal/texcoord data.

Materials (for rayvertex package only)

Each "materials" entry is expected to be a list with several entries with specific required lengths, as listed below:

AttributeLengthType
diffuse3Numeric
ambient3Numeric
specular3Numeric
transmittance3Numeric
emission3Numeric
shininess1Numeric
ior1Numeric
dissolve1Numeric
illum1Numeric
diffuse_texname1Character
normal_texname1Character
bump_texname1Character
specular_texname1Character
ambient_texname1Character
emissive_texname1Character
diffuse_intensity1Numeric
bump_intensity1Numeric
specular_intensity1Numeric
emission_intensity1Numeric
ambient_intensity1Numeric
culling1Character
type1Character
translucent1Logical
toon_levels1Numeric
toon_outline_width1Numeric
toon_outline_color3Numeric
reflection_intensity1Numeric
reflection_sharpness1Numeric
two_sided1Logical

Note: This materials validation only applies to the rayvertex package. Other renderers might choose to use their own information in the material list.

Examples

# validate a mesh
mesh = validate_mesh(sphere_mesh())