在Cocos3D加载HDRI地图 [英] Loading HDRi maps in Cocos3D

查看:878
本文介绍了在Cocos3D加载HDRI地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加载的HDRI地图在iPhone应用程序(类似于谷歌地图),然后我希望能够加载一些3D角色在场景中玩耍。

I want to load an HDRi map (similar to Google Maps) in an iPhone application, and then I want to be able to load some 3D characters to play around in the scene.

您可以在这里看到的是什么,我想加载一个例子:

You can see here an example of what I would like to load:

http://www.hdri-hub.com/hdrishop/freesamples/freehdri/item/117-hdr-041-path-free

目前我使用Cocos3D从搅拌机通过POD导出文件加载3D模型,所以也许有一种方式来加载HDRI在Cocos3D。我发现这个类CC3STBImage可以用来加载HDR类型,但我不知道如何使用它(无例如发现)。我见过CC3Texture2DContent有initFromSTBIFile:方法'PHDR'文件的扩展名,所以也许HDRI可以加载作为纹理

Currently I'm using Cocos3D for loading 3D models from Blender through POD export files, so maybe there is a way to load HDRi in Cocos3D. I found out this class CC3STBImage which can be used to load HDR types, but I don't know exactly how to use it (and no example found). I've seen that CC3Texture2DContent has the initFromSTBIFile: method for 'phdr' file extension, so maybe the HDRi could be loaded as a texture?

我成功地加载球网与图像,一看便知及以下的意见。结果特此通过一个CC3Camera望着天空盒的一些截图:

I managed to load a spherical mesh with the image, see the answer and comments below. Hereby some screenshots of the result by looking through a CC3Camera at the skybox:

推荐答案

至于你提到的,HDRI支持是由 CC3STBImage 类提供。在 CC3STBImage useForFileExtensions 可用的方法是使用这个类的文件扩展名列表。如果你不希望你的文件重命名为 *。PHDR ,你可以添加你想要这个集合的文件扩展名。

As you mention, HDRi support is provided by the CC3STBImage class. The list of file extensions that use this class is available in the CC3STBImage useForFileExtensions method. If you don't want to rename your files to *.phdr, you can add the file extension that you want to this collection.

一旦你确保你的HDRI文件扩展名是在上面的集合,可以通过简单地使用加载HDRI文件到 CC3Texture

Once you've ensured that your HDRi file extension is in the above collection, you can load an HDRi file into a CC3Texture by simply using:

[CC3Texture textureFromFile: @"myFile.phdr"];

CC3STBImage 使用的 stb_image.c 文件中提供的第三方库。看一看在HDRI支持该文件中的说明,了解更多的,以及任何潜在的局限性。

CC3STBImage uses the third-party library provided in the stb_image.c file. Have a look at the notes in that file for more on HDRi support, and any potential limitations.

请记住,iOS的OpenGL实现限制了纹理的大小。 Cocos3D 记录最大纹理尺寸为当前平台中的应用程序启动。看看在日志中这样的条目:

Keep in mind that the iOS OpenGL implementation limits the size of textures. Cocos3D logs the maximum texture size for the current platform during app start-up. Look in the logs for an entry such as:

[info] Maximum texture size: 4096

这表示最大的OpenGL纹理的宽度和高度由该平台的支持。

which indicates the maximum OpenGL texture width and height supported by that platform.

这篇关于在Cocos3D加载HDRI地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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