1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How To: Import Civ5 Meshes to Blender to Create Civ5 Units

Discussion in 'Civ5 - Modding Tutorials & Reference' started by bernie14, Oct 30, 2011.

  1. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    How to: Import civ5 meshes into blender to create civ5 units

    This tutorial assumes you know some basics about blender function but I will try to be somewhat specific and detailed for newbies as well. NOTE: everything in this tutorial was learned from other tutorials and from other threads in both civ4 and civ5, providing excellent information. Special thanks goes to Deliverator, lemmy101, CaptBlinky, Ekmek and danrell. I will cite various excellent tutorials at the end.....

    THE TOOLS:

    -3DVIA Printscreen 2.3 (http://www.3dvia.com/products/3dvia-printscreen/)
    Allows capture of a mesh in granny viewer and creates 3dxml file

    -3DXML Importer “import_3DXML.py” (file included in zip)
    Allows import of 3dxml file to blender

    -blender scripts (”copyPaste.py” and “export-fbx.py”) files included in zip
    Allows copy/paste objects between blender files and export to fbx

    -Granny Viewer (http://www.radgametools.com/granny/download.html)
    Together with IndieNexusBuddy, allows creation of a usable .gr2 file

    - Indiestone NexusBuddy, older version (http://forums.civfanatics.com/attachment.php?attachmentid=271659&d=1289089329)
    Allows creation of usable .gr2 file and creation of gr2 file from exported fbx file from blender

    -Blender 2.49 and all the goodies
    Allows mesh/skeleton/skin integration and export to fbx file
    DOWNLOADS (from Ekmek’s guide)
    To get blender to work with Civ files you need to download these programs and install in THIS SEQUENCE. Downloads for 32-bit windows and tested on Vista.
    1. PYTHON 2.6.2 (32 BIT WINDOWS)
    http://python.org/ftp/python/2.6.2/python-2.6.2.msi
    2. BLENDER 2.49a ( FOR 32-BIT WIN)
    http://download.blender.org/release/...ix-windows.exe
    3. PyFFI-py2.6-2.0.1-windows
    http://sourceforge.net/projects/pyff...s.exe/download
    4. Blender 2.4.10 NIFSCRIPTS
    http://sourceforge.net/projects/nift...s.exe/download
    5. NIFSKOPE
    http://sourceforge.net/projects/nift...s.exe/download

    -Old version of civilization 5 SDK (thanks to danrell) http://forums.civfanatics.com/downloads.php?do=file&id=17547&act=down
    http://forums.civfanatics.com/downloads.php?do=file&id=17548&act=down
    Allows working Asset Viewer to view 3d and animations of unit in progress


    THE METHOD:

    Ok, let’s get all our tools working first.....download and install the 3dvia Printscreen. I like to have my icon on my desktop and I usually do not activate it until I am going to capture a model....



    If it installed ok, when you open printscreen, this is what you see....pick our output folder and “hotkey” for when you are ready to import a mesh.....if you leave printscreen active in your toolbar (background), it will do weird stuff whenever you hit the hotkey (in this case “A”), so right chick the tool bar and exit until you are ready to capture your mesh....

    Now, you are going to need to make a couple of folders to put your stuff in.....if you like put all your stuff in one folder, but since I am a little OCD, I usually use two folders....I have one folder for “civskins”, there, I have other folders, riflemen, musketmen, swordsmen, etc, and in each german, American, Aztec, etc., etc.....then, I have a folder on my desktop, such as “swordEX” or “rifleEX”. In my civskin folders, I will do all of my blend and artwork, then copy/paste the dds (art) and exported fbx to the ***EX folder on my desktop which contains a pre-ready fxsxml and I perform the fbx to gr2 conversion here, using the old indie nexusbuddy......

    Ok so I got a little ahead of myself. Right now, let’s work on getting another civ5 swordsman mesh onto a skeleton. Go to were your dds, usually “C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\resource\DX9” and copy your dds files. I will be using the swordsman2_diff.dds and swordsman2_sref.dds. Put those files in your corresponding civskin folder and in your SwordEX folder. Now go get your gr2 file, usually in “C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\resource\Common”, in this case, the swordsman_v2.gr2 and stick that one in your civskin folder.

    You should have something that looks like this:



    Now, install your Granny Viewer (exe) and double click on the gr2 file....SNAP!!!



    CRASH!!!!!!

    That’s...OK....download the zip and install your old Indiestone Nexus Buddy. The file, named “IndieStoneNexusBuddy_old.exe” should be placed in C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v sdk\Nexus\x86 (which is the same location as the “Nexus.exe” file for it to work. I like to create a shortcut to the desktop for easy access ......now, open up your old nexus buddy and follow the steps below....1) open your gr2 file, 2) click “add” and add “UnitShader_Skinned” 3) a pop up will display and you will add the ***.sref to the SREF MAP and the ***.diff file to the Base TextureMap corresponding slots to the right of the Skinned Unit Materials. 4) Next, you will click on “unassigned” underneath the Material heading and select “MaterialUnitSkinned1”......last step 5) Save As ***, I will usually put something like “civ5_” in front, as to differentiate it from the “game” gr2....so, in this case, I am saving as “civ5_swordsman.gr2.......



    Now, double click on that gr2 file and guess what????



    BAZINGA!!! We are about 5% DONE!!!! Now we have a gr2 file that can be read by our 3dvia Printscreen program!!

    Ok, we had installed our printscreen program but we need to place the “import_3DXML.py” file which was included in the zip in the following folder (of course, as long as you placed everything in default when installing)....."C:\Program Files (x86)\Blender Foundation\Blender\.blender\scripts\import\import_3DXML.py"

    Now, we will activate 3dvia printscreen, with our granny viewer open and press the magical hotkey “A” in this case (I think the NUM lock and F lock have to be on but not sure) and voila!!



    This is our 3dXML file and we should know where it is cuz we set the output folder above......

    NOW we open BLENDER.......

    Maneuver to the 3dxml file location and import the file.....



    Now, using the keypad 1 (front view),3 (side view) and 7 (top view), center your mesh using G (go) and R (rotate)


    This is my preferred view in blender



    1) is the Outliner; helps manage/pick the bones, the switch from object to edit mode, etc...

    2) 3d window (duh!)

    3) UV image editor: pick textures, change UV map etc.

    4)Buttons: a lot of important stuff, more details later

    As you can see in the above image, the unit is not “centered”.....there may be a simple method to “snap the unit in place but I don’t know it, so I G (go) and R (rotate) both the “object” (the little dot) in object mode and the mesh in edit mode) until my init is centered. NOTE that when you click the little triangle “vertex thingy” in the outliner, you switch from edit to object mode and can move the entire “scene” vs the mesh only, thus achieving the centering

    The object can be centered by bring up your transform properties (3d window menu, mesh tab) and set the upper left coordinate numbers to “0” (zero)



    So, here are some picks of the action in general.......





    Another major step done!!! Now, we need to get this mesh some bones....

    *********REMINDER***** SAVE OFTEN AND MAKE BACK UPS IN CASE THINGS GO TERRIBLY WRONG (I’ve had objects disappear for no apparent reason if I inadvertently hit some evil key)

    Keep that blender file open, choose object mode and make sure your object is “selected” (has the little pink outline around it)

    Open up the pre-made swordsman template blend (yes, download the one I already did) in another blender session, should look something like this....



    Notice first the hierarchy of the outliner window....the scene root marked #1 contains the bone structure for the body, shield and sword, connected as parents and children.....the scene root also contains the swordsman “object”, marked as #2, and the swordsman material, #3


    Now, let’s do a quick review of the buttons window.....



    The buttons you will probably be using the most is the “Link and Materials” #1. Here you will assign your body part vertices (vertex groups) to the bones. In #2, you will select the image and in #3, you will link the “object” to the “material”......more to come......

    Go back to your new swordsman mesh. If you did not yet, place the “copyPaste.py” and “export_fbx.py” files which were included in the zip in the following folder
    C:\Program Files (x86)\Blender Foundation\Blender\.blender\scripts\copyPaste.py and C:\Program Files (x86)\Blender Foundation\Blender\.blender\scripts\export_fbx.py.

    OK....now, go to the new swordsman mesh and make sure it is selected (pink outline). In object mode, click 1-Object, 2-Scripts, 3-Copy and Paste Objects and finally, 4-Copy object(s) to buffer......



    Now, go to your (my) swordsman template blend, in object mode, make sure everything is Unselected (A button to select and unselect) follow the same instructions, but select Paste object(s) to buffer...... the new mesh has been transferred over to the template.....



    Now the real work begins.....as you can see, the new mesh is not part of the scene root and has no vertex groups or associated bones....(****REMINDER****back up and save your work before something terrible happens!!!!!)

    Line up the new mesh with the old one as best possible, good tips include using your 1,3,7 NUM views and judging your placement in areas that are very “stable”, in this case, the feet and sword. I renamed the texture “swordsman2” in the buttons window, as indicated in the following pic.



    Now, we will make the mesh part of the scene root and give it a material. First, in object mode, select your skeleton/bones....now they will be in pink. If I my digress slightly, I think this would be a good place to relook at the buttons window, you can see in this view that you can change how the bones appear (stick/octahedron/etc.) as well as whether the axes (in edit mode) and bone names are shown or hidden.



    Now, right click on the Swordsman2 mesh in the outliner window and press Select (cant capture that shot sorry) but now both your bones and the swordsman2 mesh should be outlined in pink*****it is very important that the skeleton is selected first, then the mesh, so the mesh can be properly joined to the bones. Now, in object mode, click 1-Object, 2-Parent, 3-Make Parent, 4-Make Parent to ----> Armature, 5-Create Vertex Groups?---> Name Groups....



    Viola!!!! Now you have your swrodsman2 mesh connected to your scene root and ready for material, skin and to get boned!!!



    First, let’s assign the material. Go to your buttons window and next panels click on the 3d ball looking thingy. Click on add new and just choose the VetMusket_Skinned (it’s the one there?!?)



    Now let’s give it an armature...I truly don’t even know if this is necessary, but since the other mesh has one, I just go ahead and add it.....in the buttons window, next to Panels, click the square looking thingy...add modifier, then click armature....



    Let’s set the skin/texture. The texture can probably be set later when creating the gr2, but this is a good exercise to make sure the skin fits the mesh correctly. In object mode, in the buttons window, next to panels, 1-click the sphere thingy, 2-click the square animal print looking thingy, 3-click on the file selector on the right, and 4-you will get a menu. 5-Navigate to where your new dds/texture is and 6-SELECT IMAGE. The image selected will now be in the bottom left, in the buttons window (see in next image).



    This step is more important to make sure the skin is on right. Switch to EDIT MODE, make sure you have your swordsman2 mesh selected and hit A to select all. The mesh should be lit up in yellow and the texture in the UV image editor window on the right should also be lit up yellow. 1-in the UV/image editor window, click image, 2-click open. You get a menu, 3-navigate to where your file is, 4-select your file and 5-Open Image. Notice the image is literally upside down. Easily fixed....with the cursor in the UV window, click your M (mirror) key. Select Y Axis and the texture flips, now fitting perfectly....



    Now comes the most tedious part....assigning vertices to bones....if you notice in the outliner window, you will see the mesh name and then arrows that open and close submenus.....if you click on the triangle thingy, you will enter edit mode of the mesh selected......this part is easier to work in “wireframe” draw type, so while in edit mode, click the button next to it, and you get a menu for draw type. Select wireframe.

    http://img809.imageshack.us/img809/1236/57479768.jpg " align="" border="0" />

    Switch between your swordsman and swordswman2 meshes. Go to your swordsman mesh, since that is the one boned and you will be using as reference. Make sure all vertices are Unselected. Go to your buttons window, link and materials, vertex groups. 1-Click on the menu with the vertex group name and you will get a menu with all the group names. 2-click “Base HumanRCalf” and then 3-click Select.



    If you then switch to your swordsman2 mesh and do the same thing....nothing lights up.....your goal is to select the body parts/vertex groups in your new mesh and Assign then to the proper bone. Fairly straight forward but time consuming. Essentially, you will be going back and forth from your template mesh to your new mesh and assign vertices. Some tips. In this case, I find it easier to manipulate the 3d window so the vertices I will be selecting are out of the way of other vertices and more or less “square” with selection. You can move/rotate the 3d window by pressing Alt and moving the mouse (this is quite basic but if you need even more basic help on blender, I recommend the wiki book “blender: noob to pro”). Vertices the new mesh can be “grabbed” by “lasso method” (hold Ctrl and lasso with mouse) and by “area method” (press B and a 2D target appears, move mouse to desired area and left click).



    Another tip is when the R and L areas are exactly symmetrical. After assigning one side, select the corresponding side and DESELECT the original side, then, select the corresponding vertex group from the menu and ASSIGN. If you are really obsessive, you could “capture” and image of the area you need to select from your template mesh and then select/assign the vertices in the new mesh. There will be some groups that you do not have to assign vertices to. ******IT IS VERY IMPORTANT THAT ALL VERTICIES ARE ASSIGNED*******you can be sure by exporting as a NIF.....if any vertex is unassigned, the export will fail and the unassigned vertices will light up....

    SPECIAL NOTE: in this particular case, in order for the sword sheath to animate properly, I had to move it slightly in the original template, so when assigning the Base HumanSpine2, just go ahead and move the vertices of your new mesh’s sword sheath to line up with the old mesh.



    OK!!! Now, time to say goodbye to our old mesh. 1-Click/R-click it in the old swordsman mesh and you get a menu, 2-click Delete and say bye-bye to our old friend. We are almost done....GOOD TIME TO SAVE your work!!

     
  2. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    part two....

    Time to export to fbx. In 1-edit mode, make sure all vertices are selected.....switch to object mode and again 2-select all (A) so that both the mesh AND the bones are outlined in pink. 3-click File, Export, Autodesk FBX. 4-you get the export menu *****the Root Name HAS TO BE CORRECT AND IS CASE SENSITIVE******in this case, it is “World_Center”. 5-click Export. You get your export menu. 6-click Export FBX....



    The finish line is in view.....we have our fbx file, we need an fxsxml file and then, convert the fbx to a gr2. I like to have my fbx file in both my work folder and test folder.



    I have included the fxsxml file in the zip, but you can whip it up easily, it is the standard swordsman fxsxml file, with the following changes. You can name the mesh file whatever you want, but remember it has to be exactly what you will name your gr2.



    Open up your old IndieStone Nexus Buddy and hit open, navigate to your test folder. File, Open, 1-go to the lower right menu and select fbx. 2-open up your fbx file. 3-add a UnitShader_Skinned and 4-select your sref and diff dds textures. 5-assign the MaterialUnitSkinned1 and 6-save your file to gr2 *****MAKE SURE YOU GOT YOUR NAME RIGHT*****



    Now click on your new gr2 file to make sure it got made right (the indiestone program does not export perfectly all the time).



    YES!!!!...now you can test your unit using the old civ5 SDK asset viewer. This is how and where to put it. IIRC, I unzipped part 2 first and then part 1 on top (or the other way around??). here is danrell’s explination

    ......rename it to "sid meier's civilization v sdk1", put it in "C:\Program Files (x86)\Steam\steamapps\common", not replace the original, because the old SDK can launch asset viewer, the new one can launch the game and game viewer, so you need rename the folder before you use it. (...sdk1=asset viewer,...sdk2=game viewer, remove the number when you choose which to use) .......(THANKS danrell)

    Open up your SDK and choose Nexus. Open asset viewer and then click open, navigate to your gr2 and click. In 3D view, select EventCode and in the menu to the right, choose an “action” (in the example it is 1440....SUCCESS!!!!!. now you can see the animation by going to your Animation Triggers window and scroll/click/choose 1440 in the menu on the left....it works.....I like to slow down the action, to see that the animation is smooth.......



    THAT’S IT!!!

    Please see these other excellent tutorials for additional information.....

    Making units that use Civ 5 animations by Deliverator
    http://forums.civfanatics.com/showthread.php?t=396911

    Getting Civ 4 Units into Civ 5 by Deliverator
    http://forums.civfanatics.com/showthread.php?t=394056

    How to Add New Units in Mods The EASY WAY! By lemmy101
    http://forums.civfanatics.com/showthread.php?t=392985
     

    Attached Files:

  3. Ekmek

    Ekmek on steam: ekmek_e

    Joined:
    Aug 7, 2002
    Messages:
    6,045
    Location:
    San Diego, California
  4. meteora 888

    meteora 888 Chieftain

    Joined:
    Oct 31, 2011
    Messages:
    20
    Location:
    Montreal, Canada
    pretty simple... but does it work on latter versions of blender? (I use 2.59)
     
  5. Nefliqus

    Nefliqus Chieftain

    Joined:
    Sep 16, 2010
    Messages:
    400
    Location:
    Poland
    wow, thx you for your time. Great work.
     
  6. Ekmek

    Ekmek on steam: ekmek_e

    Joined:
    Aug 7, 2002
    Messages:
    6,045
    Location:
    San Diego, California
    it should unless you are trying to import a nif which may be broken
     
  7. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    are the scripts the same as for blender 2.49?
     
  8. Ekmek

    Ekmek on steam: ekmek_e

    Joined:
    Aug 7, 2002
    Messages:
    6,045
    Location:
    San Diego, California
    I didnt explore that deep but I think they may be different which is why I stayed at 2.49b
     
  9. Jabberwockxeno

    Jabberwockxeno Chieftain

    Joined:
    Jul 10, 2012
    Messages:
    487
    The link to grannyviewer doesn't work.

    EDIT: Was able to find a download link, and a bunch of other tools: http://gr2decode.altervista.org/download.html

    Will the OpenGLXtractor work in place of the 3DVIA printscreen?

    And will there be any unforseen problem if we use 3ds Max instead of blender? Not using the method you describe here, of course, but if I am able to get the Gr2 into an obj file, and edit it in max, will there be any issues other than the new mesh not working well with the animations?

    EDIT: the 3DVIA Printscreen link doesn't work either. Tyring to get to the page via google gives me a "you do not have permission to view this page" error.

    EDIT: After a lot of searching, I was able to find a cached torrent file of it (Before mods freak out, it was freeware before it was discontinued by 3dvia, apparently).

    It didn't contain a setup file, just the program files folder of it after it was installed. Copy pasting that folder to mine SEEMS to work fine on my XP laptop, it popped up a logo, then vanished and the icon came up in the right part of the taskbar.

    Haven't tried it on my desktop yet, or tested it out on the latop. I know it's a 32 bit program, does it glitch up with 64 bit systems? Some programs do, some don't.

    EDIT (again): Finally, based on me skimming through the rest of the tutorial, you rig the mesh by using a premade rigged model, and just using the mesh to the old bones.

    How would we do this if we were using a model other than the swordsman?
     
  10. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    ok, let's see how i can help....

    first, sorry about the links, been a while since i have checked this thread....thanks for the link to grannyviewer....yes, the 3dvia is/was a freeware....

    i don't think there will be any problem using 3dmax, although i am not very familiar with the program....the key factors, i would think of the top of my head, is that the bones are named correctly and the file can be exported to fbx.....when exporting to fbx, make sure the export settings are correct for the unit you are working......after you have the fbx, using the indie tools should be the same....

    in terms of models, fortunately, danrell has just provided MANY templates (look for his units thread, he is the civ5 animation genius)....the musketman and rifleman templates are also available.....

    good luck, hoping to see some new units and let us know how things are going...you will probably end up teaching me many things...:goodjob:
     
  11. Androrc the Orc

    Androrc the Orc Chieftain

    Joined:
    Apr 19, 2004
    Messages:
    1,620
    Location:
    Vienna, Austria
    Unfortunately, the Blender links 2-4 are broken :(

    EDIT: I believe this is the correct link for Blender link 2.: http://download.blender.org/release/Blender2.49a/blender-2.49a-avifix-windows.exe

    EDIT2: I'm having some trouble with doing basic editing of .gr2s. Apparently the IndieNexusBuddy can't show up references to textures that have their "ShaderSet" be "BuildingShader_Skinned", which is the case of the texture of the pigs in truffles.gr2. This means I couldn't change the texture file path so that the pigs would use an alternate texture. GrannyViewer properly showed up those references, but unfortunately I couldn't find any way to change them through it.
     
  12. Novator

    Novator Doomed to finish everything from that cursed list.

    Joined:
    Jul 3, 2012
    Messages:
    267
    Thanks. )))
     
  13. Novator

    Novator Doomed to finish everything from that cursed list.

    Joined:
    Jul 3, 2012
    Messages:
    267
    And now crash (((
     
  14. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    you dont even have to assign the texture or materials....you just open the gr2 with indie and "save as" or just "save" and then you can open the gr2 with grannyviewer.
     
  15. Novator

    Novator Doomed to finish everything from that cursed list.

    Joined:
    Jul 3, 2012
    Messages:
    267
    I have another version of Granny viewer I think. It can't open unts from File database.
     
  16. JJimmyJ

    JJimmyJ Chieftain

    Joined:
    Jul 15, 2012
    Messages:
    15
    Hello

    I'm after a bit of help. I've got to the point where I'm copy/pasting the objects so I can use the skeleton. However, every time I use the 'copyPaste.py' I get an error in the console:
    txt = open(Blender.Get("datadir") + "/buffer","w")
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    Is there an updated script? Searching for help on this error is proving difficult.

    Thanks
     
  17. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    does it happen when copying the mesh or when pasting to the skeleton?
     
  18. JJimmyJ

    JJimmyJ Chieftain

    Joined:
    Jul 15, 2012
    Messages:
    15
    Hi bernie14.

    It's happening at the point:
    ' make sure it is selected (pink outline). In object mode, click 1-Object, 2-Scripts, 3-Copy and Paste Objects and finally, 4-Copy object(s) to buffer......'
    The error then appears.
    Its as if the object isn't found and as it expects a positive response, it falls over (I'm just guessing, not a programmer).
    The only directory I've defined is the python script one, all others left at blender defaults.

    I've attached some screenshots in a word doc.

    Thanks
     

    Attached Files:

  19. bernie14

    bernie14 Filter Manipulator

    Joined:
    Feb 2, 2007
    Messages:
    2,706
    Gender:
    Male
    Location:
    coastal flood plain
    yeah, no idea.....i guess the py file is in the right place, since you are getting the copy/paste option in scripts.....the only thing i can think nof is that you may have more than one object selected :confused: :confused:

    EDIT: also, dont know why you have that "text.001" in your text window???

    why dont you attach your blend file so i could take a look at it?
     
  20. JJimmyJ

    JJimmyJ Chieftain

    Joined:
    Jul 15, 2012
    Messages:
    15
    Hi bernie14

    Thanks again for looking.
    I've finally figured it out. It was a problem with my paths. I'm using windows 7 (64bit), so the mesh was being saved in a non-existant folder (still can't find it so not sure how it loads). I've now moved my .blender file into the default path and the copy/paste works.
    Now for the next step. No doubt I'll be posting again when I have my next brain fart :)
     

Share This Page