Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Using pyglet, I am trying to create a UVSphere mesh, and on its surface I would like to display a mercator-projection map. In researching examples of pyglet texture mapping, I have found:

Are there any simple examples of a working mesh + texture map in pyglet?

Edit: I found out the pyglet_obj_test code is looking for lines in the .obj file starting with vt in order to create texture mapping coordinates. However the Wavefront exporter in Blender apparently has no option to export this information. I exported the same mesh with each of the other available types:

  • COLLADA (.dae)
  • Stanford (.ply)
  • Stl (.stl)
  • 3D Studio (.3ds)
  • Autodesk FBX (.fbx)
  • X3D Extensible 3D (.x3d)

Perhaps there's a pyglet importer for one of these formats...

Edit 2: I clearly have a poor understanding of the wavefront format. It seems vt lines are not necessary. What I was missing is full f maps.

For instance, to simplify things way down, I created a 3d mesh that was actually a single square, with a texture mapped onto it. In Blender it shows the square with distorted texture, but the built-in wavefront exporter produces a single line of texture mapping f 2//1 1//1 3//1 4//1. These should apparently instead be something like f 2/0/1 1/0/1 3/0/1 4/0/1 (note there should be a number between the two slashes).

Apparently Blender only does a full (proper?) export of these lines if a texture is UV mapped. Applying a texture without a UV Map renders properly in Blender, but I guess the wavefront exporter doesn't properly handle it. Perhaps it's time for me to submit a Blender bug report...

share|improve this question
add comment

1 Answer

I pursued the pyglet_obj_test solution further and got it working. So, to answer my own question, here's a complete example:

  • Using Blender, create a mesh with a UV-mapped texture. The UV-mapping is important! If it is working properly, you will see the texture applied within Blender's 3d view.
  • Export the mesh from Blender using the Wavefront format, including normals.
  • Clone pyglet_obj_test, and run display.py your_mesh.obj
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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