Importing vertex meshes into Unreal
Part 1) Intro
Unreal Engine 1 is one of the older engines which seems to be user unfriendly when it comes to importing new animated meshes into the game.
In this tutorial I would like to share my workflow of how I prepare and export meshes from blender and get it into Unreal / Unreal Tournament.
I will use my new RocketCan mesh which I made for Unreal Redux as an example.
Here you can find some useful #exec parameters: Exec_Commands
Part 2) File Formats And Blender Plugin
Unreal's vertex mesh format requires two different files for the import.
A _a.3d which stores the vertex animation timeline and a _d.3d which stores the mesh data like the UV Map and materials / poly flags.
Thankfully Skywolf wrote an exporter for Blender which allows exporting meshes to the right formats!
For this tutorial I will be using Blender 2.80 however the plugin should be compatible with any Blender version released after this. Blender 2.79 and older are not supported although an older version of the plugin that works with Blender 2.79 can be found in the forum thread linked above.
Part 3a) Preparing Your Mesh - Boundary Box
If the mesh leaves that box caused by an animation or if it is bigger, your mesh will get cut and vertices will merge during the import progress.
To check the right sizing and maximize your animation range you can create a new cube in blender and scale it by factor 128 which gives you the right boundary box size
Part 3b) Preparing Your Mesh - Timeline Animation
I setup a simple armature system for the mesh which includes an "Open" and "Close" animation.
- Frame 1 is the "default" position or the "Still" position the mesh.
- Frame 3 is the "Open" position
- Frame 5 the "Close" position.
Part 4) Exporting Timeline Animationset.
Make sure your mesh is not split into different objects. It's important that all animated parts are stored in one object. Otherwise you will export only one part of it.
If your mesh is only one object select it in Object Mode.
Then go to file → export and select Unreal Engine Vertex Mesh (_a.3d, _d.3d)
Then choose a name for your Mesh and select under the point "Source:" Scene Timeline
I also recommend checking "Exporting to UCC folder Structure". This generates for you a preset for the import information which I will explain later in Part 5b)
If no error occurs after hitting export your mesh have been exported successfully.
IMPORTANT: Before you export your mesh, make sure you deleted the Boundary Box if you used one.
Part 5a) Preparing The Import
Open that folder and create new folders named "classes", "models", "sounds" and "textures".
Paste the generated .uc in the "classes" folder and the exported _a.3d and _d.3d files in to "models".
If your mesh has a custom skin put it into "textures" and new sound effects into "sounds"
Then go to the System folder in your Unreal installation and open the Unreal.ini and add a new EditPackages line under [Editor.EditorEngine]. I choose EditPackages=NewRocketCan.
And save the Unreal.ini
NOTE: The .ini entry and the new folder in your Unreal directory must have the same name!
Part 5b) Preparing The Import - The .uc File
Skywolf's vertex mesh exporter plugin generates for you a ready to use .uc file which includes all important information which Unreal needs.
I tried to mark and describe some parts in the code so you can customize it to your uses.
The changes I will apply are:
- Changing the parent class to "RocketCan"
- Applying animation names and set the start frame and the animation length for the "Open" and "Close" animation
- Removing the texture import information because I use the textures from UnrealShare.u but I will keep the MeshMap settings for each Texture Num (Blender Materials)
After my changes the new .uc looks like that:
Basically if you have more animations then one you need to tell the .uc file at which frame your next animation starts.
The StartFrame also counts to the animation length.
As we remember the „Open“ and „Close“ animation I made in blender has only three keyframes for each.
So the „Open“ animation in my example uses the frames (1, 2 and 3) = NumFrames of 3.
For the next animation the new StartFrame would be the last frame of the „Open“ animation.
So I count again for the „Close“ animation the frames (3,4, and 5) = NumFrames of 3.
If you have more animations you need to continue this counting until you reached the end of your animation timeline.
Part 6) Importing Your Mesh Into Unreal
I'm doing it the classic way and use the command prompt to build my packages.
There are different ways to open it. Simply click on the Windows icon in the taskbar and type "cmd" and open the command prompt.
Once the command prompt is open you need to navigate with "DOS" commands to your Unreal installation.
- use "cd.." to navigate one folder backwards
- with "F:" you can go to another hard-drive
- use "cd" to open a folder
Once you reached Unreal\System execute "ucc make". This command will build all your packages you have set in your Unreal.ini under "EditPackages".
NOTE: If your package ( the .u file ) still exists in the System folder, the package won't build.
TIP: Make a safety copy of your still existing package and delete the .u which shares the package name you want to build.
After you executed "ucc make" the program will tell you if errors during the import happened and tells you exactly what's wrong.
In my case the mesh was imported successfully without any warnings.
Part 7) Fine Tuning And Adjustments
Once your new actor has been successfully imported into the game open the editor and navigate to it's location in the actor browser. In my case it's a subclass of RocketCan.
Select your new actor and place it into the level and check if the mesh has the right origin, rotation and scale.
In my example I want to have a similar origin, rotation and scale like the original RocketCan actor. Usually, after the first import the mesh values are far away from it's final position.
Okay let's fix this
- Open the editors MeshBrowser
- Navigate to your new Package and select your Mesh
- open with edit the Mesh Properties
Now a properties window opened where you can setup your mesh- origin, rotation and scale.
IMPORTANT NOTE: In pre 227j versions the rotation settings are not in degrees! Also the rotation import information written in the .uc uses different values.
- 90° in the .uc equals a value of 64.
- 90° in pre 227j editor versions equals a value of 16384.
If you change the values in the Mesh properties in UnrealEd you can instantly see the changes for each value.
The changes I made for my mesh are:
- Origin Y = 20
- Rotation Roll = 90° ( Pre 227j Roll = 16384 )
- Scale X and Y = 0.125
- Scale Z = 0.25 ( always double size of X and Y )
Part 8) Final - Apply The Changes To The .uc
Open UnrealEd's actor browser, select your package and navigate to your new actor.
Then right click on it and select "Edit Script".
Now apply your changes you did in the mesh properties to the import code of your actor.
After you applied your changes to the import information select "compile changed" under tools in the script editor and close it.
Now save your package and export your package.