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:
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:
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:
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:
4.4 Now we add the background pictures that tell us where we need what vertex color. click on view -> background image:
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:
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):
4.6 hit the 'editing box', if the 'object box' is still selected:
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:
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:
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:
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:
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
5.2 make sure all vertices have colors (no entries with FFFFFF, or something different than XXFFFF), by opening up node NiTriStripsData -> Vertex Colors:
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
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:
And an ingame screenshot confirms that everything is ok:
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
this means when you hit 'x' on your keyboard the following lines will be executed until you hit the return line.
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.
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:
should click on 'Object'
should click on 'Duplicate'
should click on 'Object Mode'
should click on 'Vertex Paint'
should click on 'Color Panel'
should click on 'Hex Panel'
6.2 Enter-key script
adjust the following coordinates:
should click on 'SetVCol'
the same coordinate, i.e. 'SetVCol' again
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.
should click on 'Vertex Paint'
should click on 'Object Mode'
see this screenshot:
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
**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 :
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 :
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 :
4.4 Now we add the background pictures that tell us where we need what vertex color. click on view -> background image:
Spoiler :
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 :
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 :
4.6 hit the 'editing box', if the 'object box' is still selected:
Spoiler :
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 :
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 :
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 :
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 :
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 :
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 :
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 :
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 :
And an ingame screenshot confirms that everything is ok:
Spoiler :
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::
Code:
Sleep, 100
Code:
MouseClick,left, 190,882
Use 'AutoIt3 Windows Spy' to adjust the following coordinates:
Code:
MouseClick,left, 190,882
Code:
MouseClick,left, 203,709
Spoiler :
Spoiler :
We could also use
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:
Send, +d
Code:
MouseClick,left,307,879
Code:
MouseClick,left,307,805
Spoiler :
Code:
MouseClick,left,1039,979
Code:
MouseClick,left,1283,811
Spoiler :
6.2 Enter-key script
adjust the following coordinates:
Code:
MouseClick,left,1045,1013
Code:
MouseClick,left,1045,1013
Code:
MouseClick,left, 1909,849
Code:
MouseClick,left, 257,883
Code:
MouseClick,left, 257,863
see this screenshot:
Spoiler :
Attachments
-
enter.png172.4 KB · Views: 745
-
final.jpg275.3 KB · Views: 717
-
tutorial_blender_0.png360.7 KB · Views: 794
-
tutorial_blender_2.png59.4 KB · Views: 784
-
tutorial_blender_1b.png455.4 KB · Views: 800
-
tutorial_blender_1.png344 KB · Views: 786
-
tutorial_blender_3.png444.3 KB · Views: 742
-
tutorial_blender_4.png141.6 KB · Views: 784
-
tutorial_blender_4b.png51.4 KB · Views: 773
-
tutorial_blender_4c.png497.6 KB · Views: 779