ArcGIS Procedural Runtime
3.2.10650
|
In general, the term "instancing" refers to the re-use of data - usually geometry - by using references instead of copies. During model generation in PRT instancing can happen in two ways:
All built-in encoders of the CE SDK which support writing initial shape attributes understand the reserved initial shape attribute key "/enc/metaData/". If any attributes are prefixed with "/enc/metaData" the encoder will attempt to output them accordingly.
Here is an example how to get the attributes "myItem1, myItem2, myItem3" to output in the order "myItem1, myItem3, myItem2":
prt::AttributeMapBuilder* builder = prt::AttributeMapBuilder::create(); builder->setInt(L"/enc/metaData/myItem1", 10); builder->setInt(L"/enc/metaData/myItem2", 20); builder->setInt(L"/enc/metaData/myItem3", 30); builder->setInt(L"myItemForCGA", 99); const prt::AttributeMap* attrMap = builder->createAttributeMap(); builder->destroy(); prt::InitialShapeBuilder* isBuilder = prt::InitialShapeBuilder::create(); isBuilder->setAttributes(..., attrMap, ...); const prt::InitialShape* initialShape = isBuilder->createInitialShapeAndReset(); isBuilder->destroy(); prt::generate(...); // -> encoders will emit "myItem1, myItem3, myItem2" initialShape->destroy(); attrMap->destroy();
A PRT encoder must meet a few requirements to be successfully loaded by CityEngine as a custom exporter:
Here is an example how to setup an encoder info object inside an encoder factory (the full sources are available in the "stlenc" example):
prtx::EncoderInfoBuilder encoderInfoBuilder; encoderInfoBuilder.setID(...); encoderInfoBuilder.setName(...); encoderInfoBuilder.setDescription(...); encoderInfoBuilder.setType(prt::CT_GEOMETRY); encoderInfoBuilder.setExtension(L".ext");
All URIs in PRT follow the standard RFC3986: http://www.ietf.org/rfc/rfc3986.txt In practice this means:
Here is an example how to create such an URI from a file system path:
// linux/osx example (assuming UTF8 for native strings) std::string fsp = "/home/johndoe/my/path/hello.txt"; std::string uri = prtx::URI::SCHEME_FILE + ":" + fsp; // results in 'file:/home/johndoe/my/path/hello.txt' uri = prtx::URI::percentEncode(uri); std::wstring wuri(uri.size(), L' '); std::copy(uri.begin(), uri.end(), wuri.begin()); // now use wuri.c_str() for prt API calls... // windows example (assuming Latin1 string encoding) std::string fsp = "C:/some/path/file.txt"; // note: windows paths must be converted to forward slashes std::string u8fsp = boost::locale::conv::to_utf<char>(fsp, "Latin1"); std::string uri = prtx::URI::SCHEME_FILE + ":/" + u8fsp; // note the slash before the drive letter uri = prtx::URI::percentEncode(uri); std::wstring wuri(uri.size(), L' '); std::copy(uri.begin(), uri.end(), wuri.begin()); // now use wuri.c_str() for prt API calls...