Hi,
I tried to combine two models according to this post :How-To: Use BuildMasterAssemblyModel function
It returned true after calling “BuildMasterAssemblyModel”.
But there seems something wrong in console, and the result data seems empty.
Here’s my code, only change the cache_path.
int
CombineSample(const std::string& model_path)
{
std::string cache_path = "C:\\scztest";
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;
}
What’s wrong with my code?
Thanks !