BBMOD_MeshBuilder

Extends BBMOD_Class

constructor

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.

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();

See also

BBMOD_Mesh, BBMOD_Vertex, BBMOD_VertexFormat

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on September 19, 2022 using GMDoc.