Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SanyaUA opened this issue Aug 6, 2018 · 1 comment
Open

Comments

@SanyaUA
Copy link

SanyaUA commented Aug 6, 2018

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
Copy link

ghost commented Sep 25, 2018

Also receiving this issue on a couple of my models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant