Step 3

Step 3 - Creating and texturing the concrete pillars

In step 3 of the tutorial, we will be creating and texturing the concrete pillars that you see in this image of the finished model:

Switch the 3d view to "Front" (numpad '1' key) and zoom in on the lower left hand corner using the mouse wheel.  The view can be "panned" by holding down the shift key and middle mouse button while moving the mouse.  Move the 3d Cursor to a point about 1/2 unit to the left of the edge of the fence mesh.  The 3d cursor can be moved by left-clicking in the 3d viewport at the desired location:

Snap the cursor to the grid by pressing "shift-s" and choosing "Cursor->Grid" from the "Snap" menu that appears.  You may want to switch the 3d view to "top" view briefly to make sure the cursor is still aligned with the fence plane.

Note: If you can't see the 1/10 unit grid lines, you may need to zoom in further.  The "Snap to grid" feature works on whatever grid lines are visible in the 3d view.

Next, we are going to add a cylinder mesh to the scene.  With the mouse cursor over the 3d view, press the space bar on your keyboard and select "Add->Mesh->Cylinder" from the menu that appears:

An "Add Cylinder" dialog will appear.  Set the Vertices to "32", Radius to "0.50", the Depth to "2.5", and turn off the "Cap Ends" option:

When you've got the values for the cylinder set up correctly, click OK.  A new cylinder object should appear centered at the cursor's location:

Grab the cylinder ('g' key) and move it up on the z-axis until it is aligned with the middle of the fence mesh (hold down on the ctrl key while moving to constrain to grid):

With the cylinder selected, switch the 3d view into edit mode.  Change the "viewport shading"/"Draw type" to "Wireframe":

Switch the selection mode to "Vertices" by pressing "ctrl-tab" and selecting "Vertices" from the menu that appears.  Press the 'a' key to deselect all vertices (you may need to press it twice).  Selected vertices are yellow, un-selected vertices are a pink-ish color.  When none of the vertices are selected, you should see something like this in the 3d view:

With the mouse cursor over the 3d view, press the 'b' key to enter "box selection" mode.  Click and drag a selection box around the verts at the top of the cylinder:

Now that we've got the topmost verts selected, we are going to extrude them.  Extrusion creates a new set of vertices that are connected via edges and faces to the original set.

Extrude the verts by pressing the 'e' key on your keyboard and selecting "only edges" from the menu that appears.  When extruding, the new verts/edges are automatically placed into move/grab mode, so you can start moving them immediately.  Move the new verts up on the z-axis ('z' key to constrain motion to the z-axis) until they are aligned with the top of the fence mesh:

Next, we are going to scale the selected verts so that the cylinder "widens out" at the top.  Press the 's' key to begin scaling.  Scale the verts until they look something like this:

Left-click to complete the scale operation.

Now we are going to create the top "cap" of our pillar.  Extrude the selected verts again and then right-click to cancel the automatic move/grab operation.  Press the 'w' key on your keyboard and select "Merge" from the "Specials" menu that appears:

Choose "At Center" from the "Merge" menu that appears:

Tilt the 3d view a bit by dragging the mouse with the middle button held down.  You should be able to see the faces and edges for the new end cap:

Switch the 3d view to "front" and repeat the preceding steps to create the bottom part of the pillar and bottom endcap (moving verts down on z-axis instead of up this time).  When you are finished creating the bottom, the pillar should look something like this:

Next up, we are going to add some "Seams" to assist us in UV unwrapping the pillar.  Change the selection mode to "edges" by pressing "ctrl-tab" and choosing "Edges" from the "Select Mode" menu that appears.  Select one of the edges on the top "rim" of the cylinder by right-clicking it:

With a single edge on the top rim of the pillar selected, press "ctrl-e" and choose "Edge Loop Select" from the "Edge Specials" menu that appears:

Press "ctrl-e" again and choose "Mark Seam" from the "Edge Specials" menu that appears:

As seen in the above screenshot, the new seam shows up as a thicker orange line.

Repeat the preceding steps to mark a seam on the bottom rim of the pillar.  The pillar should now look something like this:

Next, we're going to mark some seams where the top and bottom "bevels" meet the straight sides of the cylinder.  This is done using the same steps that were used for the top and bottom rims.  After marking these seams, the cylinder should now look something like this:

Now we need to mark one more vertical seam along the side of the cylinder.  Select a vertical column of 3 edges along one side of the cylinder (doesn't matter which side) by left-clicking on each edge.  Press "ctrl-e" and mark seam.  The new seam should look something like the one in the screenshot below:

Now that we've got all the the seams marked on our pillar, it's almost time to UV unwrap it.  First, let's load up our "Concrete.png" file into Blender's UV/Image Editor window.

In a UV/Image editor window, choose "Open..." from the "Image" menu and select the "Concrete.png" image. The image should now be loaded, although it won't show up until we explicitly select it using the image selection pulldown (don't select it yet, we'll do that later).

Now that we've got our "Concrete.png" image loaded, switch the selection mode in the 3d view to "Faces".  Press "ctrl-tab" and select "Faces" from  the "Select Mode" menu that appears.  Press the 'a' key one or two times until all faces are selected:

Press the 'u' key and select "Unwrap" from the "UV Calculation" menu that appears.  You should see a new UV mapping appear in the UV/Image editor window that looks something like this:

Right now, the cylinder faces are all assigned to the "ChainLink.png" image.  We want to assign them to the "Concrete.png" image that we loaded earlier.

With all faces still selected in the 3d view, use the image selection pulldown in the UV/Image editor window to change the texture assignment for the pillar:

Now switch the 3d view's draw mode to "Textured":

The pillar should look something like this:

As you can see, the texture is a bit coarse and is stretched slightly on the sides of the cylinder.  First, we are going to correct the stretching on the sides of the cylinder.

In the UV/Image editor window, select one of the vertices corresponding to the side of the cylinder by right-clicking it.  The selected vertex should turn yellow:

Press "ctrl-l" on your keyboard (lowercase 'L', not 1) to select the entire "island":

Now we're going to scale the "UV island" vertically (on the y-axis).  With the island selected, press the 's' key to begin scaling, followed by the 'y' key to constrain scale to the y-axis.  Scale the island until it looks something like this:

Next, we're going to move and scale the end cap and bevel UV islands.

Press the 'a' key on your keyboard one or two times to clear the current selection.  Hold down on the shift key and right-click on a single vertex from each of the other islands. Don't select any vertices from the "pillar side" island that we just finished scaling.

Press "ctrl-l" (lowercase L) on your keyboard to select the islands:

With the islands selected, press the 'g' key to grab them and move them up above the "side" island.  Left-click to complete the move operation.

Press the 's' key on your keyboard and scale the islands up.  Left-click to complete the scale operation.  The scaled islands should be about this size:

Switch the 3d view back into "Object mode" and take a look at the Textured pillar, it should look something like this:

If you want more "detail" on the pillar, you may select all islands or verts in the UV/Image editor and scale them up further.

Now that the pillar is finished, we can copy it to create the second pillar.

Important Note: There are two different methods of copying an object in Blender.  The first method (shift-d) creates an independent copy of an object that may be edited separately from the original.  The second method (alt-d) creates a "linked copy" that shares the same mesh data with the original object.  When any version of a linked copy is edited, the changes are immediately applied to all other objects that share the same Blender "datablock".  Since we want our two pillars to be the same, we're going to create a linked copy of the original pillar.  This is a great labor saving device; if you ever need to edit the pillars after creating copies, you only need to edit one of them and the changes will be instantly applied to the other.

With the pillar selected in object mode, press "alt-d" to create a linked copy of the pillar.  After creating the copy, blender starts an automatic move operation, allowing you to position the copy as desired.  Move the copy along the x-axis until it is aligned with the other side of the fence.  Left-click to complete the move operation.

Next, we're going to turn off the "Double Sided" setting for our pillars.  Since the pillars are closed objects with no gaps or holes, the player won't be able to see inside them.  There is therefore no point to having them be double sided, since double sided meshes have twice the polygon count of single sided meshes.

Select one of the pillar meshes (doesn't matter which one - remember, both pillars are sharing the same mesh data).  In the "Mesh" panel of the editing buttons, locate the "Double Sided" toggle button and turn it off.  The button should look like this when it's in the "off" state:

You can select the other pillar to verify that its "Double Sided" setting has been turned off as well.  Aren't shared datablocks grand? :-)

Now we need to do one last thing before moving on to the next stage: rename the pillar objects.  Right now our pillar objects are called "Tube" and "Tube.001".  This is a problem because the exporter uses a naming convention to match up objects in different detail levels.  If you were to export the scene at this point, you'd get a nasty looking warning in the export log:

   ****************************************************************************
   Warning: Multiple Blender mesh names in Detail1 all reduce to the same DTS
    Object name: "Tube"
     The exporter will use the original names for these meshes and any nodes
     generated from them.  This may result in duplicate or unnecessary nodes,
     extra animation tracks, and inefficient mesh packing in the exported dts
     file.
       Changed dts object and node name for Blender mesh "Tube.001"
         from "Tube" to "Tube.001".
       Changed dts object and node name for Blender mesh "Tube"
         from "Tube" to "Tube".
   ****************************************************************************

So, what's going on here?  In order to create an efficient, well-packed DTS file, the exporter needs to be able to match up meshes with their counterparts in other detail levels.  We haven't covered detail levels yet in this tutorial, so don't worry too much if you don't understand this part (we'll get to it later).  Basically, the exporter matches up meshes with their counterparts in other detail levels by chopping the mesh object names at the last ".".  The exporter will therefore get cranky if you've got two meshes in the same detail level called "Tube" and "Tube.001", since only one copy of a mesh should exist in any given detail level.

Select the pillar object on the left and rename it to "Pillar0":

Select the pillar object on the right and rename it to "Pillar1":

Save your file now.

Go ahead and run the exporter again and do another test export.  You shouldn't need to adjust the material properties for the "Concrete" texture, the defaults should work fine.  After export, the DTS file should look something like this when loaded up into Torque or Showtool pro:

If you look closely at the above screenshot, you may notice a small problem.  The "fence" mesh does not appear to extend all the way to the middle of the right-hand pillar.  This is because the pillar is drawing on top of (after) the translucent fence mesh, obscuring it.  In order to correct this problem, we'll use one of the techniques described in the Transparency and Drawing Order section of the documentation: Hierarchical linking.

Note: Drawing order problems only occur when translucent materials are used.  If all of the materials in a dts file are opaque, you don't have to worry about it.

With the 3d view in Object mode, select the right-hand pillar (pillar1).  With the right-hand pillar still selected, hold down on the shift key and select the left-hand pillar (pillar0).  Both pillars should now be selected.  The order in which the objects are selected is important, so be sure you select them in the right order.  The last object selected should be a slightly brighter shade of pink:

Press ctrl-p and choose "Make Parent" from the menu that appears.  The first object that was selected is now "parented" to the second.  When parenting one object to another, the first object selected becomes the child, and the second object selected becomes the parent.  It can be said that the first object has been "parented" to the second object.  You can verify that Pillar1 is now a child object of Pillar0 using Blender's outliner window:

Next, we are going to parent the Fence mesh to Pillar1, so that the Fence mesh becomes a child of pillar1.  Select the fence mesh by right-clicking it.  While holding down on the shift key, select the right-hand pillar (Pillar1).  Both the fence and the right-hand pillar should now be selected:

Again, the order in which the two object are selected is important, be sure that you have selected the fence first, followed by the pillar. Press ctrl-p and choose "Make Parent" from the menu that appears.  The Fence object should now be a child of Pillar1:

Save your file now.

Go ahead and do another test export.  If all went well, the fence section should now look something like this in Torque or Showtool pro:

Now we're ready to move on to the next section.