A graphical artist provided me with an .obj file of a building he also provided me with a lot of .tga files for the textures of the building (e.g. the wall, the floor, a bench, a board, a bed, a closet, …). How can I use these texture files together with that obj file. I tried finding an answer by searching, though I think it is not possible. Any advice ?
Use GIMP to convert the TGA files to PNG or JPEG format.
Jme3 has TGA loader, so I don’t think this is the issue.
I suppose that object file he is providing contains multiple separate objects. If mtl lib is defined properly and put next to obj file, thing should work as you expect.
Please check if texture coordinates are provided properly for each subobject and if mtl lib maps to all textures properly.
Loading tga files is not a problem. At the moment I’m trying to do it as such:
[java] Spatial object = assetManager.loadModel(“Models/School/School_Total.obj”);
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setTexture("ColorMap", assetManager.loadTexture("Models/School/Ingang_SchuifDeur_VastB_AOMap.tga"));
material.setTexture("ColorMap", assetManager.loadTexture("Models/School/InsideWindow_AOMap.tga"));
material.setTexture("ColorMap", assetManager.loadTexture("Models/School/Ingang_SchuifDeur_VastB_AOMap.tga"));
object.setMaterial(material);
rootNode.attachChild(object);[/java]
Though I don’t get what I want.
I do not have an mtl file.
You are overwriting ColorMap over and over. How jme3 would be supposed to know which texture should be used for which part of the object?
You need a mapping between specific geometries inside obj file and textures. Normally it is done through mtl files, if you don’t have it, you can try to iterate through the contents and assign specific materials to each geometry manually - but you cannot just say
int x;
x =5;
x= 6;
x =7;
and somehow hope that x got cloned to 3 separate variables…