无法显示缓存目录中的3d文件 [英] Can't display 3d file from cache directory

查看:74
本文介绍了无法显示缓存目录中的3d文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能帮我在这里确定问题吗?

Can you please help me determine the problem here?

似乎我无法显示缓存目录中的3d文件.我遇到此错误SceneKit IO:错误,此平台不支持COLLADA文件.

It seems that I can't display the 3d file from cache directory. I'm having this error SceneKit IO: error, COLLADA files are not supported on this platform.

保存在缓存目录中的zip文件包含.dae文件和.png用于Texturee.使用Scene Kit,您可以:

The zip file im saving in the cache directory contains .dae file and .png for the texturee. With Scene Kit you can:

导入COLLADA 3D对象并构建由相机,灯光和网格组成的场景. https://developer.apple.com/library/mac/documentation/3DDrawing/Conceptual/SceneKit_PG/Introduction/Introduction.html

Import COLLADA 3D objects and build scenes composed by cameras, lights, and meshes. https://developer.apple.com/library/mac/documentation/3DDrawing/Conceptual/SceneKit_PG/Introduction/Introduction.html

谢谢.

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
    NSURL *url = [NSURL URLWithString:@"my url"
    NSData *data = [NSData dataWithContentsOfURL:url options:0 error:&error];

    if(!error)
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
        NSString *path = [paths objectAtIndex:0];
        NSString *zipPath = [path stringByAppendingPathComponent:@"zipfile.zip"];

        [data writeToFile:zipPath options:0 error:&error];

        if(!error)
        {
            ZipArchive *za = [[ZipArchive alloc] init];
            if ([za UnzipOpenFile: zipPath]) {
                BOOL ret = [za UnzipFileTo: path overWrite: YES];
                if (NO == ret){} [za UnzipCloseFile];

                NSString *floorFilePath = [path stringByAppendingPathComponent:@"house1.dae"];
                NSURL *floorPathURL = [NSURL fileURLWithPath:floorFilePath];
                dispatch_async(dispatch_get_main_queue(), ^{

                    SCNView *sceneView = (SCNView *)self.view;
                    sceneView = (SCNView *)self.view;
                    sceneView.allowsCameraControl = YES;
                    sceneView.autoenablesDefaultLighting = YES;
                    sceneView.backgroundColor = [UIColor whiteColor];
                    sceneView.scene = [SCNScene sceneWithURL:floorPathURL options:nil error:nil];
                });
            }
        }
        else
        {
            NSLog(@"Error saving file %@",error);
        }
    }
    else
    {
        NSLog(@"Error downloading zip file: %@", error);
    }

});

推荐答案

您确定您的 .dae 文件是"SceneKit压缩场景"吗?显然,iOS仅支持从 .dae 文件加载压缩的场景.Xcode在编译您的应用程序时应自动将您的Collada .dae 转换为压缩的场景(具有相同的扩展名).如果您是从应用捆绑包外部加载文件的(例如,在运行时从URL加载),则除非您已采取措施将其转换到其他位置,否则它将不是SceneKit压缩的场景.

Are you sure your .dae file is a "SceneKit compressed scene"? Apparently, iOS only supports loading compressed scenes from .dae files. Xcode should automatically convert your Collada .dae to a compressed scene (with the same extension) when it compiles your app. If you're loading the file from outside your app bundle (e.g. from a URL at runtime), it won't be a SceneKit compressed scene unless you've taken steps to convert it elsewhere.

我在此答案中找到了以下评论:

I found the following comment on this answer:

要将dae文件转换为SCNScene(名称:...)可以读取的文件,可以在终端中使用以下命令行手动转换文件:/Applications/Xcode.app/Contents/Developer/usr/bin/scntool --convert InFile.dae --format c3d --output OutFile.dae --force-y-up --force-interleaved --look-for-pvrtc-image (当然,请用您自己的文件名替换InFile.dae和OutFile.dae.)很抱歉,注释中无法进行真正的格式化.– Marcus 2月2日,18:23

To convert the dae file to a file that can be read by SCNScene(named:... you can convert the file manually by using the following commandline in terminal: /Applications/Xcode.app/Contents/Developer/usr/bin/scntool --convert InFile.dae --format c3d --output OutFile.dae --force-y-up --force-interleaved --look-for-pvrtc-image (Of course, replace InFile.dae and OutFile.dae by your own filenames) Sorry, no real formatting possible in comments. – Marcus Feb 2 at 18:23

我不知道所有这些标志是否适合您使用.根据此网站网站,还有一个名为 copySceneKitAssets 的命令行程序(在同一Xcode子目录中),它可以转换 .scnassets 目录,所以也许这就是您要使用的

I don't know if all those flags are appropriate for your use. According to this web site, there's also a command-line program named copySceneKitAssets (in the same Xcode subdirectory) that converts .scnassets directories, so maybe that's what you want to use.

这篇关于无法显示缓存目录中的3d文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆