Hello all. I've been playing around tonite and I've kind of made something useful here.
http://www.theindiestone.com/lemmyandbinky.com/civ2/GrannyMaterialHackerv2.zip
This tool can be used to copy the entire material set of a Firaxis model onto your own exported gr2 model. You can also reset the textures the materials point to to your own dds files. (See below for current limitations).
So to use it, place it in your Nexus directory and run it.
You select a firaxis gr2 in the top text box using the browse button.
Then you can browse the structure of it, to see what materials are in the gr2, and what textures are set on those materials.
You can, if you wish, replace any of the textures by
double clicking the paths in the last column, to allow you to browse for a new texture. They should be in your Resources/DX9 directory.
Then select YOUR gr2 in the 'My GR2' section, this is the model that you exported in Nexus (the all black version. this file should be placed in the Resources/Common directory) or your duplicate of the first model if you're doing a unit re-skin .
If you only have one material, or just one mesh making up your model, then you can ignore the 'mesh -> material binding' section and just click HACKIFY!
This will transfer all the materials across to your GR2, with your new textures selected in each one. It will save the gr2 out as 'yourfilename_new.gr2' in the common directory. You will need to rename and remove the '_new' from the name of your main gr2 so it'll get picked up by the nexus viewer, I just did it like this so there would be no unsavoury overwriting going on.
It doesn't quite work for everything (the texture path for the wonders / buildings textures seems to also be stored in a place I can't easily get and it seems to be using that one instead of the material setting) but we've tested it with the unit shader and it seems to work a treat. This means we've technically got everything we need for doing units.
It will allow you to transfer the material from an existing building / wonder onto your new one (we managed to get the pyramids materials and textures displaying on a test object in nexus, we just couldn't alter what texture it was pointing to), so if you want to test your wonder in-game in the meantime you can replace the unpacked dds files for the wonder you're ripping the materials from in the DX9 directory and it should work properly for your wonder that shares them (but will display the wonder you used to transfer from incorrectly using your texture, obv, but who cares if you're just testing).
ALSO assuming you can open the source dds's for reference, this tool will allow for proper unit reskinning! it will allow you to duplicate, say, the rifleman.gr2 to superrifleman.gr2, run the tool to point him at a new dds file, and therefore reskin units! All without ever going into Nexus! WEEE!
Mesh -> Material Mapping
For cases where you have multiple meshes and/or materials, and you only want certain materials adding to specific meshes, you can use this section to 'unbind' materials from your meshes. The program by default binds
every material to every mesh, to ease in use of the tool when doing simple material hacks.
For cases where you have multiple materials (builders / leaders for example, when support is in for them) you may for example want one material assigning to each mesh part of the model. To do this you can select each of your meshes in the box on the left, to show all the bound or unbound materials in the boxes to the right. By default they will all be in the bottom 'bound' section. Select each material you don't want to be bound to this mesh and click 'unbind' to take that material off that mesh.
Then click HACKIFY! when you're happy.
UPDATE
Success! Building retexturing is a go!
Uploaded a new version:
http://www.theindiestone.com/lemmyandbinky.com/civ2/GrannyMaterialHackerv3.zip
Read the enclosed readme file for more info!
This one has the following changes:
1) Civ5NexusAnimBugFix.exe - Nexus animation bug fix patch. Will fix the problem with exporting animations and them all being 5k empty files. Apply this and animations will export from Nexus perfectly.
2) MaterialMapperNexusPatch.exe - another patch that, when installed, will allow the Material Hacker to finally copy and change Building textures! This is not required unless you want to edit materials on buildings, so if you're just reskinning units then ignore this.
3) To get buildings to work, you need to rename the materials to match the names of the meshes. For example if you make a wonder called MyWonder with the following meshes in it all occupying the same space within the FBX file:
MyWonder
Tree cut
HBMyWonder
The first being your wonder model, the second being a flat stencil shape on the ground (say a circle) that specifies where to avoid drawing trees if your wonder is placed on a forest tile (this one is assumption) and the third being the model of your wonder when it's half built. (It's possible you don't *need* all three, in which case just ignore the HB and Tree cut materials, but they *may* be a requirement it's unclear yet)
...and you're using the Pyramids as your base, so you select Pyramids.gr2 in the 'Source GR2' box. You should see the following materials in the Pyramid file:
Pyramid
Tree cut
HBPyramid
Load your MyWonder model into the 'My GR2' so the meshes appear in the box below. Here you can see what your meshes are called.
There is a 'rename' button now next to the materials list at the top. So rename these materials to match your meshes:
MyWonder
Tree cut
HBMyWonder
Then click on each of your meshes, and see on the right it will show all three materials are in the 'bound' list box, showing that all three materials are bound to that mesh. So select the two incorrect ones (with differing names) and click 'unbind' to move them into the top box. Once all three materials are set up, and you have substituted the appropriate textures, then you can click on the HACKIFY! button and it should spit you out your model with the correct textures set up.
This may be all that's needed to enable wonder modding as well as unit modding. We'll have to see if any more issues crop up though.
(Note version 1, before the mesh binding feature went in is linked here, in case there's any problems or bugs with the new version:
http://www.theindiestone.com/lemmyandbinky.com/civ2/GrannyMaterialHacker.zip)