简体   繁体   English

JMonkeyEngine未加载模型

[英]JMonkeyEngine not loading models

I am using JMonkeyEngine with Eclipse and I'm having trouble loading a model. 我在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);    
    }

I originally had the file in the "assets" folder, however after some research I discovered that assetManager has access to the main project directory and I thought that maybe it cannot access the assets folder so instead I temporarily moved the Monkey.obj to the main directory. 我本来是在“资产”文件夹中的文件,但是经过一番研究,我发现assetManager可以访问主项目目录,并且我认为它可能无法访问assets文件夹,因此我暂时将Monkey.obj移到了主目录中。目录。

The error I'm getting looks like this: 我收到的错误如下所示:

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)

Am I using the assetManager correctly? 我是否正确使用assetManager?

I had a look at the line where the exception is thrown in the JME source and it is definitely trying to locate your resource at that point and can't find it. 我看了一下在JME源代码中引发异常的行,它肯定是试图在该位置查找您的资源,但找不到它。 It's pretty difficult to diagnose why the loader is not finding your model. 诊断加载器为什么找不到您的模型非常困难。 I will say that in my project my models are in "assets/Models/" and I load them using: 我会说,在我的项目中,我的模型在“ assets / Models /”中,我使用以下方法加载它们:

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

So I do think they need to be under the "assets" directory. 因此,我确实认为它们需要位于“资产”目录下。

Other than that the only suggestion I have is to find some standard models on the net and try storing them in "assets" and loading them to make sure there's not a problem with reading directories or permissions. 除此之外,我唯一的建议是在网上找到一些标准模型,然后尝试将其存储在“资产”中并加载它们,以确保读取目录或权限没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM