Mesh

Inherits: Resource < Reference < Object

Inherited By: ArrayMesh, PrimitiveMesh

Category: Core

Brief Description

A Resource that contains vertex-array based geometry.

Member Functions

void add_morph_target ( String name )
void add_surface ( int primitive, Array arrays, Array morph_arrays=Array(), bool alphasort=false )
void center_geometry ( )
void clear_morph_targets ( )
Shape create_convex_shape ( ) const
Mesh create_outline ( float margin ) const
Shape create_trimesh_shape ( ) const
TriangleMesh generate_triangle_mesh ( ) const
AABB get_custom_aabb ( ) const
Vector3Array get_faces ( ) const
int get_morph_target_count ( ) const
int get_morph_target_mode ( ) const
String get_morph_target_name ( int index ) const
int get_surface_count ( ) const
void regen_normalmaps ( )
void set_custom_aabb ( AABB aabb )
void set_morph_target_mode ( int mode )
int surface_get_array_index_len ( int surf_idx ) const
int surface_get_array_len ( int surf_idx ) const
int surface_get_format ( int surf_idx ) const
Material surface_get_material ( int surf_idx ) const
String surface_get_name ( int surf_idx ) const
int surface_get_primitive_type ( int surf_idx ) const
void surface_remove ( int surf_idx )
void surface_set_material ( int surf_idx, Material material )
void surface_set_name ( int surf_idx, String name )

Numeric Constants

  • PRIMITIVE_POINTS = 0 — Render array as points (one vertex equals one point).
  • PRIMITIVE_LINES = 1 — Render array as lines (every two vertices a line is created).
  • PRIMITIVE_LINE_STRIP = 2 — Render array as line strip.
  • PRIMITIVE_LINE_LOOP = 3 — Render array as line loop (like line strip, but closed).
  • PRIMITIVE_TRIANGLES = 4 — Render array as triangles (every three vertices a triangle is created).
  • PRIMITIVE_TRIANGLE_STRIP = 5 — Render array as triangle strips.
  • PRIMITIVE_TRIANGLE_FAN = 6 — Render array as triangle fans.

Description

Mesh is a type of Resource that contains vertex-array based geometry, divided in surfaces. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.

Member Function Description

  • void add_morph_target ( String name )
  • void add_surface ( int primitive, Array arrays, Array morph_arrays=Array(), bool alphasort=false )

Create a new surface (get_surface_count that will become surf_idx for this.

Surfaces are created to be rendered using a “primitive”, which may be PRIMITIVE_POINTS, PRIMITIVE_LINES, PRIMITIVE_LINE_STRIP, PRIMITIVE_LINE_LOOP, PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN. (As a note, when using indices, it is recommended to only use just points, lines or triangles).

The format of a surface determines which arrays it will allocate and hold, so “format” is a combination of ARRAY_FORMAT_* mask constants ORed together. ARRAY_FORMAT_VERTEX must be always present. “array_len” determines the amount of vertices in the array (not primitives!). if ARRAY_FORMAT_INDEX is in the format mask, then it means that an index array will be allocated and “index_array_len” must be passed.

  • void center_geometry ( )
  • void clear_morph_targets ( )
  • Shape create_convex_shape ( ) const
  • Shape create_trimesh_shape ( ) const
  • TriangleMesh generate_triangle_mesh ( ) const
  • AABB get_custom_aabb ( ) const
  • Vector3Array get_faces ( ) const
  • int get_morph_target_count ( ) const
  • int get_morph_target_mode ( ) const
  • String get_morph_target_name ( int index ) const
  • int get_surface_count ( ) const

Return the amount of surfaces that the Mesh holds.

  • void regen_normalmaps ( )
  • void set_custom_aabb ( AABB aabb )
  • void set_morph_target_mode ( int mode )
  • int surface_get_array_index_len ( int surf_idx ) const

Return the length in indices of the index array in the requested surface (see add_surface).

  • int surface_get_array_len ( int surf_idx ) const

Return the length in vertices of the vertex array in the requested surface (see add_surface).

  • int surface_get_format ( int surf_idx ) const

Return the format mask of the requested surface (see add_surface).

Return a Material in a given surface. Surface is rendered using this material.

  • String surface_get_name ( int surf_idx ) const
  • int surface_get_primitive_type ( int surf_idx ) const
  • Shape create_convex_shape ( ) const
  • Shape create_trimesh_shape ( ) const