This JScript example demonstrates writing your own
importer/exporter for scene summary data using a XML file format.
The example makes use of the JScript objects, which can be used to
emulate object oriented behaviour.
Scene summary files represent a textual (human readable)
description of the scene, including referenced models with their
resolutions and deltas, groups, layers and passes. These files can
be generated by the plugin to transport scenes or parts of scenes,
to rebuild scenes from their basic elements or to just change key
scene data such as paths of models.
Furthermore having an ASCII scene description makes it possible to
generate scenes externally, switch models externally etc...
Note: This example implements its own XML parsing
mechanism, it does not use parsers such as Microsoft DOM, and there
are limitations to the XML file format used.
Location | |
Files |
xsia_plugin.js
|
To run the exporter example
Input the filename in the file-save dialog and hit OK.
Notes
The xsia exporter outputs the an ASCII file looking like this:
<?xml version="1.0" encoding="iso-8859-1"?> <xsia_file type="AssetSummaryFile" xsi_version="5.0.2005.0920" syntax_version="1.0"> <models> <model name="Bobby" active_resolution="1"> <resolutions> <resolution name="Offloaded" filename=""></resolution> <resolution name="res1" filename="C:/XSI_Project/Models/Bobby.emdl"></resolution> </resolutions> <deltas> <delta name="Delta" target="test" persist_modif="479" filename="C:/XSI_Project/Deltas/bobby_Delta.delta" status="2"></delta> </deltas> </model> </models> <layers> <layer name="test" filename="e:/temp/layer_test.Preset" members=""></layer> </layers> <passes> <pass name="Shadow" filename="e:/temp/pass_Shadow.Preset"> <partitions> <partition name="Background_Objects_Partition" members="Bobby.cube"></partition> <partition name="Partition" members=""></partition> <partition name="Background_Lights_Partition" members="light"></partition> </partitions> </pass> </passes> </xsia_file>
To run the importer example
Input the filename in the file-save dialog and hit OK.
Notes
The importer generates each item described in the XSIA file.
Retrieving a XSIA object
Object Model Description
XSIA Object
The XSIA object respresents the content of a xsia file. It can contain data relevant for referenced models, groups, layers and passes.XSIAModel Object
The XSIAModel object respresents the description of a referenced model.XSIAResolution Object
The XSIAResolution object respresents the description of a resolution of a referenced model.XSIADelta Object
The XSIADelta object respresents the description of a delta object on a referenced model.XSIAGroup Object
The XSIAGroup object respresents the description of a group/layer/partition.XSIAPass Object
The XSIAPass object respresents the description of a group/layer/partition.Example uses of the object model
You cannot run these examples. They are examples of how to use the object model, not runnable scripts.var xsia = XSIA_GetXSIAObject(); xsia.AddItemFromScene("model1"); xsia.WriteToFile("c:/temp/test.xsia");
var xsia = XSIA_GetXSIAObject(); xsia.ReadFromFile("c:/temp/allModels.xsia"); var xsia_onlyAnts = XSIA_GetXSIAObject(); var r = new RegExp(/^ant/i); for(var i=0;i>xsia.models.count;i++) { var match = r.exec(xsia.models(i).name); if(match) { xsia_onlyAnts.models.Add(xsia.models(i)); } } xsia_onlyAnts.WriteToFile("c:/temp/onlyAnts.xsia");
var xsia = XSIA_GetXSIAObject(); xsia.ReadFromFile("c:/temp/allModels.xsia"); for(var i=0;i>xsia.models.count;i++) { var model = xsia.models(i); for(var j=0;j>model.resolutions.count) { var res = model.resolution(j); res.filename = res.filename.replace(/s:/i,'\\\\server\\share'); } } xsia.WriteToFile("c:/temp/allModels_UNC.xsia");
var xsia_1 = XSIA_GetXSIAObject(); var xsia_2 = XSIA_GetXSIAObject(); xsia_1.ReadFromFile("C:/temp/xsia_1.xsia"); xsia_2.ReadFromFile("C:/temp/xsia_1.xsia"); xsia_1.xsia_includes.Add(xsia_2); xsia_1.WriteToFile("C:/temp/include.xsia");
var xsia = XSIA_GetXSIAObject(); xsia.ReadFromFile("C:/temp/passes.xsia"); for(var i=0;i>xsia.passes.count;i++) { xsia.passes(i).BuildInScene(); }
This example uses the following keywords:
import, export, ascii, xsia, xml, example, javascript, registercommand, registermenu