Blender 3D Animation How-To
I have not purchased the manual for Blender, and when I began making characters for Freecraft I had no idea what I was doing. It could easily be argued that this is still the case :) Therefore, this guide is very rough, and there are probably many other ways to create and animate characters in Blender for the purposes of populating Freecraft with the various units it needs. If anyone has better ideas about this, please feel free to add them to the howto.
I have arrived at a system for providing the required animation frames using Blender that takes advantage of key-frames in an unorthodox way. This is what I will describe in this howto. I hope that people will be able to use this information without knowing too much about Blender or animation, so I will define a few terms before I begin.
Keyframes: All animation has 'frames', and I'm sure this does not require much explanation. Keyframes are frames in which the animator defines the position, degree of rotation, size, or any other attribute of an object (or even a material, or just some vertices) and asks the computer to remember this information. This information provides the start and end points of the motion of an object, or the transformation of something, and the computer interpolates the motion or state of the object for all the frames in between.
Freecraft, however, does not require smooth animation of this kind. It simply requires four or five frames, containing distinct poses of a character in the process of walking, fighting, dying, etc. These have to be produced with the character facing different directions. There is no 'tweening' involved, since we don't need frames to be produced in between the key positions. Hence, in the method I am describing, keyframes are used simply to store each pose, with the character facing each direction, so that the images for each frame can be quickly and easily produced.
Renders, rendering: The point of the modelling and animation we do within Blender is to produce a series of images. These images are rendered, using an engine designed to produce a 2d image replicating the view we would have through the camera in the scene, based on the objects and the lighting we have designed. Images produced this way are referred to as 'renders'.
Other important terms refer to the elements of the Blender interface. I would rather not spend a lot of time discussing this, although it is very tricky and difficult to learn. Please go to the Blender website (http://www.blender.nl) and follow their links to some excellent tutorials. However, I will try to be as descriptive as I can.
OK, to load up your Blender file, hit space bar to bring up the main menu (with your mouse in the display window). Go to 'File' -> 'Load file as', then click around to find your Blender file. After you click on the file name, hit return. Now what do you do? The first point I would like to make is please don't move the lights or the camera. These have been placed in a way that is reasonably consistent from character to character. If they are moved, the characters will look strange when they are placed side-by-side in Freecraft. Lights are small dots with circles around them, and the camera is a square pyramid, with the base facing the modelled character.
To get a good view of the character, these keys are useful:
- Numpad: 7, 1, and 3 The number pad keys are essential. 7, 1 and 3 will change your view of the character to the top, front or side views.
- Numpad: 8, 4, 2 and 6To rotate manually you can use the 8, 4, 2 or 6 keys.
- Numpad: 5 The 5 key toggles perspective and orthographic views.
- Numpad: 0 The 0 key shows you the view through the camera lens.
- Numpad: 9 I forget what the 9 key does for now.
- Mouse buttons: You can also use 'trackball' with either the middle mouse button on a three button mouse, or Alt+left mouse button on a two button mouse. Zoom and pan can be controlled easily using the small buttons on the Blender interface below the 3d display window.
- Keyboard: z To toggle between wireframe and shaded views, use the z key. Shift+z displays a different kind of shaded view that isn't usually very helpful.
- F12: I would like to mention that F12 brings up a render of the scene, which can be lowered behind the Blender window with esc.
Other useful short-cuts:
- F3: F3 can be used to save an image. All you do is navigate to the location where you would like to save it, type in the name, and press return TWICE.
- Tab key: This toggles an object in and out of 'edit mode'. If an object is not in 'edit mode' it can be selected and moved, rotated, scaled, etc. All these operations affect the object as well as its centre. The centre of each object is signified by a small pink sphere. In edit mode, you can see all the edges and vertices making up the selected object. Vertices can be selected and moved around. Nothing you do will effect any other object in the scene, or the centre of the selected object. I would advise that since the characters are already modelled for you (unless you've created a new one yourself), you should never be in edit mode. If it seems that you are, hit Tab again to get out of it.
The IPO curves window: Most of the Blender files I have created are saved in such a way that when you load them, the character is displayed in a window on the left of the screen, and another window is open to the right that contains a bunch of curves (as long as an object is selected). Until you save some keyframes, these curves will be flat. This window is useful, later on, so that you can delete keyframes or otherwise manipulate them as you get further into animation.
The character should be standing in its initial position. We first need to produce views of the standing character facing in each important direction. These are: South, Southeast, East, Northeast and North. The order I have just listed these in is the opposite of the order they are in the input files for the characters. Please remember this. It is more convenient to work in this order in Blender.
To set up 'standing' in each direction, switch to the top view (numpad 7). Make sure you are in frame number 1. This can be altered using the arrow keys on your keyboard. Look for the number on your screen that changes by one if you hit the right or left arrow keys, or by ten if you hit the up or down arrow keys. If you click on the right edge of this button it goes up by one. Click on the left and it goes down. Click and drag and it goes up or down much faster. Shift+click and you can type a number in. This is how most buttons work in Blender.
Now, hit the b key so that you can draw a selection box around the entire character. Everything selected will turn pink. You will probably select some lights, or even the camera by accident. Please deselect them by holding down shift and right clicking on them. Sometimes you will have to switch to a side or front view to do this, since Blender can get confused about which object you are clicking on.
Now, with all the character's body parts selected, hit the i key to insert a keyframe. A menu will come up under your pointer. Click on 'locrot'. This will store information about the location and rotation of all the character's body parts at this frame. Now, to rotate the entire character so that we can get a view of it facing southeast, make sure that the small button with the cross-hairs on it under the display window is clicked. Now left-click at the centre of rotation for the character. A circle with crosshairs should appear where you clicked (switch to wireframe if you can't see it). You may have to adjust the centre of rotation later to make sure you get it right, so that the character doesn't seem to be sliding around as it rotates, and it all fits inside the square at each direction. Try to note the postition you have defined for the centre of rotation so that you always use the same spot. I may have defined this for you - please look at the readme for your character.
When you've done this, hit the right arrow to go to frame 2. Hit the r key to rotate the character. Hold down ctrl to confine the rotation to 5 degree intervals. Now move your mouse around until the character has rotated exactly 45 degrees towards the east. Left-click to set the rotation. If you've done something wrong, and want to revert to the initial position (if you haven't yet set the rotation with a left-click), right click to go back.
Don't select or deselect anything new (hopefully, you didn't before you rotated, either). Now hit i and select locrot again.
Continue this until you have inserted the last keyframe with the character facing away from the camera. Now you should save, by hitting space bar, 'file' -> 'save'. Then bring the character around to the front again, and hit the right arrow to advance to the next frame. You can check that the keyframes are working correctly by hitting the left and right arrow keys and seeing how the character responds. If any of the keyframes are looking wrong, you can delete them, however this must be done for each individual object making up the character's body. In the right-hand window, you can switch to displaying keyframes by clicking on the small button with the key icon. (If this window isn't up, click on the button at the very top of the display window to the left of the text saying 'SCR:screen.001'. Click on 'screen'). You should now see a bunch of vertical lines, intersecting some curves. To bring all the curves and lines onto the screen click the button with the house on it. The lines represent each keyframe, the curves represent the motion or rotation of the object in various directions over time. They aren't important for Freecraft. However, the vertical lines are important, because we can select them, by right-clicking or hitting b and dragging out a square, and delete them by hitting x.
Now we want to start making the character move. If it is a two-legged character, we want it to walk. A four-legged or winged character is more complex, and I should have described its appropriate motion in its readme.
I will discuss walking here for simplicity. At the very least, we want the character's legs and arms to move. Switch to the front view (numpad 1). Now right-click on part of one leg. Hold down shift and right click on the other parts (most have a thigh, calf and foot or hoof). They should all now be pink.
Switch to the side view. Now, to rotate the leg at the hip, please left-click to place the crosshairs at the point where you want the leg to pivot. Then hit r and move the leg forward a little, and left-click. Now we want to bend it at the knee. Deselect the thigh by holding shift and right-clicking. Move the pivot point to the knee. Hit r and move the calf and foot back a bit, so that the knee is bent. If you selected the wrong place for the pivots, and the parts of the leg are now separated or look funny, select the bits you want to move, hit g for 'grab', and move them back into place. Click the left button to release them.
Now you want to move the other leg back a bit. You just have to select it, and rotate it backwards all at once. Then rotate the arms so that the opposite arm to the forward leg is swinging forward a bit, and the other arm is swinging backward.
When it looks right, switch to the top view, select all the body parts, and insert a new keyframe. Place the centre of rotation back where it was before, advance to the next frame, rotate 45 degrees, and insert a new keyframe. Do this all the way around to the back. Save, and bring the character around to the front again.
That's how it goes. Keep moving parts of the character and inserting the keyframes until you have four positions defined for walking. You can use the existing image files for the peasant or faun to see how I chose to animate them. Fighting, dying, and anything else the character has to do is up to your imagination, but you can email me for help if you need it :).
Once you have all the stages of the animation in place, it's time to render the images. This is very easy now. Go to frame 1. In the second row of buttons under the display window is one that depicts a mountain at sunset (or something like it). If you click on this one you will see all the options that can be configured to change the properties of the rendered image. I like to have the size set on 200x200. Also, make sure 'Targa' is depressed, as well as 'rgb' and the 8 under OSA. This will ensure they match the images I produce.
Hit F12 to render, and F3 to save the image file. You have to type the image name and add .tga to the end. Hit return twice. Now hit the right arrow to advance one frame. Hit F12. Hit F3. Name the image. Hit return twice. Keep going. It's easy :)
Now that you have all your images, you have to tile them all together to make an input file. I do this before scaling them down. Using ImageMagick, I use the command 'convert -append (list of image names with .tga) (image with .png)' to get all the renders that make up a single column in the input file stacked together. Then when the columns are done, 'convert +append' with similar arguments (the input and output files will both be .png) sticks the columns together into one file. This can be done any other way you prefer, of course.
Now I open the image file in a graphics package like GIMP, and scale the image so that each tile is 72 by 72, or whatever the appropriate size is. Then I use 'select' -> 'by colour' or its equivalent, with fuzziness set at 0, to select all the black in the background. Flood fill this with white. The reason I do this is that the anti-aliasing that happens when you reduce the size of the image produces a lovely dark outline around the character, if it is done on a black background. With proper colouring, this would be done by hand using a better selection of colours, but this is a good shortcut.
Now all that remains is to index the image with the appropriate palette, and then make sure that all the areas of clothing contain the correct shades of red, so that they are replaced with the team colours. Then you should make sure there are no stray white pixels where they shouldn't be, or pale grey pixels in the white areas. This is painstaking, and quite boring, but it's necessary for your unit to appear nice and clean in the game.