It is recommended that you read the creating a mapping table section before proceeding.
The MappingTable object allows the Turbulenz Services to control where your game assets are hosted without requiring changes to your game’s code. Subsequently, all requests for game assets must be made with a URL received from a getURL call.
A mapping table can be created with the TurbulenzServices.createMappingTable method.
Required scripts
The MappingTable object requires:
/*{{ javascript("jslib/utilities.js") }}*/
/*{{ javascript("jslib/services/mappingtable.js") }}*/
The MappingTable file path is set in the local server. It must be in JSON format with the following structure:
{
"version": 1.0,
"urnmapping":
{
"logicalAssetPath1": "physicalAssetPath1",
"logicalAssetPath2": "physicalAssetPath2",
...
"logicalAssetPathN": "physicalAssetPathN",
},
"overrides": // optional (see below)
{
...
}
}
Where logicalAssetPath1 is a string giving the logical path for an asset and physicalAssetPath1 is the physical path to that asset. For example the mapping table for the Sample App is:
{
"version": 1.0,
"urnmapping":
{
"textures/duck.png": "E91_Ym3MMRjHxq4mvC7qQQ.png",
"shaders/standard.cgfx": "RVX9ZZ8vsQgi1c18tHQ2fw.json",
"shaders/debug.cgfx": "IJ_nEyT7jofhyafUf-Opqg.json",
"models/duck.dae": "-IsFBQM8MlnCoRVwRERq1A.json",
"shaders/defaultrendering.cgfx": "_fgBTnJyIvZg0VdNYMAGFw.json"
}
}
Optionally, the Mapping Table data can contain an overrides property, used to specify profiles that override the default table (for example, to automatically load assets of different resolutions based on hardware capabilities). The overrides property must take the form:
"overrides"
{
"profilename1":
{
"urnmapping":
{
"logicalAssetPath1": "profile1AssetPath1",
"logicalAssetPath2": "profile1AssetPath2",
...
},
"parent": "otherprofilename", // optional
},
"profilename2":
{
...
},
}
Each profile can specify just those paths which should be overriden. If a given URL is not found in the urnmapping for the current profile, the parent is checked recursively. If no parent is specified, the default table it used.
MappingTables are created with an active profile name equal to the platformProfile attribute of the SystemInfo object. Developers can also populate MappingTables with custom profiles and activate them at runtime.
For more information about JSON please visit json.org.
Summary
Remap a logical game asset to its real URL path.
Syntax
function missingCallbackFn(assetPath) {}
mappingTable.getURL(assetPath, missingCallbackFn);
//example usage:
var request = function requestFn(assetPath, onload)
{
return TurbulenzEngine.request(mappingTable.getURL(assetPath), onload);
};
Returns a JavaScript string. This string is the URL to load the logical game asset.
Summary
Add a logical alias to another logical path in the mapping table.
Syntax
mappingTable.alias(aliasPath, logicalPath);
//example usage:
mappingTable.alias('lambertshader.cgfx', 'blinnshader.cgfx');
We recommend that you either change your assets to reference logical assets correctly, add effects (EffectManager.add) or use the managers map functions (ShaderManager.map, TextureManager.map and EffectManager.map) rather than use this function.
Summary
Add a logical-physical path pair to the mapping table.
Syntax
mappingTable.map(logicalPath, physicalPath);
//example usage:
mappingTable.map('blinnshader.cgfx', 'IJ_nEyT7jofhyafUf-Opqg.json');
This function is only for debugging. If you need to alias another asset already in your mapping table use MappingTable.alias instead.
Summary
Returns the string name of the currently active profile.
Syntax
var currentProfile = mappingTable.getCurrentProfile();
Summary
Sets the currently active profile.
Syntax
mappingTable.setProfile("mycustomprofile");