Problem Loading Object File

I only found 1 other post related to my question and it was about textures. I am trying to load an OBJ file that has an MTL file with it. No textures (image files) or anything. It’s a simple coffee cup.



I am doing it just as the example in Starter.pdf and I keep getting a NullPointerException on the follwing line:



converter.convert(model.openStream(), BO);



Here is my code up to that point just in case.


protected void simpleInitGame()
    {
        URL model =  HelloModelLoading.class.getClassLoader().getResource("/com/gthought/jme/models/mug.obj");
        FormatConverter converter = new ObjToJme();
        converter.setProperty("mtllib", model);

        ByteArrayOutputStream BO = new ByteArrayOutputStream();
        JmeBinaryReader jbr = new JmeBinaryReader();
        BinaryToXML btx = new BinaryToXML();

        try
        {
            converter.convert(model.openStream(), BO);
            .......



Gregg

First thought is the model object is null. Since model is a URL, that would be because that is not the location of the obj file.

"mojomonk" wrote:
First thought is the model object is null. Since model is a URL, that would be because that is not the location of the obj file.

I have double checked that over and over and I know that is the location. I have loaded images for textures in previous examples the same way, just in the images folder:


...class.getClassLoader().getResource("/com/gthought/jme/images/image.jpg");

Well, I added a print for model.toString() right after I create the URL and it turns out it is null. Really don’t know why. The file is there. Images load just fine from that same path. I’ll keep staring at it. :slight_smile:

try



...class.getClassLoader().getResource("com/gthought/jme/images/image.jpg");

Well, what was happening is for some reason IDEA wasn’t copying my files to the classes folder. So I manually copied them there and all is well. Sorry for wasting everyone’s time. :slight_smile: