submit_object

function

submit_object(_object, _material[, _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 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.

Returns

BBMOD_DynamicBatch Returns self.

Example

carBatch.submit_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 you own variation of it.

See also

BBMOD_DynamicBatch.default_fn, BBMOD_DynamicBatch.render, BBMOD_DynamicBatch.render_object, BBMOD_DynamicBatch.submit

Do you find this page helpful?

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