Noob that needs help importing models

Hey guys, noob here. I just started a taking an online class where we will be using JMonkeyEngine to do assignments. I’ve never used it before, though I am familiar with java. I’m having a problem that the instructor can’t seem to answer, so I’m coming here for help.


All I need help with is importing a model. Our first assignment says to download any blend model from blendswap.com and import it into JMonkey. I’ve followed the instructions as they were presented in the instructional video we were given, but I’m not having any luck. Here’s the gist:

  1. I create a new BasicGame in JMonkey.
  2. I add jme3 test data to the library.
  3. I download a blend model (I’ve done multiple, from multiple blend versions).
  4. I click Import Model and select the .blend file.

This is where things get wonky. When I try to import, just about every model says that there is missing files, typically .png. I’m assuming these are textures, but I’m not certain. I chose to not look for these missing files, since I guess they weren’t included in the download, and continue on. The majority of the blends I tried importing would skip over the preview model screen and, as a result, wouldn’t show up in the models asset folder. One model actually did give me a preview, but some error about being able to locate vertices for triangulating mesh’s (sorry, I’m going off memory) appeared. The model itself was just an incomprehensible polygon in space. This model showed up in the asset folder, but when I tried adding it to a scene I was given a null pointer exception.

I know this shouldn’t be this difficult, but I just don’t know what it is I’m doing wrong. Anyone know? (I’m using JME version 3.1)

I’ll let others chime in for the gory details of proper asset importing (my development time so far has gone into fairly extensive backend server development and not dealing with assets), but you are correct about the .png files being textures. PNG stands for Portable Network Graphic, and it’s a common file format for things like textures. It’s better than formats like, say, JPEG for most texture-related purposes since it uses lossless compression (unlike JPEG, which uses lossy compression that may result in a texture with lower visual quality). Blender usually stores a path to a texture in the .blend file instead of actually packing textures into the file, if I remember correctly, although I believe that there is a way to pack textures into a .blend (although you won’t be able to do this unless you’re given the textures). If you open a model with missing textures, I’m not surprised that it’s not visible.

First of all:
Premade models often aren’t game ready. This means some rather artistic modelling methods being used and hence not optimal performance or bugs during importing. Sometimes you have to open the blender file and clean it up a bit first, delete the lights, the uneccessary scene etc.

Second: You talk about jme3-testdata. You could do each: Use Models from testdata (just load them in code) or use blendswap models, the assignment allows both iirc.

Textures: Open the Model, you’ll see that it’s Material refers to Textures using a relative path (e.g. ./wood.png). This means the SDK tries to find wood and move it into the AssetPath.
If you open the model in blender, does it have a texture?

You can also move the blender file into the assets folder and rightclick it in the sdk and select convert to j3o, maybe that helps in finding textures.

Another dead safe way is using blender to pack the textures inside the blend file. Use File->Pack all Textures (you could also manually pack them on a per texture base, which is just useless additional work^^).

Now it should work.

1 Like

In the past when I have had trouble importing models, I start a new blender file, delete everything that is in there (cam + light + cube), then press shitf + f1 to import some data … navigate to the file I was having trouble importing, select the object I need and import it … then I ctrl + a and apply scale, then ctrl +a and apply rotation, then ctrl + a and apply location … I find this strips out all the rubbish that the exporter/importer is having trouble with.

1 Like

As danielp said the images are not packed.

Assuming your using blender 2.78 default, to your right side bottom is the properties panel.

Hover over the icons at its top and select the material tab. This is your list of materials.

Select your first material then back at the top of the properties panel select the textures tab.

Under this there is a panel called image. This is the texture for that material. In that panel you will see a drop down list that says source: . Below that is a link to the actual file. This is your texture image location. This is the file the SDK importer is looking for. To the left of that line there is a little box. This is the pack toggle. Click it and the importer will find the images for you.

You have to do this for every material in the list under materials tab that has a texture and for every texture listed. This is the hard way referred to by Darkchaos but in the future you can just click it when you make the texture.

Alternatively you can navigate to the file when the SDK importer asks if you want to locate it and it will also add the texture image to the directory you tell it to download the .j3o file into on the last importer screen.

But the easiest of all (as explained by Darkchaos) in blender, hit your spacebar, enter the word pack, select “Pack all into .blend”.