Model Skinning and Importing for UNREAL™ a tutorial by Ken Post Jr. (aka. Syncan) Animator /Music Composer  

Required software: 3D Studio MAX, Unreal(ED), 3ds2unr.exe
 
      I have written this tutorial for third-party/mod developers who, like myself,  have had a tough time finding complete, comprehensive information.  Almost all of this was written from my own experiences and research developing models for an Unreal addon.  This is a true story.  Names have been changed to protect the innocent.  Some computer peripherals were harmed during the making of this tutorial.


UPDATE! 8/11/98 I'd like to thank everyone for their kind emails. For all those who have questions, please be patient. I get alot of email each day; and I will indeed answer everyone... just give me some time. :) -Ken

Unwrapping your model for skinning

There are two methods here...so which method is better/easier?
Both of these methods work quite well, and are pretty much balanced in difficulty... it's really up to you, the animator/modeler, to decide which you're most comfortable with.  Good Luck!
. Method 1 - Mutilating Your Mesh!

With this method of skinning, you MUST unwrap your mesh object before animating it.  This is because you are actually animating a morphed object.

Split Up the Mesh
First, you will need to split your mesh up into sections that you can, for the most part, map planarly (flat).   This done using the "edit mesh" modifier.

Select your mesh and apply an 'edit mesh' modifier.  Click 'SUB-OBJECT' and select the type 'Face'.  (See Fig. 1)
You will now be able you select individual faces on your mesh by simply left-clicking on them in the viewport.  Holding CTRL while left-clicking will add faces to the current selection.  Holding ALT while left-clicking will subtract faces from the current selection.
Once you have a selection of faces that you feel is appropriate for planar mapping (i.e.. the front of the face), click the DETACH button under the MISC. section of the 'edit mesh' options.  You will be prompted to enter a name for the detached piece; do so and hit enter. (See Fig. 2)
.    

Clone Your Mesh
Repeat the previous steps until you've detached every piece of your mesh into sections.  *IMPORTANT: Make sure that you DO NOT move these sections around up to this point!*  Now that your mesh is in sections, unselect 'SUB-OBJECT' in the modifier and drag-select all of the sections.  Make a clone of it by holding shift and left clicking the mesh.  Pull the clone to far to the right or something of the original, and hide that baby.  Now SAVE!   This is a VERY important step.  If you miss doing this, later on you will be quite frustrated.

Lay Out Your Pieces
Next, you need to lay out these sections in a sensible manner. (Fig. 3)  (You've probably seen a skin before, whether it be from Unreal or Quake/Quake2).  There are good examples of these at various skin sites on the web, such as House of Style, and you can also browse the texture directory of Unreal in UnrealED.  Also, the more sections that you can "re-piece" together, (i.e.. the inside/outside of the arms, the front/back of the torso) the better.  This is done by basically moving one section next to it's adjacent section an aligning their vertices.  This helps avoid seams in your model when painting your skin.  *IMPORTANT: Do not weld these points!*

Re-attach Your Sections
Now you need to re-attach your sections together again, into one mesh like you had before.  Select a section and under its 'edit mesh' modifier (make sure 'SUB-OBJECT' isn't selected), hit the 'ATTACH' button.  With the button on, select another section. Then select another. Keep selecting the sections until they are all selected.  You now have one mesh again!  Now unhide that clone you made earlier.  Okay, did you write down the order that you selected those sections in?  GOOD!  Because you need to select the sections of this clone mesh in the same exact order. So do the same, and re-attach the sections of the clone together into one object.   

Once this is done, select the unwrapped mesh.  Apply a 'UVW Mapping' modifier to it, and select planar mapping.  Make sure it's applied to the correct axis that you have your sections facing, and hit 'FIT'.  Finally, you need to output this unwrapped layout to a graphic file (such as .tga or .bmp), using a plug-in utility such as Unwrap or Texporter.  This is what you'll use as your skinning template.

Morph Your Mesh
Now make sure the unwrapped mesh object is still selected.  Go to 'CREATE --> COMPOUND OBJECTS --> MORPH'.
(Fig. 4)

.
Hit the 'PICK TARGET' button, and then select the clone object.  Your unwrapped mesh should form back into the original shape.  (That IS if you've done everything correctly...it may take you a couple tries when you first do this.)   Now that you have this morphed object, you can delete that clone.  Finally, do an edit mesh on the object, 'SUB-OBJECT/Vertex', and weld vertices with a threshold of about .01 (I've heard .1 elsewhere, but with my meshes, it welded TOO many points together.)   You now have a perfectly skinable mesh.. the UV coordinates are all there. That's pretty much it.  Save the scene, and GO PAINT THAT SKIN!
.   Method 2 - Utilizing Unwrap UVW

With this unwrapping method, you don't actually unwrap your mesh like the previous method.  You work with the coordinates more virtually, utilizing the 'Unwrap UVW' modifier.

Mapping Parts of Your Mesh
First, select your mesh. Apply the 'meshselect' modifier, click 'SUB-OBJECT/Face', and select, for example, all faces of the head.  Apply the 'UVW mapping' modifier, and select a mapping type you think would most appropriately fit to these faces.  In this case, cylindrical mapping would probably work best for a head. (Fig.6)  Make sure you are mapping on the right axis, and click the 'FIT' button.  Next, apply the 'Unwrap UVW' modifier, and click the 'EDIT...' button to see how your mapping turned out. (Fig. 7) If your not happy with the mapping, you need to delete the 'Unwrap UVW' modifier from the stack, and modify your UVW mapping parameters.  When you're satisfied with the unfolded mapping coordinates in the EDIT UVW screen, move them out of texture space (the square outline in the center) so they don't conflict with your next face unwrapping.
.

Make Your UV Unwrap Map
Repeat the previous procedure until you have unwrapped all of your mesh faces.  Now apply a 'meshselect' modifier and select ALL of the faces of your mesh.  Apply an 'Unwrap UVW' modifier, and hit the 'EDIT...' button again.  You should be able to see all of your unwrapped mesh pieces in the EDIT UVW window.  If there are some funky looking faces in the middle of the texture space square, that means you didn't select some faces somewhere.  If this is the case, you have to delete the last 'Unwrap UVW', and find the faces you didn't select.  You can then re-apply this final unwrap modifier again.  Now you want to take all these texture parts and fit them into that texture square. (Fig. 8)  You might have to scale, rotate some pieces.. pretty much the same deal as fitting the sections together in method 1.   Once that's set up, exit the UVW editor.   Edit the stack, and cut all the modifiers below the last 'Unwrap UVW' modifier which you just worked with.  Finally, output the UVW coordinates to a graphic file with the Unwrap or Texporter plug-in, and you're ready to make your skin!
.  

Importing your model into Unreal

Okay, I'll assume you have an animated mesh loaded into MAX.  Depending on the object, this might include a bone structure for deformation.  Now, you can't just export this to a .3ds file and expect 3ds2unr to convert all this animation data (it just won't).  Rather, you have to have a sequence of objects in your .3ds file that 3ds2unr can use.

Making the Sequence of Objects for a .3ds file
Let's say you have a scene loaded called 'Walk.max'.  It has 15 frames of a guy walking.  In order to export this in it's entirety, you need to create a separate object for each frame.  This is done with the "snapshot" function.  First, name your mesh something with no numbers in it.  For this example, we'll name the object 'GUY'.  With your mesh selected, go to 'Tools --> Snapshot'   Click the 'range' radio button.  For the 'FROM:' field, enter the starting frame.  For the 'TO:' field, enter the ending frame.  In this example, you would enter '0' for the starting frame, and '14' for the ending frame.   In the 'COPIES:' field, enter the total number of frames... in this case '15'.   Make sure the 'MESH' radio button is selected under 'CLONE METHOD', and hit enter.  Depending on the number of frames in the animation and your processor speed, you may have to go get something to drink to kill time; or maybe even take a short walk.
.
You should now have 15 new objects in your scene, each having the original object name, followed by a sequence number (i.e.. GUY01, GUY02, GUY03, etc...)  These are the animation frames, in order.  Delete the original mesh object (GUY) and any bone structures you may have.   You can now save this scene out to a .3ds file.  Go to 'File --> Export ---> 3D Studio.  For this example, we'd call the file 'walk.3ds'.   You now have a .3ds file with a complete object sequence!

Convert Your Skin for Unreal
Remember that skin you made?  You need to convert that to 256 colors (indexed color) and save to .pcx format.  This can usually be done with the same graphics editing program that you PAINTED the skin in, such as Photoshop or Paintshop Pro.  Using "Adaptive" palette conversion without diffusion usually gives the best results. Also, be sure that your skin does not exceed the 256x256 pixel size limit.

Convert Your .3ds file for Unreal
Now for the hard-core importing.   Go into your Unreal directory and make a new subdirectory.  We'll call this one, 'tutorial'.  This is ultimately going to be your package name.  Copy '3ds2unr.exe' and your .3ds file into this directory, and at a DOS prompt type, '3ds2unr -setproj'.  This will open up a little browser window. (See Fig. 10)  Select the subdirectory that you just made and hit 'OK'.   Now make two directories within your subdirectory; one called 'Classes', the other called 'Models'.   Into the 'Models' directory, copy that .pcx skin file that you made.  Now at the prompt, type '3ds2unr [classname] {file}.3ds'.  [classname] is what you want to call the model that you're importing, and {file} is the name of the .3ds file that you exported.  For this example, we would type '3ds2unr guy walk.3ds'.  Got it? Good!  This is going to create three files:  two .3d files, which will be made in the 'models' directory... and a .uc file which will be made in the 'classes' directory.  (Note: You can list more than one .3ds file for a class.  This is how you import all those different types of animations for your class.)

Edit Your Class File
You are now going to make some minor changes to that .uc file, which is your model's (or actor's) script file used by Unreal.  You can edit the .uc file in notepad or whatever.   (Fig. 11)

Change the following:

class [classname] expands Actor;

to

class [classname] expands ScriptedPawn;
 

and...

#exec TEXTURE IMPORT NAME=Jguy1 FILE=MODELS\[filename].PCX GROUP=Skins FLAGS=2

to

#exec TEXTURE IMPORT NAME=Jguy1 FILE=MODELS\[yourfilename].PCX GROUP=Skins FLAGS=2

[filename] refers to the name automatically given to the .pcx file when the .uc file was made.  [yourfilename] is the name that you gave  your .pcx skin file.

You can now save this .uc file.   We're almost done!
 

Let Unreal See Your Package, Baby
Go to the 'unreal/system' directory and edit 'unreal.ini'.  To get to where you want to go quickly, go to the 'FIND' option in your text editing program.  In the search field, type 'EditPackages[5]'.  You should be taken to the line 'EditPackages[5]=UnrealI'. (See Fig. 12) Underneath this line, make a new line for your subdirectory/package.  In this example, you'd create the line EditPackages[6]=tutorial'. Save the .ini file and go to a DOS prompt in the 'unreal/system' directory.  Type 'unreal -make', and unreal will import your model/class/package.

The Moment Of Truth - Your Model in UnrealED
Now to see your model. Load up UnrealED, and go to 'Window --> MeshViewer'.  Scroll down the list until you find your model/class name.  There it is, in full glory!   Whatever .3ds file(s) you specified with 3ds2unr will be listed in the 'animation' list.
.  
 



There a couple specific problems you may see when importing your model... here are the answers.

MESH DISTORTION -  Your model/scale size is WAY too low.   Scale up the model to proper size in MAX and re-import it into UnrealED.   Unreal truncates the coordinates by 1/8th unit on the X-Y axis, and 1/4 unit on the Z axis. ...   If your model is tiny, the low resolution between vertices will cause anomalies in the mesh on a frame to frame basis.  (This effect might be useful if your player is supposed to be under the influence of hallucinogenics.)

LINE BREAKS IN SKIN/SEAMS -  This is also due to the coordinates truncating.  When you paint over the skin mesh exported by Unwrap or Texporter, be VERY liberal when painting over the mesh boundaries. (Forget everything you were taught in kindergarten!) Otherwise, some of the skin background color might show through on the model in Unreal, giving a very unpleasant shimmering effect.

THE MESH MIRRORS IN CONVERSION -  Yes, it does. :)
 

My brain hurts!!
At first, this importing tutorial may seem overwhelming... but I promise you (assuming your IQ is above 100), that after working a bit with this, it will become a no-brainer task.  You'll be breezing right through it!

What? It didn't work?!!
There is no guarantee that you will be successful on your first try.  It may take a couple times... retrace your steps, you probably didn't do something right.  Make sure your model is within the 256x256 allowed coordinate space...are all your objects in the .3ds file in sequence with no breaks?   Scrutinize EVERYTHING!
 

I hope this tutorial answers some of your "what the @#$!", "how the @#$!", and "why the @#$!" questions.  Best of luck with your Unreal endeavors.
 

- Ken Post Jr.
OMG-Games, LLC
 
email questions/corrections/suggestions to ken@omg-games.com



 
  This tutorial is not affiliated in any way with Epic MegaGames, Inc. Unreal is a registered trademark of Epic Megagames, Inc.