Blender/Custom Sword

From the Oblivion ConstructionSet Wiki
Revision as of 17:18, 5 October 2006 by imported>Sickleyield
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Custom Sword in Blender

This is a very detailed tutorial showing you how to create a simple sword from the ground up in Blender. It’s quite involved, so anyone who feels they can make it more readable is welcome to edit. That’s what wikis are for. 

Important Preliminaries: Necessary Tools

You will need:

-A BSA unpacker: http://www.tescreens.be/oblivionmodwiki/index.php/TES4BSA -The latest version of Blender: http://www.blender.org/cms/Home.2.0.html …And a working knowledge of the program, because it’s complicated: http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro -NifSkope, a powerful editor for meshes: http://sourceforge.net/project/showfiles.php?group_id=149157&package_id=170735 -The Blender NIF Scripts from Sourceforge, which allow export of meshes from Blender in the right format for Oblivion: http://sourceforge.net/project/showfiles.php?group_id=149157 -A graphics editor like the GIMP or Photoshop. This tutorial won’t cover making a custom texture, just tell you how to get one onto the mesh.

Important Preliminaries: Configuring the NIF Scripts

Be sure to configure your NIF Scripts to version 20.0.0.4. You can do this by clicking on the little python emblem in the main menu to take you to the scripts screen. Then click on scripts - system - import/export. This should allow you to choose your .nif import or export scripts from a dropdown menu. Make sure it says .nif version 20.0.0.4 and size 10. (I've heard people say 1, but 10 is what works for me. If your meshes seem too big or small when exported, this is the setting you change.)

Useful Blender Shortcuts

This is intended as a reference for the entire tutorial, so you can refer back to it as needed.

r: rotates the mesh from whatever direction you are viewing it. Use carefully or the results are very odd. s: scale the entire mesh up or down by dragging the mouse up or down. Also drags the mesh out of alignment with the axes, especially z, so you’ll want to move it around afterwards. r and x, y, or z: rotates the selected mesh or vertices on the x, y or z axis. s and x, y, or z: scales the mesh along an axis. z: when used in edit mode, makes every vertex visible and the faces transparent. Very useful for selecting hidden vertices from any given angle. b: a crosshair appears that you can click and drag to create a rectangular selection box. b, b: a circle appears that you can scale up or down by rolling the mouse wheel to create a selection area.

Mouse wheel: hold down and drag to “roll around” the screen and look at the mesh from different angles. Hold down shift/wheel and drag right or left to move right or left only. Scroll mouse wheel up or down to zoom in and out.

Starting from Scratch: Choosing your Collision Capsules

Blender can't import and export collisions at the present time, so you'll need to find a sword from the existing game that is close to the shape you want. Don't worry if the size is a little off. Things are easy to resize in Blender and in NifSkope. I recommend you start with a one-handed sword such as the Elven longsword. Claymores and shortswords mostly differ in how you treat them in the Construction Set, which will be our last step.

Delete the collision capsules from the mesh. There should be some branches that say BSX, UPB, bhkrigidbody, etc., and they should all be ABOVE the one that says "nitristrips" or "nitrishape." If you delete some but still can't import, there are still more to delete. After you do this, save the nif under a new name so you don't mess up a game mesh you might need later.

Okay, NOW import this mesh into Blender. You can do this by clicking file - import - netimmerse/gamebryo. Now you're looking at a sword mesh. See how it’s lying flat on the “ground” of the gray Blender interface? Don't move it. It has to be right there for the game to place it properly in characters’ hands.

Creating Your New Sword: Starting Out in Blender

Here comes the fun part. If your version of Blender has a little cube appear when you open the program, delete that first by pressing “a” and “delete” and selecting “yes” at the menu prompt.

I would suggest you create the new sword in the same plane as the default game one, just off to one side. Then you will be able to slide it into position using the “g-x” and “g-y” commands later. I will refer to this game mesh as the “reference sword” from here on out.

There are a few different ways to do this. One of the easiest is with extrusion. For that to happen, you’ll need something to extrude from, so I suggest adding a Icosphere for the pommel: File – add mesh – Icosphere – let’s say two iterations. Seems huge now, doesn’t it? You can scale it down to the right size now, or just create a giant sword and scale the whole thing down later. Either way, things will be easier if you align it to the axes first. You want one endpoint of the sphere to be facing the same direction as the reference sword’s point is facing, along the Y axis. Use the “z” key and a bounding circle (press b twice) to select the whole Icosphere, or for a faster method press “a.” Use the “r” command to rotate the sphere. Typing “r-x” will let you rotate on the X axis, “r-y” on the Y axis, and “r-z” on the Z axis.

You can hold the mouse wheel (yes, the wheel) down and drag back and forth to look at the mesh from different angles, or use the number keys on the numpad (NOT the ones above the keyboard letters).

Note about Blender: Blender has menus now, but the keyboard shortcuts are still far faster and easier to use when you’re making new meshes on the fly. See the bottom of the tutorial for a list of most-used shortcuts, to which I will be referring throughout this section.

Creating Your New Sword: The Handle (Extrusion)

Now, where was I? Yes. Extrusion. You should now have the sphere lined up so that it had a middle top vertex facing the same direction as the blade of the reference sword. Select and delete that vertex (delete key). See the hole? This is how wide your sword’s hilt or handle will be. If it seems too narrow, select and delete the row immediately around it, too. Then select the row that surrounds the hole. Bounding box may not work well here, so you can use right click to select one vertex and then hold “shift” and go on clicking to select more vertices.

Once you have the vertices selected, press e for extrude and select “edges only.” Now drag the mouse upwards and watch as new faces appear, following your mouse pointer. You can extrude on just one axis by pressing e and then pressing g-x, g-z, or in this case g-y. This will make your handle nice and straight. Notice that you can use “s” to make the ring of new vertices bigger or smaller, too. When you have them at the size and length you want for your first segment, click the left mouse button to set them in place.

This is a good time to remind you that extruded faces sometimes have messed-up normals, so you should go down to the buttons window and click “draw normals.” All the normals (the pointy things) should face outwards. If they don’t, you need to select the face with the bad normal by clicking all four of its vertices and then click “flip normals” in the buttons window. Make sure you only select the faulty faces, or your entire sword will be affected. I usually only turn the normals on for checking up, otherwise they clutter up the view too much.

Okay, now you have something that looks like a badminton birdie. Select the topmost ring of vertices again and extrude it. Keep this up until you have a multi-segmented handle. Try to make the middle segments wider than the end ones. When your handle is the length you want it to be (again, compare the reference sword for this), you’re ready to create the guard part of your sword.

Creating Your New Sword: The Guard (Subdivision, Merging, and Pushing/Pulling)

Our first sword here will look more like the Chillrend mesh, which doesn’t have big pointy guard segments, though I’ll tell you how to add those. Accordingly, you want to select your last ring of handle vertices and then click “subdivide” down in the buttons window. Whoa! The number of vertices doubled. This will help your guard section look more round and less faceted. Extrude it upwards a little and examine the results. You can repeat this as many times as you like to get a hemispherical guard section, or subdivide again to get more vertices if you still think it looks too angular.

Remember, the more vertices you create, the more you’ll have to merge. When you get to the top of the guard, you’ll need to merge some of the vertices so your sword’s blade will only have four vertices. You can do this by selecting two or more vertices you want to merge and pressing “alt-m,” then selecting “center.” Do this until there are just four vertices in a rough diamond shape.

Now, about this guard section. There’s another reason why we want it to have more vertices: that makes it a lot more flexible as to its shape. For example, if you want spikes all the way around, you can select alternating vertices in one row and then scale them outwards until they’re as pointy as you want them. If you want two pointy guard pieces like the steel longsword has, you can select two vertices on opposite sides and pull those out. Experiment with selecting and “g” and the axes and see what you can come up with. You can also select just the vertices in your guard section and use “s-z” to make it flatter. This works with any part of the mesh, and you can use it to make your pommel more coin-shaped (like the Elven sword’s) and less round if you like.

Creating Your New Sword: the Blade (Extrusion and Merging)

When you’re ready to do this part, it’s easy. Just select the four vertices of the diamond at the top of your guard section (remember those?) and extrude upward. I recommend doing it through two or three separate extrusions, but not more than that, because you want a smoother length of steel (or mithril or whatever) here. Keep narrowing the shape as you go upward, and then merge the four vertices (again, select-alt-m) into one at the top to make a point.

You can use more vertices and different scaling to create different blade shapes, too, but I’m not going into that here. Just consider the possibilities, and I hope you find them as much fun as I do.

Getting Your Sword Ready to Export: The UV Map

Now you need to be able to see the UV window, so divide your buttons window into two. You can do this by holding the mouse cursor over the line between the 3d window and the buttons window and right-clicking, then selecting an option. You now have two little buttons windows. Click the little button in the left one that looks like it has a grid on it, then select “UV Image Editor” instead of “buttons.” You should now see a blank grid, because we haven’t changed the main screen to UV Select mode yet! Go up and click on the button where it now says “edit mode” and change to “UV Face Select” mode. Press “a” to select everything. Your mesh should now look like it’s covered with pink facets. If some of them look transparent, the normals are facing the wrong way, and you need to go back to edit mode and fix them per the previous section’s remarks.

But if that’s not a problem, you’re ready to unwrap. Click on “UVs” in the UV Image Editor buttons, then select “Unwrap.”

Yikes! Odds are that you’ve got a very odd-looking thing in the UV Editor window now. This is what happens when the computer unwraps all those pink facets into two dimensions. You can tell which face is on which part of the UV Map by pressing “a” in the main window to deselect all the faces, then clicking just one face to make it turn pink. That face will now appear by itself in the UV window.

Vertices and faces can be selected and moved in the UV Editor just like in the main window, but they’ll only affect the UV map and they only move in two dimensions. I suggest moving the vertices around so that the faces of the sword’s blade are together and don’t overlap anything. This will make texturing easier. Eventually you’ll want a UV map where all the faces are lined up and connected only where the real faces are connected, but that’s a lot of clicking and dragging I won’t go into here. For now, we have a UV map, and that’s what matters.

Getting Your Sword Ready to Export: Material and Texture

Now it’s time to go back into edit mode. Click the little circle in the edit buttons. This should take you to the materials screen. Click “assign new,” then find the little rectangular button that says “texface.” Now off to the right you should see a series of tabs, including one that says “input,” and when you click on it you will see some buttons saying “UV,” “orco,” etc. Make sure “UV” is the one that is checked.

Now look up where the materials button was. There should be a button next to it with a little stripey square on it. Click that to go to the texture screen. You may need to click “add new” to add a new texture. Just make sure you select “image” from the dropdown menu, then click “load image.” This is a nice feature – you can load your custom texture right from Blender and export with it attached. If you don’t have a texture yet, any old texture file will do. We just need to assign one so that Blender will know the mesh has that property.

Eep! Your texture doesn’t appear on your mesh! Why is that? I don’t fully understand it myself, but suffice to say Blender won’t show the actual texture that’s going to go on the mesh. You can assign one just for Blender to view through the UV screen if you set the view to “textured,” but it has to be a jpeg and it won’t go on the final mesh at all. In any case, don’t panic. The texture you loaded is there. You just can’t see it.

Exporting your Mesh

Huzzah! We’re ready to export.

But FIRST, make sure your sword is in the right position. Move it over the reference sword so that they overlap, then select the reference sword and delete it. Save. You may also need to click “ctrl-a” to apply scale and rotation. Now click file – export – netimmerse/gamebryo and put your sword’s nif into the data\meshes\weapons folder.

And now it’s NifSkope time. The following is mostly a copy from my shield tutorial:

Necessary NifSkope Alchemy: Getting the Mesh Ready for the Game

Open up your nif with NifSkope. See how your new texture appears on the mesh, even though it didn’t show up in Blender? Bravo. Be sure and expand the texture node branch to make sure it has the following series of numbers going downwards: 6,1,3,1,1. If it says 5,2, etc., change it. Believe me, you'll thank me later.

EDIT for latest NifSkope version: With the newest one you only have to change one number. The very last thing in the texture node is a number 0 that needs to be changed to a 1.

Now go to file - new window. Remember the original mesh you chose for its collision boxes, the bhk capsule shapes? The one that still has those shapes, because it's the original version that you did NOT save over with a new one? Load that in the new window. Find the nitristrips node for the actual reference sword itself - when you click on it it will be highlighted in the main window. Right click - block - remove branch. Now it is gone but its collision shapes (the bhkcapsuleshape nodes) are still there.

Go back to your new sword. Click on the node for your sword's nitrishape. Now right click - mesh - smooth normals, then right click - mesh - strippify, then right click - mesh - update tangent space. This last one is very important. Now you're ready to copy your mesh into the old one. Right click again (it should be a nitristrips now, since you strippified it) and click block - copy branch. Switch back to the old mesh's window and right click on the node that says 'scene root.' Now block - paste branch. Your sword should appear in the window. You might get an error message about the version, but just click OK, it's just the niftools folks' way of messing with your head. It may be in the wrong place, because we still have to parent it to the old mesh's scene root.

Now left click the little plus sign by the scene root node to expand it. Scroll down to the "children" node under that. Click it to expand it. There should be a line under it that says "none." Type the number of your new mesh's node here.

EDIT for latest NifSkope version: The newest one has an autochild feature that does this for you. If you check the child list, your mesh’s number should already be there. Lucky you!

Now save the nif under the name of your new sword (do NOT save it as the name of the old one). Make sure it's in the directory where you want it to be.

Adding/Changing a Texture

It’s easiest to do this from Blender and export the mesh with the texture on it, but if that doesn’t look right or et cetera, you can add a different texture in NifSkope.

I'm not going to tell you how to make a texture from scratch here, but once you have one, you've only got to type the texture path into the top of the texture node in NifSkope next to the little flower symbol. It will usually look something like data\textures\weapons\mynewsword.dds. This tells NifSkope where your texture is. For now I'll leave it that the texture must be a .dds file and it must have a normal map, which is called something like mynewshield_n.dds.

Important warning: make sure the slashes in the texture name lean backwards, like this: \ and not forwards like this: / or the game will refuse to recognize the texture. NifSkope will sometimes try to change this around on you.

Getting the Sword Into the Construction Set

Double click on the construction set icon on your desktop to load up the CS. If you don't have this icon on your desktop, I urge you to put it there right now. Now wait for it to load. This may take a while, and then there will be very few items on the screen. That's because we haven't loaded any data files.

Click file - data in the top menu. You should see a list of all the mods on your computer here. If you don't have any, it'll probably just show oblivion.esm. Click on that so that a little "X" appears next to it, making it active, and then click "OK."

Now wait for THAT to load. You may want to twiddle your thumbs or go get a beverage or light some candles here, to pass the time.

Eventually it will finish loading and you can see everything that is present in the game. Exciting, isn't it? Find the objects window, which has a list that says "Actors," "Items," etc. Click on Items to expand it, then click on Weapons. Now you see a list of all the weapon sets in the game. You can click on one set, say "Glass" or "Daedric," in the left-hand pane and it will show you all the pieces in just that set in the right-hand one.

Choose a sword that has the kind of stats you want. Glass and Daedric are very popular because they are the best light and heavy armor in the game. Remember, if this is a one-handed sword, you need to choose one that is also one-handed as a template. Don't choose one that says "arena" anywhere in the ID, because those have scripts on them that you don't want to mess with. Double click the sword of your choice to bring up its information. Click on the name of the nif (say, glass/longsword.nif). A little window will pop up with the data directory in it. Click through until you find your own new sword mesh. Click on that and click "OK". Your sword mesh name should now appear in the window.

You'll need to do the same with a new icon, which you can learn to make here: http://cs.elderscrolls.com/constwiki/index.php/Creating_Transparent_Icons

Now this part is very important. You need to change the ID of the new sword, not just the name. The ID is above the name and looks something like "WeaponGlassLongsword" or "GlasShield". You must change this to a new ID such as "Mynewsword," or you will replace every glass sword in the game with yours. Be sure and give it a unique name, too, so that everyone knows what an amazing sword you've made.

When that is done, click OK. You'll get a message asking if you want to create a new ID. ALWAYS SAY YES.

Getting Your New Sword Into the Game

Now your sword will appear in the Weapons list. It will be listed alphabetically by its ID, although you can change the sorting method by clicking the headings of the list. Now you can drop it into the inventory of a merchant, into your house, or into the street of a random city. Go to file - save in the main CS menu and give your mod a name. Close the CS. This might take a while.

Now you can playtest. Be sure and check your mod by name in the Data Files list on the Oblivion start menu before you start playing.

Have fun.

SickleYield