I use AssimpKit library in my iOS application for export different 3d formats into ARKit app, but I have a problem with applying external textures to the model. Geometry of the model exporting correctly. But external textures does not apply. I have read all issues in the library repo and it didn’t help.
Code which is responsible for import 3ds models:
NSString * modelDir = [paths[0] stringByAppendingPathComponent:url.lastPathComponent];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelDir error:nil];
for (NSString * fileName in directoryContent) {
if ([fileName.pathExtension isEqualToString:@"3DS"])
{
NSString *scnFileName = [fileName stringByReplacingOccurrencesOfString:@"3DS" withString:@"scn"];
NSString *scnFilePath = [[paths[0] stringByAppendingPathComponent:@"SCN"] stringByAppendingPathComponent: scnFileName];
if (![[NSFileManager defaultManager] fileExistsAtPath:scnFilePath]) {
[[NSFileManager defaultManager] createFileAtPath:scnFilePath contents:nil attributes:nil];
}
scene = [SCNScene assimpSceneWithURL:[NSURL URLWithString:[modelDir stringByAppendingPathComponent:fileName]]
postProcessFlags:AssimpKit_Process_FlipUVs | AssimpKit_Process_ValidateDataStructure];
if ([scene.modelScene writeToURL:[NSURL URLWithString:scnFilePath] options:nil delegate:nil progressHandler:nil]) {
NSLog(@"Serialized success for %@. Output to %@", fileName, scnFilePath);
NSLog(@"Size of the scn file is %llu", [[[NSFileManager defaultManager] attributesOfItemAtPath:scnFilePath error:nil] fileSize]);
} else {
NSLog(@"Serialized FAILED for %@", fileName);
}
} else {
continue;
}
}`
Example of the model:
Nighstand.zip
Received error:
CGImageSourceCreateImageAtIndex:3490: ERROR: CGImageSourceCreateImageAtIndex: source is nil
CGImageSourceCreateImageAtIndex:3490: ERROR: CGImageSourceCreateImageAtIndex: source is nil
CGImageSourceCreateImageAtIndex:3490: *** ERROR: CGImageSourceCreateImageAtIndex: source is nil
I use AssimpKit library in my iOS application for export different 3d formats into ARKit app, but I have a problem with applying external textures to the model. Geometry of the model exporting correctly. But external textures does not apply. I have read all issues in the library repo and it didn’t help. Code which is responsible for import 3ds models:
`NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
Example of the model: Nighstand.zip Received error: CGImageSourceCreateImageAtIndex:3490: ERROR: CGImageSourceCreateImageAtIndex: source is nil CGImageSourceCreateImageAtIndex:3490: ERROR: CGImageSourceCreateImageAtIndex: source is nil CGImageSourceCreateImageAtIndex:3490: *** ERROR: CGImageSourceCreateImageAtIndex: source is nil