SC::Store::AssemblyTree::BuildMasterAssemblyModel
will gather part modes and create the master assembly model.
Sample Code
- There are two models, microengine1.scz and microengine2.scz, in C:\HOOPS_Communicator\quick_start\converted_models\authoring_samples_data
- Combine two models and create a assembly model “combine_microengine_sample”.
int
CombineSample(const std::string& model_path)
{
std::string cache_path = "C:\\HOOPS_Communicator_2021\\quick_start\\converted_models\\authoring_samples_data";
std::string model_name = "combine_microengine_sample";
ApplicationLogger logger;
try {
// Open the cache
SC::Store::Database::SetLicense(HOOPS_LICENSE);
SC::Store::Cache cache = SC::Store::Database::Open(logger);
SC::Store::AssemblyTree assembly_tree(logger);
uint32_t root_id = 0;
assembly_tree.CreateAssemblyTreeRoot(root_id);
assembly_tree.SetNodeName(root_id, "assemblytree_sample");
uint32_t child_node = 0;
assembly_tree.CreateChild(root_id, child_node);
assembly_tree.SetNodeName(child_node, "first");
bool res = assembly_tree.SetExternalModel(child_node, "microengine1");
float matrix_data[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
0.0f, 100.0f, 0.0f,
};
SC::Store::Matrix3d * matrix = (SC::Store::Matrix3d *)matrix_data;
assembly_tree.CreateChild(root_id, child_node);
assembly_tree.SetNodeName(child_node, "second");
res = assembly_tree.SetExternalModel(child_node, "microengine2");
assembly_tree.SetNodeLocalTransform(child_node, *matrix);
std::string modelPath = cache_path + "\\" + model_name;
if (cache.Exists((cache_path + "\\" + model_name).c_str())) {
printf("Model already exists.\n");
return 1;
}
res = assembly_tree.BuildMasterAssemblyModel(cache_path.c_str(), modelPath.c_str(), cache_path.c_str(), false);
}
catch (std::exception const & e)
{
std::string message("Exception: ");
message.append(e.what());
message.append("\n");
logger.Message(message.c_str());
return 1;
}
return 0;
}