Mesh

class nvisii.mesh(*args, **kwargs)
static are_any_dirty()

Indicates whether or not any meshes are “out of date” and need to be updated through the “update components” function

static clear_all()

Clears any existing Mesh components.

compute_metadata()

Computes the average of all vertex positions. (centroid) as well as min/max bounds and bounding sphere data.

static create_box(*args, **kwargs)

Creates a rectangular box centered at the origin aligned along the x, y, and z axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • size (vec3, optional) – Half of the side length in x (0), y (1) and z (2) direction.

  • segments (ivec3, optional) – The number of segments in x (0), y (1) and z (2) directions. All should be >= 1. If any one is zero, faces in that direction are not genereted. If more than one is zero the mesh is empty.

Return type

Mesh

Returns

a reference to the mesh component

static create_capped_cone(*args, **kwargs)

Creates a cone with a cap centered at the origin and pointing towards the positive z-axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the flat (negative z) end along the xy-plane.

  • size (float, optional) – Half of the length of the cylinder along the z-axis.

  • slices (int, optional) – Number of subdivisions around the z-axis.

  • segments (int, optional) – Number of subdivisions along the z-axis.

  • rings (int, optional) – Number of subdivisions of the cap.

  • start (float, optional) – Counterclockwise angle around the z-axis relative to the positive x-axis.

  • sweep (float, optional) – Counterclockwise angle around the z-axis.

Return type

Mesh

Returns

a reference to the mesh component

static create_capped_cylinder(*args, **kwargs)

Creates a cylinder with a cap centered at the origin and aligned along the z-axis

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the cylinder along the xy-plane.

  • size (float, optional) – Half of the length cylinder along the z-axis.

  • slices (int, optional) – Number of subdivisions around the z-axis.

  • segments (int, optional) – Number of subdivisions along the z-axis.

  • rings (int, optional) – Number of subdivisions on the caps.

  • start (float, optional) – Counterclockwise angle around the z-axis relative to x-axis.

  • sweep (float, optional) – Counterclockwise angle around the z-axis.

Return type

Mesh

Returns

a reference to the mesh component

static create_capped_tube(*args, **kwargs)

Creates a tube (a cylinder with thickness) with caps on both ends, centered at the origin and aligned along the z-axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – The outer radius of the cylinder on the xy-plane.

  • innerRadius (float, optional) – The inner radius of the cylinder on the xy-plane.

  • size (float, optional) – Half of the length of the cylinder along the z-axis.

  • slices (int, optional) – Number nubdivisions around the z-axis.

  • segments (int, optional) – Number of subdivisions along the z-axis.

  • rings (int, optional) – Number radial subdivisions in the cap.

  • start (float, optional) – Counterclockwise angle around the z-axis relative to the x-axis.

  • sweep (float, optional) – Counterclockwise angle around the z-axis.

Return type

Mesh

Returns

a reference to the mesh component

static create_capsule(*args, **kwargs)

Creates a capsule (a cylinder with spherical caps) centered at the origin and aligned along the z-axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the capsule on the xy-plane.

  • size (float, optional) – Half of the length between centers of the caps along the z-axis.

  • slices (int, optional) – Number of subdivisions around the z-axis in the caps.

  • segments (int, optional) – Number radial subdivisions in the cylinder.

  • rings (int, optional) – Number of radial subdivisions in the caps.

  • start (float, optional) – Counterclockwise angle relative to the x-axis.

  • sweep (float, optional) – Counterclockwise angle.

Return type

Mesh

Returns

a reference to the mesh component

static create_cone(*args, **kwargs)

Creates a cone centered at the origin, and whose tip points towards the z-axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the negative z end on the xy-plane.

  • size (float, optional) – Half of the length of the cylinder along the z-axis.

  • slices (int, optional) – Number of subdivisions around the z-axis.

  • segments (int, optional) – Number subdivisions along the z-axis.

  • start (float, optional) – Counterclockwise angle around the z-axis relative to the x-axis.

  • sweep (float, optional) – Counterclockwise angle around the z-axis.

Return type

Mesh

Returns

a reference to the mesh component

static create_convex_polygon(name, vertices, segments=1, rings=1)

Creates a convex polygon from a set of corner vertices.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • vertices (std::vector< glm::vec2,std::allocator< glm::vec2 > >) – The corner coplanar vertex coordinates. Should form a convex polygon.

  • segments (int, optional) – The number of segments per side. Should be >= 1. If zero an empty mesh is generated.

  • rings (int, optional) – The number of radial segments. Should be >= 1. = yields an empty mesh.

Return type

Mesh

Returns

a reference to the mesh component

static create_convex_polygon_from_circle(name, radius=1.0, sides=5, segments=4, rings=4)

Creates a convex polygonal disk with an arbitrary number of corners.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – The radius the enclosing circle.

  • sides (int, optional) – The number of sides. Should be >= 3. If <3 an empty mesh is generated.

  • segments (int, optional) – The number of segments per side. Should be >= 1. If zero an empty mesh is generated.

  • rings (int, optional) – The number of radial segments. Should be >= 1. = yields an empty mesh.

Return type

Mesh

Returns

a reference to the mesh component

static create_cylinder(*args, **kwargs)

Creates an uncapped cylinder centered at the origin and aligned along the z-axis

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the cylinder along the xy-plane.

  • size (float, optional) – Half of the length of the cylinder along the z-axis.

  • slices (int, optional) – Subdivisions around the z-axis.

  • segments (int, optional) – Subdivisions along the z-axis.

  • start (float, optional) – Counterclockwise angle around the z-axis relative to the x-axis.

  • sweep (float, optional) – Counterclockwise angle around the z-axis.

Return type

Mesh

Returns

a reference to the mesh component

static create_disk(*args, **kwargs)

Creates a circular disk centered at the origin and along the xy-plane

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Outer radius of the disk on the xy-plane.

  • innerRadius (float, optional) – radius of the inner circle on the xy-plane.

  • slices (int, optional) – Number of subdivisions around the z-axis.

  • rings (int, optional) – Number of subdivisions along the radius.

  • start (float, optional) – Counterclockwise angle relative to the x-axis

  • sweep (float, optional) – Counterclockwise angle.

Return type

Mesh

Returns

a reference to the mesh component

static create_dodecahedron(name, radius=1.0, segments=1, rings=1)

Creates a regular dodecahedron centered at the origin and with a given radius.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component Each face is optionally subdivided along the edges and/or radius.

  • radius (float, optional) – The radius of the enclosing sphere.

  • segments (int, optional) – The number segments along each edge. Should be >= 1. If <1 empty mesh is generated.

  • rings (int, optional) – The number of radial segments on each face. Should be >= 1. If <1 an empty mesh is generated.

Return type

Mesh

Returns

a reference to the mesh component

static create_from_data(*args, **kwargs)

Creates a mesh component from a set of positions, optional normals, optional colors, optional texture coordinates, and optional indices. If anything other than positions is supplied (eg normals), that list must be the same length as the point list. If indicies are supplied, indices must be a multiple of 3 (triangles). Otherwise, all other supplied per vertex data must be a multiple of 3 in length.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • positions (std::vector< float,std::allocator< float > >) – A list of vertex positions. If indices aren’t supplied, this must be a multiple of 3.

  • position_dimensions (int, optional) – The number of floats per position. Valid numbers are 3 or 4.

  • normals (std::vector< float,std::allocator< float > >, optional) – A list of vertex normals. If indices aren’t supplied, this must be a multiple of 3.

  • normal_dimensions (int, optional) – The number of floats per normal. Valid numbers are 3 or 4.

  • tangents (std::vector< float,std::allocator< float > >, optional) – A list of vertex tangents. If indices aren’t supplied, this must be a multiple of 3.

  • tangent_dimensions (int, optional) – The number of floats per tangent. Valid numbers are 3 or 4.

  • colors (std::vector< float,std::allocator< float > >, optional) – A list of per-vertex colors. If indices aren’t supplied, this must be a multiple of 3.

  • color_dimensions (int, optional) – The number of floats per color. Valid numbers are 3 or 4.

  • texcoords (std::vector< float,std::allocator< float > >, optional) – A list of 2D per-vertex texture coordinates. If indices aren’t supplied, this must be a multiple of 3.

  • texcoord_dimensions (int, optional) – The number of floats per texcoord. Valid numbers are 2. (3 might be supported later for 3D textures…)

  • indices (std::vector< uint32_t,std::allocator< uint32_t > >, optional) – A list of integer indices connecting vertex positions in a counterclockwise ordering to form triangles. If supplied, indices must be a multiple of 3.

Return type

Mesh

Returns

a reference to the mesh component

static create_from_file(name, path)

Creates a mesh component from a file (ignoring any associated materials)

Supported file formats include: AMF 3DS AC ASE ASSBIN B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS M3D MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • path (string) – A path to the file.

static create_from_obj(name, path)

Deprecated. Please use create_from_file instead.

static create_icosahedron(name, radius=1.0, segments=1)

Creates a regular icosahedron centered at the origin and with a given radius.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – The radius of the enclosing sphere.

  • segments (int, optional) – The number segments along each edge. Must be >= 1.

Return type

Mesh

Returns

a reference to the mesh component

static create_icosphere(name, radius=1.0, segments=4)

Creates an icosphere, otherwise known as a spherical subdivided icosahedron.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – The radius of the containing sphere.

  • segments (int, optional) – The number of segments per icosahedron edge. Must be >= 1.

Return type

Mesh

Returns

a reference to the mesh component

static create_line(name, start, stop, radius=1.0, segments=16)

Creates a line from a circle extruded linearly between the specified start and stop positions.

type name

string

param name

The name (used as a primary key) for this mesh component

type start

vec3

param start

The start position of the linear path.

type start

vec3

param start

The stop position of the linear path.

type radius

float, optional

param radius

The radius of the extruded circle

type segments

int, optional

param segments

Number of subdivisions around the circle.

rtype

Mesh

return

a reference to the mesh component

static create_plane(*args, **kwargs)

Creates a plane (a regular grid) on the xy-plane whose normal points towards the z-axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • size (vec2, optional) – Half of the side length in x (0) and y (1) direction.

  • segments (ivec2, optional) – Number of subdivisions in the x (0) and y (1) direction.

  • flip_z (boolean, optional) – Flips the plane such that the face is pointed down negative Z instead of positive Z.

Return type

Mesh

Returns

a reference to the mesh component

static create_rectangle_tube_from_polyline(*args, **kwargs)

Creates a tube from a rounded rectangle extruded linearly along the specified path.

type name

string

param name

The name (used as a primary key) for this mesh component

type path

std::vector< glm::vec3,std::allocator< glm::vec3 > >

param path

A set of vertices describing a linear path.

type size

vec2, optional

param size

Half of the length of an edge

type segments

ivec2, optional

param segments

Number of subdivisions along each edge

rtype

Mesh

return

a reference to the mesh component

static create_rounded_box(*args, **kwargs)

Creates a rectangular box with rounded edges, centered at the origin and aligned along the x, y, and z axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • radius (float, optional) – Radius of the rounded edges.

  • size (vec3, optional) – Half of the side length in x (0), y (1) and z (2) direction.

  • slices (int, optional) – Number subdivions around in the rounded edges.

  • segments (ivec3, optional) – Number of subdivisions in x (0), y (1) and z (2) direction for the flat faces.

Return type

Mesh

Returns

a reference to the mesh component

static create_rounded_rectangle_tube_from_polyline(*args, **kwargs)

Creates a tube from a rounded rectangle extruded linearly along the specified path.

type name

string

param name

The name (used as a primary key) for this mesh component

type path

std::vector< glm::vec3,std::allocator< glm::vec3 > >

param path

A set of vertices describing a linear path.

type radius

float, optional

param radius

The radius of the rounded corners

type size

vec2, optional

param size

Half of the length of an edge

type slices

int, optional

param slices

Number of subdivisions in each rounded corner

type segments

ivec2, optional

param segments

Number of subdivisions along each edge

rtype

Mesh

return

a reference to the mesh component

static create_sphere(*args, **kwargs)

Creates a sphere of the given radius, centered around the origin, subdivided around the z-axis in slices and along the z-axis in segments.

type name

string

param name

The name (used as a primary key) for this mesh component

type radius

float, optional

param radius

The radius of the sphere

type slices

int, optional

param slices

Subdivisions around the z-axis (longitudes).

type segments

int, optional

param segments

Subdivisions along the z-axis (latitudes).

type sliceStart

float, optional

param sliceStart

Counterclockwise angle around the z-axis relative to x-axis.

type sliceSweep

float, optional

param sliceSweep

Counterclockwise angle.

type segmentStart

float, optional

param segmentStart

Counterclockwise angle relative to the z-axis.

type segmentSweep

float, optional

param segmentSweep

Counterclockwise angle.

rtype

Mesh

return

a reference to the mesh component

static create_spherical_cone(*args, **kwargs)
Creates a cone with a spherical cap, centered at the origin and whose tip points towards the z-axis.

Each point on the cap has equal distance from the tip.

type name

string

param name

The name (used as a primary key) for this mesh component

type radius

float, optional

param radius

Radius of the negative z end on the xy-plane.

type size

float, optional

param size

Half of the distance between cap and tip along the z-axis.

type slices

int, optional

param slices

Number of subdivisions around the z-axis.

type segments

int, optional

param segments

Number subdivisions along the z-axis.

type rings

int, optional

param rings

Number subdivisions in the cap.

type start

float, optional

param start

Counterclockwise angle around the z-axis relative to the positive x-axis.

type sweep

float, optional

param sweep

Counterclockwise angle around the z-axis.

rtype

Mesh

return

a reference to the mesh component

static create_spherical_triangle_from_sphere(name, radius=1.0, segments=4)

Creates a triangular region on the surface of a sphere.

type name

string

param name

The name (used as a primary key) for this mesh component

type radius

float, optional

param radius

Radius of the containing sphere.

type segments

int, optional

param segments

Number of subdivisions along each edge.

rtype

Mesh

return

a reference to the mesh component

static create_spherical_triangle_from_triangle(name, v0, v1, v2, segments=4)

Creates a triangular region on the surface of a sphere.

type name

string

param name

The name (used as a primary key) for this mesh component

type v0

vec3

param v0

First of the three counter-clockwise triangle vertices

type v1

vec3

param v1

Second of the three counter-clockwise triangle vertices

type v2

vec3

param v2

Third of the three counter-clockwise triangle vertices

type segments

int, optional

param segments

Number of subdivisions along each edge.

rtype

Mesh

return

a reference to the mesh component

static create_spring(*args, **kwargs)

Creates a spring aligned along the z-axis and with a counter-clockwise winding.

type name

string

param name

The name (used as a primary key) for this mesh component

type minor

float, optional

param minor

Radius of the spring it self.

type major

float, optional

param major

Radius from the z-axis

type size

float, optional

param size

Half of the length along the z-axis.

type slices

int, optional

param slices

Subdivisions around the spring.

type segments

int, optional

param segments

Subdivisions along the path.

type majorStart

float, optional

param majorStart

Counterclockwise angle around the z-axis relative to the x-axis.

type majorSweep

float, optional

param majorSweep

Counterclockwise angle around the z-axis.

rtype

Mesh

return

a reference to the mesh component

static create_teapotahedron(name, segments=8)
Creates the Utah Teapot using the original b-spline surface data. (https://en.wikipedia.org/wiki/Utah_teapot)

The lid is points towards the z axis and the spout points towards the x axis.

type name

string

param name

The name (used as a primary key) for this mesh component

type segments

int, optional

param segments

The number segments along each patch. Should be >= 1. If zero empty mesh is generated.

rtype

Mesh

return

a reference to the mesh component

static create_torus(*args, **kwargs)

Creates a torus centered at the origin and along the xy-plane.

type name

string

param name

The name (used as a primary key) for this mesh component

type minor

float, optional

param minor

Radius of the minor (inner) ring

type major

float, optional

param major

Radius of the major (outer) ring

type slices

int, optional

param slices

Subdivisions around the minor ring

type segments

int, optional

param segments

Subdivisions around the major ring

type minorStart

float, optional

param minorStart

Counterclockwise angle relative to the xy-plane.

type minorSweep

float, optional

param minorSweep

Counterclockwise angle around the circle.

type majorStart

float, optional

param majorStart

Counterclockwise angle around the z-axis relative to the x-axis.

type majorSweep

float, optional

param majorSweep

Counterclockwise angle around the z-axis.

rtype

Mesh

return

a reference to the mesh component

static create_torus_knot(name, p=2, q=3, slices=8, segments=96)

Creates a circle extruded along the path of a knot. (https://en.wikipedia.org/wiki/Torus_knot)

type name

string

param name

The name (used as a primary key) for this mesh component

type p

int, optional

param p

First coprime integer.

type q

int, optional

param q

Second coprime integer.

type slices

int, optional

param slices

Number subdivisions around the circle.

type segments

int, optional

param segments

Number of subdivisions around the path.

rtype

Mesh

return

a reference to the mesh component

static create_triangle(name, v0, v1, v2, segments=4)

Creates a triangle from the specified vertices

type name

string

param name

The name (used as a primary key) for this mesh component

type v0

vec3

param v0

First of the vertex positions of the triangle.

type v1

vec3

param v1

Second of the vertex positions of the triangle.

type v2

vec3

param v2

Third of the vertex positions of the triangle.

type segments

int, optional

param segments

The number of segments along each edge. Must be >= 1.

rtype

Mesh

return

a reference to the mesh component

static create_triangle_from_circumscribed_circle(name, radius=1.0, segments=4)

Creates a triangle centered at the origin and contained within the circumscribed circle.

type name

string

param name

The name (used as a primary key) for this mesh component

type radius

float, optional

param radius

The radius of the containing circle.

type segments

int, optional

param segments

The number of segments along each edge. Must be >= 1.

rtype

Mesh

return

a reference to the mesh component

static create_tube(*args, **kwargs)

Creates an uncapped tube (a cylinder with thickness) centered at the origin and aligned along the z-axis.

type name

string

param name

The name (used as a primary key) for this mesh component

type radius

float, optional

param radius

The outer radius of the cylinder on the xy-plane.

type innerRadius

float, optional

param innerRadius

The inner radius of the cylinder on the xy-plane.

type size

float, optional

param size

Half of the length of the cylinder along the z-axis.

type slices

int, optional

param slices

Subdivisions around the z-axis.

type segments

int, optional

param segments

Subdivisions along the z-axis.

type start

float, optional

param start

Counterclockwise angle around the z-axis relative to the x-axis.

type sweep

float, optional

param sweep

Counterclockwise angle around the z-axis.

rtype

Mesh

return

a reference to the mesh component

static create_tube_from_polyline(name, path, radius=1.0, segments=16)

Creates a tube from a circle extruded linearly along the specified path.

type name

string

param name

The name (used as a primary key) for this mesh component

type path

std::vector< glm::vec3,std::allocator< glm::vec3 > >

param path

A set of vertices describing a linear path.

type radius

float, optional

param radius

The radius of the extruded circle

type segments

int, optional

param segments

Number of subdivisions around the circle.

rtype

Mesh

return

a reference to the mesh component

static create_wireframe_bounding_box(*args, **kwargs)

Creates a wireframe bounding box spanning the region between the minimum corner to the maximum corner, and aligned along the x, y, and z axis.

Parameters
  • name (string) – The name (used as a primary key) for this mesh component

  • min_corner (vec3, optional) – The position of the bottom left near corner of the axis aligned bounding box.

  • max_corner (vec3, optional) – The position of the top right far corner of the axis aligned bounding box.

  • size – The side length in x (0), y (1) and z (2) direction.

  • thickness (float, optional) – The thickness of the wires in the wireframe.

Return type

Mesh

Returns

a reference to the mesh component

generate_smooth_normals()

Replaces any existing normals with per-vertex smooth normals computed by averaging neighboring geometric face normals together. Note that this does not take into account the surface area of each triangular face.

static get(name)
Parameters

name (string) – The name of the Mesh to get

Return type

Mesh

Returns

a Mesh who’s name matches the given name

get_aabb_center()
Return type

vec3

Returns

the center of the aligned bounding box

get_bounding_sphere_radius()
Return type

float

Returns

the radius of a sphere centered at the centroid which completely contains the mesh

get_center()
Return type

vec3

Returns

the average of the vertices of the mesh, which will lay roughly in the center.

get_colors()
Return type

std::vector< glm::vec4,std::allocator< glm::vec4 > >

Returns

a list of per vertex colors

static get_count()
Return type

int

Returns

the number of allocated meshes

static get_dirty_meshes()
Return type

std::set< nvisii::Mesh * >

Returns

a list of meshes that have been modified since the previous frame

static get_edit_mutex()

For internal use. Returns the mutex used to lock entities for processing by the renderer.

static get_front()
Return type

Mesh

Returns

a pointer to the table of mesh components

static get_front_struct()
Return type

MeshStruct

Returns

a pointer to the table of MeshStructs required for rendering

get_id()
Return type

int

Returns

the unique integer ID for this component

get_max_aabb_corner()
Return type

vec3

Returns

the maximum axis aligned bounding box position

get_min_aabb_corner()
Return type

vec3

Returns

the minimum axis aligned bounding box position

get_name()
Return type

string

Returns

the name of this component

static get_name_to_id_map()
Return type

std::map< std::string,uint32_t,std::less< std::string >,std::allocator< std::pair< std::string const,uint32_t > > >

Returns

A map whose key is a mesh name and whose value is the ID for that mesh

get_normals()
Return type

std::vector< glm::vec4,std::allocator< glm::vec4 > >

Returns

a list of per vertex normals

get_tangents()
Return type

std::vector< glm::vec4,std::allocator< glm::vec4 > >

Returns

a list of per vertex tangents

get_tex_coords()
Return type

std::vector< glm::vec2,std::allocator< glm::vec2 > >

Returns

a list of per vertex texture coordinates

get_triangle_indices()
Return type

std::vector< uint32_t,std::allocator< uint32_t > >

Returns

a list of triangle indices

get_vertices()
Parameters

vertex_dimensions – The number of floats per vertex to return. Valid numbers are 3 or 4.

Return type

std::vector< std::array< float,3 >,std::allocator< std::array< float,3 > > >

Returns

a list of per vertex positions

static initialize_factory(max_components)

Allocates the tables used to store all mesh components

static is_factory_initialized()
Return type

boolean

Returns

True if the tables used to store all mesh components have been allocated, and False otherwise

is_initialized()
Return type

boolean

Returns

True the current mesh is a valid, initialized mesh, and False if the mesh was cleared or removed.

mark_dirty()

Tags the current component as being modified since the previous frame.

static remove(name)
Parameters

name (string) – The name of the Mesh to remove

property thisown

The membership flag

to_string()
Return type

string

Returns

a json string representation of the current component

static update_components()

Iterates through all mesh components, computing mesh metadata for rendering purposes.