i am using assimp libary to load models to my ios app. but for some large model files loading times are too long for an mobil app.
considering the convert process time. i decided to convert my models by a tool before run time.
my main goal is writing this scene to file.
i have very basic c++ experience. First i tried assimp::expoerter class.
i complied assimp libary with export settings on.
But when i try to use export method i am getting this error message.
No matching member function for call to 'Export'
method is there but i can't use it.
scene = (aiScene*) aiImportFile([[openPanel filename] cStringUsingEncoding:[NSString defaultCStringEncoding]], aiPostProccesFlags | aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_PreTransformVertices | 0 );
if (scene) {
NSString *pPath = [openPanel filename];
pPath =[NSString stringWithFormat:@"%@%@", pPath, @"_new"];
NSLog(@"New file Path : %@", pPath);
Assimp::Exporter *exporter = new Assimp::Exporter();
exportFormatDesc = exporter->GetExportFormatDescription(0);
exporter->Export(scene, exportFormatDesc->id, pPath);
const aiExportDataBlob *blob = exporter->ExportToBlob(scene, exportFormatDesc->id);
size_t blobSize = blob->size;
aiString blobName = blob->name;
}
then by reading Assimp::Exporter Class Reference gives me the idea of using aiExportDataBlob to create file.
ExportToBlob which returns a linked list of memory buffers (blob), each referring to one output file (in most cases there will be only one output file of course, but this extra complexity is needed since Assimp aims at supporting a wide range of file formats).
ExportToBlob is especially useful if you intend to work with the data in-memory.
const aiExportDataBlob *blob = exporter->ExportToBlob(scene, exportFormatDesc->id);
size_t blobSize = blob->size;
aiString blobName = blob->name;
But i have no idea to write this blob to a file.
Any advice or help appreciated.
You're passing
NSString *
where the function expectsconst char *
. I'm not familiar with Objective-C, but I think you want[pPath UTF8String]
to get pointer to a C-style character array from theNSString
.(Also, you're leaking the
Exporter
: C++ doesn't have garbage collection. I'm sure you don't want to create it withnew
but, if you do need to for some reason, remember todelete
it when you're done).