View Single Post
Old 01-05-2004, 01:38 AM   #9
The Devanstator
Rookie
 
The Devanstator's Avatar
 
Join Date: Dec 2003
Location: British Columbia
Posts: 27
That's great, Phelon, here's what I've learned. Once I had a clear look at these files, it took very little time to derive the following:

==============================================
-Files extracted from an erf have a 128-byte header.

-At offset 8 is an unsigned short for width

-At offset 10 is an unsigned short for height

-Immediately following the header is the image data

-Byte order is left to right, bottom to top

-32 bits for a pixel (Red,Green,Blue,Intensity)

-Image data ends at offset = (x*y*4)+128

-The file footer is some number of strings like "mipmap 0", which must be discarded

==============================================
-The Targa files have an 18-byte header.

-At offset 12 is a short for x-dimension

-At offset 14 is the short for y-dimension

-Immediately following the header is the image data

-Byte order is left to right, bottom to top

-32 bits for a pixel (Blue,Green,Red,Intensity)

-Image data ends at offset = (x*y*4)+18

-The file footer is unimportant info followed by "TRUEVISION-XFILE"

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOW TO CONVERT FROM ERF-EXTRACTED FILES TO TARGA

-Create new targa file and place first bytes as "000002000000000000000000"

-Get 4 bytes from other file at offsets 12-16 and put in tga file

-Place "2008" to complete the header

-Read each set of 4 bytes from file and switch byte 1 with byte 3 then place it in the tga

-Keep doing this until your read point is at offset = (x*y*4)+128

-Add "000000000000000054525545564953494F4E2D5846494C452 E00" for the footer

-Save file and you are done.

------------------------------------------------------------------------------------

I have just started writing a program to do this and since I still have all my low-level c functions handy I can borrow them from Kotor Mod Utility. Within 48 (I hope) hours skinning in Kotor will be no harder than any other game.
The Devanstator is offline   you may: quote & reply,