Bully-Board

Bully Modding Section => Bully Modding => Bully Modding Archives => Topic started by: gtafan on March 09, 2015, 08:36:24 AM

Title: COL format
Post by: gtafan on March 09, 2015, 08:36:24 AM
I was looking through bully col file and try to understand how they worck. There are some similarities with GTA col formats but also some diferences. I am going to present some results of my researches here. I´ll use C/C++ syntax for data formats.
The file can be divided in FileHeader and Data, while Data can also be divided in DataHeader and DataBody.

struct FileHeader {
        char signature[4];
        unsigned int size;
}

-signature: specifies the version and known values are: "COLL", "COL2" and "COL3"
-size: containes the size of Data in bytes.

Here goes the DataHeader:

If version>1 unsigned short flags[2];

-flags[0]: known values are: 0x2 for "COL2" and 0x3 or 0x4 for "COL3"
-flags[1]: known values are: 0x0 for "COL2" and 0x1 for "COL3"

char name[20];
unsigned int id;

-name: every of the  20 bytes are 0x0
-id: the id of the collision model

-posibly bounding objects: 48 byte divided into 2 blocs first 16 byte posible bounding sphere and second 32 byte posible bounding box

the bounding box use the Box datatype that could look like that:

struct Box {
float min[3]
unsigned int minZero
float max[3]
unsigned int maxZero
char surface[4];
}

-min and max: could contain the position of min and max
-minZero and maxZero: always 0x0
-surface: containes the values for material, flag, brightness and light

Here goes the DataBody:

This part is stil incomplete and a lot of stuff is just aligations based on GTA col format. The  structs I was able to recognise are Sphere, Vertex and Face:

struct Sphere {
        float values[4];
        char surface[4];
}

-values: radius and (x,y,z) position of center of the sphere
-surface: containes the values for material, flag, brightness and light

struct Vertex {
short values[3];
}

-values: vertices used for the faces. short type is used to reduce used memory, the real values of a vertex can be calculated by dividing through 128.f

struct Face {
       unsigned short vertices[3];
       unsigned char material;
       unsigned char light;
}

-vertices: IDs of vertices from the Face(triangle)

The structure of DataBody look like:

unsigned int numSpheres;
Sphere spheres[];
unsigned int unk;
unsigned int numBoxes;
Box boxes[];
unsigned int numVertices;
Vertex vertices[];
if(numVertices%2) short pading;
unsigned int numFaces;
Face faces[];

-numSpheres: number of Spheres in the array
-spheres[]: the array of Spheres with size numSpheres
-unk: always 0x0
-numBoxes: number of Boxes
-boxes: the array of Boxes with size numBoxes
-numVertices: number of Vertices in the array
-vertices: the array of Vertices with size numVertices
-pading: always 0x0
-numFaces: number of Faces in the array
-faces: the array of Faces with size numFaces

the rest is stil to be discovered, but it look something like:

unsigned int unknownValue;
Box box;
unsigned int numUnknownStructs;
UnknownStruct unknownStructs[];

-unknownValue: no idea what it good for but known values are: 0xEF5DCB33
-box: another posible Box (quite shure it´s some kind of FaceGroup for all faces)
-numUnknownStructs: number of UnknownStructs in the array
-unknownStructs[]: the array of UnknownStructs with size numUnknownStructs (seems to be in some way related to FaceGroups


struct UnknownStruct{
void unknown[8]
unsigned short start;
unsigned short end;
}

I have realy no idea how the 8 Byte from unknown can be interpreted.
Title: Re: COL format
Post by: AfterLife on March 10, 2015, 06:20:36 AM
I don't really understand... But good find.
Title: Re: COL format
Post by: gtafan on March 10, 2015, 09:40:10 AM
I don't really understand... But good find.
Like I said, C/C++ syntax is used, that requires some programming knowledge.

I just wrote a tool that reads the sphere section from Bully col file and export it into cst file. The cst file can than being read by GTA colleditor2.
Title: Re: COL format
Post by: deadpoolXYZ on March 10, 2015, 11:13:04 AM
What does the col files exactly do? I found them in stream.img so I suppose they are related to textures or models.
Title: Re: COL format
Post by: gtafan on March 11, 2015, 08:09:43 AM
What does the col files exactly do? I found them in stream.img so I suppose they are related to textures or models.
They are related to models in some way, they contain the collision data for the model.
Title: Re: COL format
Post by: Mick3Mouse on March 11, 2015, 08:14:22 AM
This is collision data for all things in the game.
Title: Re: COL format
Post by: Mick3Mouse on March 11, 2015, 08:15:55 AM
http://filext.com/file-extension/COL (http://filext.com/file-extension/COL)
Title: Re: COL format
Post by: GreenOmnitrix on March 11, 2015, 10:42:57 AM
I believe the .COL files are related to some sort of collision file. In World.img there are.col files for the nerds glasses, and I think it's when you punch the nerds and their glasses go flying off.
Title: Re: COL format
Post by: Mick3Mouse on March 11, 2015, 11:40:24 AM
yeah duh.....


i just fucking told them you fucking parrot


fuck you go and die


*allah akbar!!!*


*explosion*
Title: Re: COL format
Post by: DaBOSS54320 on March 11, 2015, 12:06:26 PM
Collision fellas, preventing you from walking through shit and crashing cars.

The col files would define what parts of models are "solid" in a way.
Title: Re: COL format
Post by: gtafan on March 11, 2015, 12:12:06 PM
I believe the .COL files are related to some sort of collision file. In World.img there are.col files for the nerds glasses, and I think it's when you punch the nerds and their glasses go flying off.
http://www.gtamodding.com/index.php?title=Collision_File (http://www.gtamodding.com/index.php?title=Collision_File)
The structure of the file has some changes, but the datastrucktures, at least the really important ones, are still the same.
I have writen a tool, that extracts the collision model from a col file and convert it into CST format, that can be read by gta colleditor. If somebody is interested, I can post the tool with its sorces later.
Title: Re: COL format
Post by: deadpoolXYZ on March 11, 2015, 02:28:42 PM
Possibly going off topic here but is there a way to load the .col files with lua? Most of the thigs I spawn with createpersistententity doesn't seem to have collision, for example the auditorium.

Then there are some props like the scaffold which seems to already spawn with collision.
Title: Re: COL format
Post by: DaBOSS54320 on March 11, 2015, 05:55:04 PM
I've never used that function but 2 ideas. Maybe 1, it's another function that spawns with collision, or 2, maybe it's another argument you have to pass to the function that's bool (true/false) for if it has collisions.
Title: Re: COL format
Post by: gtafan on March 12, 2015, 10:50:50 AM
The tool has still some bugs, I can´t understand, but here some pics of collision models from some vehicles:

70wagon
(http://i63.fastpic.ru/thumb/2015/0312/d6/c514cc33d3f2a26d806ee6ed3c63f0d6.jpeg) (http://fastpic.ru/view/63/2015/0312/c514cc33d3f2a26d806ee6ed3c63f0d6.jpg.html)

truck
(http://i57.fastpic.ru/thumb/2015/0312/c6/cbd302dd8348782e00da31541ce10ac6.jpeg) (http://fastpic.ru/view/57/2015/0312/cbd302dd8348782e00da31541ce10ac6.jpg.html)

policecar
(http://i57.fastpic.ru/thumb/2015/0312/b2/e1d025a7638ec6ffe860818d45a472b2.jpeg) (http://fastpic.ru/view/57/2015/0312/e1d025a7638ec6ffe860818d45a472b2.jpg.html)
Title: Re: COL format
Post by: GreenOmnitrix on March 13, 2015, 02:03:54 AM
The tool has still some bugs, I can´t understand, but here some pics of collision models from some vehicles:

70wagon
(http://i63.fastpic.ru/thumb/2015/0312/d6/c514cc33d3f2a26d806ee6ed3c63f0d6.jpeg) (http://fastpic.ru/view/63/2015/0312/c514cc33d3f2a26d806ee6ed3c63f0d6.jpg.html)

truck
(http://i57.fastpic.ru/thumb/2015/0312/c6/cbd302dd8348782e00da31541ce10ac6.jpeg) (http://fastpic.ru/view/57/2015/0312/cbd302dd8348782e00da31541ce10ac6.jpg.html)

policecar
(http://i57.fastpic.ru/thumb/2015/0312/b2/e1d025a7638ec6ffe860818d45a472b2.jpeg) (http://fastpic.ru/view/57/2015/0312/e1d025a7638ec6ffe860818d45a472b2.jpg.html)

Nicely done.
Title: Re: COL format
Post by: gtafan on March 13, 2015, 07:34:59 AM

Nicely done.
Thanks, but unfortunatelly the tool is still not worcking properly and produces sometimes some wired exceptions, I can´t understand. Once this is fixed, I´ll publish the first beta here.
Title: Re: COL format
Post by: gtafan on March 17, 2015, 09:52:23 AM
So I have finally finish my tool that converts Bully col files to cst ones. The tool can be downloaded here: http://dfiles.eu/files/3efsjzdxe (http://dfiles.eu/files/3efsjzdxe)
The cst files can be opened with any tex editor. Collision File Editor II can also open the cst files and view the model. Collision File Editor II can be downloaded here: http://www.gtagarage.com/mods/show.php?id=1154 (http://www.gtagarage.com/mods/show.php?id=1154)
Title: Re: COL format
Post by: Al Arlington on March 19, 2015, 08:27:08 PM
So would this mean one could convert Bully's collison's to GTA SA/VC/III?

Title: Re: COL format
Post by: gtafan on March 20, 2015, 08:48:23 AM
So would this mean one could convert Bully's collison's to GTA SA/VC/III?
Yes, you just need first to convert Bully's collison's to CST using my tool, and than open the CST with colleditor. The coleditor can save it than as SA/VC/III collison's.
I am also worcking on a tool that should be able to read most R* 3D era formats (GTA SA/VC/III, Manhunt 1/2 and Bully) and save GTA SA/VC/III and Manhunt 1/2 formats. I don´t think this tool be finished soon. One of the reasons is, MINGW su**s.
Title: Re: COL format
Post by: MadmaN on June 30, 2015, 03:05:14 AM
MINGW is a pain in the butt. That I can personally attest to. But this is just due to it being a bit different then other programming ide's.

C# (c sharp) is my favorite language for coding apps and the like. I also have used many others too so...pretty familier with most languages. Tho I have been slowly walking away from all coding for some time now due to being just burnt out on programming in general due to doing this for too many years now.

I may be able to provide some assistance with a few things and possibly if you are game....pick your brain a little bit. It won't hurt me a bit...I promise!

I was planning at one time to do this as well but got put way too behind on a lot of things due to taking on way too much on my own and well...I paid the price for that one...rofl.
Title: Re: COL format
Post by: gtafan on April 14, 2016, 06:58:32 AM
So here a tool with GUI converting Bully colls to GTA ones: http://depositfiles.com/files/g7clb8asw (http://depositfiles.com/files/g7clb8asw)