Blackfoot Repair (kludge)

Started by tirpider, November 17, 2011, 02:45:16 PM

Previous topic - Next topic
November 17, 2011, 02:45:16 PM Last Edit: November 22, 2011, 01:36:44 PM by tirpider
Blackfoot Repair (kludge)

Blackfoot is the un-intentional appearance of part of the skeleton of a model.
In some cases, it appears on or below the ground, directly between the legs of the character.
Sometimes it is a diamond shape inside the body of the model, and only appears (passing through the body or head,) during animation.

I believe what causes this, is the lack of, or improper FLGS in the skeleton MODL chunk(s).
There may be more to the issue, but this repair will get the blackfoot off the model and the game.

I'm going to ramble about some stuff now, feel free to skip to "Ok. So how do I do that?" to avoid boredom.
Bear with me as I am as good a writer, as I am a programmer. (meh)

First off, What is a MODL chunk?
[spoiler]MODL is a tag inside the msh file that defines geometries, points, and spaces for that model.
There are several types of geometries, and usually many MODL chunks per msh. Each can have it's own skin, shape, and visiblility settings. Those settings are contained in sub tags. To see an example of all these tags, load up a msh in the Starwars Battlefront Viewer and select "Show" then "Debug Window."[/spoiler]

Ok, What does all that mean?
[spoiler]Good question. Some of it is self explanitory, some isn't. I've got a thread on the msh structure [here]http://www.swbfgamers.com/index.php?topic=3905.0. I don't know what most of it means and am learning more about it every day. You don't have to know all about it to interact with it though. (Just like BFBuilder, eh?) Basicly, it's all the settings, geometries, material, camera, translation information, the game needs to render the model.[/spoiler]

What part Fixes blackfoot?
[spoiler]FLGS.
I don't know what setting diferent values for it does. GT has a thread on it and I'll link to it from here.
Browse through a known, good model's debug view in the viewer, and note which models have a FLGS field, and which ones don't.  FLGS will be located after NAME and PRNT, and before TRAN and GEOM.  Almost all the eff_*, bone_*, and root_* MODL chunks have it, while few of the others don't.
Now check the debug view of your model that has blackfoot. I'm almost certain, there are several skeleton pieces (eff_*, bone_*, and root_*) that don't have a FLGS tag.
The fix is to insert a FLGS field into the proper place.[/spoiler]

How will that fix it?
[spoiler]I'm guessing that FLGS has something to do with whether the engine renders a MODL or not. Perhaps it is just a visability setting. An XSI guru can tell you more about that part, cause I don't know.
What I do know is that copyig a FLGS field from a known good model into the skeleton pieces of one with blackfoot, makes the blackfoot go away. So this is more of a kludge than a fix.[/spoiler]

Ok. So how do I do that?
Finally. The meat and bones.

Tools:
Make a work folder containing the following:

       
  • a msh with blackfoot. (You don't need tga's, odf's, or .options's for this, just the msh file)
  • a msh with no blackfoot. (any one from the bfbuilder assets will do)
  • SWBF_MSH_TOOLS_v*.zip

Setup

       
  • Unzip the tools into the folder with the msh's your working with.
  • run MSH2chunks_v*.exe
    This will create a sub directory for each of the msh's in the folder, and fill them with .chunk files.
    (The benefit to breaking the msh up is now you don't have to hunt through the whole msh for every MODL)
  • Open the folder with the chunks of the model with blackfoot.
  • make a new folder in this folder.
    The name isn't important at all, new folder is fine.
  • select all the MODL chunk files with bone_ root_ eff_ sv_ or DummyRoot in thier name.
  • COPY them to the new folder.
    It will seem like all of them, but some should be left out of this. (l_hand, r_hand, helmet, head, pack, ect.)
  • Open the folder you just copied those MODL chunks to and one at a time, open each one with XVI32 and see if it has a FLGS field. Delete the ones that do. (this is why we copied them)
    It will be within the first 100 characters in the file, 12 bytes(spaces) before TRAN.
    At the end of this step you should have a folder with only the pieces that have no FLGS field.
  • Go to the folder with the known good model's chunks and open it's DummyRoot chunk with XVI32.
  • Click once on the "F" in FLGS on the right hand panel.
  • Hold SHIFT and use the cursor keys to move right 11 spaces.
    This will mark the characters red. You should have 12 spaces marked (from the first 'F' to the space just before 'T' in TRAN)
    hit ctrl-c to copy the block to the clipboard.
  • close the DummyRoot chunk and go back to the new folder with all the FLGS-less chunks.
One at a time, open each chunk with XVI32 and do the following:

       
  • Click tools, then Data Inspector. (Make sure the data inspector is visible, we need it)
  • Click on the first 'T' in TRAN and press ctrl-v.
    This will insert the FLGS block and should insert, not overwrite anything.
  • Since we just added 12 bytes to the size of this chunk, we need to adjust its size header acordigly.
    Click once on the 5th space from the begning. (dec. offset 4) It will be the first space after MODL.
  • On the Data Inspector, double click the number after 'longint' to bring up the encode number dialog.
  • Make sure the 'lonint(4 bytes)' option and 'Overwrite at current address' option are selected.
  • Add 12(the size of the FLGS chunk we just inserted) to the number and type it into the number box. (don't copy and paste the number or you'll have to open the good DummyRoot again to get the FLGS chunk back on the clipboard.)
  • Press OK, to overwrite the old size with the new.
  • Save the chunk and open the next one.
Ok, now you have a folder full of 'fixed' MODL chunks.

       
  • Count the files you just fixed.
  • Multiply that times 12.
    That is how many bytes you just added to the model size.
  • Now we need to add that to the HEDR and MSH2 field.
    Go to your blackfoot model's chunk directory and open the first file. (HEDR)
  • Click once on the 5th space from the begning. (dec. offset 4) It will be the first space after HEDR.
  • On the Data inspector, double click the number after 'longint' to bring up the encode number dialog.
  • Make sure the 'lonint(4 bytes)' option and 'Overwrite at current address' option are selected.
  • Add the number from the previous step to the number in the box and press ok and save. (it's ok to copy/paste to and from the calculator now)
  • Do the same for MSH2 (the second file in the directory.)
    The numbers will be different.
Time to put it all back together.

       
  • Copy all those fixed files back into the model's chunk directory. (overwriting the existing ones.)
  • Copy or move the Chunk2MSH tool into this directory and run it.
  • This puts all those pieces back together into a new msh file named "new_msh.msh"

Have a look at it in the MSH Viewer. If nothing shows up, then something is wrong with a size field somewhere. (most likely HEDR or MSH2)

Now rename the file, munge and test the msh in Battlefront.
If Battlefront crashes, then one of the 'fixed' MODL chunks probably didn't need fixing. Make sure you only did the bone_ root_ eff_ ones and not any of the actual geometry ones like 068_MODL_054_l_hand.chunk (note, no root, eff, or bone in it's name.)

Thats's it.
If it's working, rename it appropriatly and add it to your arsenal of assets, and delete the chunk work folder.
If it isn't working, go over the steps again, if it still isnt working, feel free to ask questions.

NOTE
I updated the chunk2MSH tool. If you are using "chunk2MSH_v2.exe" then you don't need to preform the purple steps. The program does it for you.

-edits-[spoiler]
11/22/2011 -marked un-needed steps, due to tool upgrade.
[/spoiler]