Tonight I continued more modeling in Blender. I would like to go ahead and complete all pieces of armor. Once all of the armor pieces are complete, there may not be much to do for the player model. I created a helmet from starting with a cube, using a background image of a helmet I found on the web. Using multiple loop cuts (Ctrl-R), I was able to make the cube outline the background image. I also used the loop cuts to make an outline of the center eye piece and mouth opening. Once each of those were outlined, I extruded inwards to give a carved out appearance. Since I didn’t have a guide for the sides, top, or bottom, I just added to vertical loop cuts and expanded slightly outward. The side and back usually don’t have much detail, and the player probably will never see the top or bottom of the helmet.
After reading a few tutorials, I was able to remember how to do UV mapping in Blender. First, it’s best to have two views open, one for the 3D view and one for the UV/Image Editor. In the 3D view, I had to set viewport shading to Texture to see the texture mapping in real time. I selected my helmet object and went into Edit mode. Now set the selection mode to select Faces, and I selected the faces for the first texture. I did this by selecting all faces (A key) and then unselecting the faces in the eye pieces and mouth opening (Shift Right Click). Then I selected Mesh, UV Unwrap, UV Unwrap. In the UVMap viewport, I selected the plus button to create a new image of size 1024×1024. When I did this, the unwrapped image appears.
Using Gimp I created a seamless image using one of the images from CGTextures.com. I selected that image and copied, and used that Clipboard pattern to fill a new image of size 1024×1024. I saved this new image as a PNG, and then selected that image in the UV Map viewport using Image, Open Image. I translated and rotated the 2D points in the UV map slightly to give the texture map a better appearance. The texture map on the 3D model updates in real time as the 2D points are being modified. Next, I did the same process in Gimp to create a 1024×1024 texture for the eyes and mouth. I unselected all of the faces in the 3D view (A key) and only selected the faces in the eyes and mouth (Shift Right Click). The free select tool (Cntrl Left Mouse Button) makes selecting multiple faces much faster. With the new faces selected, I created a new image in the UV Map view by pressing the plus button using size 1024×1024. Again, I selected Mesh, UV Unwrap, Unwrap to place the selected faces on the 2D UV Map plane. By selecting Image, Open Image I added my second texture to the UV Map view, which automatically updates the texture on the 3D model.
The last tricky part is that even though the textures display in the 3D viewport, the textures will not display when rendered (F12), which is the only way to generate an image file. Rendering the image will still result in a non-textured image. The trick is to select the object in Object mode, select the Material tab to display the default material for this object, then scroll down to the Options section and check both Face Textures and Face Textures Alpha. I don’t have a clue why these are not selected by default if those are required to make the UV map during a render. After playing with the lighting and cameras, I was able to get a decent render of the helmet that I modeled and textured.
That’s enough for one night, so I will probably wait until tomorrow to do the rotation animation into sprites. At some point, I would like to try to export the model into Autodesk .fbx format and use the model directly in my game code. However, this will probably require much effort to convert my 2D sprite based game into a 3D space. However, I think it can be done, since my game display code is for the most part decoupled from the game logic. In theory, I should be able to make a new instance of my GameScreen class that does 3D rendering, and be able to switch between 2D sprite mode and 3D rendering mode by just changing the pointer to the GameScreen class instance.