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

You're machine gunner looks good Bernie - I can't see any dropped triangles or issues. I'm sure it will be fine in game too - I trust Nexus 3d viewer - I've not seen any unit that works in there not work in game.

It would be nice if we can write a tutorial that doesn't include "wait until you get lucky"... :)

attachment.php
 

Attachments

  • mg.jpg
    mg.jpg
    22.7 KB · Views: 587
Well I found an interesting discovering messing around with my pyramid blend.

I didn't unistall blender266 so I decided to see what it's fbx emporter does. Recall that the 266 exporter doesn't give the pop-up and it names the armature what ever you name it in outline (which is why 266 worked when we tested out the gunship stuff by 249 didn't).

Well the blender 266 fbx export (for some reason) exports multiple skeletons. Thats a big plus! Especially for wonders!

But I run into the mesh wall again. I tried with the meshes under each skeleton. And after export to gr2 they didn't show up. I tried joining the meshes but keeping it rigged to the vertex groups/bones in each skeleton. and only one mesh showed up.

I think I'll try a few more things. but wanted to report that exporting of multiple skeletons is possible ONLY IF you use blender 266.
 
BREAKTHROUGH


Man, after more trial and error I final got something that would show, with multiple meshes!


The trick I did was create three armatures/skeletons
-HBPyramid
-Pyramid
-Treecut

each skeleton has the the same bone underneath it.

Now rig each mesh you need only to that one bone. Join the object and then duplicate the object into the three skeletons. Since the meshes in the other object don't have a bone they won't show. But with the other skeletons they will.

I need to test in game. But so far when toggling the meshes in grannyviewer they appear and disappear (though it doesn't show me the mesh preview which had me worry) but the whole mesh showed in grannyviewer preview and in Nexus.

Now I need to make a quick wonder mod to test it and if successful I'll post my template.
 
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:


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:


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:


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.



i think if it works like my skeleton experiment - what you could do is have three identical objects. but rig them separately. so join the horse and the rider together but only rig the rider in one object. then the horse in the other. the unrigged parts won't show. maybe.
 
I've updated my customized import/export scripts to make the process even simpler.

Changelog v2

TXT Import:
+ Only creates vertex groups for bones that have mapped vertices.
+ Makes adjustment so that the top level object has the name of the WORLD bone.

FBX Export:
+ Automatically discovers the name of the top level WORLD object.

Download Link

Note: these version probably only work for unit graphics. Use the v1 process if your interested in exploring other types of GR2.
 
TXT Import:
+ Only creates vertex groups for bones that have mapped vertices.
+ Makes adjustment so that the top level object has the name of the WORLD bone.

granny viewer shows the hierarchy I wonder if its possible to delete that extra world bone and have the parenting right? it would make life simpler. but I'm ok as is! Thanks!


More progress - I exported a multi-skeleton mesh and this time the meshes showed in the preview. What changedwas that I used different materials and dds files. But one material per object.

I tried to test the pantheon in game but I'm blocked from steam here (and cant upload anything here) So I'll have to try later. But I have a good vibe that I can make custom, fully functioning wonders now.:eek:
 
I have assumed that the top level bone always includes the word "WORLD" somewhere. This might not be a good assumption. If it doesn't always hold I can code it a different way.

It doesn't for wonders. and might break my importing/exporting.
 
granny viewer shows the hierarchy I wonder if its possible to delete that extra world bone and have the parenting right? it would make life simpler. but I'm ok as is! Thanks!

Not sure what you mean by extra world bone. You'll have to be more specific. This is how things look now when I import the lancer with my v2 script. The script automatically does what had to be done manually in step 5 to speed up the process:

attachment.php


It doesn't for wonders. and might break my importing/exporting.

Ok I've reverted the download link to V1, but attached V2 scripts to this post. They'll speed up unit graphic importing/exporting anyway. At some point I'll figure out the code to automated step 5 in a more robust way.
 

Attachments

  • world.jpg
    world.jpg
    25.5 KB · Views: 547
More progress - I exported a multi-skeleton mesh and this time the meshes showed in the preview. What changed was that I used different materials and dds files. But one material per object.

What do you mean by preview? GrannyViewer or Nexus? You'll have to do a more detailed write up of your process if you get this working - I'm not really following at the moment!
 
What do you mean by preview? GrannyViewer or Nexus? You'll have to do a more detailed write up of your process if you get this working - I'm not really following at the moment!

There is a model list in granny viewer that you can right click o go detail view and then see the skeleton hierarcy and bone position

there is also a mesh list tab in granny viewer that has a list of cels. if you click the pictures in the cells you can make the mesh invisible or visible (they start as all visible as default). This is how you can view the different meshes in a gr2.


Once I finish the testing of the wonder I'll create a tutorial of how to make a Wonder Template and how to export it.
 
If it's useful here, I've decompiled a more recent version of NexusBuddy.

Also, is it now possible to rig different skeletons to existing animations? I'd have particular use for being able to have a normal biped unit being able to attack using the flaming boulders from catapults/trebuchets attacking cities. I think it would look quite convincingly like a magical attack for some good fantasy mods!
 
Also, is it now possible to rig different skeletons to existing animations? I'd have particular use for being able to have a normal biped unit being able to attack using the flaming boulders from catapults/trebuchets attacking cities. I think it would look quite convincingly like a magical attack for some good fantasy mods!

It would certainly look better than this:
Spoiler :
attachment.php
 
It would certainly look better than this:
Spoiler :
attachment.php

You don't need to modify any skeleton at all to change effects. It should be easy to change the nuclear bomber to a regular bomber or regular catapult to a flaming one by changing the effects in the fxsxml file and corresponding FX_triggers file. The gr2 files only change the models and animations. The sounds and FX's used are all linked in simple text. Super easy to change. That's how I was able to make a tank sound and shoot like the mech infantry with my recent Russian BMP-2.

I'm not sure but it should also be possible to give mele units a ranged attack. All units have some kind of ranged attack for attacking cities - you could make the swordsman throw a flaming object as their main attack by simply changing which event codes go to which gr2 animation file in the fxsxml file for that unit. I haven't tried this but I know when making my one units I'm able to mix and match animations no problem.
 
ok...this is what I did, using the machine gunner as example....

...

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....

...

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: !!!!

Your process works perfectly for the Lancer as well. Nice!

attachment.php


I think the trick is to group the meshes in the same way that they are in the original vanilla gr2 - you can check this in GrannyViewer. So because the Lancer is two meshes in the original - one for the horse and one for rider/lance/sword this is how I grouped the meshes after following your process.

I'm going to try this for the Egyptian War Chariot. If it works for something with two humans, two horses and other bits then we're really in business and I can look into Blender scripting for your process.
 

Attachments

  • lancer.jpg
    lancer.jpg
    21.5 KB · Views: 526
in regards to LH, the haile selassie creates an smd file, but txt to blender wont import the skeleton...

I discovered that if export from Milkshape3D as an Unreal/UT PSK file and you can successfully import the skeleton into Blender 2.66. You have to enable Import/Export Unreal Skeleton Mesh in User Preferences - Addons.

attachment.php


Export to GR2 is a bit messed up but the mesh (albeit without a head) and the skeleton are still there. We have fixed these types of problems for units already.

attachment.php


The via-ASCII TXT method gives a mesh with the UV mappings intact (unlike the Unreal export) with will probably be useful seeing as we would need to texture the model by hand since the LH textures are inaccessible.

attachment.php


If we brought all that together somehow it might be possible to get a working custom leaderhead. Anyway, I'm focusing on units for now - but can return to this at some point if someone else hasn't had any progress.

Edit: Turns out the reason why the SMD->TXT->Blender method wasn't working for Selassie was that there is a limit hardcoded in the TXT import script:

Code:
def import_ms3d_ascii(path):
	# limits
	MAX_NUMMESHES = 1000
	MAX_NUMVERTS = 100000
	MAX_NUMNORMALS = 100000
	MAX_NUMTRIS = 100000
	MAX_NUMMATS = 16
	[COLOR="Red"]MAX_NUMBONES = 100[/COLOR]
	MAX_NUMPOSKEYS = 1000

Changing this line to MAX_NUMBONES = 1000 allows both Selassie and the War Chariot which both have > 100 bones to be imported with skeletons and meshes. This is good because the Unreal way wouldn't have included my bone rotation fix. :)

Selassie Scissorhands:
attachment.php
 

Attachments

  • selassie.jpg
    selassie.jpg
    27.4 KB · Views: 473
  • selassie_granny.jpg
    selassie_granny.jpg
    64.6 KB · Views: 589
  • selassie_uv.jpg
    selassie_uv.jpg
    139.5 KB · Views: 531
  • selassie-txt-249.jpg
    selassie-txt-249.jpg
    47.4 KB · Views: 513
Also, is it now possible to rig different skeletons to existing animations? I'd have particular use for being able to have a normal biped unit being able to attack using the flaming boulders from catapults/trebuchets attacking cities. I think it would look quite convincingly like a magical attack for some good fantasy mods!

As has been said having units generate effects is separate from the 3D modelling side. If you actually want a unit to actively throw a fireball then we would need either need to use a vanilla animation where the unit has a throwing attack. The only throw animation I know of in Civ 5 is the Atlatist. In Civ 4 this Fire Mage uses the Grenadier animation, so another option might be to port those animations.
 
Back
Top Bottom