render_object

function

render_object(_object[, _materials[, _fn]])

Description

Enqueues all instances of an object for rendering in batches of BBMOD_DynamicBatch.size.

Arguments

Name Type Description
_object Asset.GMObject An object to render.
_materials Array<Struct.BBMOD_Material> An array of materials to use.
_fn Function A function that writes instance data to an array which is then passed to the material's shader. Defaults to BBMOD_DynamicBatch.DataWriter if undefined.

Returns

Struct.BBMOD_DynamicBatch Returns self.

Example

carBatch.render_object(OCar, [matCar], function (_data, _index) {
    // Position
    _data[@ _index] = x;
    _data[@ _index + 1] = y;
    _data[@ _index + 2] = z;
    // Uniform scale
    _data[@ _index + 3] = image_xscale;
    // Rotation
    new BBMOD_Quaternion()
        .FromAxisAngle(BBMOD_VEC3_UP, image_angle)
        .ToArray(_data, _index + 4);
    // ID
    _data[@ _index + 8] = ((id & $000000FF) >> 0) / 255;
    _data[@ _index + 9] = ((id & $0000FF00) >> 8) / 255;
    _data[@ _index + 10] = ((id & $00FF0000) >> 16) / 255;
    _data[@ _index + 11] = ((id & $FF000000) >> 24) / 255;
});

The function defined in this example is actually the implementation of BBMOD_DynamicBatch.default_fn. You can use this to create your own variation of it.

See also

BBMOD_DynamicBatch.DataWriter, BBMOD_DynamicBatch.render, BBMOD_DynamicBatch.submit, BBMOD_DynamicBatch.submit_object

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on November 16, 2022 using GMDoc.