|
CustomSkimmerTutorial
IntroductionIn this tutorial we will be making a custom skimmer vehicle based on the manta. I'm not going to go into detail about modelling rigging or uv unrap I'm going to assume you have all those skills down to some degree before starting. We will be learning a few more twists and tricks that we can do with blender as well as some more advanced vehicle stuff beyond some of the bits we did in the wheeled vehicle tutorial. Before we startYou will need your model ready to go, in this instance we are going to make a manta type vehicle so make a model to suit. You will also need the ASE export script for blender so you can export static meshes for the death meshes. You can get that here: http://www.katsbits.com/htm/tools_utilities.htm#ase With painting the damage mesh I'm going to use blender's internal texture painting tool this is not without it's peculiarities so you might prefer to use something else. One tool with a limited freeware paint option is Blacksmith3d which has the advantage of being able to turn culling off and paint through the mesh. It requires an .obj file as it's model but blender can export that. I'm not going to cover the details but it is an alternative for those that want it. Setting up your skimmer modelStep one is to have a model and rig it. The rig should be fairly similar to the wheeled vehicle rig but without the wheels and with a couple of new additions. Here is my basic model I'm using for this tutorial with the bone hierarchy on the right. So the setup I have is this:
very simple a good deal more simplified than the wheeled example since we only have one seat and only one turret and I'm lazy. Most of it will be familiar but the new additions are the damage bones. These are used to tell the engine how to damage the mesh. Apply the vertex groups to the other bones as normal and leave the damage bones alone we will be using a different technique for them than usual. Here is a shot showing the bone positioning: Weight Painting The Damage BonesOk now we will setup the damage bones influence, ie the bits of the mesh that they will effect when the engine detects the skimmer is damaged. For this we are going to use blenders weight painting mode. Select your mesh and then in the mode dropdown select Weight Paint the model will probably go blue like this: It might go red if so don't worry. This mode allows you to paint the influence onto the model using the mouse and it represents the weight on a vertex of a given vertex group (selected in the vertex group drop down on the buttons toolbar as highlighted in the image) by a colour. If the group has no influence the vertex will be blue, if it has full influence the vertex will be red. For instance this is what the base group (which encompases the main body of the craft) looks like: Note that the turret is still blue this is because the vertex group has no influence on it as it is controlled by another group. Influence inbetween 0 and 1 are different colours between red and blue (ie greens oranges and so on). So now we are going to paint the damage groups influence onto the mesh. This has the advantage that it can be more organic than selections and is a bit easier. So first select the damage_front vertex group from the dropdown. Then using the mouse paint influence onto the front of the craft with the left mouse button. It should go from blue to red. Remember to paint the underside of the mesh and other areas that maybe you can't see from the current view. If you make a mistake you can erase it using the subtract option located in the paint tools on the buttons bar as shown in the image that follows: When you are done it should look something like the above. Do the same for the other three groups damage_left damage_right and damage_rear. Ok with that out of the way we can start making our damage mask. Making a damage mask using texture paintingA damage mask is basically a mask that tells unreal how to apply a burned out material to our model. It is used in conjunction with the damage morphs to make the vehicles look damaged and broken as they get beaten up. We are going to use Blender's texture paint to make a mask. This is a bit like weight paint except we are painting a texture directly onto the model. It is a pretty neat feature of blender but it does have a few bugs in it and it can be a little tricky to set up. Step 1: Getting a texture on your model to paint ontoOk first things first we need a texture to paint onto. Split the window and bring up the UV/image window. Create a new texture by going Image->New and then setting the parameters. Leave the background black and the default size should do for this mask it doesn't need to me amazingly high res I used 2048 but that is probably overkill 1024 should be fine. you can give your texture a meaningful name I don't tend to bother as I add one when I save it. Step 2: Making sure the texture is visible and usableWe now need to make sure our texture is applied to the model and visible in the editor otherwise we won't be able to paint to it or see it. Go into edit mode (pressing tab or clicking it in the drop down) make sure all the vertex's are selected by pressing A in the UV window select the texture in the drop down (it might already be selected). Go to the mode drop down and select texture paint also make sure the draw type (little cube dropdown on the bar of the 3d window) is set to textured so the texture mapping is performed. Your model should go black and you can now paint onto it. Step 3: Painting the damage maskPainting is basically as you would imagine left click to paint the current colour onto the mesh. Right click allows you to sample the colour currently under the mouse pointer. There are a few other modes like smear and smooth but other than that it is pretty basic. Controls are either reached by the buttons bar or by pressing N. Damage masks are basically made of the primary colours and some half way mixes the progression is Red then Red+Blue then Blue then Blue+Green then Green working front to back in sort of stripes. In Hex which blender will use for colour picking you are looking at 0xFF0000 0xFF00FF 0x0000FF 0x00FFFF 0x00FF00. You apply the red to the front then working backwards the pink then the blue then the light blue then the green at the back. transitions should be fuzzy. To give an example of what we are aiming at this is the manta's damage mask applied to it when you are done save the texture in the UV/image window by clicking Image->Save As Thinks to be wary ofBlender's texture paint is still a touch buggy. Basically it seems to be converting the surface point the mouse is selecting on the model to the UV coordinates then applying the brush to the texture in 2D. It does some mapping between areas of the UV's but it doesn't mask those UV very well so if you have unconnected UV areas next to each other and you use a big brush you can get textures bleeding across. You can avoid this a little by making sure your UV has some space between the areas and using a small ish brush but even so you will often get some bleeds. I tend to take the texture I make this way then tidy it up in some other image editor where I have more control. Also it only paints what is visible in the current view undersides and so on need to be done by rotating around etc. But for ease of creating the initial texture the texture paint is pretty good. Creating the Damage Morph TargetsNow we have a damage mask we need some morph targets. At this point we should have got the mesh and export it, it is very important the mesh you used to create the damage morphs is the same one that was exported to our skeletal mesh including things like normal checking and converting to triangles. Any differences will mean our damage morphs won't work. This is because the damage morphs are just modified versions of the mesh that act as targets for the morphing code. It takes the parts of the mesh that the coresponding bone is tied to and then morphs the clean mesh to the damaged one. If the meshes are different in any way at the vertex level they will not line up correctly and the morph will go crazy. You will know this on importing the morph targets as the mesh will be totally screwed up with vertex's everywhere. So we should start immediately after the export of the final mesh. So here is our final mesh we have converted it to triangles and made sure the normals are all correct and so on and exported it. Now we need to make some damage targets by deforming the damage areas we made earlier and exporting a new skeletal mesh with those settings. We could do that by hand but for a quicker way I like to use a texture based mesh deform technique to automatically deform the mesh using a displacement modifier. Creating a deform texturefirst we need a texture to displace our mesh. Go to the texture window and pick out a procedural texture of some type. Something with a fair amount of randomness is good clouds or wood or marble or somesuch. In this example I used Musgrave. call the texture something you will remember and then back to the editing tab. Adding the modifierIn object mode in the mesh tab select Add Modifier on the modifiers tab. Pick a displace modifier a little set of options will appear bellow. Set the Vgroup: to the name of your front damage vertex group in my case damage_front and then set the Texture to one you just created. Tweak the parameters to a pleasing damage effect (you may have to hit the buttons next to the modifier so its effect is visible) Repeat this till you have a modifier for each of the damage areas. You can speed this up by hitting the copy button in the modifier and then just changing the vgroup. Exporting the Damage MorphsFor the effect of the morph to be seen on the exported mesh we need to apply them. Go to the first modifier and hit Apply this will apply the damage to the mesh. Export this as another skeletal mesh call it something like Skimmer_Damage_Front.psk or some such. Then undo applying the modifier by pressing Ctrl+Z and go to the next one and apply the export it. This is so the meshes exported only have the one modifier applied. When we are done we should have four files one for each of the damage bones front left right and rear. Making the Death MeshOnce we are done with damage morph targets we can now create a death mesh for our vehicle. This is achieved by applying all the modifiers and then exporting that as a static mesh. Apply the modifiers as before only this time apply them all at once. Now export the resulting mesh as an ASE file which is the format Unreal uses for static meshes (ie ones with no skeleton or animation) this uses the ASE exporter we got at the beginning of this tutorial. name it something suitable skimmer_death.ase I think is what I used. Importing Into UE3Fire up unrealed and create a new package. I used VH_Skimmer. Load in all your textures and your main mesh and your static death mesh. Don't load the damage targets we will use them in a bit. First things first we will create our materials for our damage and so on. This is going to be a bit different than last tutorial as we will be using materialinstances this time. Setting Up Material InstancesWe will be using the material instances system for this What the hell are MI?Material Instances are basically a way of templating materials. Epic have set up some base materials that have a load of parameters in them to achieve various things in the game. We can quickly use this by creating instances parented to the epic materials and then plugging our own textures and setting in to customise while still maintaining things like burn out damage spawning or even tank tread animation. Throughout this process we are basically duplicating the setting in the manta but using our own textures so if in doubt check the equivalent there and you should be able to figure it out. Creating our base MICFirst up we need to create a Material Instance object. This is fairly easy right click in the generic browser and select MaterialInstanceConstant from the dropdown. This is called something like MIC_VH_Skimmer_Blue Parent it to Material'VH_All.Materials.M_VH_All_Axon_Base' This basically pulls in everything from that template into our instance and allows us to customise it. Basically set it up as in the image bellow plug your textures in to the various slots if you don't have that texture type leave it blank (i went a bit fancy and fiddled with a specular map for a laugh) Setting Up the rest of the MI'sOk we create one just another 3 or so to go :S Create another MI and call it MIC_Skimmer_Spawn_Blue this is used when we spawn (clever naming eh) we parent this one to our other MI MIC_VH_Skimmer_Blue set it up as follows Now we need a burn out MI this is basically the texture that gets applied when the vehicle is damaged. Create another MI name it MIC_Skimmer_Blue_BO Parent it to Material'VH_All.Materials.M_VH_Burnout' set it up like this Now we need something a bit more fancy a Material Instance Time Varying or MITV. I think this takes a texture then applies it progressively according to a certain parameter. So right click hit MaterialInstanceTimeVarying(WIP) call it MITV_VH_Skimmer_Blue_BO parent it to the burnout material MIC_Skimmer_Blue_BO and then set it up as follows And you're done ... with the blue textures now we need some red ones. To save time select all your Blue textures and right click duplicate then rename anything blue to red. Now we need to make a few changes as follows Ok now we are done with materials bout time too. Making Morph Target SetOk now we will make the morph target set. Open the skeletal mesh of our skimmer. In the file menu select New MorphTargetSet call is something sensible like VH_SkimmerCustomMorphTargetSet. Go into the morph tab and make sure your new morph set is selected Now select File->Import MorphTarget Go to your directory where you exported your morph targets then select them all (you can select more than one) it will then ask you to name each morph target I left them as I had named them before. Once this is done you can see all your morph targets in the morph tab (you might need to refresh it) and can select them and see them applied to your model. If it looks all broken and all over the place you may need to go back and regenerate your meshes (you can generally import the corrected mesh over the top of the old one by giving it the same name so you haven't lost all your work so far). You can see the damage on the front of this mesh (as well as the sockets I put on it) PhysicsCreate a physicalmaterial by right clicking and selecting physical material. Set it as follows. Duplicate that and add Drive to the end of its name change it as follows Create a physics asset (by right clicking the mesh and add physics asset or some such) name it something you will remember setup the collision mesh and add the non drive physical material to it Setting up the Anim TreeThis will have some new steps in this to add our damage morphs and death mesh Create and AnimTree and then add in the preview skeletal mesh of our skimmer and the morph target set. Add in the various bones (I added a load I didn't need for some reason you basically need base and gunpivot) If you can't add the bones check you selected the skeletal mesh correctly as this is where it gets the bones from. Setting the TurretAdd a UTSkelControl_TurretConstrained control by right clicking and selecting it from the list. This controls how your turret bone moves. I constrained it's pitch and roll and called it gunpivot. Link it to your turret control bone gunpivot. Since the turret setup is not very elaborate this will do. Adding the death meshAdd a UTSkelControl_Damage control and link it to base bone. Set the on death section and add our static death mesh skimmer_death to the deathstaticmesh box. This will then spawn the dead mesh when our vehicle is destroyed. You will notice this control can be used to spawn other static meshes on damage or what have you this is how various bits ping off vehicles when they are damaged. Setting Up Morph NodesNow we need to setup the morph nodes. Create a MorphNodeWeight Control and a MorphNodePose control by right clicking. Set the MorphNodeWeight name to MorphNodeW_Front and then MorphNodePose MorphName to the name of your front damage morph target in this case skimmer_dam_front Duplicate these and rename till you have four of each. One for Front,left,right, and rear. Link them up so it looks like this. You should be able to test it is all working now by dragging the MorphNodeW sliders from 0-1 and the preview mesh should change. If this doesn't work check your nameing and that the preview morph target is set. Save the PackageWe are now done with the package save it and copy it into the published directory so it can be found by the compiler. ScriptingWe are using the manta as our base so take the UTVehicle_Manta.uc UTVehicle_Manta_Content.uc and UTVehicleFactory_Manta.uc files from the source to use as a base. Or you can use my completed skimmer code http://steam-punk-pirates-mod.googlecode.com/svn/trunk/TutorialCode/Skimmer/UTVehicle_Skimmer.uc Create a new directory under src or use an existing one, if you create a new one make sure you add it to your compile path in UTEditor.ini or it won't compile it. UTVehicleFactory_SkimmerThe easiest file first change the name at the top then change the mesh and the class settings called. Remeber in the vehicleclasspath the preceding name is the modpackage name not the name of the package unrealed made. UTVehicle_SkimmerFirst change the name and make sure there is a semicolon on the end of the line. Delete the two lines after that that are native and abstract at about line 339 you'll see where the wheels are defined change the bone name for each to match your base bone equivalent. the rest of these parameters define how the wheels and physics work so some tweaking of these may be required to get desired performance characteristics. There are ways of tweaking them real time to see the effect in game. UTVehicle_Skimmer_ContentRename the file then head down to line 100 or so. Set the Skeletal Mesh, the AnimTree, the Physics, and the MorphTargetSet to their correct values. Alter the seat settings to the correct bones and sockets, the manta has two guns so I removed one of them. This seat section defines how many people can ride this vehicle so to add more seats you can just add another Seat section of code with additional parameters and you'll have a two person manta. Head further down to about line 200 to set all the textures and physical materials to their correct names. And we are done Final Words and Example Screen ShotsThis would still require a fair amount of tweaking and fiddling to get a final ready vehicle but this is far enough for now. You can fiddle with the vehicle parameters in realtime by typing editactor class=svehicle in the console while riding in the vehicle. Some changes like seat alterations require you to get out and reenter for them to take effect. Also none of these settings are saved (you can copy them to the clipboard for later insertion into your code) and they only apply to the current instance so if the vehicle respawns or you reload all the settings go. As you can see the driver seat needs some tweaking to make it look right. That's better Damage before and after Some more damage and I think the death mesh. |