Helmet Model

helm_render2

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.

Screenshot from 2012-12-15 00:54:18

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.

Screenshot from 2012-12-15 01:04:02

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.

What is Resistor for XBLIG?

The objective of Resistor is to build connections to carry electrical flow to activate LEDs (light emitting diodes). To avoid damaging these components, the flow level must be reduced using resistors. Each level is graded upon number of pieces used, the luminosity of the LEDs, and the time required to complete the level. This game teaches the basics of resistor color code values.

Each level has a power source with an electric flow level.  Use wires (A button) to connect this power source to all of the LEDs on the level.  Be careful to not connect a wire that has a higher electrical flow value than the number displayed on the LED, otherwise the LED will be destroyed and the game will end.  To lower the electrical flow, use a resistor (X button) to lower the electrical flow of the wire.  The target is to use a resistor that will lower the electrical flow just enough to activate the LED.  Lowering the electrical flow too much will still activate the LED, but the luminosity grade for the stage will be penalized.  After every ten levels, a new higher level resistor will be awarded.  The currently selected resistor can be changed using the bumper buttons (LB and RB).  Complete the levels as quickly as possible with the fewest number of pieces to get the best grade rankings.

http://www.youtube.com/watch?v=34Qp6-tC5CA

Graphical and Music Assets

screen069

I took a break from engine programming, and I started working on some of the graphical and audio aspects of the game.  I would like to have a small playable demo in the near future.  For now I am just using royalty free assets, but I would like to go back later and make my own custom art and music.  The font I used is called Ethnocentric, which was downloaded from 1001freefonts.com.  Be careful to read the license agreement for any font downloaded form this site, because not all give you permission to use the font for sale in commercial works.  However, most fonts allow inclusion in commercial works as long as the font is not modified or sold as a part of a font compilation.  The title background texture was acquired from CGTextures.com, which allow use of their textures as long as those are not sold as a part of a texture compilation and it is not used in an open source project.  For the background music, I used two songs from Kevin MacLeod’s incompetech site.  Again, I would like to make my own music in the future, but for now I will use those pieces which only require attribution in the credits screen.

Again, writing good code to play music can be more difficult than it looks.  When going from the game to a menu, I would like the music to change.  However, I don’t want to game music to start all over again when going back to the game.  I could just have the game music play through the menu at a lower volume.  One idea I had was to create a Song variable in the ResistorKit screen class, since usually one only song is associated with each Screen type.  I would just need to have methods to modify it, so that the music could be changed for each game screen.  Additionally, it would be nice to have a way for the music to fade from one song to another when changing areas in the game world.

I reworked some of the screen handling code to add the new credits screen.  One problem is that the “QUIT” state did not have a corresponding screen, so I made a dummy quit screen so that the game states are aligned with the game screens.  I can probably also use the quit screen to display information as the game is closing, such as “thank you for playing” or information on how to buy if the game is running in trial mode.

On the title screen, I went ahead and implemented a scrolling background.  This seems to be a running theme in my games.  I set the scroll rate to 8 pixels per frame, so it scrolls really quickly.  I may need to slow it down if it makes people dizzy.

On the game screen, I went ahead and updated the bounding box display code so that when the instance variable that controls its display is set to true, then the bounding boxes for all game objects (player, enemies, collectibles, projectiles) are displayed.  I also updated the graphic for the player’s projectile, using a supernova effect that I created with Gimp but I’m still not happy with it.