submit_object

function

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

Description

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

Arguments

Name Type Description
_object Real An object to submit.
_material Array<Struct.BBMOD_Materials> 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.default_fn if undefined.

Returns

Struct.BBMOD_DynamicBatch Returns self.

Example

carBatch.submit_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.DataWriter. You can use this to create you own variation of it.

See also

BBMOD_DynamicBatch.DataWriter, BBMOD_DynamicBatch.render, BBMOD_DynamicBatch.render_object, BBMOD_DynamicBatch.submit

Do you find this page helpful?

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