render_object(_object, _material[, _fn])


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


Name Type Description
_object Real An object to render.
_material Struct.BBMOD_Material A material to use.
_fn Function/Undefined A function that writes instance data to an array which is then passed to the material's shader. Must return number of slots it has written to. Defaults to BBMOD_DynamicBatch.default_fn.


BBMOD_DynamicBatch Returns self.


carBatch.render_object(OCar, mat_car, function (_data, _index) {
    // Position
    _data[@ _index] = x;
    _data[@ _index + 1] = y;
    _data[@ _index + 2] = z;
    // Uniform scale
    _data[@ _index + 3] = image_xscale;
    // Rotation
    var _quat = new BBMOD_Quaternion()
        .FromAxisAngle(new BBMOD_Vec3(0, 0, 1), image_angle);
        _quat.ToArray(_data, _index + 4);
    // Written 8 slots in total
    return 8;

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.default_fn, BBMOD_DynamicBatch.render, BBMOD_DynamicBatch.submit, BBMOD_DynamicBatch.submit_object

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on May 18, 2022 using GMDoc.