Table Of Contents

Previous topic

17.20. The Source Object

Next topic

17.22. The TechniqueParameters Object

This Page

17.21. The TechniqueParameterBuffer Object

A TechniqueParameterBuffer object is an optimal container for large numbers of floating point values to be set as a technique parameter, for example as the array of values containing bone matrices for skinning.

This object is only recommended for large arrays or for those that don’t match the number of elements of the objects provided by the MathDevice.

17.21.1. Constructor

A TechniqueParameterBuffer object can be constructed with GraphicsDevice.createTechniqueParameterBuffer.

17.21.2. Methods

17.21.2.1. map

Summary

Requests write access to a region of the TechniqueParameterBuffer.

Syntax

var writer = parameterBuffer.map(firstValueToMap, numValuesToMap);
if (writer)
{
    var v3zero = mathDevice.v3(0, 0, 0);

    for (var n = 0; n < (numValuesToMap / 3); n += 1)
    {
        writer(v3zero);
    }

    parameterBuffer.unmap(writer);
}
firstValueToMap (Optional)
The zero-based index of the first value to map. If it is not specified the whole TechniqueParameterBuffer will be mapped.
numValuesToMap (Optional)
The number of values to map. If it is not specified all the values after and including firstValueToMap will be mapped.

Returns a parameter value writer.

The writer can be called once for each mapped value. It can also be called with multiple values as parameters or with an object containing multiple values as a single parameter in order to write multiple values with just one call, this is more optimal than a call per value but be careful not to write more than the ones the TechniqueParameterBuffer was created with or the writer will fail.

17.21.2.2. unmap

Summary

Communicate to the TechniqueParameterBuffer that write access to a mapped region is no longer required.

Syntax

var writer = parameterBuffer.map(firstValueToMap, numValuesToMap);
if (writer)
{
    // Do something with the writer here

    parameterBuffer.unmap(writer);
}
writer
The writer returned by a previous call to map.

This method must be called if map returns a valid writer.

17.21.3. Properties

17.21.3.1. numFloats

Summary

Number of floating point values stored on the TechniqueParameterBuffer.

Syntax

var numFloats = parameterBuffer.numFloats;

Note

Read Only

17.21.3.2. dynamic

Summary

True if the TechniqueParameterBuffer was created as dynamic and hence can be modified at runtime, false otherwise.

Syntax

var isDynamic = parameterBuffer.dynamic;

Note

Read Only

17.21.3.3. data

Summary

The array of values stored on the TechniqueParameterBuffer.

Create the TechniqueParameterBuffer as dynamic if you are planning to update the values at runtime.

Changing or requesting the values can be an expensive operation.

For a more optimal way to modify the values please use the methods map and unmap.

Syntax

// request all the data
var parameterData = parameterBuffer.data;

// update some
parameterData[0] = 0.5;
parameterData[1] = 0.25;
parameterData[2] = 0.125;

// put it all back
parameterBuffer.data = parameterData;