1
votes

I am looking for a mobile SDK or any code which can convert .ply,.dae,.stl files to .scn file supported by SceneKit framework of apple.

I tried using AssimpKit for the same but it provides the animation to the provided object. i want the provided file to be converted in .scn format and to be saved in document directory.

I have used the following code what it does is animating the provided file with the SceneKit. I would like to know if there is a way to get the object file exportable in document directory with .scn format using AssimpKit framework or any other SDK.

Any help will be appreciated.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                         NSUserDomainMask, YES);
    NSString *docsDir = [paths objectAtIndex:0];
    NSString *bob = [docsDir stringByAppendingString:@"/Bob.md5mesh"];////Bob.md5mesh
    if([[NSFileManager defaultManager] fileExistsAtPath:bob]) {
            // load model
        SCNAssimpScene *scene =
        [SCNScene assimpSceneWithURL:[NSURL URLWithString:bob]
                    postProcessFlags:AssimpKit_JoinIdenticalVertices |
         AssimpKit_Process_FlipUVs |
         AssimpKit_Process_Triangulate];

        NSLog(@"SCENE NODE: %@",scene.rootNode);

            // load animation
        NSString *bobAnim = [docsDir stringByAppendingString:@"/Bob.md5anim"];
        [SCNScene assimpSceneWithURL:[NSURL URLWithString:bobAnim]
                    postProcessFlags:AssimpKit_JoinIdenticalVertices |
         AssimpKit_Process_FlipUVs |
         AssimpKit_Process_Triangulate];
        NSString *bobId = @"Bob-1";
        SCNAssimpAnimSettings *settings =
        [[SCNAssimpAnimSettings alloc] init];
        settings.repeatCount = 3;
        SCNScene *anim = [scene animationSceneForKey:bobId];
        [scene.modelScene.rootNode addAnimationScene:anim forKey:bobId
                                        withSettings:settings];

            // retrieve the SCNView
        SCNView *scnView = (SCNView *)self.view;

            // set the scene to the view
        scnView.scene = scene.modelScene;

            // allows the user to manipulate the camera
        scnView.allowsCameraControl = YES;

            // show statistics such as fps and timing information
        scnView.showsStatistics = YES;

            // configure the view
        scnView.backgroundColor = [UIColor blackColor];

        scnView.playing = YES;

please help me for the same.

Thanks in advance.

1

1 Answers

0
votes

Open the files with XCode. From the top bar, select "Editor" -> "Convert to Scene Kit scene file format." I know this works for .stl and .dae, I haven't tried with .ply.