BBMOD_MeshBuilder

A constructor defined in BBMOD_MeshBuilder.gml

Extends BBMOD_Class

new BBMOD_MeshBuilder([_primitiveType])

Description

Allows you to build meshes through code.

Arguments

Name Type Description
_primitiveType Constant.PrimitiveType The primitive type of built meshes. Defaults to pr_trianglelist.

Properties

Name Description
Faces List of vertex indices that make up a face. First three indices are the first face, next three indices are the second face etc.
PrimitiveType The primitive type of built meshes.
Vertices List of mesh vertices.

Methods

Name Description
add_face Adds a face to the mesh.
add_vertex Adds a vertex to the mesh.
build Builds a mesh from the added vertices and faces.
make_tangents Makes tangent and bitangent vectors for added vertices.

Inherited methods

Name Description
destroy Frees resources used by the struct from memory.
implement Implements an interface into the struct.
implements Checks whether the struct implements an interface.
is_instance Checks if the struct inherits from given class.

Example

Following code shows how you can create a plane mesh using the mesh builder.

var _meshBuilder = new BBMOD_MeshBuilder();
var _vertexFormat = new BBMOD_VertexFormat(true);
var _v1 = new BBMOD_Vertex(_vertexFormat);
_v1.Position = new BBMOD_Vec3(0.0, 0.0, 0.0);
var _v1Ind = _meshBuilder.add_vertex(_v1);
var _v2 = new BBMOD_Vertex(_vertexFormat);
_v2.Position = new BBMOD_Vec3(1.0, 0.0, 0.0);
var _v2Ind = _meshBuilder.add_vertex(_v2);
var _v3 = new BBMOD_Vertex(_vertexFormat);
_v3.Position = new BBMOD_Vec3(1.0, 1.0, 0.0);
var _v3Ind = _meshBuilder.add_vertex(_v3);
var _v4 = new BBMOD_Vertex(_vertexFormat);
_v4.Position = new BBMOD_Vec3(0.0, 1.0, 0.0);
var _v4Ind = _meshBuilder.add_vertex(_v4);
_meshBuilder.add_face(_v1, _v2, _v4);
_meshBuilder.add_face(_v2, _v3, _v4);
var _mesh = _meshBuilder.build();
_meshBuilder = _meshBuilder.destroy();

See also

BBMOD_Mesh, BBMOD_Vertex, BBMOD_VertexFormat

Do you find this page helpful?

Copyright © 2023, BlueBurn. Built on May 02, 2023 using GMDoc.