Results 1 to 4 of 4

Thread: How do Weapon Graphics Work??

  1. #1

    Default How do Weapon Graphics Work??

    Hello! I'm fiddling around with Ancient Total War and I wanted to create an Egyptian spear unit. However, there are assets in the BIF files that aren't used by any of the units in the game. How do I...well...interpret any of the codes and coordinates involving the weapon and shield files? How does any of that work? Sorry for the rather broad question; if there's a guide for this, please let me know! I am using readbif, for the record!

  2. #2
    Second-hand chariot salesman Senior Member macsen rufus's Avatar
    Join Date
    Dec 2004
    Location
    Ratae Corieltauvorum
    Posts
    2,507

    Default Re: How do Weapon Graphics Work??

    That's a long and involved question, do you have a few weeks?

    I'll try and recall bits from the top of my head, but might have to come back later.

    First off, when working with coordinates of weapons, they apply to positions in the LOW RES version of the BIF. Each weapon is identified by its top left and bottom right corner in the file and they are all defined in the Textures/Men/[BIF plate]/Weapons.txt file

    I'll use an example from the vanilla game, as that's what I've got loaded on this machine (but won't run it.... the other machine does....)

    Look at Textures/Men/Burnous/Weapons.txt and you'll see this:

    Code:
    1,239,64,246,2,1
    145,244,187,247,1,1
    91,248,187,250,3,1
    58,252,187,254,2,1
    208,246,255,254,1,2
    58,252,187,254,3,1
    These are weapons numbered 1 to 6. In each line the entries are x1, y1, x2, y2, length and width. x1 and y1 are the co-ordinates of the top left of the weapon, and I'm sure you're up to speed enough to figure x2 and y2 from that. These are pixel numbers. In ReadBIF if you hover the pointer over tool over the BIF plate (low res, remember) you can read out the pixel coordinates on the right hand panel somewhere. We can forget the length and width for a while, as they scale the weapon (ie an axe can be a hand axe or a big two-hander or a polearm by stretching or squeezing these values; likewise a spear can become a pike.... but I'm getting way ahead of myself here). But you can see weapon 4 and 6 in this list have the same x, y coordinates, but different length/width values. They are basically two different projections drawn from the same image but at different scale.

    Shields are defined in a similar manner, but differently:

    See Textures/Men/Burnous/Shields.txt

    Code:
    189,218,205,254
    115,222,140,247
    Obviously shield 1 and shield 2. These are defined simply by the corners, no length or width, because they are realised differently in BIF.

    When setting the actions in ReadBIF, you have to input the weapons' rear and front coordinates. If the length is given as two in weapons.txt, the weapon will extend beyond the front coordinate to twice the indicated length, so for a spear you generally need to place the 'front' of the weapon at HALF WAY to where you want to extend it to. For weapons like swords the 'rear' coordinate obviously needs to coincide with the hand. Spears usually need to sit behind the hand to look normal.

    Now you might begin to realise how long-winded it is to set up these coordinates. For every angle, in every action, in every one of the twelve plates in the BIF you will need an entry in the actions file.

    My WIFI keeps dropping out so I'll have to split this up....
    Last edited by macsen rufus; 04-27-2022 at 18:20. Reason: dodgy wifi
    ANCIENT: TW

    A mod for Medieval:TW (with VI)

    Discussion forum thread

    Download A Game of Thrones Mod v1.4

  3. #3
    Second-hand chariot salesman Senior Member macsen rufus's Avatar
    Join Date
    Dec 2004
    Location
    Ratae Corieltauvorum
    Posts
    2,507

    Default Re: How do Weapon Graphics Work??

    For purposes of an example, let's look at the MuwahidFoot unit.

    In the .../Burnous/ folder you'll see two files which define the unit's weapon and shield, not surprisingly called MuwahidFoot_W and MuwahidFoot_S. These files contain but a single number, which refers to one of the lines in the Weapons.txt and Shields.txt files, and you'll see MuwahidFoot uses weapon 6 (58,252,187,254,3,1) and shield 1 (189,218,205,254).

    Now comes the nasty bit... how these are rendered in battle. Navigate towards Textures/Men/Items/ and you'll see a list of directories labelled Weapon1 to Weapon8, and Shiield1 to Shield6. Go into Weapon6 and there are all the units which use weapon6 for their respective BIFs, including of course, our exemplum MuwahidFoot.

    Inside that directory you'll get to the files that define things. There is a file for each action the unit can perform - in our case they are charge, die, fight, stand, run and walk. To keep things easy for now, we'll look at the stand.txt:

    Code:
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    Now you see why I chose 'stand': because it reveals the basic structure of the file. There are four sets of twelve entries. The BIF plate contains four different perspectives of the unit, each 45 degrees apart (it reflects these to make up the full 8 perspectives you need to cover all angles, which is why in battle the shields and weapons can be seen shifting to the unit's opposite hands).

    Each set of entries here lists the coordinates of the weapons in the twelve successive plates of the BIF - this is why they are all the same in each set, because when standing, the weapons aren't moving from frame 1 to frame 2 to frame 12.

    The coordinates in this file, eg -3 -25 -3 -5 0 are x1,y1,x2,y2 and draw order. The draw order is either 1 or zero depending on whether the item is in front of the man or behind him, and I can't remember which way round they are right now.

    The coordinates are as I mentioned above, the rear end and the front end of the weapon, and they are expressed as pixels relative to the ORIGIN pixel of the man in the BIF plate, which is generally speaking the spot on the 'ground' between his two feet (we'll let cavalry slip by unmentioned for now....)

    The good news is that ReadBIF can generate these item action files, but you still have to tell ReadBif where you want the weapons and shields.

    I'm running out of time, and you have a lot to absorb, so I'll just finish off for now with the shield file, in our case Textures/Men/Items/Shield1/MuwahidFoot/stand.txt

    Code:
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    10 -38 8 -38 10 -15 8 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    6 -36 11 -36 6 -15 11 -15 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -1 -34 8 -34 -1 -13 8 -13 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1
    -8 -36 0 -36 -8 -12 0 -12 1

    As you'll see, there is the same basic structure, twelve frames for each of four perspectives, and there is the same draw order at the end, because sometimes the weapon might be 'towards' the viewer, sometimes the shield (although I have found it best when doing these to always have the shield rendered towards the viewer for aesthetic reasons - it just looks better...)

    The big difference you'll notice is that there are FOUR sets of coordinates for the shield, defining the position of each corner of the shield (or rather the bounding rectangle which contains the shield on the BIF plate). This allows the shield to be rendered as a 2D object as opposed to the weapon's 1D object. So shields can be foreshortened for different perspectives. Again the coordinates are expressed relative to the origin point of the man on the BIF plate.

    I hope that's enough to get you going, if it hasn't put you off for life When I get more time I'll go into using ReadBIF to generate the shield and weapon positions and explain the ActionsPage files which define the images to call for each unit in its various actions.
    Last edited by macsen rufus; 04-27-2022 at 22:24.
    ANCIENT: TW

    A mod for Medieval:TW (with VI)

    Discussion forum thread

    Download A Game of Thrones Mod v1.4

  4. #4
    Second-hand chariot salesman Senior Member macsen rufus's Avatar
    Join Date
    Dec 2004
    Location
    Ratae Corieltauvorum
    Posts
    2,507

    Default Re: How do Weapon Graphics Work??

    I'm back with the next installment

    First off, to get the weapon and shield editing to actually work, you need ReadBIF 23c which is available on Mediafire

    I'll run you through the basics, because it's not very intuitive until you know....

    Sticking with our example of MuwahidFoot I'll take you as far as changing a weapon setting. First off, use ReadBIF 23c to open up Textures/Men/Burnous.BIF (remember NOT the _H version).

    This is where the ActionPage comes in - on the top of the ReadBIF control panel select 'Special' >> 'Load anime rect' then navigate to /Textures/Men/ActionPages/MuwahidFoot.txt, which is the file that tells the game where to get the images from within the BIF. If you get this right, you should see this:

    Click image for larger version. 

Name:	ReadBIF_tut01.jpg 
Views:	43 
Size:	156.3 KB 
ID:	25416

    The rectangles highlight all the images used by the unit. Don't worry if some seem unused, they will be for other units with different actions (eg swordsmen instead of spearmen). Note that various numbers are posted on each rectangle, they identify each sequence and run through all 12 frames. The little red spot in each seq is the unit origin I referred to above.

    Next click on 'Sort anime seq into actions'; a box will open with the relevant actions shown. As we've been using 'Stand' for our example, I'll stick with that for now, so left click on Stand in the list. This will show four views of Frame 1 of standing still.

    Click image for larger version. 

Name:	ReadBIF_tut02.jpg 
Views:	38 
Size:	152.2 KB 
ID:	25417

    Click on the 'Seq 8' thumbnail, and increase the zoom: once you reach 1:7 then the pixel grid comes up. This can be useful later, and you really need the zoom to see what's what. You should now have this image:

    Click image for larger version. 

Name:	ReadBIF_tut03.jpg 
Views:	37 
Size:	312.7 KB 
ID:	25418

    You are now able to load weapon and shield data from the existing files. Next right click on 'stand' and see the drop down menu which comes up:

    Click image for larger version. 

Name:	ReadBIF_tut04.jpg 
Views:	35 
Size:	181.6 KB 
ID:	25419

    You can either load ALL the data for every action and seq, or just the one you're on. For now we'll just load the one - click on 'Load weapon' and then navigate to Textures/Men/Items/Weapon6/MuwahidFoot/Stand.txt

    Click image for larger version. 

Name:	ReadBIF_tut05.jpg 
Views:	38 
Size:	237.1 KB 
ID:	25420

    You need to look carefully at this, but I have selected 'extend weapon' so the whole spear is shown. Note the red and yellow dots in the spear - these are the coordinates which define its position in the seq. From the post above you might recognize that the first entry -3 -25 -3 -5 0 has been reflected in the boxes beside the image, with the zero being translated as 'Draw item first', ie on the far side of the man.

    However this isn't an ideal image, so we are going to turn the chap around a bit to look at him from the front. To do this, left click on the Seq 11 thumbnail, and he'll now look like this:

    Click image for larger version. 

Name:	ReadBIF_tut06.jpg 
Views:	37 
Size:	231.9 KB 
ID:	25421

    Notice the data in the boxes on the right has changed, matching the coordinates of the last section of the Stand.txt file: 9 -21 10 0 1 with the 1 at the end signifying that the item is now drawn after the man.

    The next thing to explain is the coordinates. As I mentioned above, these give the relative positions of the 'back' of the weapon (the yellow spot) and the 'front' of the weapon (the red spot) in pixels away from the origin. If you untick the 'extend weapon' box, the length between the two spots is all that will show - which is fine for swords, but spears are better visualized when they are extended for obvious reasons. The x coordinates are straightforward in that negative values are to the left of the origin, and positive values to the right. The y coordinates are a little confusing in that negative values are above the origin, and positive values below.

    So now we can have a bit of fun, and waggle the spear a bit. I've changed the figure 10 in the third box to a 7. As this reduces the value the bottom of the spear will move to the left by three pixels.

    Click image for larger version. 

Name:	ReadBIF_tut07.jpg 
Views:	34 
Size:	231.4 KB 
ID:	25422

    And of course the top moves to the right because the other point is unmoved and the whole thing will pivot. All that remains is to save the changes, and we do that by right clicking on 'stand' again and selecting 'Save weapon' from the drop down menu. This will replace the previous ..Weapon6/MuwahidFoot/Stand.txt file. If we open this with Notepad we can see the change:

    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    -3 -25 -3 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    4 -25 4 -5 0
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -23 9 -3 1
    9 -21 7 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    9 -21 10 0 1
    With that we have successfully altered ONE frame of twelve, for one sequence out of four, for ONE action. You can run the ReadBIF timer whilst you're in this editing view so you can check for smoothness of movement. If we were to do this now, the result would show the spear twitching once every twelve frames though only in that one angle of view.

    BUT it does give you all you really need to know to do more, though it can get tedious doing a whole unit. The shields are fundamentally the same except that you have four corners to fix for each frame/seq/action combination. Of course, you will remember to back up any files you intend to alter
    Last edited by macsen rufus; 04-27-2022 at 22:30.
    ANCIENT: TW

    A mod for Medieval:TW (with VI)

    Discussion forum thread

    Download A Game of Thrones Mod v1.4

    Member thankful for this post:

    Ludens 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO