Extract GR2 to Blender with mesh AND skeleton and re-export to GR2

LH textures have a header file added to them so they can't be opened it by GIMP

...or any other program as far as I know. Also sadly grnreader98 doesn't export the leaderhead skeletons.
 
5. Blender 2.49a: Import the Milkshape3D ASCII .txt file using my customized script: Scripts -> Import -> Milkshape 3D ASCII (.txt). Now for the slightly fiddly manual bit. Open up the Outliner in a window in Blender and locate the first bone in the Armature (may be called Dummy_WORLD, WORLD_center, point_WORLD, etc). Clear the parent of any children of the WORLD bone. Now delete the WORLD bone by using X key in Edit Mode, and then rename the topmost Armature object to whatever the name of the WORLD bone was. See before and after pics. (This WORLD bone is a byproduct of the conversion process and is doing nothing helpful other than incorrectly rotating our skeleton - the export process will give a nice clean root bone.) Save your .blend file. Pat yourself on the back for creating a Blender unit template! :goodjob:

Probably should add some notes here:

- On import you may not see your object. Why I have no idea. but if you cange "object Mode" to "Edit Mode" and zoom out then you'll see your import.

- if you put your cursor on a divider line it will make two arrows. right click and choose "split" then split your screen. you'll see mirrors of your object. Click the left most button and choose "outliner" to get the skeleton. expand those out and you'll see the armature part. Also if you click object then your imported object with finally show by itself

QUESTION - Do we need to rotate the object they always come in at a weird angle. before I would rotate them does your script handle that?
 
...or any other program as far as I know. Also sadly grnreader98 doesn't export the leaderhead skeletons.

does anyone know how to decompile grnreader98.exe and see why it can't handle skeletons? Too many bones? I have been able to get the meshes (its easier than the 3dxml way) but not having the skeletons is a bummer.
 
QUESTION - Do we need to rotate the object they always come in at a weird angle. before I would rotate them does your script handle that?

I just tried it without rotating the Civ 5 blend but rotated the imported civ 4 mesh to the civ 5 mesh position and it looks OK in Nexus viewer with all animations working. Will try it in game latter on and let know how it goes.
 
Too many bones?
Even nifscript can't import/export full data about lh into blender. So we have to do nifswap and add shaders. The answer is "too much data" or "the difference between the functions of the programs".
 
I really appreciate you posting this, Deliverator; it's going be very useful indeed to me :D!
 
Probably should add some notes here:

I'm going to add code to the script to automate the manual tweaking - it should be easy now I'm used to the Blender Python API. You can basically automate any repetitive actions that you'd do by hand in a script - very useful.

Also, I'm going to create a much better and simpler tutorial for Civ 4 unit into Civ 5 with Civ 5 animations, but I'm making sure the process is as simple as I can possibly make it first. So for example I am writing a Blender extension will rename all the bone names/vertex groups from Civ 4 BIP/Bip01 to the names used in Civ 5. My aim is to remove as much manual brain-work from the process as possible.

- On import you may not see your object. Why I have no idea. but if you cange "object Mode" to "Edit Mode" and zoom out then you'll see your import.

Not sure I've had this issue - the first thing I generally do is use Numpad-1, 3, 7 to view the imported unit from the different directions so maybe that fixes the issue.

- if you put your cursor on a divider line it will make two arrows. right click and choose "split" then split your screen. you'll see mirrors of your object. Click the left most button and choose "outliner" to get the skeleton. expand those out and you'll see the armature part. Also if you click object then your imported object with finally show by itself

I'll update the OP with empty template.blend file that has the Outliner in the layout, but as I've said I hope to do the WORLD bone stuff in the import script so you won't need to work with it anyway.

QUESTION - Do we need to rotate the object they always come in at a weird angle. before I would rotate them does your script handle that?

You shouldn't need to, as Wolfdog has found. One thing to be aware of it that the exported Civ 5 unit will be "lying on its back" in Blender. This is correct and desired because Z-axis is Up in GR2 format, whereas Y-axis is Up in Blender. So in Blender Numpad-1 will show the Bottom view of the export Civ 5 instead of the Front, and Numpad-7 will show the Front instead of the Top. This means you will need to rotate the mesh you want to rig back 90 degrees about the x-axis at some point. (At some point I can probably update the Milkshape Import and FBX Export scripts so this isn't the case - but one process simplification at a time... :))

I just tried it without rotating the Civ 5 blend but rotated the imported civ 4 mesh to the civ 5 mesh position and it looks OK in Nexus viewer with all animations working. Will try it in game latter on and let know how it goes.

Cool - post a screenshot when you're done!

does anyone know how to decompile grnreader98.exe and see why it can't handle skeletons? Too many bones?

I'm not an expert in the field of decompiling exe files - I guess this is C++ code? I used a program to inspect the Civ 4 exe called PE explorer once - see this thread but I've no ideas if it will work in this case.

The frustrating thing is that it reports the number of bones OK and if you run with no parameters and say yes to everything it reports on the bone mesh mappings. So I don't think it's "too much data". Comparing GR2s in GrannyViewer the LH bone names have double-quotes around them which is definitely the type of thing that could screw up the exporter.

I can understand why the grnreader98 source code isn't readily available - GR2 is a proprietary format and the even the executable isn't easy to find.
 
Its only a Marder I and its not as complicated as a soldier or cavalry unit, but still it worked. Here is the screen shot.
 

Attachments

  • Marder.jpg
    Marder.jpg
    27.1 KB · Views: 267
Its only a Marder I and its not as complicated as a soldier or cavalry unit, but still it worked. Here is the screen shot.

Nice. What do you think the most complex unit in Civ 5 is? I'm thinking the War Chariot maybe. I want to prove the hardest case first - then everything else will be easy.
 
just a quickie....

in regards to LH, the haile selassie creates an smd file, but txt to blender wont import the skeleton...

in regrds to the units, i smd'd the machinegun, artillery and cannon, but had weird results, as if some of the objects were all sucked into one point (the gr2 looked ok in granny BUT not in [old] asset viewer), so, with the MG, i imported the four seperate objects and kept them seperate, parented them, got rid of the original single object and exported to fbx....in indiStone, i created seperate unitshaders and assigned them....it WORKED!
 
just a quickie....

in regards to LH, the haile selassie creates an smd file, but txt to blender wont import the skeleton...

in regrds to the units, i smd'd the machinegun, artillery and cannon, but had weird results, as if some of the objects were all sucked into one point (the gr2 looked ok in granny BUT not in [old] asset viewer), so, with the MG, i imported the four seperate objects and kept them seperate, parented them, got rid of the original single object and exported to fbx....in indiStone, i created seperate unitshaders and assigned them....it WORKED!

How did you separate the objects? In milkshape?'


Man, this is turning into the biggest breakthrough since Lemmy
 
in regrds to the units, i smd'd the machinegun, artillery and cannon, but had weird results, as if some of the objects were all sucked into one point (the gr2 looked ok in granny BUT not in [old] asset viewer), so, with the MG, i imported the four seperate objects and kept them seperate, parented them, got rid of the original single object and exported to fbx....in indiStone, i created seperate unitshaders and assigned them....it WORKED!

I have this sucking-in-to-one-point thing with cavalry too, I'm sure it's fixable - I'll take a look tonight.

Can you explain exactly what you mean by "i imported the four seperate objects and kept them seperate, parented them, got rid of the original single object"?

I've always found that the problem with a multiple object FBX is that Nexus Buddy FBX->GR2 often mangles the meshes - drops triangles, moves vertices etc. If we could get around this issue is would make a lot of Civ 4 conversions easier seeing as many custom units use multiple meshes, materials and textures. Up to now my experience has been that to make properly formed Civ 5 units you are restricted to one mesh (by the FBX->GR2 conversion), and one material/texture by Nexus Buddy. That means you have to merge your DDS textures into a single file. I'd be happy to be proved wrong!
 
Up to now my experience has been that to make properly formed Civ 5 units you are restricted to one mesh (by the FBX->GR2 conversion), and one material/texture by Nexus Buddy. That means you have to merge your DDS textures into a single file. I'd be happy to be proved wrong!

IIRC I heard from Firaxis that this is part of the code for generating the GR2. Something to do with the license they have from RadTools. It'll be single mesh unless something changes. A real bummer if we ever get to leaders.
 
just a quickie....

in regards to LH, the haile selassie creates an smd file, but txt to blender wont import the skeleton...

I've been able to make smds of a few leaders, I think its easier than the 3dxml method so I took that off my computer. But I think its the smd grnreader thats the issue. Its real fortunate that smd and milshape ascii can both be opened in notepad. I can see that the skeleton doesn't show in the smd and thats why i didn't import into milkshape 9atleast for montezuma). i'll see what Haile does.
 
Well, I've been digging into the wonder, tile imp, and resource files.

Structurally - tile imps and resources look to be joined (well the one's I'm interested in, didn't look at mines or trading posts). And they share a problem that I found in Wonders too.

MULTIPLE SKELETONS :mad:

I messed with the pyramids and in the new.gr2 you'll see multiple skeleton numbers and in model list in granny viewer you see the different "models" (the half-built (hb), pyramids, and tree cut). this is structurally different than units. units have one skeleton.

I did export an fbx with multipe meshes, that use the same material, but multiple skeletons. And each mesh showed up. But on export only one skeleton appeared in the gr2. not sure if thats because it can only export one mesh 9and I had one mesh per skeleton) but the fact that it exported was nice.

I may just rig the different phases as bones but my hunch is that it will display all 3 at once. The real confusing part is to what triggers the modes. the wonder.ddxtl doesn't reference skeltons or animations(there are none, so make an animation is out). its just weird.

I may give the 3 bones template a shot. but considering that it only imported one bone (and I have had success with adding bones and skeltons) it maybe that the game sees them as "gr2s on top of eachother and in the same file" and acts that way.

what a pain.
 
UPDATE:


After painstakingly converting all the wonders I found none of them have a simple skeleton. BUT I did find the Colosseum and Radio Tower as the only models that display with a single skelton. Even though we cant get the under construction graphics I *think* that if I make a template with it we can have wonders show in game. I'll attempt a mod that does that.
 
How did you separate the objects? In milkshape?

Can you explain exactly what you mean by "i imported the four seperate objects and kept them seperate, parented them, got rid of the original single object"?

ok...this is what I did, using the machine gunner as example....

i opened the [indiestone modified] original gr2 and noticed the number of meshes. There are 4, the ammo, the loader, the gunner and the gun....

I created a blend file as per your TUT, save that as say, "base_file" or "original" or whatever....

then, save a copy as "mesh1" or "object one" or using the name of the meshes (ammo, gunner, etc).....let's go with "AMMO BOX"....in object mode, delete the skeleton (all the bones), then, go to your mesh and in edit mode, delete faces, verticies, etc EXCEPT those belonging to the ammo box....save that mesh....do the same thing, using your original blend, to isolate the gunner, then loader, then the gun meshes...

you now have 4 mesh files and your original blend.....open up the original blend, minimize it.....open up your mesh blends...use your ["DELIVERATOR'S] copy/paste script to copy the meshes/objects onto the original/base blend file....

after you have copied over the four meshes, delete the original mesh (the one that has all the objects together)......then, in object mode, select the skeleton and ONE mesh, and “make parent to armature” one mesh at a time.....export to FBX....

when you open up your fbx in indiestone, you will see four materials/objects.....add four material types/unitshaders_skinned and assign 1 to 1 (note: I don’t necessarily assign the textures before saving as gr2....you can come back to the gr2 later)

export to gr2....view in granny viewer, if OK *****, recheck in [old] asset viewer..

*****you are absolutely right that multiple (more than one) objects tends to cause a painful number of export to gr2 errors....i think I got lucky and the FIRST time I exported using 4 objects, it all worked....unfortunately, it seems you jinxed me a little :mischief:, and the next 5 or 6 times, I had messed up gr2s :mad: ....so I tried something else......I tested combining several objects (join mesh) and tested various combinations...after several tests, (and specifically addressing this unit) I combined the ammo box, the loader and the gun and left the gunner separate, exported to fbx...now, I only had two objects to assign in indiestone and the conversions to gr2 were much more stable.....

I am attaching the test template...it has not been tested in game...

I am sure there is a much more elegant way to do this fix and I hope this explanation will help you (and/or someone else) to make this less painful for us all :crazyeye: !!!!
 

Attachments

Here's what I've discovered about the pinching issue with multi-mesh objects.

When you first follow the process for the Lancer you get this:

attachment.php


It might look like something wrong with the mesh, but there isn't anything wrong with the mesh or the skeleton. The problem is with the thing that relates the two - the vertex groups - how the mesh is rigged to the skeleton.

Also, it might look like the problem is with the rider, but it's not - it's something in the horse data that is affecting the rider.

If I delete the Horse mesh and do nothing else then the rider comes out fine:

attachment.php


If I delete all the Horse Vertex Groups and map the whole Horse to a single Horse bone all meshes come through the process fine:

attachment.php


A step in the right direction, but now we have an unrigged, unanimated horse.

So there is some data in the Horse Vertex Groups that the process doesn't like. It ought just to be a process of elimination job to find out where the problem lies. An alternative would be just to manually re-rig the Horse to make the template but I don't have time for that now. So progress, but not quite there.
 

Attachments

  • pinch1.jpg
    pinch1.jpg
    27.3 KB · Views: 1,068
  • pinch2.jpg
    pinch2.jpg
    21.1 KB · Views: 987
  • pinch3.jpg
    pinch3.jpg
    36.6 KB · Views: 941
hen, save a copy as "mesh1" or "object one" or using the name of the meshes (ammo, gunner, etc).....let's go with "AMMO BOX"....in object mode, delete the skeleton (all the bones), then, go to your mesh and in edit mode, delete faces, verticies, etc EXCEPT those belonging to the ammo box....save that mesh....do the same thing, using your original blend, to isolate the gunner, then loader, then the gun meshes...

you now have 4 mesh files and your original blend.....open up the original blend, minimize it.....open up your mesh blends...use your ["DELIVERATOR'S] copy/paste script to copy the meshes/objects onto the original/base blend file....

after you have copied over the four meshes, delete the original mesh (the one that has all the objects together)......then, in object mode, select the skeleton and ONE mesh, and “make parent to armature” one mesh at a time.....export to FBX....

when you open up your fbx in indiestone, you will see four materials/objects.....add four material types/unitshaders_skinned and assign 1 to 1 (note: I don’t necessarily assign the textures before saving as gr2....you can come back to the gr2 later)

I think you can get the same result in indiestone by just using the P-key to seParate the four sub-meshes. Lasso select each object holding down Ctrl and then use P to split out each part as a separate mesh. I'm probably teaching my grandmother to suck eggs here...

At the moment I'm focused on finding a solution that uses only one mesh for all units as I think the corruption to meshes when using multiple meshes is a bit of a deal breaker right now. It's something to do with vertex group mappings as far as I can tell.
 
Back
Top Bottom