Creating Units

From WiCWiki

Revision as of 15:55, 23 November 2007 by Tabu (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Creating Units Introduction

This “howto” will take you through the process of creating a player controlled unit.


- Layers

- UV

- Texture

- Skinning/Weighting

- Bones

- Scene Setup

- Tracks Setup

- Animation/States

- Showbox

- Surfaces

- Hierarchy Setup

- Physics

- Shadows

- LODs

- Nodes

- Particles


Tip: Keeping a clean folder setup makes it easier to work. Here is an example of keeping it easy.

Separate the different types of files in their own folders, save all your meshes in one folder and all your animation states (*.lws) in to one folder and so on.

The Shadow file you save in the showbox (*.sdw) has to be in the same folder as the .mre/mrb.

Remember to set it up in the beginning because it’s hard to do it afterwards without screwing things up.

Image:FolderSetup.JPG


Unit Workflow in Modo

Layers

When building a unit we use a system mostly consisting of four layers. The different layers might not be necessary but help to improve the quality of your unit and the performance of the game in general. The layers are as follows,


Main layer

The main layer will contain the base of your model.

Image:BodyLayer.jpg


Detail layer

In the detail layer you will have all the small parts that you don’t think contribute as much to the overall silhouette of your unit. The parts in this layer will fade away over distance to enhance the performance of the game.

In the picture below the details are split-up into two layers “heading_details” and “body_details”. Heading details are the ones that will follow the turret and needs to be on a separate layer because they will be linked to the “Heading Bone” later on.

The same principles apply to the body details layer which will be linked to the “Body Bone”.

Image:DetailLayer.jpg

Window layer

If your unit features windows or other reflective surfaces such as mirrors you should have them in a layer of their own. This is to be able to give them their own properties and shaders.

PCC layer

PCC is short for Player Created Content. This is just a polygon plane you place just above the base mesh. The plane is where you want the user to be able to add a picture that they upload via Massgate. This is to be able to give it specific properties and shaders.

Image:PccLayer.jpg

Tracks model

The Tracks of the tank is modelled in a completely separate file.

First you model the tracks, this is fairly straight forward.


Then you need to UV-map everything except the wheelside’s in one axis, either U or V. this so we can use the UV Translate in the Showbox later to animate the tracks texture (which needs to be tiled).

The side of the wheels you UV-map planar from the side so it forms a circle in the UV space with it’s center at UV 0,5 0,5. This is so the side can be Rotated with UV rotation in the Showbox.

Image:tracksmodel.jpg

The trax will be using 2 textures, 1 for the wheel side which is UV animated with rotation, and one that is UV animated with translation, either in the U or V axis. But since we only got 1 surface and 1 UV-map we need to add a vertex color map, which alpha will decide which texture ends up where.

This needs to be done in Lightwave, and we usually use “Vertex Paint” to set this up.

Image:tracksmodel_02.jpg

When you have done the vertex color map you need to apply it to the surface in Lightwave under the “Advanced” tab for that surface.


Inside the showbox to use this setup you need to select the surface named “Tracks/Wheels (Special UV 1 st / 2 nd lerp)”, and then apply your track and wheel side texture on slot 1 and 3 in the texture list.

2 and 4 is used for specluar values.


Settings up the uv animation is explained later. …

Image:TraxModel.JPG

UV

When UVing standard rules apply such as try to give the parts the same resolution and if you need more space you can always resize things that goes on the underside of the tank.

We also use a system that allows for random decals and stickers on the units. It is also possible to use the Alpha channel of that map to remove actual mesh with. We call it Random texture “Rand textures” for short.

To use this system create a new UV map, in the example below its called UVset2 and as you can see we scale up the pieces that needs the most texture resolution. Since this UV will have a smaller sized texture we need that extra resolution.

Something to have in mind is to have the pieces you want to “alpha out” get a unique UV space. The naming convention of these textures needs to be specific. They have to end with *_rand(number of the texture)of(how many rand textures you have) in my case it looks like this “m60_a3_UVset2_rand1of5.DDS”

Image:UVsetup1.jpg

To get the second UV set to work correctly you should set the “Effect” to “subsurface amount” in the shader tree. Don’t forget to set the UV map to “UVset2” in the texture locator. See picture below.

Image:UVset2_Setup.jpg

Example of the Rand Textures in action:

Image:RandtexEx.JPG

Texture

Your model has to have a texture assigned to it. Remember to choose right UV set. It is important to only have one material per layer. If you don’t it will either crash or split it into two in Showbox.

A unit uses a Color map, specular map and the rand texture. It’s pretty straight forward. The only thing worth mentioning is that in the color maps Alpha channel is used as a bump map.

The rand texture uses an overlay function much like the one in photoshop. It can be set to either “Multiply” or “Screen” in my case I use the Screen function meaning that all the black in my color map will disappear.

In the picture below you can see what my Rand texture looks like. The Alpha is best explained with white equal’s visible and black equals not visible mesh. The other picture shows where in the Showbox you set the rand texture to screen mode (the area marked in red).

It also shows where you swap between the Rand textures (1.).

For additional information on textures and surface setups check page about Shaders


Textures and Units

Your model has to have a texture assigned to it. Remember to choose right UV set. It is important to only have one material per layer. If you don’t it will either crash or split it into two in Showbox.

A unit uses a Color map, specular map and the rand texture. It’s pretty straight forward. The only thing worth mentioning is that in the color maps Alpha channel is used as a bump map.

The rand texture uses an overlay function much like the one in photoshop. It can be set to either “Multiply” or “Screen” in my case I use the Screen function meaning that all the black in my color map will disappear.

In the picture below you can see what myRand texture looks like. The Alpha is best explained with white equal’s visible and black equals not visible mesh. The other picture shows where in the Showbox you set the rand texture to screen mode (the area marked in red).

It also shows where you swap between the Rand textures (1.).

Image:RandTexture.jpg

For additional information on textures and surface setups check page about Shaders


Skinning/Weighting Units

A tank usually consists of these base bones: Body, Heading, Pitch and Barrel. In some cases your unit will have for example 50cal guns and/or antennas and in those cases you will create additional bones and corresponding weight maps.

Do not weight the detail layers since they will be linked to the bones instead of weighted.

Image:Weightmaps.JPG


Bone setup in units

Up to this point I have been working in modo. I now bring my LWO file into Lightwave´s modeller to create the bones for the unit.

When you have the LWO file loaded click on the setup tab (1.) followed by “Create skelegons” (2.). Create the skelegons in the body layer.

The skelegons will be converted to bones later on.

Image:LWmStarted.jpg

Now you place your skelegons as the picture shows. Remember to be precise with the pivot points of the skelegons because that is where it will rotate around.

Name your skelegons exactly the same as your weight maps as they are case sensitive.

Image:SkelegonPLace.jpg


IMPORTANT!

Under “Skelegons” choose to “Edit skelegons” when doing that another handle will appear. Rotate this handle so that it points straight up; repeat this on all of the skelegons.

Image:RotateEdit.jpg


IMPORTANT!

You have to remove the skelegons from the object in the Lightwave´s modeller before saving it. But do this after you send it to the Scene editor (read next segment).

Recommended would be to cut out the skelegon and paste them in a separate file if you for any reason would need them again.


Setting up a unit scene in Lightwave Layout


Send your model and skelegons to the scene editor by clicking on the downward pointing arrow in the top right corner and then “Send object to layout”.

Now if you enter schematic viewport your hierarchy should look something like the picture below. Start out by in the Items>Add menu Create a new Null and name it “Master”.

Leave the MasterNull in the origo of the scene.


Image:AddMasterNull.jpg


Select the body mesh and under the Setup tab>Add click the “Cvt Skelegons” button. After that you should have something like the picture below.

Image:HierarchySetup1.jpg


Start setting up the Hierarchy with the Master Null being the top node. To parent select a node and CTRL+LMB click on then next node.

Then everything follows naturally.

Parent the bodymesh to the Master.

Parent the Bodybone to the bodymesh.

Parent the headingbone to the Bodybone.

Parent the pitchbone to the headingbone.

Parent the barrelbone to the pitchbone.

It is pretty straight forward.


After that we parent the Detail meshes and the PCC to the right bones. See the picture below.

Image:HierarchySetup2.jpg


Now to make sure the weight maps are working properly select each bone and enter their properties. Do this by selecting a bone and hit “p” on your keyboard.

Make sure the “Current Bone” and “Bone Weight Map” matches and also tick the checkbox for “Use Weight Map Only”.

When this is done you can always double check it by selecting the bone and rotate it and if you have everything setup correct it will behave as planned.

Don’t forget to undo any test rotation.


Image:BoneProperties.jpg


Setting up the units tracks

The setup for the tracks is pretty similar to the setup for the rest of the tank. The bones you create here are mainly used to simulate the suspension of the tracks/wheels as they will follow the height of the ground in-game.

Create a Master_trax skelegon that you weight the top part of the tracks to, this part of the tracks will be static and not follow the ground height changes.

Next setup one skelegon per two wheels or in my case I let the four centre wheels share one bone since it’s cheaper. Do not forget to weight the track that will go along with the wheel to the same weight map.

I named the weight maps T1 through T5 but they could be named anything as long as the weight map and skelegon shares the exact same name.


Image:TraxSetup2.JPG

Image:TraxSetup3.JPG

Send your model and skelegons to the scene editor by clicking on the downward pointing arrow in the top right corner and then “Send object to layout”.

Select the tracks and Cvt to Skelegons then setup the tracks hierarchy. All the wheels are parented to the Master_Trax bone.

Image:TraxHierarchy.jpg


IMPORTANT!

Same rule as for the rest of the tank you have to remove the skelegons from the object in the Lightwave´s modeller before saving it.

Recommended would be to cut out the skelegon and paste them in a separate file if you for any reason would need them again.


At this point you can create Nulls for all the particle effects you wish to add later on. Start by adding a Null and then move it into position and lastly parent it to the bone it will follow.

In the example below the Muzzleflash, trax_smoke and Exhaust_smoke were added for later particle effects. The tracks were also connected to the MasterNull.

Image:HierarchySetup3.jpg

Save this setup as an LWS file and name it name_setup or something of the like as it is good to have a backup file where nothing has been moved.

Now you have your scene all setup to start animating and then import it to the Showbox.


Animations and states for the unit

At this point you should create the three most basic States used by a unit. The states are “Stand” for when the unit is at a complete halt, “Walk” for when the unit is moving and “Fire” for when the unit is firing.

We do this by opening the setup scene you just saved and start animating. The stand state could be just the unit doing nothing unless you want it to move while it’s standing still. In this case I just save the unit as m60_a3_STND.lws, I add STND so I know what state the file contains when I import it later.

Next on my list of things to do is a Walk state. When creating the walk state I just select the Bodybone and add some minor movement to the body of the tank. Make sure the animation loops smoothly and also since it’s a looping animation open up the “Graph editor” (CTRL+F2).

Select all the channels to the left and then select all the keys in the middle window and finally change the pre and post behavior to repeat (see picture below). Save the walk state using the same naming convention m60_a3_WALK.lws.

Image:AnimRepeat.JPG

Create a fire state using the same principles as before select a bone add keys and animate. It’s not always necessary to do the “repeat” procedure above since it’s only for animations that has to loop in-game. Save the animation.


At this point we are ready to start using the Massive Ent. In-house editor “SHOWBOX”. The showbox is where the unit is finalized and then exported to the game.


Tip: For additional information on bones and animation rules se the Animations Document. <link>


Getting the unit into showbox

The showbox is a really big tool and is used in all graphical content creation for World in conflict. This tutorial will only go through the parts that concerns unit creation.

While creating a unit you mostly use the tabs marked in red below so let’s focus on them for now.

Tip: Save frequently while using the showbox, to do this you click on File>MRB Export. When loading a file load the *.MRE file.

Image:TabsWeUse.JPG


Now we start by importing our first state. Either use the “Open” button or under File>open choose the stand state, in my case m60_a3_STAND.lws.

After you choose to open the file you will be prompted with another window, this window is where we tell the engine what state it’s going to be.

In this case use (Stand).

Image:StateSelect.jpg


Now add the remaining states by clicking on the objects tab and then the “add complete state” button. Start out with the walk state and when prompted with the states window choose (Walk).

Now do the same with the fire state and in the states window choose (Primary fire).


Unit surfaces in showbox

This could be a good time to go through the surfaces on your unit and assigning the appropriate ones. To access the surface section of showbox click the Mesh tab (1.) and then a surface tab will appear in the lower part of the screen.

In the upper left you see the mesh layers you created in you 3D application before. Start by selecting the Body layer (2.) then click the surface tab (3.) followed by setting the Surface File dropdownbox (4.) to “normalmap units”. Set the right textures by clicking on the text slots (5.) and if you are using bump click the bump option (6.).

Image:SurfaceChange.JPG


Repeat this procedure for your detail layers as well. If you have a PCC layer you choose “unit player created content graphics” in the Surface file dropdownbox (4.).

For the tracks layer choose the “Tracks/Wheels (special UV 1st/2nd lerp)” ” in the Surface file dropdownbox (4.). Next set the right textures (5.) and the tracks shader uses two sets of UVs one for the tracks and one for the side of the wheels.


After setting the textures click the Mesh tab situated right next to the Surface tab (1.). This is where you set the animation for the tracks and its all done by translating and rotating the UVs. Start by setting the Color calc (2.) to “Vertex lightmap (lightcalc * vertexrgb)” then set the translate and rotate boxes marked in the picture (3.). The figures in the example might not be suitable for every situation so you should play with the number till you get them right. Next check the “Center Scale and Rotation” checkbox (4.) and finally hit “Apply Values” (5.). After doing this the tracks should start moving.

Image:TraxSetup.JPG


Unit hierarchy setup in showbox

Click the Hierarchy tab and then in the white area right click to set mode for how the hierarchy is shown and select “Flat”. Here you will find everything you had in the lightwave scene including the Nulls.

Image:SelectHmode.JPG

Let’s start by setting the walk state to a loop. Since I only animated the body bone for this state I will expand the body bone tab on the plus and that will reveal the different states that the bone contains.

Then I select the Walk state adding new options in the lower part of the screen such as the Animation tab and position tab. Click the checkbox for “Spline loop” and then “Apply”.

Next expand the Master Null and select the FIR1 state and in the animation options check the “Force start from beginning” checkbox and also set the interpolation time to 0.0. why?

This time hit the “Apply to Childs” button and it will be applied to the FIR1 state on every bone in the hierarchy.

Image:AnimTab.JPG

Now go down to the Master_Trax bone and remove the FIR1 state since the tracks won’t be affected by the firing state. You remove it by selecting it and in the animation options click the “Remove State” button.

You can repeat this for the rest of the track bones. Next expand Master_Trax again and select the STND state and this time set the UV Animations speed to 0.0 for both 1st UV set and 2nd UV set.

You do this to stop the animation on the tracks when your tank is in the stand state.


Setting up the Constraint for the Tracks/wheel suspension is also done here. Select the bones for the wheels one at a time in this case start with T1. Check the GetY checkbox and in the Constraint Up and constraint Down boxes set a number somewhat like in the example.

Repeat this for the rest of the Wheel bones. And don’t forget to hit the “OK” button to save the values. You can before you start test what value you want to go with by in the offset box set a value. Don’t forget to put it back to 0.0 before you continue.

Image:GetYwheels.jpg


Setting up Unit physics in showbox

Physics

Image:PhysicsMenu.JPG

The physics are needed for the model to react to the world around it. In the physics tab you will find all the physics attributes needed for the unit.

(1.) Start by expanding the tab by clicking the “>>” button. (2.) “Add Body”. (3.) Set the “Attach to Bone” to Master. (4.) Dynamic should be turned off and set to 0 on units. (5.) Set the “Layer “to (Units).


Not all the physics attributes are used for units, but those that are, are the follwing:


Body – is the name of the body which contains 1 or more elements.

Attach to bone – the bone which the body is attached to, without this the body would not follow the bones movement.

Dynamic – This needs to be set to 0 for units, since they are not dynamic in the sence that a box bouncing is dynamic

Layer – All different physic things in the game are assigned to different layers to make calculations for physics more optimized, and for units that layer is the “unit” layer.

Has AI – If something is supposed to not move and stuff should drive around it, this should be set to 1, but units are the stuff doing the driving so that should be 0 for units.

Element – Several Elements can exist within 1 body, this is to get weight offset or to be able to fill out odd shapes, and also to have different material on different parts of a mesh.

Material – This will decide what type of explosions and effects that will spawn when a bullet hit this element

Physics – this decides if a box falling onto this element will bounce against it or fall through, if you want it to bounce to this element set it to 1

LOS/LOF – this decides if the element will affects LOS/LOF, Line of Sigt, Line of Fire, so if you want this element to stop bullits and people to see through it, put it to 1.

AI – This is the same as “Has Ai” but on Element level

Aim Target – If you want other units to aim to a specific element within a unit when they fire on it, put the aim target to 1 for that element.




Setup the element boxes. Start by placing the base box then right click and choose clone and move it to fit the turret. See picture below.

Set the element material to metal

Image:PhysboxSetup.jpg


Next click on the (1.) “Edit Joints” tab. (2.) “Create New Joint” and make sure it’s a ball_joint. (3.)Double click the ball_joint to open up the joint properties.

(4.) Finally click the dropdown box and set RB1 to master and then “Apply Values”.

Image:EditJoint.JPG


Unit Shadows

In order for the unit to cast shadows there has to be a shadow mesh. You could use the original mesh but it would be too expensive. The Shadow mesh has to be built up of closed geometry with no holes in the mesh and all triangulated. Try to resemble the shape of the unit as close as possible or there might be shadow artefacts.

There should also be a LOD for the Shadow. Named Ex: Shadow_Lod2. You setup the shadows under the “Shadow” button situated next to the “Physics” button. (1.) Click here to create a new *.sdw file. The sdw file contains the shadow information and the sdw should have the exact same name as the original file but end witah .sdw.

(2.) If you for any reason want to load a .sdw file this is where you do that. (3.) Every time you make a change in the shadow editor and want it to Save/Update this is the button. (4.) The button for adding a LOD2 shadow. (5.) To edit the LOD2 shadows check this box. (6.) When working with unit shadows use the “Add Skinned” button.

When building the shadows for units you should split it up into pieces much like the weight maps. See the area marked in red below. Save each shadow piece in its own file. Then click “Add Skinned” to add the pieces. You will be prompted with a new window where you choose what bone to connect the shadow piece to.

(7.) In this box you set the distance for when the LOD2 shadow kicks in. When you have added all the shadow mesh don’t forget to Save/Update. You can preview your shadows in the Showbox if you click on the “Shadows” button.

Image:ShadowMenu.jpg Image:AddShadowMesh.jpg


Unit LOD's

LOD


LOD stands for level of detail and is a system we use to improve the performance of the game. What it does is that it swaps out your model for a cheaper version that doesn’t contain as much geometry. We have 3 LOD levels and our in-house rule of thumb is that for each level we reduce the tri count by 50%.

The LODs should only contain one layer that means no detail layers or anything else. When you are done with the LOD file save it with the same filename and in the same folder as the original file followed by _LOD2. In my example m60_a3_LOD2.lwo and up to _LOD4.

Showbox detects the LODs automatically if named correctly. The next LOD option can be found next to the shadows tab. This is where you determine if a mesh is a detail layer or if it is a window. Set your detail layers to 1 in the “Is Detail” box that means it is going to fade over distance in the game.

You should also set “Don’t Fade (units)” to one on your Body mesh. When everything is setup click apply.

The tracks will also need LOD levels and since they are in a separate file you will have to repeat the previous procedure. It works almost in the same way as we did with the Body of the tank.

You go in and reduce the tracks tri count and then save them _LOD2.lwo and up to _LOD4. The Showbox will then automatically recognize them.

Image:LodMenu.JPG

Unit Nodes

Go to Nodes for more info on this.

Unit and particles

Go to Particle Editor for more info on this.

Personal tools
User Created Content