I'm a doctor, not a mechanic
This page follows on from where the 3D Studio Max Weapon Modeling And Import tutorial ends.
Once you have the *.3ds files ready (from the above tutorial) place them all into a new empty directory. Copy the 3ds2unr.exe file into the same directory.
Now you need to decide on what your output file will be called. For my grenade weapon first person view I used grenadefp which is what I will continue using here.
The 3ds files I ended up with after animation and export were:
- sel_desel.3ds - the de-select/select animation
- pinpull_fire.3ds - animation for pulling the pin and then throwing
That was it actually. You might have more. My pin pull and fire were in the same file because at the end of the pin pull the arm is drawn back for the throw and not in the rest position so I thought it was simpler this way.
Open up a DOS box, cd to your new directory that contains 3ds2unr and type in the following command:
3ds2unr.exe grenadefp sel_desel.3ds pinpull_fire.3ds
Replacing the command arguments with your output name and input 3ds files.
If this is the first time you have run 3ds2unr it will prompt you for a project directory. I selected the directory in which we currently were (where 3ds2unr was). If this is not the first time you have run the util it will carry on with whatever setting it was originally given. This is OK if you know where it is but you do have the option of redefining it by typing the following command:
Assuming this is the first time the utility has been run it will create 2 sub-directories in the project directory (does it or do you have to manually create them? It was all of yesterday I did this):
If there were no problems with the conversion you will find, after the utility has completed, a new *.uc file in the classes directory, and new *_d.3d and *_a.3d files in the Models directory. In my case I had a grenadefp.uc, grenadefp_d.3d and grenade_a.3d files.
You have now finished with 3ds2unr.
If you get an error that you don't understand or want to learn how to use transparent/two-sided object materials etc. then the easiest thing is to read the .DOC file that comes with the 3ds2unr download above. It contains a lot of good information on model/material restrictions and advice on how to achieve different effects.
Once you have the output files it's time to get them into the game. Since my 3ds2unr project directory was nowhere near my UT directory I manually copied the model files into the Models sub-directory of my mods package directory under UT. You will then also need to copy the texture files you used in Max into your models directory. (make sure they are 8bit colour depth and are a power of 2 in resolution - 128*128 or 128*256 or 256*256 etc)
Then open the generated .uc file in notepad and copied all of the #exec directive statements that this contained and paste them at the top of your new weapon class.
The first thing you will need to change is the texture import lines. Example code:
#exec TEXTURE IMPORT NAME=Jgrenade FILE=MODELS\hand.bmp GROUP=Skins FLAGS=2 // skins #exec TEXTURE IMPORT NAME=Jgrenade1 FILE=MODELS\grenbody.bmp GROUP=Skins FLAGS=2 // skins #exec TEXTURE IMPORT NAME=Jgrenade2 FILE=MODELS\grenarm.bmp GROUP=Skins FLAGS=2 #exec MESHMAP NEW MESHMAP=grenadehn MESH=grenadehn #exec MESHMAP SCALE MESHMAP=grenadehn X=0.1 Y=0.1 Z=0.2 #exec MESHMAP SETTEXTURE MESHMAP=grenadehn NUM=1 TEXTURE=Jgrenade #exec MESHMAP SETTEXTURE MESHMAP=grenadehn NUM=2 TEXTURE=Jgrenade1 #exec MESHMAP SETTEXTURE MESHMAP=grenadehn NUM=3 TEXTURE=Jgrenade2
The TEXTURE IMPORT lines will contain texture files that dont exist. Replace the FILE setting with the correct bitmap or pcx file name.
Ensure that in the SETTEXTURE lines that the correct texture is set to the correct NUM value. The NUM value refers to the material ID of the polys in your scene. So for example my arm models all have material ID of 1. My grenade body and ring pull have material ID 2 and the grenade arm has a material ID of 3 (done this way to allow a 2 sided material for the grenade arm)
Next, you may need to change is the placement and orientation of the model. The line for this on my model ended up like this:
#exec MESH ORIGIN MESH=grenadehn X=100 Y=0 Z=70 YAW=128
The origin (X=100 Y=0 Z=70) tells unreal where on the screen the model will appear (X is into the screen, Y is left/right and Z is up/down). Play with the numbers until it looks right. YAW, PITCH and ROLL can also be defined to rotate the model as required (128 is equivalent to 180deg). My model was facing the wrong way initially.
You will also find that the model may be too small or too large on import. To modify this add (or modify) the line
in the default properties of the class. A value of 1 keeps the model dimensions as they are. Smaller numbers reduce the size...
It can take quite some time to get the model exactly as you want it on screen.
One thing to be careful of is numbers used for the origin. If the model gets moved away too far from the players point of view it will start to clip into walls when you get close.
Next come the animation sequences.
My final code looked like this:
#exec MESH SEQUENCE MESH=grenadehn SEQ=All STARTFRAME=0 NUMFRAMES=59 #exec MESH SEQUENCE MESH=grenadehn SEQ=down STARTFRAME=0 NUMFRAMES=11 rate=6 #exec MESH SEQUENCE MESH=grenadehn SEQ=select STARTFRAME=10 NUMFRAMES=11 rate=6 #exec MESH SEQUENCE MESH=grenadehn SEQ=still STARTFRAME=0 NUMFRAMES=1 #exec MESH SEQUENCE MESH=grenadehn SEQ=idle STARTFRAME=0 NUMFRAMES=1 #exec MESH SEQUENCE MESH=grenadehn SEQ=loading STARTFRAME=21 NUMFRAMES=21 rate=8 #exec MESH SEQUENCE MESH=grenadehn SEQ=fire STARTFRAME=41 NUMFRAMES=8 #exec MESH SEQUENCE MESH=grenadehn SEQ=downempty STARTFRAME=48 NUMFRAMES=11 rate=6
The ALL sequence should be done for you. You will need to list out all the other animation sequences specifying the exact frame they start on and how many frames they last. The RATE keyword at the end of some of the lines allows you to speed up or slow down the animation. You will need to play with it until it feels right.
Finally, write the code to call the animations and make your weapon work :)
One last thing. The above code assumes a right handed weapon. Once you have this finished you can copy all of the #exec statements and paste them below the originals. All you have to do is change the MESH IMPORT MESH line so that it has unmirror=1 at the end. i.e.:
#exec MESH IMPORT MESH=grenadehn ANIVFILE=MODELS\grenfp_a.3d DATAFILE=MODELS\grenfp_d.3d X=0 Y=0 Z=0 unmirror=1
Then replace all occurances of the mesh name (grenadehn here) with a different name (I used grenadehnl). You can also remove the TEXTURE IMPORT lines since we have already imported the required textures.
Now for an annoying bit. After getting everything spot on for the right hand view you may find that left hand view is out. Again it is just a question of playing with the origin of the mesh and also the following:
Which can be found (or added) to the default properties of the class.
This allows for a model to be mirrored for left/right hand views and be placed exactly where the author wants it. It makes for a lot of tweaking but you can always get the effect you want eventually.
Wang: This could do with being a bit more detailed and is "fluffy" in a few areas. Anyone who knows more about the subject should add on/modify where necessary.
Col Kassad: Very nice! :)
Wang: There is something I should add to this that I found out later that only applies to this type of 2 stage firing. On the client in a network game if a weapon is not animating it will be sent to the idle state. When my animation for pulling the pin finished I held the weapon at the last frame of this animation until the user released the fire button. At this point the throw animation ran. Holding the weapon at a specific frame meant it wasn't animating so off it went out of the ClientFiring state. I had to add a 2 frame static animation that could loop in the ready to throw position.
Shuriken: Hey - can anyone tell me if this and the previous tutorial are the same method still used for importing models and animations into UT2003? I've found it really hard to find tutorials about the subject for UT2003... can anyone point me to some if it uses a different method?
Chip: Shuri, this method can be used for getting vertex animations into UT2003, but that type of animation isn't used for "modern" UT2K3 character models and weapons – they're exported/imported as skeletal meshes, using either ActorX (for Max and Maya full apps) or with the unEditor plug-in for Maya 4.0.1 PLE. The difference between the animation types can be seen if you've ever played the Invasion game type – all the Unreal1 monsters are vertex anims (the method used for Unreal1 characters),and their limited anims are obvious.
In UEd, check the Animations browser to see the extent of skeletal anims used in UT2K3 (File>Open will shows how many .ukx files are used), and the Meshes browser will show the vertex anims. Note that some objects like waving flags are still best done with vertex animation due to the complexity of the motion, or because the mesh shape changes (goop blobs).
So a full answer to your question means you have to define what type of Animation you're planning. Some links that might help: udn2:ModelingTableOfContents, udn2:ActorX, udn2:UnrealVertexAnimation, Maya PLE Character Model Tutorial
Shuriken: Wow, thanks - detailed reply :) (this is all new to me, so I need all the help I can get...)
From what I've been working with today, I've realised that I'll definately need bones in the model to attach emitters to. So I assume I have to go the ActorX route (I'm working in Max btw)... but I'm confused about Skeletal Animation. Is it completely different form of animation? Or can I do the regular 'move+rotate' animation that is detailed in the first part of this tutorial.. all I need is some simple recoil effects + select/down.
Also, every weapon mutator I have comes with a .ukx. Is this necessary for skeletal meshes? I know with vertex animating the models you can embed it in the code, which is what I wish to do - possible for skeletal animation?
Chip: Hmmm...hard to answer succinctly, but basically vertex animation & skeletal animation are significantly different methods of accomplishing the same task – animating a mesh. Vertex animation draws on more system resources (from what I've read) during game play, and can be harder to animate for some types of movement (like humanoid stuff.) For weapons, I don't know that it makes much diff, but all "stock" UT2K3 weps are .ukx files, which are skeletal mesh anims. Here's another UDN page to study – it makes the .ukx package a bit more understandable: udn2:AnimBrowserTutorial
I haven't done any weapons yet, so the "embed it in the code" question I can't speak to, but just from the standpoint of ease of animation, export & import, the skeletal route seems better to me. Check out the ShockRifle_1st model & anims in Weapons.ukx (use the Animations browser) – a good recoil anim example, among others.
*Someone*: Do you know if I can just clone the objects and move them into their individual frames?