4
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Blender exports this automagically... Lines starting with vt indicate texture coordinates (UV), and faces defined in the format f 1/1 2/2 3/3 are faces with an UV map. $\endgroup$ – someonewithpc Nov 1 '14 at 19:07
3
$\begingroup$

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.

enter image description here

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.

$\endgroup$
  • $\begingroup$ How do I find these particular settings to tick (Apply Modifiers / Include Edges / ...) in Blender? This is what I'm looking at RN i.imgur.com/xd3mgdI.png $\endgroup$ – Tobias Kolb Jun 15 at 13:47
  • 1
    $\begingroup$ @TobiasKolb Press T to open the shelf with the options. $\endgroup$ – iKlsR Jul 2 at 14:52
1
$\begingroup$

Minimal example to include texture coordinates / vt in OBJ format:

  1. File -> New
  2. Change from Object Mode to Edit Mode
  3. Click Shading / UVs from the upper left vertical aligned tabs
  4. Under UV Mapping, change from Unwrap to Cube Projection under
  5. Export to OBJ

Conclusion: The key to include vt in OBJ is step 4. Step 4 is only available in Edit Mode.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.