dmsurti / AssimpKit

A library (macOS, iOS) that converts the files supported by Assimp to Scene Kit scenes.
http://assimpkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
477 stars 54 forks source link

The problem with the import of external textures for the 3ds model #109

Open SanyaUA opened 6 years ago

SanyaUA commented 6 years ago

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);

    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

ghost commented 6 years ago

Also receiving this issue on a couple of my models