Author Topic: ff9 bone structure  (Read 9728 times)

tasior

  • Guest
ff9 bone structure
« on: 2011-04-15 00:14:39 »
I played with models ff9. Loading models and textures is no problem. As shown in the accompanying pictures. Everything worked fine until I wanted to attach the bone. I'm loading structure as is described in the documentation on the wiki. The first thing I wanted to do is display a bone structure. And this is what I get:

The second picture is the same bone structure, just rotated. Could be considered part of the legs but the rest is not suitable for anything.
These bones belong to the model of Steiner (38 from db folder 7). Here's bone structure:

Magic: 0x0000
Bones count: 28
Groups count: 3
Bytes: 14080
Id 1: 20
Id 2: 603
Id 3: 272
Bone pointer: 0x14
Group pointer: 0x84

ID Parent_ID LENGTH
0 0 65521
1 0 0
2 1 48
3 2 41
4 3 80
5 4 88
6 1 48
7 6 41
8 7 80
9 8 88
10 0 0
11 10 121
12 11 50
13 12 46
14 13 98
15 14 71
16 15 50
17 13 98
18 11 50
19 10 121
20 19 21
21 10 121
22 21 50
23 22 46
24 23 98
25 24 71
26 23 98
27 21 50

First frame of the animation (angles in degrees):
BONE_ID PITCH YAW ROLL
0 200,4396 67,16483 194,2857
1 358,8571 270,1538 287,2967
2 359,5604 270,9451 360
3 46,76923 59,95604 55,2967
4 64,7033 0 0
5 314,5494 19,34066 359,1209
6 359,5604 89,14286 0
7 21,45055 334,7692 290,989
8 53,71429 0 0
9 5,362638 357,3626 5,978022
10 92,30769 309,8901 11,95604
11 214,6813 83,69231 22,41758
12 347,0769 343,5604 2,989011
13 16,96703 10,54945 53,97802
14 244,2198 33,31868 359,1209
15 359,5604 358,9451 26,9011
16 270,1538 0 0
17 38,32967 0 0
18 174,4176 66,54945 360
19 26,9011 0 0
20 348,4835 21,53846 47,82418
21 214,6813 276,3956 358,6813
22 330,9011 358,6813 359,9121
23 291,6044 347,5165 16,43956
24 292,3077 359,033 359,3846
25 1,934066 35,25275 14,94506
26 54,41758 0 0
27 305,3187 70,59341 291,7802

The first thing that draws attention is that the first bone length is 65521. It's non error reading file. I look into hex editor end there is this value. But i assume that is root bone and length is always 0. A second is structure. In the post http://forums.qhimm.com/index.php?topic=8781.0 Chev has a completely different structure for Steiners bones. It is possible that is a different model but I checked a lot of them and nearly all have very similar structure to this one.
I uses OpenGL to display. I use this function:

void boneDraw (Bone * root)
 {
 glPushMatrix ();

 glRotatef (root-> roll, 0.0, 0.0, 1.0);
 glRotatef (root-> yaw, 0.0, 1.0, 0.0);
 glRotatef (root-> pitch, 1.0, 0.0, 0.0);

 glBegin (GL_LINES);

 glColor3f (1.0, 0.0, 0.0);
 glVertex2f (0, 0);
 glColor3f (0.0, 1.0, 0.0);
 glVertex2f (root-> length, 0);

 glEnd ();

 glTranslatef (root-> length, 0.0, 0.0);

 for (int i = 0; i <root-> childCount; i + +)
 boneDraw (root-> child );

 glPopMatrix ();
 }

What I'm doing wrong?

Sorry for my English.



Urls to bigger images:
http://vjiatrs.w.interia.pl/ff9/bone.jpg
http://vjiatrs.w.interia.pl/ff9/bone_rot.jpg
http://vjiatrs.w.interia.pl/ff9/steiner.jpg
http://vjiatrs.w.interia.pl/ff9/weapon.jpg
http://vjiatrs.w.interia.pl/ff9/weapon1.jpg
http://vjiatrs.w.interia.pl/ff9/monster.jpg

Chev

  • *
  • Posts: 35
    • View Profile
Re: ff9 bone structure
« Reply #1 on: 2011-04-17 08:21:28 »
Root bone length is indeed irrelevant. Your bone structure is right. Even though it may not intuitively look like the same skeleton as mine when it's unfolded like that, it is, down to the very byte. It'll make more sense once you solve your angle problem.

For the animation I have different numbers, but that's probably because I am looking at a different anim. Hopefully what you need to correct i exactly what I did back then, the transformation order. In XNA it was yaw*pitch*roll*translation(0,0,bonelength) *parentTransform, so if my basic opengl isn't too bad it should be the reverse, and probably with a translation axes switched around. So something like:

glPushMatrix ();

glTranslatef (root-> length, 0.0, 0.0);
glRotatef (root-> roll, 0.0, 0.0, 1.0);
glRotatef (root-> pitch, 1.0, 0.0, 0.0);
glRotatef (root-> yaw, 0.0, 1.0, 0.0);

More or less. Basically translate first and switch the angles/coords around, and it'sprobably not gonna make sense visuall until you hit just the right order.

tasior

  • Guest
Re: ff9 bone structure
« Reply #2 on: 2011-04-17 13:11:15 »
Alright! Thanks for your reply. I was hoping that it'll be from you. Your multiply order helped me a lot. It should be first translate and then rotate. There was one more mistake in my function. I draw bone after translation and rotation instead before.So this is proper function is:
Code: [Select]
void DrawBone(Bone *root)
        {
            glPushMatrix();
            {               

                glBegin(GL_LINES);
                {
                    glColor3f(1, 0, 0);
                    glVertex3f(0, 0, 0);

                    glColor3f(0, 1, 0);
                    glVertex3f(0, 0, root->length);
                }
                glEnd();

                glTranslatef(0, 0, root->length);
                glRotatef(root->roll, 0, 0, 1);
                Gl.glRotatef(root->yaw, 0, 1, 0);
                Gl.glRotatef(root->pitch, 1, 0, 0);
                 
                for (int i = 0; i < root->childCount; i ++)
                    boneDraw (root->child[i] );

            }
            glPopMatrix();
        }
And now It look's perfect:):):):)


Thank you one more time!

Chev

  • *
  • Posts: 35
    • View Profile
Re: ff9 bone structure
« Reply #3 on: 2011-04-17 15:03:05 »
Good work!

obesebear

  • *
  • Posts: 1389
    • View Profile
Re: ff9 bone structure
« Reply #4 on: 2011-04-18 04:15:50 »
Very impressive! Have you figured out all of the models then?

tasior

  • Guest
Re: ff9 bone structure
« Reply #5 on: 2011-04-18 08:26:37 »
I have models from:
dir 7 - Monster Data
dir 8 - Weapon Data (simplest, no animation)
dir 10 - party members Data

Now thanks to Chev I have animation also. Dir 10 contains battle models and those that you can walk. Second one have only 5 animations and battle models textures are placed in the same tpage as weapon textures. Next I want to get models from dir 4(Field models) but I have to deal with tim textures because they 16bit with clut in another file.
In the end I want to create application that can view (and maybe export) all models from FF9.img, now I'm working on extracted files because it's simpler to analyse them.

In far planes I want have more options in application, like dialogs viewing.

Chev

  • *
  • Posts: 35
    • View Profile
Re: ff9 bone structure
« Reply #6 on: 2011-04-18 19:49:30 »
Personnally I never figured out where the textures for dir 4 or dir 3 (map models) are, but then again I didn't have a good way to browse the directories.

tasior

  • Guest
Re: ff9 bone structure
« Reply #7 on: 2011-04-18 23:38:51 »
Actually with all this stuff that is posted on this forum (and wiki) is pretty simple to analyze ff9 data. Of course, many things still have to be done (scenario, text, camera setting, texture animations...). But with information from you Chev, Zande and Zidane_2 this is much simper. E.g. Battle scene viewer source code from Zidane_2, release me that 16bit tim could have clut in another file. Psx development kit is also very helpful (structures and file headers), especially with tim(s) but with out all this informations from you it was useful.

So now I just have to analyze and write some code:) Wish me luck, I'll post all my progress.

BBug

  • Guest
Re: ff9 bone structure
« Reply #8 on: 2011-07-19 18:54:10 »
chev, will you release a beta of your software? or will there any release anytime soon?

Wally Kliskey

  • Guest
Re: ff9 bone structure
« Reply #9 on: 2011-07-21 01:06:23 »
That's very good and impressive models. I'm totally shocked. I also want to to learn to male it myself!

Chev

  • *
  • Posts: 35
    • View Profile
Re: ff9 bone structure
« Reply #10 on: 2011-07-23 11:25:24 »
chev, will you release a beta of your software? or will there any release anytime soon?
There won't be any anytime soon. There's tons of things to clean up, it has little to no interface and you need to recompile it to change directories. Plus it's really part of a bigger, unrelated program so it'd have to be isolated first, not to mention it's been two years since I made it so there's bit I'd have to rewrite just to understand them. And I don't have much time for personal programming nowadays, so I'm not really considering it.

Plus, well, the specs are known and available, so it's not like nobody can just do what I did. It took me one week full time to make it and half of it was figuring out what I'd read wrong, so I encourage others to do the same.  :)

dragicorn

  • Guest
Re: ff9 bone structure
« Reply #11 on: 2011-12-15 01:21:27 »
This is your only most recent post and pming you is out of the question (blocked).

Is there any model viewer available to view the FF9 models with texture and animations? Chev? A few questions too, perhaps. Did you actually lose your Model Viewer? Did you ever manage to recover it? What's this 'larger project?'

PSX, games, or any emulator won't work on my pc, and no one has figured out how to trouble shoot it, PCs and Laptops come pricy these days, and I'm sorta on the poorer end of class, so this PC is all I got (thanks to a friend). So I'm reduced to using model viewers and such :S. It's cool though.

Chev

  • *
  • Posts: 35
    • View Profile
Re: ff9 bone structure
« Reply #12 on: 2011-12-16 19:47:53 »
Noesis works fine with FF9 models, there's a plugin for it, IIRC it now does everything my viewer used to do.
I haven't lost my viewer, time was the resource I started to lack, it still works as it used to, with a few extra little things (partial crappy support for map models) and slightly cleaner code.
The larger project is completely unrelated to FF or game model viewing, it's just convenient to reuse it for viewers because it has all the 3D and UI stuff already set up.
« Last Edit: 2011-12-16 19:50:27 by Chev »