Hi,
I’m creating model using libSC, I wonder if it is possible to generate XML file and shattered sub SCS files without using libconverter ?
The files created should be the same as :
and can be loaded by communicator web viewer correctly.
Thanks.
Hi,
I’m creating model using libSC, I wonder if it is possible to generate XML file and shattered sub SCS files without using libconverter ?
The files created should be the same as :
and can be loaded by communicator web viewer correctly.
Thanks.
Hi,
I have seen this post before your reply.
It is different from my request. I want to write or create .XML and .SCS files by libSC, not read.
Thanks.
You should be able to write to Stream Cache as the article talks about.
With respect to generating an XML file, please refer to the libsc function SerializeToXML.
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 !
scz.zip (1.3 MB)
Hello @820110017,
There isn’t anything wrong with your code that I can find.
When building the master assembly model, there is not actually a model (geometry that has a valid bounding box) in the resulting SC file as it contains only the assembly information. Thus, the message PrepareStream seems invalid - possible empty Model?
is appropriate in this case.
So provided that you have set your directory correctly (C:\\scztest
contains microengine1.scz and microengine2.scz), I would expect your code to work. As a quick test, here is my result:
Thanks,
Tino