JMonkeyEngine没有加载模型

时间:2015-01-09 21:20:11

标签: java models jmonkeyengine

我在Eclipse中使用JMonkeyEngine而我在加载模型时遇到问题。

@Override
    public void simpleInitApp() {    
        Spatial monkey = assetManager.loadModel("Monkey.obj"); //<---line 34
        Material mat_default = new Material( 
            assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        monkey.setMaterial(mat_default);
        rootNode.attachChild(monkey);    
    }

我最初将文件放在“assets”文件夹中,但经过一些研究后我发现assetManager可以访问主项目目录,我想也许它无法访问assets文件夹,所以我暂时移动了Monkey.obj到主目录。

我得到的错误如下:

Jan 09, 2015 1:10:14 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 RC2
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 9.18.13.4709
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: NVIDIA Corporation
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.5.0 NVIDIA 347.09
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: GeForce GTX 770/PCIe/SSE2
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.50 NVIDIA
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
Jan 09, 2015 1:10:14 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Monkey.obj
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:378)
    at MainGame.Main.simpleInitApp(Main.java:34)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
    at java.lang.Thread.run(Unknown Source)

我是否正确使用了assetManager?

1 个答案:

答案 0 :(得分:0)

我查看了JME源代码中抛出异常的行,它肯定会在此时找到您的资源但无法找到它。很难诊断装载机为什么找不到你的模型。我会说在我的项目中,我的模型是在&#34; assets / Models /&#34;我用它们加载它们:

getAssetManager().loadModel("Models/items.blend");

所以我认为他们需要在&#34;资产&#34; 。目录

除此之外,我唯一的建议是在网上找到一些标准模型并尝试将它们存储在&#34; assets&#34;并加载它们以确保读取目录或权限没有问题。