Quantcast

Jump to content

» «
Photo

[Q/P] ifp file format

12 replies to this topic
Beholder
  • Beholder

    Mustard Tiger

  • Members
  • Joined: 17 May 2005

#1

Posted 08 January 2008 - 10:16 AM

I've been searching all over the place and can't seem to find any info on the ifp file format. sad.gif I would really appreciate it if somebody can point in the right direction.

Thanks a bunch!
-Beholder

REspawn
  • REspawn

    REgent

  • Members
  • Joined: 06 Jul 2002

#2

Posted 08 January 2008 - 10:42 AM

yea, Hollower wrote up a txt doc before that I have reposted below, its old so dont know how much of it is true for SA.

CODE

=================================================================
IFP file format for Grand Theft Auto III and Vice City animation
   Written by Hollower ([email protected])
=================================================================
(updated Jan 2004)

This file is intended for programmers only.

First column is the number of bytes. V means that the length varies.
Second column is the suggested data type (C/C++).
Third column is a brief description of the data.
Strings are padded to 4-byte alignment.

This is how I broke up the file for reading in. The section markers
indicate the more "correct" way, but I used this simpler grouping
(ie. why worry about the parent section of "INFO" blocks when they
should always be in this order anyway), and I used the section markers
for error checking. Using my grouping also makes it easier to output
an IFP file that is valid for GTA3/GTA:VC. This may change in future
GTA games.


IFP FILE HEADER
----------------
4       (char[4])       "ANPK" --- section marker
4       (int)           Offset to end of file
4       (char[4])       "INFO" --- section marker
4       (int)           Offset to end of header
4       (int)           Number of anims
V       (char[V])       Internal file name (null terminated string)

ANIMATION INFO
----------------
4       (char[4])       "NAME" --- section marker
4       (int)           Length of anim name string
V       (char[V])       Anim name (null terminated string)
4       (char[4])       "DGAN" --- section marker
4       (int)           Offset to end of animation
4       (char[4])       "INFO" --- section marker
4       (int)           Offset to first object (usually 8)
4       (int)           Number of objects
4       (int)           NULL

OBJECT INFO
----------------
4       (char[4])       "CPAN" --- section marker
4       (int)           Offset to end of object
4       (char[4])       "ANIM" --- section marker
4       (int)           Offset to frame info (usually 48)
28      (char[28])      Object name (null terminated string, padded to 28 bytes)
4       (int)           Number of frames
4       (int)           NULL
4       (int)           Index of last frame (Number of frames - 1)
4       (int)           Index of next sibling (-1 if none)
4       (int)           Index of previous sibling (-1 if none)

FRAME INFO
----------------
4       (char[4])       Frame type (see below)
4       (int)           Length of frame data

FRAME DATA
----------------
Frame data is all floats. Structure depends on frame type.

Frame types:

"KRT0"  Root    quaternion rotation (float x,y,z,w),
               vector translation (float x,y,z),
               time (float seconds)

"KR00"  Child   rotation, time

"KRTS"  Scaled  rotation, translation, scale (float x,y,z), time


Root frames contain extra data for translating the model in the
world. Child frames are simply rotations, concatenated as they
go up the hierarchy.

You can probably guess, the letters here stand for
(K)eyframe, (R)otation, (T)ranslation, (S)cale, (0)None
so presumably there could also be other combinations like "K0T0" but
the above are the only ones found in all of the files I studied.


Notes
----------------

Overall file structure looks like this:

Header
 |
 +-Animation
 |    |
 |    +-Object
 |    |   |
 |    |   +-Frame
 |    |   +-Frame
 |    |   +-Frame
 |    |   +- ...
 |    |
 |    +-Object
 |    |   |
 |    |   +-Frame
 |    |   +-Frame
 |    |   +-Frame
 |    |   +- ...
 |    |
 |    +- ...
 |
 +-Animation
 |    |
 |    +-Object
 |    |   |

...and so on.

Object names are a reference to the DFF mesh or bone
which will be rotated with the frame data. The string
is not case sensitive.

An animation does not need to reference every part of a
model, only the ones that will move. They also do not
require an equal number of frames or matching time index.

There are sometimes anomalies like anims with 0 objects
or objects with 0 frames.

For reference, the base pose can be viewed by creating
animations with Rotation = {0.0f, 0.0f, 0.0f, 1.0f}.



I hope this file has been helpful. Now let's see some editors!

- Hollower


Beholder
  • Beholder

    Mustard Tiger

  • Members
  • Joined: 17 May 2005

#3

Posted 08 January 2008 - 11:28 AM

Wow, should be interesting. Thanks REspawn! colgate.gif

Would it be possible to add it to the file formats sticky? It seems to have most everything else but this.

Thanks again.

-Beholder

REspawn
  • REspawn

    REgent

  • Members
  • Joined: 06 Jul 2002

#4

Posted 08 January 2008 - 02:14 PM

No worries, yea must really get back to finishing that list notify.gif

steve-m
  • steve-m

  • Members
  • Joined: 26 Jul 2002

#5

Posted 09 January 2008 - 12:53 PM

The file format for SA is different though (four character code is "ANP3"), but I don't think that's documented anywhere either. If you desperately need it, I could try to assemble a format doc from some old code I once wrote. But aren't there import/export scripts for 3dsmax that allow editing .ifp files? I guess their authors could help you out as well.

Beholder
  • Beholder

    Mustard Tiger

  • Members
  • Joined: 17 May 2005

#6

Posted 10 January 2008 - 05:25 AM

steve-m,

I guess it would it depend on how different SA is from VC. At quick glance it looks as though the section markers aren't in SA's ped.ifp, as well as the frame types. Also, there is a reference to studio max in the first animation, abseil. I'm not usually much when it comes to cracking file formats, but I have a pretty decent base to work from and can take a crack at it (no pun intended). If I get stuck I'll try to seek one of those 3ds authors and if that doesn't go anywhere I'll just post back here and cry myself to sleep.

For anybody else that plans to use the doc posted here, I would like to mention that as far as VC's ped.ifp file is concerned, in the object infp section, the NULL int following the number of frames should not be read/written if the offset to frame info is 44, as opposed to if the offset is 48. monocle.gif

Thanks REspawn and steve-m, you guys rock!

-Beholder

AK-73
  • AK-73

    Hustler

  • Members
  • Joined: 31 Oct 2005

#7

Posted 10 January 2008 - 07:08 PM

If you're concerned with animations in Vice, I'd like you to refer you to two mods of mine:

First my ifp suite which is open source and which enables exporting directly into the (VC) .ifp from gmax. It does contain a bug though which I can't fix because I can't upload files onto gtagarage. (Anybody knows when this is going to change?) But the exporter is open source, so depending on what you want to do, it might help.

Secondly my GTA:MA mod which allows adding new animations as a side-benefit. I have even added new animations from SA into VC with it. Just ask ceedj. wink.gif

Anyway, I don't know the SA file format but I am fairly well-acquainted with the VC .ifps. If you need some help, feel free to pm me.

Now if I could only convince steve-m or some of the other veterans to help me make sense of the rest of the ps2 lcs .mdl file format... wink.gif Wäre richtig gut. wink.gif

Alex

Aschratt
  • Aschratt

    Three Headed Monkey

  • Members
  • Joined: 12 Apr 2006

#8

Posted 12 January 2008 - 01:34 PM Edited by Aschratt, 12 January 2008 - 01:49 PM.

Well... I took a look to the ANP3-Format some moths ago... I haven't realy finished my work on this, cause I thought I can find something out about Cutscenes, and how they work, but then I found out that cutscenes are ANPK-Animations... I posted this stuff to the wiki:
http://www.gtamoddin...?title=Cutscene

There are not many differencies between ANPK and ANP3. Section Markers are removed and sections are more sorted and compressed now (Like the compression in the COL3 - collision-files).

Yesterday I found time to create an txt like hollower did once:

CODE
=================================================================
IFP file format for Grand Theft Auto San Andreas animation
  Written by Aschratt ([email protected])
=================================================================
(updated Jan 2008)

This file is based on the decodings of hollower from 2004.
For more information search GTA Forums.

Binary Structure:

====    Header    ============

4b     - CHAR[4]   - 'ANP3' (Version Identifier String)
4b     - INT32     - Offset to end of file (Relative to stream position pointer, so usually you have to add 8 to get the file's content size)
24b    - CHAR[24]  - File's Internal Name
4b     - INT32     - Number of Animations

====    Animation Info    ====

24b    - CHAR[24]  - Animation Name (!!! String stops with first null-char ('\0'). Everything after this is ignored... R* Put some debug stuff there sometimes (Like 3dsm directorys))
4b     - INT32     - Number of Objects
4b     - INT32     - ?
4b     - INT32     - ?

====    Object Info    ========

24b    - CHAR[24]  - Object Name
4b     - INT32     - ?
4b     - INT32     - Number of Frames
4b     - INT32     - ? (Frame DATA TYPE: KRT0 = 0, KR00 = 1, KRTS = 2)

====    Frame Info    =========

2b     - INT16     - ? (RX)
2b     - INT16     - ? (RY)
2b     - INT16     - ? (RZ)
2b     - INT16     - ? (RW)
2b     - INT16     - ? (TX)
2b     - INT16     - ? (TY)
2b     - INT16     - ? (TZ)
2b     - INT16     - ? (TIME)

Like nearly all new coordinate formats in SA the Animation Packages are compressed.
To get the real-world floating coordinates simply divide the short values with 128!

================================

Notes: I think that there is a constant value in the object-info section which defines
the frame's data type. This means that there are still those data-types like in ANPK.

But I am not sure about this and still have to search some examples and try a little bit
around. Mostly the frame info data type is like the root structure.

These decodings are done by scratch in an hour. I had not much time, but I hope it will
help you for further decodings.

Greetings... Aschratt!

Homepage: [URL=http://www.aschratt.com]http://www.aschratt.com[/URL]
E-Mail:   [email protected]


I hope this helps!

To the cutscene animations:
They are ANPK-Packages, but somehow they got an diffrent structure in some phrases... somehow the sibling numbers are mission sometimes or only one of them exists... sometimes the number of frames is too high and the last frame seems to be removed.
Maybe in SA ANPK is Version 2 and ANP3 Version 3, so that VC-Animations are not longer compatible to SA Animations. But I have to test this (Maybe it is only an mistake of mine).

Greetings... Aschratt!

Beholder
  • Beholder

    Mustard Tiger

  • Members
  • Joined: 17 May 2005

#9

Posted 13 January 2008 - 06:19 PM

Thanks Aschratt!

I haven't looked at the cut scenes stuff but for the SA ped.ifp, you're notes did the job. I think the object structure is a bit backwards though, I believe it should look something like this...

CODE

====    Object Info    ========

24b    - CHAR[24]  - Object Name
4b     - INT32     - ? (Frame DATA TYPE: KRT0 = 4, KR00 = 3, KRTS = 2(?))
4b     - INT32     - Number of Frames
4b     - INT32     - ?


I didn't find any frames that use KRTS. Another thing I'm kinda curious about is that are objects with only 2 frames, and no change in the translation/rotation values. Other than that all is good. I'm moving on to dff files now. smile.gif

Thanks everybody!
-Beholder

steve-m
  • steve-m

  • Members
  • Joined: 26 Jul 2002

#10

Posted 14 January 2008 - 03:27 PM

To convert the transformation data in Frame Info to floats, divide the signed INT16s by the following values:
  • real part of the quaternion (RX, RY, RZ): -4096
  • imaginary part of the quaternion (RW): 4096
  • position vector: 1024
  • time key: 60

Haven't checked those, just looked them up in my old code. Especially the quaternion seems a bit weird, likely I got that wrong.

The third INT32 in Object Info is the Bone ID, it (usually) matches those used in DFF files.

Here is some code I used to map animations to dff frames, might be helpful:
CODE
// Check, which of the animations can be applied to the loaded model
// must do in reverse order, because VC models have 2x "root"!
Animation[i1].AnimObject[i2].ObjFrame := -1;
j := length(DFF.Frame)-1;
while (Animation[i1].AnimObject[i2].ObjFrame = -1) and (j >= 0) do begin
 if (AssignByBoneID and (Animation[i1].AnimObject[i2].BoneID = DFF.Frame[j].BoneID))
 or (not AssignByBoneID and (CompareText(Animation[i1].AnimObject[i2].Name, DFF.Frame[j].Name) = 0))
 then Animation[i1].AnimObject[i2].ObjFrame := j;
 
 dec(j); // j--
end;

(AssignByBoneID is a Boolean for using BoneIDs rather than frame names for matching, preferably for SA models/anims)

derty
  • derty

    My member's custom title is "Solid Snake"

  • BUSTED!
  • Joined: 01 Nov 2007

#11

Posted 14 January 2008 - 03:33 PM

QUOTE (Beholder @ Jan 13 2008, 13:19)
Another thing I'm kinda curious about is that are objects with only 2 frames, and no change in the translation/rotation values.

Maybe these are like the TVs/VCRs, ETC? 2 frames: the static state and the "lifted"/interacted state?
Just a guess, watchin this topic, interesting. Greets Steve.

Aschratt
  • Aschratt

    Three Headed Monkey

  • Members
  • Joined: 12 Apr 2006

#12

Posted 14 January 2008 - 07:50 PM

QUOTE (derty @ Jan 14 2008, 16:33)
QUOTE (Beholder @ Jan 13 2008, 13:19)
Another thing I'm kinda curious about is that are objects with only 2 frames, and no change in the translation/rotation values.

Maybe these are like the TVs/VCRs, ETC? 2 frames: the static state and the "lifted"/interacted state?
Just a guess, watchin this topic, interesting. Greets Steve.

I don't think so...
I think that this is like in cutscene animations... they are only used as "spaceholders". Means: You got one frame at point 0 and one at point X. between those points the animation does nothing.
So you can stop an animation for a certain time (e.g.). In cutscenes this is used very often.

Imagine: the first Cutscene in SA.

It has many animations (The suitcase, CJ, the Stuartess, the Taxi and the taxi Driver.) But how to combine those animations? (There is no info about the time they are loaded).
Easy awnser: All Animations started at the same point. but thos who aren't used until they are in view are stopped for this time span. So for example in the first cutscene the Taxi starts to drive after the suitcase falls into the hole. But the taxi-animation is startet when CJ starts to walk.

To make this more imaginable (if you haven't understand me ^^), simply import the cutscene into 3ds max (KAMs supports them).

Gian_Yagami
  • Gian_Yagami

    Snitch

  • Members
  • Joined: 08 Nov 2011

#13

Posted 19 August 2013 - 06:48 AM

Nice, but is too elusive.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users