I'm working on an OBJ parser for a game engine I am creating. I have the model being loaded correctly and all, but I've never really used blender before and I'm not entirely sure how to get my UV Mapped texture into the OBJ file. Inside the OBJ file, lines typically start with "v", "vn", and "f" for me, which seems normal. However, I saw someone who had lines starting with "g" that indicated texture coordinates in his OBJ file. Does anyone know how I could do this? I already have the texture mapped and everything, I just can't understand how I am supposed to get it into the exported OBJ file.
If you want texture coords when exporting to
.obj, make sure you have Include UVs ticked in the exporter options (it should be checked by default). Also, make sure that you actually unwrapped the model, check UV Maps under Data in the Properties panel to make sure that a UV map is assigned to your object.
If you should open an obj file you should see something like
vt 0.000100 0.000100
vt 0.999900 0.000100
f 1/1 2/2 4/3 3/4
where the lines with
vt are texture coordinates and the line(s) with
f specify faces that are a part of the UV map. Read more on the obj format here. That being said, it is an open format and people might roll their own custom exporters and importers and name these identifiers differently (not recommended). I know that
g is used by default for groups so you might be looking in the wrong place, also if you have a texture with the model make sure their is a
.mtl file along with the obj to ensure that everything works correctly.
Minimal example to include texture coordinates / vt in OBJ format:
- File -> New
- Change from Object Mode to Edit Mode
- Click Shading / UVs from the upper left vertical aligned tabs
- Under UV Mapping, change from Unwrap to Cube Projection under
- Export to OBJ
Conclusion: The key to include vt in OBJ is step 4. Step 4 is only available in Edit Mode.