Create a mesh grid using coordinates from arrays.
Generates a mesh using data in provided in 2D arrays of vertex coordinates. Triangle faces are automatically computed by this function by joining adjacent vertices at neighbouring indices in the array. Texture coordinates are generated covering the whole mesh, with origin at the bottom left.
xvals (array_like) – NxM arrays of X and Y coordinates. Both arrays must have the same shape. the resulting mesh will have a single vertex for each X and Y pair. Faces will be generated to connect adjacent coordinates in the array.
yvals (array_like) – NxM arrays of X and Y coordinates. Both arrays must have the same shape. the resulting mesh will have a single vertex for each X and Y pair. Faces will be generated to connect adjacent coordinates in the array.
zvals (array_like, optional) – NxM array of Z coordinates for each X and Y. Must have the same shape as X and Y. If not specified, the Z coordinates will be filled with zeros.
tessMode (str, optional) – Tessellation mode. Specifies how faces are generated. Options are ‘center’, ‘radial’, and ‘diag’. Default is ‘diag’. Modes ‘radial’ and ‘center’ work best with odd numbered array dimensions.
computeNormals (bool, optional) – Compute normals for the generated mesh. If False, all normals are set to face in the +Z direction. Presently, computing normals is a slow operation and may not be needed for some meshes.
Vertex attribute arrays (position, texture coordinates, and normals) and triangle indices.
Create a 3D sine grating mesh using 2D arrays:
x = np.linspace(0, 1.0, 32) y = np.linspace(1.0, 0.0, 32) xx, yy = np.meshgrid(x, y) zz = np.tile(np.sin(np.linspace(0.0, 32., 32)) * 0.02, (32, 1)) vertices, textureCoords, normals, faces = gltools.createMeshGridFromArrays(xx, yy, zz)