Blender/Creature Meshes 101

From the Oblivion ConstructionSet Wiki
Revision as of 15:26, 19 August 2006 by imported>Fragment
Jump to navigation Jump to search

DO NOT EDIT OR DELETE THIS PAGE, I'M KEEPING THE SOURCE AT HOME IN MY EDITOR FOR NOW!

Place comments/questions/bugs on the discussion page, please.

Tutcre101-scrn-goatblender.gif

What we plan to achieve is to get this model into Oblivion, as a creature, which behaves and moves in certain ways. We use Blender and a number of other free tools to that end.

I of course threw the model together in one and a half hour, and it shows. You'll learn how to get your own, much improved model into Oblivion in this tutorial.

Notation:

  • List items like this are actions to follow.

This defines a goal of some sort.


The Blurb, or preface

While I still played Oblivion, I always wished for more creatures, more simple animal live for Oblivion, because, you see, the bears and slaughterfish and eight other animals don't seem to be quite enough to fill a world this large.

So I started out to follow CuteUnits call for more sealife, and tried to educate myself on the creation of new creatures for Oblivion. About 60 hours later, and endless gnawing on the tools, and howling with frustration, and much gnashing of teeth, and pestering people on the forum, I managed to get my first model into the game.

While I learned as much in such a short time as I haven't for years, I would rather have had a simple "click here, then there"-style-guide to follow, to get me started. This guide is meant as such a guide, designed to help you getting started.

Be warned though on two accounts, first: Learning all this is not easy, there are seldomly quick successes to be had. You need to take your time, play with things. Second: When you continue to explore the guts of NIF and meshes and materials, there's much trouble on your way. You need to be persistent. No tutorial can teach you this.

I'm of course standing on the shoulders of giants. Few things you find in here are actually my own.

That said, let's delve right in.


Preparations

Delve right in? Not so fast. There are a few programs you need to download, and the data we're going to mod has to be unpacked. Oh, and there is a rather complex and large program you need to learn.

Required: Basics

You need to know how to deal with .zip files, how to work in Windows Explorer (e.g. how to navigate to a folder and look at the contents), how to install and run programs, how to use a search engine and the search function on forums.

If such things are beyond you, you're so wrong here.

Required: Tools

Download and install all of these.

Blender Blender NIF export scripts NIFskope BSA commander (or alternative, see below)


Required: Unpack your BSA

...

My unpacked BSA files go in c:\programme\bsacmd\out. Yours will be somewhere else. I'll refer to that folder under the name of "unpacked BSA folder" below.

Required: Learn Blender

HINTS

As any very complex program, Blender cannot be learned by just exploration. You need to read the manual. Really, now. Go. I'll be waiting here for you.

The german version is quite a bit better organized. If you understand german better than english, use that.

You need to learn the basics of the modeller we use first. The documentation is as free as the program, and you will have to spend a few hours learning to move in Blender, to select and move things, to edit a mesh. To that end, doing a tutorial will get you started nicely.

This is the newbie documentation for blender.

Follow the tutorial, and I mean, follow it, using Blender and the mouse and the keyboard, up to, and including, the Quickie Model section. You should be good to go from there. You'll need to read up on other sections later, though. And try to remember that there's a section devoted to splitting windows. I'll test you later!

Finding and preparing an existing creature to mod

HINTS

Do not choose a model with shape-key-animations. You can recognize these in NIFskope when an animation plays when you hit the play button. They also have a special node called NiGeomMorpherTransformer. Stay the hell away from creatures with these.

One of the limitations of the process described here is that we (read: I) cannot yet edit the animations of the creatures we make. The only thing we can do is to replace the "skin" of existing creatures to be our own. We have to live with the existing animations, although we will be able to "blend out" certain parts of them.

We thus have to find a model which already somewhat fits our idea of the new creature, especially which already moves in the right way. Let's have a look.

  • Open the unpacked BSA folder we created earlier. From there go to meshes, then creatures. Open the sheep folder.
  • In there double-click skeleton.nif. Left-click and drag in the window with the green lines (render view), and the model should rotate. What you see here is the "skeleton" of the creature, made up of individual bones.
  • If you select Render>Draw Havok, you'll also see the collision boxes (or ellipsoids), rendered in a darker shade of green.
  • Close NIFskope. Double-click sheep.nif, rotate this a bit. That's the model of the creature.
Tutcre101-scrn-folderstructure.gif

What we're going to achieve is to replace the model of this with our own. We make ourselves at home in the Oblivion\Data folder by copying the sheep folder there under a different name.

  • Now copy the whole sheep folder to Oblivion\Data\meshes\creatures. You may need to create the meshes\creatures folders in your Data folder first.
  • Since we do not wish to replace the sheep coming with Oblivion, we rename the sheep folder to "oursheep".
  • Make a backup copy of the .nif files right now. That's not strictly neccessary, but convenient. Just select them, hit Ctrl-C, Ctrl-V. Should you want to start anew with a fresh skeleton.nif or so, it will be right there.

That's the folder we're going to work with. In there are the files we're going to mod!


Creating a clean skeleton

We later need to "rig" the new mesh to the skeleton, but Blender cannot yet import it in the form as it is here. So while we're there, we right now create a skeleton.nif suitable for importing into Blender.

Tutcre101-scrn-cleanskelly.gif
  • Double-click skeleton.nif. NIFskope opens with the skeleton file.
  • In the menu, select Spells>Block>Remove by ID
  • In the text field, enter ^BS|^NiBS|^bhk|^hk|^NiTransform (just add the last part)
  • Click OK
  • In the Block List Window, select the "Root Node", "0 NiNode Scene Root"
  • leave NIFskope open

We actually just deleted all havok data. Oops! But as we're not going to use any of it directly in the game later, it will be OK. The problem is, Blender will not be happy with just the naked bones - there must be a skin they're attached to.

[[image:tutcre101-scrn-copybranch.gif|right|thumb]

So, what we need to do now is to copy the relevant skin mesh into the .nif. .nif files store the bare meshes as NiTriShape or NiStripShape. We find that mesh, and then copy the required mesh into the cleaned skeleton.

  • in NIFskope, chose File>New Window
  • in the new window, click Load, load the sheep.nif
  • open the 0 NiNode in the Block List by clicking the "+" besides it
  • in there is a NiTriShape (other models have NiStripShapes)
  • right click them, click Block>Copy Branch
  • in the window with the skeleton.nif, right click "0 NiNode Scene Root", select Block>Paste Branch
  • in front of the new node is a number, remember that, for me, today, it's 90
HINTS

A collection of things, an "array" in NIFskope is made of a number of the items listed, and a list of the items ID themselves. Above the "Children" property there's a property named "NumChildren". Since we have only one NiTriShape, we don't need to change that. Had we two or three of them, we'd have increased that number accordingly, and right clicked on the children node and said Array>Update there. Other arrays work alike thoughout NIFskope.

The next step is to make the mesh a children of the "0 NiNode SceneRoot" node. We have the mesh outside the Scene Root tree and now want to put it inside. To achieve that:

  • select the scene root node
  • make sure you see the "Block Details" window. Hit F2 if you do not.
  • scroll down, you should see "NumChildren" and "Children" directly below
  • double-click the value in NumChildren, increase by 1 (=by the number of meshes we added)
  • right click on the "Children", chose Array>Update
  • open it (+)
  • double-click "None" and replace with the number you remembered above, it was 90 for me.

Tutcre101-scrn-entering90.gif

When you hit Enter, the copied mesh wandered into the scene root node! And the sheep mesh is now correctly positioned on the skeleton.

Finally:

  • save the file as cleanskel.nif
DEBUGGING

When Blender loops endlessly upon importing, the mesh in the .nif is broken. It can be fixed by exporting as .obj and reimporting it. I sincerely hope that doesn't happen to anyone else.

Phew! That was quite some work, to make a cleaned skeleton like this. But the good news is, you only need to do that once for each creature. You can reuse the cleaned skeleton for other creatures which are based on the same skeleton.

Did I mention we're going to just delete the mesh as soon as we're importing it? Damn, so much work.

So, let's switch tools, to Blender.


Blender work

DEBUGGING

Your surface normals must point in the right direction, or weirdness will ensue. If you have darker surfaces in the shaded view in Blender, they're not "normal". If you have a closed model, that's pretty simple to fix: SPACE, Edit>Normals>Recalculate outside. I do that quite often on the slightest suspicion that something is wrong. Blender will get it wrong once in a while when you start to place vertices by hand and fill the polygons in by hand. But, that's easy to fix.

Make sure you don't have double vertices (SPACE, Edit>Vertices>Remove Doubles). Also make sure you didn't accidentially put lines through or vertices inside into in your model. If normalization does not appear to do what it should, that's usually the problem: Your model is not continuous. You have doubled vertices or open-ended surfaces.

So, what do we want here? As you've been told above, you needed to learn to move around in Blender. We're going to use that new skill of yours to attach the skin to the bones. A second goal is to "paint" the sheep with a texture.

For the future: You will need to do any of the following steps multiple times, in an iterative fashion. For example, the animation is dependant on the polys, as animations just move polys. You may later find that you have too few of them in certain places which bend a lot. That means you need to increase the polycount, by making new cuts, loop-cutting, subdividing and simple vertex moving. But changing vertices will destroy your UV-mapping, so that needs to be redone. It pays to double- and triple- and quadruple-check your model before dealing with the texture. And it very much pays to get the animation right before texturing.

For the model we want to import into Oblivion there are some requirements.

The model needs to roughly fit the existing ones. Look for example at the dog model, the original has a raised head and the tail in a straight line. You can just about forget to start with a dog sitting, its tail wound around the paws. If you have a model with a wrong tail, well a tail is quickly deleted and redone, but much more problems than that and I would rather start anew. You can play around with the overall size in the construction set later, or leave parts of the rigging out. If you want to have a small dog, just set size to 0.5 later. If you want to have a dog with a capped tail, just don't rig the last tail bones.

To keep everything as simple as possible, use one material only. When you use more than one material (or material index), you will get multiple meshes in the NIF you export. That's good later if you plan to have multiple textures on one mesh, but we're not trying fancy stuff like that right now.

Another possible requirement is - that is based on my bad experience only, I might be totally wrong - that the model needs to be a continuous flow of polygons. Don't have holes in it, don't have open edges. Every edge of the model needs to connect to another one.

Skinning the model

Enough blah blah.

  • open Blender
  • load the goat model
  • switch to wireframe view (ZKEY)
  • in the menu, File>Import>NetImmerse/Gamebryo
  • chose cleanskel.nif
Tutcre101-scrn-skellyimported.gif

You now see the same structures you earlier saw in NIFskope, in Blender. In the front is the sheep mesh, inside - look closely - you can see the skeleton. We want to rig that skeleton to our mesh. Study the Bethesda model for a moment, how they did things. Then, in Object Mode, right click the sheep mesh and delete it (XKEY). That hurt, right? What you have left is the basic skeleton.

Tutcre101-scrn-goatposition.gif
  • scale and move and rotate the sheep model into a good position. Rotate by exact amounts (hold CTRL). Do not change the skeleton in any way! That will not do what you think it does.
  • hit Ctrl-A to apply the scale and position changes
  • save your work using F2, NUMPAD+, ENTER (that adds a version number)
  • right click the goat mesh, shift-right click the skeleton, hit ctrl-P, select armature, select don't create vertex groups

We just parented the mesh to the skeleton. That means if you move the skeleton, the mesh moves along with it - a good start! But what we actually need is not only a movement of the mesh along with the skeleton, but a deformation of the mesh itself. To that end, we must tell which vertices belong to which bone(s). That process is called weight painting. The deformation does not use absolute yes-or-no values, but a value between 0 and 1 (or 0% and 100%), it's "weighted". The value determines how much a vertex is influenced, not only if it's influenced at all. Of course a value of 0 means it's not influenced at all.

Why it's called painting, you shall soon see with your own eyes:

Tutcre101-scrn-selectposemode.gif
  • right click the skeleton, select pose mode
  • right click the mesh, select weight paint mode

The model turned all blue now, and you have the new "Paint" panel in the buttons view. Let's take a quick look at that panel.

Tutcre101-scrn-buttonpanel.gif

(1) is a slider, below are 5 buttons to set the sliders value directly. As you probably have guessed all on your own, it's the weight we would assign to a vertex.

(2) sets opacity. Set this to 1, we don't really need the amount of control this offers.

(3) is the size. You may need to make this smaller when you paint tricky things.

(4) wire turns on the wireframe model. Turn on or off as you like.

Tutcre101-scrn-spinepaint.gif

Let's start painting. Don't become too obsessed with assigning weights right now, you can do that later with your own models.

  • be sure to be in an exactly sideways view, NUM3
  • select weight 0.5, opacity 1.0, turn on wireframe
  • press TAB to go into edit mode
  • place the cursor over a bone in the spine
  • TAB back into weight paint mode
  • right-click once

You've now selected the bone you want to paint weights for.

  • "paint" the vertices next to the bone, all the way down to the belly. Hold the mouse button, drag down.

The area around the vertex becomes green. Green stands for weight 0.5, yellow for 0.75, red for 1.0, dark blue for 0, light blue for 0.25. Later you want to paint the vertexes next to the ones you just painted with a lower weight, the quickie way we're doing this here leads to edgy movements.

DEBUGGING

If NIFskope shows parts of the model stretched to the Scene Root (generally on the "floor" in the center), or Oblivion or the CS shows the exploding polys effect (you'll understand), you forgot to rig a vertex. Each vertex must be rigged to at least one, and to a maximum number of 4 bones.

If the scale and/or position of the model is all wrong in NIFskope and later in the CS the animation, you need to apply scale and position in Blender before exporting to .nif. Hit Ctrl-A.

  • paint each and every vertex using the steps outlined above

The paint will "paint through" to the other side of the model. For the spine, that's good, for the legs, not so good. You will need to rotate your view alot. You can undo the last stroke with UKEY, and of course you can overpaint wrongly assigned vertices with weight 0 if weighting of the other side is unavoidable.

This will take a while ... leave no vertex out, and do not assign more than 4 bones to one vertex. You cannot really break something otherwise, and errors you make here will teach you a lot. Go and make some errors. It'll sometimes be funny, too!

  • save, I saved as "sheepbones.blend", as we entered a new state of the process

You can export your work now and look at it in NIFskope. The vertices you missed are drawn to the base of the world, which is luckily not that far away - in NIFskope.

  • from the menu, choose File>Export>NetImmerse/Gamebryo, export as sheepbones.nif
  • open sheepbones.nif in NIFskope and check for errors
  • correct errors in Blender, go back to step one until happy
  • don't forget to save the corrected work in Blender

You cannot yet put the model into the CS, as we miss a UV map.

UV mapping the model

The "UV" here is meant as coordinates, like XYZ on the axes in Blender. They point to a location in a texture file, which is a 2-dimensional picture. If you call the width the U axis and the height the V axis, and store values for these coordinates with the vertices in the model, you can effectively wrap a 2-dimensional picture around a 3-dimensional mesh. That's how texturing with pictures basically works, and it's the only method of texturing used for Oblivion. And Oblivion won't like it one bit if there is no UV mapping on the model.

We must assign a UV map to the model.

QUICKIE:

We're going to do a quickie with that one, as the making of a full blown UV map using multiple material IDs and whatnot should be the very last step. At least the model should be finished. Redoing the UV map later when the texture is already finished is going to be a real pain.

  • here's the test I mentioned above: split the 3d viewport window, and set the window type to UV/Image Editor - check back with the Noob to Pro manual if you didn't grok that :)
  • in object mode, select the mesh
  • switch to UV Face Select mode, all faces should be selected
  • move mouse to the UV editor, hit EKEY, let him at it
  • from the bottom window menu, UVs>Save UV Face Layout ..., click "Ob", OK, name it oursheep

The result is an unusable UV mapping. We don't care one bit - for now. With the last step we also created a simple texture file, oursheep.tga. Now we assign that to our model:

  • in the buttons panel, select shading buttons (or hit F5)
  • click "new" in the material tab
  • in the texture tab, click add new
  • in the map input tab, click UV
  • select texture buttons (F6)
  • set texture type from none to image
  • in the newly appeared image tab, click load image, select oursheep.tga
  • export to sheepbones.nif: Menu File|Export|NetImmerse/Gamebryo
  • do a regular save
  • quit Blender
DEBUGGING

Not UV mapping the model will result in emptiness in the CS and Oblivion. The model will just not show.

Done!


LONG, PAINFUL, DRAWN-OUT PROCESS:

XXX ...

Now let's move back to NIFskope.


Putting it all together

Now we have a .nif containing a skeleton, and a mesh. We're now going to mod the origninal sheep.nif to use our new mesh. Sounds like we're nearly there, doesn't it? And, want to know something? We don't need the skeleton, as we didn't need the sheep mesh in Blender before. But now, we don't simply delete it, we're just not going to copy it.

DEBUGGING

If, on pasting the new mesh into the old file, you get an error message failed to map parent link "NiNode|oursheep" not all of the vertices are weighted. Go back to weight painting.

  • open the sheep.nif in oblivion\data\meshes\creatures\oursheep folder, where we made ourselves a home some time before
  • in NIFskope, select File>New Window
  • in the new window, load sheepbones.nif
  • open NiNode 0 and Ninode 1, there you see the skeleton NiNode and the NiTriShape node
  • right-click the NiTriShape node, Block>Copy Branch
  • switch to the other NIFskope-Window
  • Right click the Scene Root, Block>Paste Branch
  • OK the version alert box, [x] the message: infinite recursive link construct detected. We're laughing in the face of danger, hahahaha!

...


CS work: make a mod

Texturing quickie

As I'm not much of an artist, I can't really help you with actually drawing the texture. If you have nice pictures for the model, you can possibly use them to quickly cut&paste together a passable texture. I'd put the the saved UV layout we created during the UV mapping phase into a separate layer and draw on a see-through-layer on top of that. I believe texture sizes must be powers of two, e.g. 128x512, 1024x1024, 256x2048 and so on, but I may be wrong.

When you have fisnished the texture, it has to be in the right format and in the right place. There are may good guides on that on the CS wiki, but here's a quickie using The Gimp. The Photoshop way may be easier - if you have Photoshop.

DEBUGGING

If you later have pink models, the CS or Oblivion couldn't find the textures. Check the entries in the NiTextureProperty you set. If everything is correct, you may have the usual trouble which BSApatcher solves.

Tools required: gimp (free) and the gimp DDS plugins (also free)

  • create/open the texture file in gimp
  • save as .dds file in oblivion\data\textures\creatures\goat\goat.dds
  • select DXT3, check create mipmaps

Now, open the goat.nif again with NIFskope.

  • in the Block List, open Scene Root>NiTriShape>NiTexturingProperty
  • set the value of the NiSourceTexture in there to textures\creatures\goat\goat.dds