MCPcopy Create free account
hub / github.com/OGRECave/ogre / XMLToBinary

Function XMLToBinary

Tools/XMLConverter/src/main.cpp:283–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void XMLToBinary(const XmlOptions& opts, MeshSerializer& meshSerializer)
284{
285 // Read root element and decide from there what type
286 pugi::xml_document doc;
287 auto result = doc.load_file(opts.source.c_str());
288 if (!result)
289 {
290 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
291 StringUtil::format("Unable to load '%s' - %s", opts.source.c_str(), result.description()));
292 }
293 pugi::xml_node root = doc.document_element();
294 if (StringUtil::startsWith("mesh", root.name()))
295 {
296 MeshPtr newMesh = MeshManager::getSingleton().createManual("conversion",
297 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
298
299 XMLMeshSerializer xmlMeshSerializer;
300 xmlMeshSerializer.importMesh(opts.source, newMesh.get());
301
302 if( opts.mergeTexcoordResult != opts.mergeTexcoordToDestroy )
303 {
304 newMesh->mergeAdjacentTexcoords( uint16(opts.mergeTexcoordResult), uint16(opts.mergeTexcoordToDestroy) );
305 }
306
307 if (opts.nuextremityPoints)
308 {
309 for (size_t i = 0; i < newMesh->getNumSubMeshes(); i++)
310 {
311 SubMesh* sm = newMesh->getSubMesh(i);
312 sm->generateExtremes (opts.nuextremityPoints);
313 }
314 }
315
316 meshSerializer.exportMesh(newMesh, opts.dest, opts.endian);
317 }
318 else if (StringUtil::startsWith("skeleton", root.name()))
319 {
320 SkeletonPtr newSkel = SkeletonManager::getSingleton().create("conversion", RGN_DEFAULT);
321
322 XMLSkeletonSerializer xmlSkeletonSerializer;
323 xmlSkeletonSerializer.importSkeleton(opts.source, newSkel.get());
324 if (opts.optimiseAnimations)
325 {
326 newSkel->optimiseAllAnimations();
327 }
328 SkeletonSerializer skeletonSerializer;
329 skeletonSerializer.exportSkeleton(newSkel.get(), opts.dest, SKELETON_VERSION_LATEST, opts.endian);
330 }
331}
332
333void skeletonToXML(const XmlOptions& opts)
334{

Callers 1

mainFunction · 0.85

Calls 11

getSubMeshMethod · 0.80
generateExtremesMethod · 0.80
optimiseAllAnimationsMethod · 0.80
createManualMethod · 0.45
importMeshMethod · 0.45
getMethod · 0.45
exportMeshMethod · 0.45
createMethod · 0.45
importSkeletonMethod · 0.45
exportSkeletonMethod · 0.45

Tested by

no test coverage detected