Tutorials @ chrisholden.net

 UDK Documentation: Blocking Out a Level

 Static Meshes

If you've built game assets before, they should appear mostly as intended in UDK. A few important considerations before importing are Units & Grid, Lightmapping UVs, and possibly Collision.

I'll be using max for this example.

Unit's and Grid

Default units for 3d Studio Max and UDK are 1 for 1.

This is demonstrated here by creating a box in Max and a brush in UDK, both with the same 128 unit dimensions.


Ideally, all game assets should maintain the same pixel density. This keeps some objects from being blurry or super detailed next to other assets. There are exceptions to the rules, such as character faces or objects in the distance. To match the default pixel depth of brushes in UDK, objects need a 128 box UVW Mapping in 3d Studio Max. I usually apply this to placeholder meshes to give them a consistent appearance in game. Once creating custom UVs, it's a great base to use for scale.

UDK's grid, like most games, uses the "power of 2" grid units. (2, 4, 8, 16, 32, 64, etc.) So it's best to build with these in mind, and set your models pivot point (with object selected in max > Hierarchy > Affect Pivot Only). The end position of the pivot depends on a lot of thing. Tiling walls or sidewalks might want the point at one corner, a statue at the center of the base, or a door with the pivot placed so it can rotate open. Properly setting up the model's pivot for grid snapping makes everything come together neatly in Unreal. Not everything has to be perfectly on the grid, such as a pile of rocks, but these are good practices.

Also, the model must be at 0,0,0 on the grid when exporting from max. If not, they will be off center that same amount in UDK.



Lightmapping UVs.

UDK bakes lightmaps. This is a large texture that represents all the lighting. You can find yours by searching LightMapTexture2D in the content browser. This is an additional UV channel where none of the UVs are overlapping, and they all fit neatly into the box. It works the same as baking lighting to a texture, any overlapping causes errors.

So here's my quick process I toss on a placeholder static mesh.

1) Add an Unwrap UVW. set the Map Channel to 2, and Edit...

2) In the Edit UVWs window, I hit '3' to switch to Face Sub-object Mode, and select all the faces.

3) In the menu, go to Mapping > Flatten Mapping > Ok

I usually use default settings because this placeholder doesn't matter too much, we just need something that works. The result will be a working lightmapping channel. This can be improved quite easily by stitching UVs (selecting verts, right clicking and Stitch Selected), and using Freeform Mode. Just remember; no overlapping and keep it within the single tile.

You can also do this within UDK by opening the static mesh, and going to Window > Generate Unique UVs. The results usually won't be as good as setting them up yourself, but work nonetheless.



Name the object

If you're testing or just setting up a quick scene, the name doesn't really matter. It's mainly for your own organizational purposes. Naming conventions become important in larger projects, and sharing files with others. Here's an example of how I might name a crate mesh for a more organized package;

  SM_Props_Crate02

Give everything prefixes that organized them alphabetically by category. The SM_ for Static Mesh, and the "props" putting it within a group of other static mesh "props". In the case of a modular set, such as a modular fence maybe SM_Fence_Post01 and SM_Fence_ChainLink so that when I open content browser, all those pieces will appear together, even when look at the bulk of the package.

You can see in this example image from my procedural building test; Parent_ being the parent materials, Proc_ obvious being the Rulesets, and right below is SM_Building01... being named as described above for being static meshes and within the modular set of building01. Naming conventions makes working with your files a lot less of a headache.






Collision

Collision is very important if you're making games, so be sure to check the official documentation.

A little philosophy on collision; Collision should be as simple as gameplay can allow. Complex collision can lead to many problems, mostly dealing with things getting stuck inside of objects and performance. Models don't always need collision either. If a simple blocking volume can go around it or if it's a small, snagging object then it doesn't need collision at all. In the end, it all depends on the gameplay.

Depending on how complex the shape is or how much the player will interact with it, you may want to model your own collision. If not, unreal can do this for you.

For example, Double Click a Static Mesh in Content Browser to open Unreal Static Mesh Editor, and where is says collision on the menu, there's a drop down of plenty of options. For this simple box, we'll use 6DOP simplified collision. If you click the green blob inside the pink ring icon, this will show collision. This works the same with custom collision.

 



For custom collision, I prefer to build it out of primitive boxes.

The collision model should be the same name as the model it's made for with the UCX_ prefix.

For this example, I would call it UCX_SM_Props_Crate02. In Max, I'd have two models SM_Props_Crate02 and UCX_SM_Props_Crate02. When exporting, I would select both of these, treating them as one file, SM_Props_Crate02. (More on exporting next section)

For this more complex collision since you can't use convex shapes, I used a single collision mesh with three primitive box elements (one for the stairs and one for each rail).





Exporting from Max

In max, with your model selected (and the custom collision selected if you created it) Export Selected as an ASE file. Remember to name it based on your naming conventions. There are other supported formats as well with other uses besides .ASE

Don't forget to make sure the model is at 0,0,0. The pivot is setup correctly, and you've reset xforms for good measure.



Importing to UDK

Right click inside the content browser and click Import. Select your ASE file and hit OK. From the Import screen you can setup the Package, Group and Name for the model. I tend to keep common things grouped, such as all static meshes, texture, materials, and so on get their own group. This helps keeps things organized. You also need to have your own package named AND SAVED to see some updates in unreal (static meshes for example, tend to not appear in game unless the package is saved).



If you have custom collision, you may get a pop-up, but don't worry about it. The model should now be in Content Browsers with a default material (blue/white checker).



Applying a Material

Double click your static mesh in the Content Browser to open the Unreal Static Mesh Edtior. you will see that has a checker texture on it so let's go ahead and change that. Select any material you deemed appropriate. I suggest a color/material that represents what that object is supposed to be if you don't already have a custom material. With that material selected, to back tot he mesh editor, and click the small green arrow icon in the Material slot. This will apply whatever material you have selected in the Content Browser.



If you click in the model viewer itself, you can rotate/pan/zoom around your mesh. Set it to a nice angle that best represents this model's purpose in a thumbnail, and click the eye icon in the toolbar (SaveThumbnailAngle). Now when you see it in the Content Browser, it be easy to understand what that object is at a glance.



Adding a Static Mesh to a Scene

There's actually a lot of ways to do this. Here's a few;
1) Left click drag your static mesh into the scene from Content Browser.
2) With static mesh selected in Content Browser, Hold 'S' and left click with the mouse anywhere in the scene.
3) With static mesh selected in Content Browser, right click with the mouse anywhere in the scene and Add Static Mesh.
4) With static mesh selected in Content Browser, right click any object and Replace with Static Mesh.




Either way, save, right click and hit Play from here, and Hurrah! A box.

You may need to rebuild lighting as something new models come in completely black. This is common more with interiors, but this example is an outdoor scene with a Dominant Directional Light.



Dynamic objects

Any object can become dynamic (player can push it around). This works best for small things like trash, buckets, barrels, and so on. All you have to do is open the Static Mesh Editor, check the Can Become Dynamic check box (model MUST have collision), and set the Mass Scale in the Body Setup. For these barrels I set the mass to 4. It makes them very easy to move around, any lower and they fly through the air when you bump against them. The neighboring crates I set the mass scale of 10 so they are difficult to move.







 

Tutorials @ chrisholden.net