OGRE EXCEPTION

本文记录了解决Ogre与PhysX示例加载资源问题的过程,包括定位错误原因、调整资源文件路径及配置文件设置,最终成功加载资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一次运行physX+ogre的例子遇到的异常:



找不到文件,去OgreSDK里面找到这个resources_d.cfg 拷到和*.sln 同级的目录下面




然后又产生了这个问题。百度说:

----------------------------------------------------------------------------------------------------------------------------------------------------------

OGRE EXCEPTION(7:InternalErrorException): ../../media/packs/SDKTrays.zip - error whilst opening archive: Unable to read zip file

 

SDKTrays.zip应该是一个资源文件,出这个错一般是因为bin/debug下的 resources_d.cfg这个配置文件找不到SDKTrays.zip这个文件(文件不存在)或者是路径写错了。于是是赶紧去检查目录下该文件是否存在,结果发现原来没有media目录(该目录保存着各个例子需要的资源文件),于是去SDK下把它的media目录copy到我们新建的项目目录下来 (与Bin,samples等目录同级),再运行。这次终于可以了。


----------------------------------------------------------------------------------------------------------------------------------------------------------

但是我的不是这个问题,我的resources_d.cfg里面是这样写的:

# Resources required by the sample browser and most samples.
[Essential]
Zip=../../media/packs/SdkTrays.zip
FileSystem=../../media/thumbnails


# Common sample resources needed by many of the samples.
# Rarely used resources should be separately loaded by the
# samples which require them.
[Popular]
FileSystem=../../media/fonts
FileSystem=../../media/materials/programs
FileSystem=../../media/materials/scripts
FileSystem=../../media/materials/textures
FileSystem=../../media/materials/textures/nvidia
FileSystem=../../media/models
FileSystem=../../media/particle
FileSystem=../../media/DeferredShadingMedia
FileSystem=../../media/PCZAppMedia
FileSystem=../../media/RTShaderLib
FileSystem=../../media/RTShaderLib/materials
Zip=../../media/packs/cubemap.zip
Zip=../../media/packs/cubemapsJS.zip
Zip=../../media/packs/dragon.zip
Zip=../../media/packs/fresneldemo.zip
Zip=../../media/packs/ogretestmap.zip
Zip=../../media/packs/ogredance.zip
Zip=../../media/packs/Sinbad.zip
Zip=../../media/packs/skybox.zip


[General]
FileSystem=../../media


接着找

在wiki上面看到的(http://www.ogre3d.org/tikiwiki/Building+Ogre+with+CMake)

----------------------------------------------------------------------------------------------------------------------------------------------------------


If you are installin in an ipod / iphone, see the first troubleshooting link:

Creating resource group Essential 
Added resource location '/Users/taehyungkim/Documents/ogre_src_v1-7-1-2/Samples/Media/thumbnails' of type 'FileSystem' to resource group 'Essential' 
Current language: auto; currently c++ 
(gdb) continue 
An exception has occurred: OGRE EXCEPTION(7:InternalErrorException): <path>/Media/packs/SdkTrays.zip - error whilst opening archive: Unable to read zip file. in ZipArchive::checkZzipError at <path>/OgreMain/src/OgreZip.cpp (line 280)

Looks like your app can't read the zip file. My guess is that your resources.cfg contains absolute paths to the resources and it's trying to load files that are outside the application bundle.

Change it to use absolute paths instead, like this:

Code: Select all

Zip=Media/packs/SdkTrays.zip

----------------------------------------------------------------------------------------------------------------------------------------------------------

看来是这个问题,从SDK拷过来的确实写的不完全的路径,修改!

# Resources required by the sample browser and most samples.
[Essential]
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/SdkTrays.zip
FileSystem=../../media/thumbnails


# Common sample resources needed by many of the samples.
# Rarely used resources should be separately loaded by the
# samples which require them.
[Popular]
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/fonts
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/materials/programs
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/materials/scripts
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/materials/textures
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/materials/textures/nvidia
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/models
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/particle
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/DeferredShadingMedia
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/PCZAppMedia
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/RTShaderLib
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media/RTShaderLib/materials
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/cubemap.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/cubemapsJS.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/dragon.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/fresneldemo.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/ogretestmap.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/ogredance.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/Sinbad.zip
Zip=D:/OGRE/OgreSDK_vc10_v1-7-4/media/packs/skybox.zip


[General]
FileSystem=D:/OGRE/OgreSDK_vc10_v1-7-4/media




运行。

好像是对了吧~结果ogre下拉窗口上面没有显示……什么都没有,应该有那种选择用opengl或者directx渲染的,结果没有……
好吧,接着改!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值