PDA

View Full Version : Question about .obj and .mtl



4dartist
12-13-2011, 02:45 PM
I purchases a boat from turbosquid and it has a .obj and .mtl. The model is all one surface sadly and I can't figure out how to apply this .mtl if it's even possible. I got Dodgy's import script but one of the two import scripts didn't work and the one that ran gave me errors when trying to open the file. So I'm stuck. The model has a UV map and I used that in the script.

Any ideas?

Error on script is: Line 319, illegal arithmetic operation on data type.

Same error in 10.1 and 9.6. Maybe it's because I'm on a mac..

4dartist
12-13-2011, 03:03 PM
Nevermind, forget about it. I should have known better than to buy something as .obj

nickdigital
12-13-2011, 03:08 PM
I normally load an obj as I would a lwo file. Is it not loading in properly?

xxiii
12-13-2011, 04:02 PM
Same here. I have two other applications that write out .obj/.mtl, At least one of them also uses UV maps, and the output from both load (as if it were an .lwo) fine -- including the UV map -- into Lightwave (though they sometimes need scaled).

If you've tried a normal load, and it still doesn't work, perhaps the .mtl of your object is doing something more complex that isn't supported by the importer. I think its just a text file if you wanted to open it in an editor and take a look around.

Does the object have any images with it?

MTL format (http://www.fileformat.info/format/material/)

4dartist
12-13-2011, 05:46 PM
The object loads ok (although it's orientation is all messed up and it's all in lovely triangles, like they baked out the subD version.. so annoying). So the geometry is fine, it just has no surface information. It's all one surface called Default. It came with a .mtl file and one jpeg texture that would match up with the UV (i hope).

I think maybe my problem is that I separate images and objects into different folders and the .mtl is with the image instead of the object. Tomorrow when I'm back at it, I'll try to toss it all together and open it.

Just to be clear are you saying that when opening a .obj file lightwave looks for an associated .mtl? Does it require a certain naming convention? Obviously if it doesn't see the .mtl file it doesn't query to find it.

I'll give this a shot tomorrow. Thanks for the responses.

xxiii
12-13-2011, 09:22 PM
The obj contains a reference to the mtl. If that reference does not contain a path then its expecting it to be in the same place as the obj.

In turn the mtl contains references to textures, and if they don't have a path, they in turn need to be in the same place.

One of my applications writes this in the obj:

mtllib basic city.mtl
So its expecting the mtl to be in the same place as the obj. Then within the mtl it writes:

map_Kd textures/road.png
So its expecting a textures folder in the same place as the mtl, and road.png to be inside that textures folder.

Apparently, the Lightwave obj loader isn't prepared for these files to be anywhere different than the obj and mtl say they are (unlike .lwo, which will ask you to find any missing parts). Or maybe it only needs the mtl to be in the "right" place and will ask about textures it can't find.

So, as you say, try loading it exactly as it came from turbosquid and see if that works.


...it's orientation is all messed up and it's all in lovely triangles,

Oh, yes, I forgot to mention, I usually have to rotate OBJ +90 on X after loading. Lightwave uses a Y-UP left-handed coordinate system, but a lot of other applications use a Z-UP right-handed. OBJs also have no concept of units, so objs may come in disoriented and fat-headed :D. (If whoever modeled your boat decided that "1" was a cubit, you'll have to scale accordingly).

The triangles isn't necessarily a bad thing, and turbosquid has been pushing (http://support.turbosquid.com/entries/20210403-checkmate-requirements-at-a-glance) for models to be either tris or quads (http://support.turbosquid.com/entries/253954) (there are good reasons to avoid ngons, especially in models that are meant to work in multiple applications).

Builtdown
12-14-2011, 01:18 AM
Open the obj in modeler.
Go to Surface Editor
Press the T button next to Color
Set Projection to UV
Check the UVMap pulldown to see if there is an UV map. Select it if there is.
Set the texture map you got to the Image.

This works most of the time for me. I never do anything with the mtl-file.

Danner
12-14-2011, 09:39 AM
.mtl just saves you from manually assigning the UV and texture, it's a big help when there are a lot of textures. When importing Objs I often get vertex normal maps that I have to deactivate in the Surface Editor. They usually look odd and they don't allow you to control the smoothness. Check other surface parameters carefully, some imported objects will have weird things turned on, like reflection bluring or luminosity when they are not supposed to.


On the triangles thing, Triangles are messy and besides making the object hard to see it's hard to edit it. So I usually try to remove them using TrigonX, some objects "de-triangulate" fine and others don't.

A link to TrigonX here
http://forums.newtek.com/showthread.php?t=75307&highlight=merge+trigons+64bit&page=5

safetyman
12-14-2011, 10:00 AM
With LW 9.6, you could just load the .obj and it would use the .mtl file to automatically assign all the textures. In LW 10, this is broken (at least for me). Anyone know how to make it work?

4dartist
12-14-2011, 11:00 AM
The triangles isn't necessarily a bad thing, and turbosquid has been pushing (http://support.turbosquid.com/entries/20210403-checkmate-requirements-at-a-glance) for models to be either tris or quads (http://support.turbosquid.com/entries/253954) (there are good reasons to avoid ngons, especially in models that are meant to work in multiple applications).

I just don't understand taking a model that you most likely created with clean poly flow and using Sub-D then basically baking out the Sub-D version and selling that smoothed triangle version. Why not also add in the unsmoothed original mesh? Is it because they are afraid people will rip them off? Is it because they don't realize people want to sub-d the model in their own application? Is it because they think people don't know what a sub-d is? Is it because when modeling in max they just use a tessellating smooth option at the end? I've spend thousands of dollars on turbosquid models because a lot of times they save me time, but they could be even better if they were more manageable and editable. Even models that are '.lwo' listed are basically just ported from Max as triangles. There are a rare few gems out there that are quads.. rare.

Ok done ranting. On a positive note keeping the .mtl file with the .obj worked just fine! The model has surfacing and the texture applied. Thanks so much for the help!

xxiii
12-14-2011, 12:55 PM
I just don't understand taking a model that you most likely created with clean poly flow [...] There are a rare few gems out there that are quads.. rare.

I wish I'd mentioned in my prior post that turbosquid was pushing for models to be mostly quads with tris where necessary, but what I wrote implies differently. I didn't research it enough, but I hope they're pushing for those quads to be planar. (non-planar quads, at least beyond a certain point, are not clean in my opinion).

4dartist
12-14-2011, 01:03 PM
I wish I'd mentioned in my prior post that turbosquid was pushing for models to be mostly quads with tris where necessary, but what I wrote implies differently. I didn't research it enough, but I hope they're pushing for those quads to be planar. (non-planar quads, at least beyond a certain point, are not clean in my opinion).

Ah ok. I'm glad for any push turbosquid is doing to steer artists into posting quad based meshes that the purchaser can subdivide. It would increase the value of the product by a lot because I would be able to edit the model to fit my needs. Right now they are basically so dense you can't make changes.

Right now I'm fixing tons of flipped surfaces and missing triangles in this 4 wheeler model I downloaded. Also pipes for the vehicle are splines and not actual geometry. Bummer.