I have been looking for cool 3d-models on turbosquid. So far I have only got the ones working that have .mtl files attached to them, and I am using the TestObjJmeWrite to test them out. I have one I really want to use but it has a .dds texture. How do you load these? I keep getting a file not found mesh.mtl…I know this is probably a very stupid question but if someone could give me a link or a brief rundown of the difference between the textures and how to load them that would be appreciated. Thanks.
if an .obj model uses textures AND/OR materials, it has a .mtl file.
Use the ResourceLocatorTool to locate your Resources (.mtl file, referenced textures within the .mtl file) and NEVER EVER change the path to the textures in the .mtl file as suggested above, thats just plain ugly.
I think DDS is a Microsoft dx texture format (a quick lookup says so - Direct Draw Surface)
I have some experience at working with various graphics formats, so if you can post an example model (preferably withcode to load and display it) I am willing to look at it for you over the weekend. The reference I saw says it might be the same format as TGA and I added a patch to handle compressed TGA files not all that long ago.
Having looked a little closer into this, im not sure if anything is needed and JME might take care of it for you as it seems to have built in support for DDS?
DDS seems to cover various formats, DDS (DXT1 compression) is a derivative of the S3TC standard, and other versions seem to be variations on a theme - dont know the level of support.
As for how…well thats a different matter altogether
I keep getting a file not found mesh.mtl
This is the file that points to the textures(and thier properties I think)that the .obj file uses, it is just text and can be viewed in a text editor.
1 ObjToJme converter=new ObjToJme();
2 try {
3 URL objFile=this.getClass().getClassLoader().getResource("Sources/Link.obj");
4 converter.setProperty("mtllib",objFile);
5 ByteArrayOutputStream BO=new ByteArrayOutputStream();
6 logger.info("Starting to convert .obj to .jme");
7 converter.convert(objFile.openStream(),BO);
Within the first few lines of a .obj file you will see a line like 'mtllib link.mtl', so in the 4th line of the code above it finds the .mtl file from the line starting with "mtllib".
Make sure the .mtl file is in the same directory as the .obj file, and all the texture files that the .obj needs.
This way at least the model should load, somtimes there are issues with it actually finding their textures from there, you could open the .mtl file in a text editor, change all the paths to the textures to the right place
map_Ka srcSourcesLinkSS04.tga
Or search the forums/wiki for how to use the ResourceLocatorTool
Thanks for that last post, I didn't realize where the link to the MTL file was coming from. That was very helpful. I guess now I just don't know what to do if those objects I download don't come with MTL files? I still get the error message even though they never came with the MTL? Maybe it was just a crappy OBJ file I downloaded…
I only know from exporting from 3ds max, as a wavefront .obj file. It always comes with a .mtl file. There are some other .obj formats, I'm not sure about how they deal with textures. Maybe the ones with no .mtl files will import into a modelling program ok, from there export as .obj and it might produce the .mtl file for you.
If you only has one texture for the model, then there might not be any mtl file. Just add the texture as a texture renderstate for the model after loading it (load the model without mtl file).
DDS is one of the best formats, it supports alpha, compression and precomputed mipmaps. But not all types of the format can be loaded in jME.
dhdd said:
if an .obj model uses textures AND/OR materials, it has a .mtl file.
Use the ResourceLocatorTool to locate your Resources (.mtl file, referenced textures within the .mtl file) and NEVER EVER change the path to the textures in the .mtl file as suggested above, thats just plain ugly.
When exporting from a modeler, it's up to the one exporting to select if he wants to export it with a mtl file or not.
Haladria said:
When exporting from a modeler, it's up to the one exporting to select if he wants to export it with a mtl file or not.
yes, that is why I wrote "if an .obj model uses ...". You can export the .obj file without a .mtl file but then you won't have materials or textures. ;)
Thanks guys for all the activity. You guys are right some of the obj I have found only have one texture, thus no need for the mtl file. So setting the texture state after the model was loaded worked fine. Also as someone suggested too just loading the model into blender and setting the textures myself (took me so long to figure how to do that) worked well too and made it a little easier to customize the obj to my liking. Also it is a good note to NOT change the mtl file manually. I tried that and it was a HUGE pain. So thanks again for all the post, you have all been helpful.
DDS is one of the best formats, it supports alpha, compression and precomputed mipmaps. But not all types of the format can be loaded in jME.
The only types that cannot be loaded are 3D textures and odd combinations of luminance/alpha/grayscale channels which I find useless to support. Everyone should use the DDS format for production; I have done various benchmarks and found DDS with DXT & mips to load about 40x to 80x faster than equivalent JPG or PNG textures in jME.
Momoko_Fan said:
Everyone should use the DDS format for production; I have done various benchmarks and found DDS with DXT & mips to load about 40x to 80x faster than equivalent JPG or PNG textures in jME.
I'm sold. Now I just have to get to the production phase.