BBMOD_MeshBuilder

A constructor defined in BBMOD_MeshBuilder.gml

Implements BBMOD_IDestructible

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.
destroy Frees memory used by the struct.
make_tangents Makes tangent and bitangent vectors for added vertices.

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(_v1Ind, _v2Ind, _v4Ind);
_meshBuilder.add_face(_v2Ind, _v3Ind, _v4Ind);
var _mesh = _meshBuilder.build();
_meshBuilder = _meshBuilder.destroy();

See also

BBMOD_Mesh, BBMOD_Vertex, BBMOD_VertexFormat

Do you find this page helpful?

Copyright © 2024, BlueBurn. Built on September 07, 2024 using GMDoc.