Model Animation

http://www.youtube.com/watch?v=0qEkqUv6CRQ

New model created using keyframes which generates the animation images.  Now using a 20 frame walk cycle.  FPS meter drops slightly due to XSplit recording software.

Engine

Spent some time streamlining the game engine.  There were a few glitches when moving from one room to another, so almost all of those should be resolved now.  It can be really tricky detecting collision with a block in an adjacent map array, while keeping the map offset straight and moving the player to the next map at the appropriate time.  I was thinking that it may be easier to just keep a single array which holds the blocks of the current screen, and then copying the blocks from the room arrays to the current screen array.  However, I think the method I have now seems to work, but it is a little bit of a pain to keep track of which room the player, projectiles, and enemies are located, especially when they cross the room boundary.  When the projectiles and enemies cross the room boundary, they will need to be removed from their current room and added to the next room.

Modeling with Animation

I found another tutorial on YouTube for making a model with animation in Blender.  Well, the first 12 minutes are just making the armature, which I learned how to do last week.  Then it shows how to create the keyframes and animation, which is really easy once you know how to do it.  I think before I didn’t have the record button pressed, along with dragging the keyframe, which caused my first model attempt to not animate.  With those settings enabled, I was able to get my simple model to run.

Pressing the play button makes my model run.  There is another animation button which renders each frame, but it doesn’t display if or where the images for each frame are saved.  After some searching, I found the output directory hidden by scrolling to the bottom of the right pane.  I set that to my project directory in a folder named anim, and then pressed the animation button which generated a png for each frame.  The first set of files didn’t have transparency, so I had to go back and select the RGBA option next to the PNG option.  It actually just displays as a second RGB button, probably due to limited button space.

 

The next problem is that the image is way too big (960×540) and out of proportion to be used as a character sprite.  I did some searching on the Gimp forums and found that multiple files can be cropped and modified at once by using Open as Layers.  This way, I was able to crop, scale, and resize the image to 48×96 which is the size of two tiles in the game.

.

Now the problem is getting each layer back out as an image.  Unfortunately, I didn’t find any information on how to do this in Gimp.  I started by copying each layer and then pasting as a new image, and saving after each paste.  However, this got really old after doing it about 8 times out of 20 frames.

Did some searching a found a Python script that someone wrote to save all of the layers in an image to PNG.  This worked (after dealing with file extensions and figuring out where to put the plugin), but it saved the file with the .png extension, even though the layer name already has .png, which resulted in the files coming out at image.png.png.  I just had to modify one line to not add the .png extension to the end.

Now that I had the images, I imported all of them into my game project’s Content area.  It may be more efficient to make a sprite sheet, but I doubt it will make that much of a performance enhancement.  It’s something I can look into later.  I added all of the images to my texture array, and modified the walk animation of my character to use 20 frames instead of 3.

One Reply to “Model Animation”

Comments are closed.