如何使用AssimpKit将PLY文件转换为Apple SceneKit支持的SCN文件

时间:2018-04-13 05:24:27

标签: ios swift xcode scenekit

我尝试了同样的AssimpKit,但它为所提供的对象提供动画。我希望提供的文件以.scn格式转换并保存在文档目录中。

我使用了以下代码,它使用SceneKit动画提供的文件。我想知道是否有办法使用AssimpKit框架或任何其他SDK以.scn格式将文件目录中的目标文件导出。

任何帮助将不胜感激。

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;

0 个答案:

没有答案