Making Tileable Features

tesb

Emperor
Joined
Jan 16, 2010
Messages
1,593
In this tutorial i 'quickly' describe how to add tileable features to the game.

1. Software:

First you need the following programs:

NifSkope: http://niftools.sourceforge.net/wiki/NifSkope
Blender, Python and Nif scripts*: http://niftools.sourceforge.net/wiki/Blender
Autohotkey: http://www.autohotkey.com/

*On this site you will find in section "Blender 2.49 Recommend Downloads" all downloads and their installation order. Use those links and do not download the latest versions of Blender or Python, they do not support the scripts to in- and export *.nifs!


2. Required Files:
Now you need:

2.1 the trees from civilization 4**: snowy01_01.nif, snowy02_01.nif, ..., snowy15_01.nif
2.2 a couple of basic meshes for your new feature (in this example mush_base.nif)**
2.3 pictures that describe the position of the meshes**: 01_01.tga, 02_01.tga, ..., 15_01.tga
2.4 the autohotkey scripts:
Spoiler :
Code:
#IfWinActive, Blender ahk_class GHOST_WindowClass

;copies mesh, selects vertex paint and deletes first too entries,
;i.e. just type the coloe, e.g. 01, 02, 0a, etc.
x::
MouseClick,left, 190,882	;click on Object
Sleep, 100
MouseClick,left, 203,709	;click on duplicate mesh
Sleep, 100
Send, {Click}
Sleep, 100
MouseClick,left,307,879		;click on object mode 
Sleep, 100
MouseClick,left,307,805		;click on vertex paint
Sleep, 100
MouseClick,left,1039,979	;click on color panel
Sleep, 100
MouseClick,left,1283,811	;click on hex panel
Sleep, 100
Send, {Home}			;sets cursor to first position within hex panel
Sleep, 100
Send, {Del 2}			;deletes first two entries
return

;confirms color entry, applies color to the whole object
;and goes back to object mode, i.e. no copy of object is cerated
Enter::
Send, {Enter}
Sleep, 100
MouseClick,left,1045,1013	;click on SetVCol
Sleep, 100
MouseClick,left,1045,1013	;click on SetVCol
Sleep, 100
MouseClick,left, 1909,849	;make sure to aim on empty space
Sleep, 100
Sleep, 100
MouseClick,left, 257,883	;click on Vertex Paint
Sleep, 100
MouseClick,left, 257,863	;click on Object Mode
return
simply copy this code into your autohotkey script. The scripts have to be adjusted if you use another resolution than 1900*1200, more on that in section: 6

**the files can be found below (second reply)

3. How do tileable features work:
Tileable features, e.g. forests, jungle and so on work very differently from regular features, improvements and the like.
3.1 They need at least 15 different versions per feature usually named: FeatureNameXX_01.nif, where x goes from 01 to 15. This is needed because they will change their art depending on how they are aligned on the map, so that they will look organic.
3.2 They will also adjust to resources, farms and rivers, i.e. you will not see tileable features on rivers and so on.
3.3 They will also dynamically adjust for terrain hight, so when you place a feature on hills, they will be placed along the slope correctly.
3.4 They are animated automatically (waving in the wind)

However for this to work, each mesh within a feature file need to have a particular vertex color, e.g. each tree in snowy01_01 need a specific vertex color, else you will get errors, most notably they will be partially vanished in the ground.

4. Getting Started with Blender:

When you start up blender you will be greeted by this screen:
Spoiler :
attachment.php


4.1 The first thing to do is getting rid of the cube. To do that simply hit 'delete' on your keyboard and confirm.

4.2 Now import snowyXX_01.nif (in this case snowy05_01.nif): File -> Import -> Netimmersive/Gamebryo. Your screen should look like this now:
Spoiler :
attachment.php

If you do not see the trees directly from above hit '7' on your numkey pad.

4.3 Now we right click on the trees and hit 'delete' again, we don't need the trees, just the planes of the ground. Right click on the planes and click on the 'Object-Box' (or hit F7) and click on 'wire', see screenshot:
Spoiler :
attachment.php


4.4 Now we add the background pictures that tell us where we need what vertex color. click on view -> background image:
Spoiler :
attachment.php

Load the appropriate picture, e.g. when using snowy05_01 we need 05_01.tga. Set the Blend to 0, adjust the size and the x and y coordinates, so they numbers add up with wire frames of the ground planes, like this:
Spoiler :
attachment.php


4.5 Import the basic meshes of your feature, in this case: mush_base.nif. You will now see the basic meshes that will make up your feature (in this case some mushrooms):
Spoiler :
attachment.php


4.6 hit the 'editing box', if the 'object box' is still selected:
Spoiler :
attachment.php


4.7 Now we need the Autohotkey scripts, i will go into detail how they work in section 6. If your resolution is not 1900*1200, read section 6 and adjust those scripts now!. If you made sure the scripts work for your resolution go to the next point.

4.8 right click on any of the base meshes, click 'x' on your keyboard. The autohotkey script will do its work and you will see this:
Spoiler :
attachment.php

Now you simply have to type in the color code that you see on the planes, for example if you put a feature (in this case a mushroom) on plane 1, you type 01, so the entry will read: "01FFFF". Letters will look like 0aFFFF and so on.

Now simply hit 'enter' on your keyboard and the second script will do its work. Now you simply use the red and green arrows to drag the feature on the bottom right corner of the plane with the same number that you have chosen, e.g. 01FFFF goes to the bottom right corner of the 1 plane:
Spoiler :
attachment.php


Now repeat step 4.8 until you placed sufficient features on each plane. You can ignore some planes or put more than one feature on a plane, depending what feature density you want. In this case we plant additional mushrooms on some planes. Just make sure that the vertex color corresponds with the plane, i.e. 07FFFF goes on plane 7 and so on.

You can also use rotate by hitting 'r' on your keyboard or scale by hitting 's' to add a bit variety, if needed.

4.9 Now we right click on any of the placed features then hold shift and keep right clicking on all other placed features until we selected them all. Now we hit 'crtl j' to merge them into one object and center the object onto the cursor:
Spoiler :
attachment.php

if the cursor is not on its default position at the coordinate origin simply hit 'shift c'

4.10 Now you have only your feature object selected (highlighted by purple outlines, unselected meshes have black outlines, see the screenshot above. Export the object (File -> Export -> Netimmersive/Gamebryo) with the following properties:
Spoiler :
attachment.php

Use the correct file names, in this case mushroom05_01.nif


5. Final touches with Nifskope:
5.1 open mushroom05_01.nif and remove the following nodes:
-EnvironmentIntesityIndex
-EnvironmentMapIndex
-NormalMapIndex
-SpecularIntensityIndex
Spoiler :
attachment.php


5.2 make sure all vertices have colors (no entries with FFFFFF, or something different than XXFFFF), by opening up node NiTriStripsData -> Vertex Colors:
Spoiler :
attachment.php


5.3 open up the corresponding snow.nif, in this case snowy05_01.nif and copy paste the 'NistringExtraData' node from the trees to the Mushrooms. Also copy the whole NiTriShape branch of the shadows and attach the branch to 'Scene Root' node
Spoiler :
attachment.php


5.4 We simply change the texture of the shadows to a new custom one (shadow.dds) and edit the UV to match the new texture, because mushrooms have different shadows than trees. If you finished everything your mushroom05_01.nif shoud look like this:
Spoiler :
attachment.php


And an ingame screenshot confirms that everything is ok:
Spoiler :
attachment.php





6. The Autohotkey scripts

These scripts make heavy use of coordinates and were made for a resolution for 1900*1200. If you have a different resolution you need to adjust those values. Luckily this is easy to do. First start up Autohotkeys 'AutoIt3 Windows Spy', Blender and the Autohotkey script.
With AutoIt3 Windows Spy you get a little box that tells you the coordinates of your mouse cursor (use 'In active Window' values).

But let's take a quick look at the scripts themselves:
6.1 x-key script
it starts with
Code:
x::
this means when you hit 'x' on your keyboard the following lines will be executed until you hit the return line.
Code:
Sleep, 100
means the script is paused for one tenth of a second. this is necessary for blender, because without small wait times some lines might be skipped.
Code:
MouseClick,left, 190,882
is the code for a left click with your mouse on specific coordinates and only those values have to be adjusted
Use 'AutoIt3 Windows Spy' to adjust the following coordinates:
Code:
MouseClick,left, 190,882
should click on 'Object'
Code:
MouseClick,left, 203,709
should click on 'Duplicate'
Spoiler :
attachment.php

Spoiler :
We could also use
Code:
Send, +d
to duplicate the mesh, but i made the experience that sending short cuts does not always work with blender, but manually using the mouse does.

Code:
MouseClick,left,307,879
should click on 'Object Mode'
Code:
MouseClick,left,307,805
should click on 'Vertex Paint'
Spoiler :
attachment.php

Code:
MouseClick,left,1039,979
should click on 'Color Panel'
Code:
MouseClick,left,1283,811
should click on 'Hex Panel'
Spoiler :
attachment.php



6.2 Enter-key script
adjust the following coordinates:
Code:
MouseClick,left,1045,1013
should click on 'SetVCol'
Code:
MouseClick,left,1045,1013
the same coordinate, i.e. 'SetVCol' again
Code:
MouseClick,left, 1909,849
click on empty space inside the main window with the meshes. make sure to pick a coordinate that will most likely click on empty space.
Code:
MouseClick,left, 257,883
should click on 'Vertex Paint'
Code:
MouseClick,left, 257,863
should click on 'Object Mode'
see this screenshot:
Spoiler :
attachment.php
 

Attachments

  • enter.png
    enter.png
    172.4 KB · Views: 745
  • final.jpg
    final.jpg
    275.3 KB · Views: 717
  • tutorial_blender_0.png
    tutorial_blender_0.png
    360.7 KB · Views: 794
  • tutorial_blender_2.png
    tutorial_blender_2.png
    59.4 KB · Views: 784
  • tutorial_blender_1b.png
    tutorial_blender_1b.png
    455.4 KB · Views: 800
  • tutorial_blender_1.png
    tutorial_blender_1.png
    344 KB · Views: 786
  • tutorial_blender_3.png
    tutorial_blender_3.png
    444.3 KB · Views: 742
  • tutorial_blender_4.png
    tutorial_blender_4.png
    141.6 KB · Views: 784
  • tutorial_blender_4b.png
    tutorial_blender_4b.png
    51.4 KB · Views: 773
  • tutorial_blender_4c.png
    tutorial_blender_4c.png
    497.6 KB · Views: 779
- additional attachments -
 

Attachments

  • tutorial_blender_7.png
    tutorial_blender_7.png
    324.1 KB · Views: 768
  • tutorial_blender_6.png
    tutorial_blender_6.png
    312.9 KB · Views: 744
  • tutorial_blender_5.png
    tutorial_blender_5.png
    128 KB · Views: 725
  • tutorial_nifskope_1.png
    tutorial_nifskope_1.png
    358.9 KB · Views: 782
  • tutorial_nifskope_2.png
    tutorial_nifskope_2.png
    494.4 KB · Views: 758
  • tutorial_nifskope_3.png
    tutorial_nifskope_3.png
    64.4 KB · Views: 749
  • x2.png
    x2.png
    78 KB · Views: 757
  • x1.png
    x1.png
    125.2 KB · Views: 856
  • tutorial_nifskope_4.png
    tutorial_nifskope_4.png
    376.2 KB · Views: 825
  • x3.png
    x3.png
    257.6 KB · Views: 729
Here are the resources:


numbers.7z contains the XX_01.tga images with the numbers/letters of the vertex colors for each plane and *.nif

snowy.7z contains the vanilla trees and shadows(with FFH texture)

mushroom05_05.7z contains the complete mushroom05_05.nif as well as basic mushroom meshes (mush_base.nif) that were used to create mushroom05_05.nif
 

Attachments

Addendum:

1. do not scale your base meshes as written in section 4.8 (rotating is fine)
2. 14_01.tga misses on entry in the upper right it is '6'
3. snowy11_01 does not have an offsetcount this in an error from the vanilla files, use the offsetcount from the shadow (untested) or from evergreen11_01.nif (in the vanilla cIV fpk)
 
Back
Top Bottom