Material

I have been trying to follow the tutorial, but I haven’t been able to assign my material to my .obj. Currently, I have loaded Test.j3o, Test.mtl, Test.obj. Understandably, when I load the Test.obj, the material doesn’t load. My problem is what codes should I use? Please also note that the JPG containing the UVW is not included in the list of models or anywhere else.

I managed to solve it myself. I just created the textures in the same folder (not in a new folder as default in 3DS Max) and JME loaded it automatically. Sorry for creating a topic for nothing, If the Admins want to, they can delete it.

What do you mean about “the material doesn’t load”? Give more informations. It’s causing any exception? Try load your model in scene viewer and assign the material to the geometry. Also, why are you using .obj. instead .blend, or .mesh.xml? Anyway you will have to create a .j3m material via "new file


>new Material Definition" and drop the .mtl, because .mtl materials doesn't support muh features in jme.
Edit: I saw you solved your problem alone :roll:.

I think that the .mtl file does something. However my mistake was that I was placing the UVW texture in a separate folder. The .mtl file apparently points to the texture but JME doesn’t access it right. Therefore putting the texture in the same folder did the trick. Now, when loading the .obj, the texture gets loaded automatically, provided the .mtl file is there.



EDIT: Do you think I should edit the current Wiki to say what I said?

If you wanna move your textures to the “/textures” folder, just move them to “/textures” and create a new Material Definition file, and point to the textures in “/texture” location.

What wiki?

@glaucomardano, I prefer it this way. Each texture is accompanying its model so I don’t get confused. I assume this doesn’t change anything?



EDIT: The tutorial about Materials… 6.Hello Materials. I think it could help some people.

.j3o extensions are the official model extensions in jme. When you load a model using “assetManager.loadModel()”, that model is been loaded and converted to .j3o, then if you just load the .j3o directly, it leaves to be converted and give more performance.

Using .mtl instead .j3m you are avoiding to use the most features in jme, .mtl doesn’t support much feature.

But if you think it all confuse…

memonick said:
EDIT: The tutorial about Materials... 6.Hello Materials. I think it could help some people.

Yeah. Also, you don't need assing the j3m materials to its models manually in source code, you can do ti easily in scene composer ;):
http://www.youtube.com/watch?v=Feu3-mrpolc

Hmm, I already tried it, but I couldn’t do it.



I have this code:



Material mat_stl = new Material(assetManager, “Materials/TestSubjectUVW.j3m”);

ts.setMaterial(mat_stl);



but the game doesn’t run. How do I apply the material?

No, you don’t need to create the material in source code if you already created your material in material editor in jmp. How did you see in that video above, the .j3m material is created and assigned to the v-raptor model, and after that the v-raptor model is loaded in source code by:



[java]

Node node = (Node)assetManager.loadModel(/model/v-raptor.j3o);

rootNode.add(node);

rootNode.addLight(new PointLight());

[/java]



If you wanna create a material in source code instead, the material source parameter in Material constructor have to be a “MaterialDefinition” and not a “Material”. You have to understand what’s the diference between a material and a material definition, read this page on wiki.