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

Can't manage to export fbx as scn #92

Closed
leandrodemarco opened this issue Dec 11, 2017 · 5 comments
Closed

Can't manage to export fbx as scn #92

leandrodemarco opened this issue Dec 11, 2017 · 5 comments

Comments

@leandrodemarco
Copy link

leandrodemarco commented Dec 11, 2017

This is probably some dumb mistake I'm missing, but been stuck with it for quite a few hours now so I'd appreciate any help or hint to solve it. I have a bunch of .fbx files I'd like to convert to .scn
I'm doing it on Mac, with a very tiny simple app which on it's applicationDidFinishLaunching: method has the following lines

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *fbxDir = [paths[0] stringByAppendingPathComponent:@"FBX"];
    NSArray *directoryContent  = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:fbxDir error:nil];

    for (NSString *fileName in directoryContent) {
        NSString *scnFileName = [fileName stringByReplacingOccurrencesOfString:@"fbx" withString:@"scn"];
        NSString *scnFilePath = [[paths[0] stringByAppendingPathComponent:@"SCN"] stringByAppendingPathComponent:scnFileName];

//        if (![[NSFileManager defaultManager] fileExistsAtPath:scnFilePath]) {
//            [[NSFileManager defaultManager] createFileAtPath:scnFilePath contents:nil attributes:nil];
//        }

        SCNAssimpScene *scene = [SCNScene assimpSceneWithURL:[NSURL URLWithString:[fbxDir stringByAppendingPathComponent:fileName]]
                                            postProcessFlags:AssimpKit_JoinIdenticalVertices | AssimpKit_Process_Triangulate];

        if ([scene writeToURL:[NSURL URLWithString:scnFilePath] options:nil delegate:nil progressHandler:nil]) {
            NSLog(@"Serialized success for %@. Output to %@", fileName, scnFilePath);
        } else { NSLog(@"Serialized FAILED for %@", fileName); }
    }
}

In theory everything goes fine as for each one of the files I see the log message:
Serialized success for <fileName>.fbx. Output to /Users/Leandro/Documents/SCN/<fileName>.scn

If I forcefully create a file at that path with the commented lines, the file remains 0 bytes in size.
I've disabled sandbox of the app as it says here but no changes: https://forums.developer.apple.com/thread/88701

@dmsurti
Copy link
Owner

dmsurti commented Dec 12, 2017

@leandrodemarco

You need to write out the modelScene and/or animationScenes inside your SCNAssimpScene object. See: https://dmsurti.github.io/AssimpKit/appledocs/html/Classes/SCNAssimpScene.html

So it should be for example:

[scene.modelScene writeToURL...]

@leandrodemarco
Copy link
Author

HI @dmsurti, thanks for the quick reply and for the great work maintaining this library. I forgot to mention in my original post I had also tried writing out the modelScene with exactly same results. Would it help if I upload one of the fbx files? (it weights around 20 MB)

@dmsurti
Copy link
Owner

dmsurti commented Dec 13, 2017

@leandrodemarco

thanks for the quick reply and for the great work maintaining this library
👍

Have you also tried loading the file with the macOS/iOS sample apps in the AssimpKit repo? That way you know that there is no problem in reading and viewing the fbx file.

Would it help if I upload one of the fbx files

Sure thing, upload the FBX file. IIUC, you are not able to write this FBX to a scn file? Otherwise, uploading a sample project to GH would also help.

@leandrodemarco
Copy link
Author

leandrodemarco commented Dec 14, 2017

Sorry for the delay @dmsurti. Here's a link to one of the fbx files: https://ufile.io/zpqe5

IIUC, you are not able to write this FBX to a scn file?

Exactly that, my Mac "app", just contains those lines I posted.

Have you also tried loading the file with the macOS/iOS sample apps in the AssimpKit repo?

I've just cloned the repo. I just opened the workspace and see there's an OSX-Example app. You mean to compile that?

@dmsurti
Copy link
Owner

dmsurti commented Dec 15, 2017

@leandrodemarco There is no problem per se in AssimpKit with the fbx model. I loaded it fine and also wrote it out to a .scn file without any issues.

The minimal relevant sample code to save is:


[scene.modleScene writeToURL:panel.URL
                                         options:nil
                                       delegate:nil
                         progressHandler:nil];

I have attached the compressed exported scn file here. kia-hq-anim-00.scn.zip

Orthongal to the export issue, there is a problem in that some geometry is not rendered correctly. I have opened a separate issue for that here:

screenshot 2017-12-15 14 00 40

You can also download an app if you want to verify: http://www.isonapps.com, which is developed using AssimpKit. I have used this app to import your fbx and export it to .scn.

You will need to debug your file path related code; sorry I won't be able to help any further than this.

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

2 participants