READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Need help Fixing MAXScript Colin Mcrae Rally 04/05 .P3D file

Post questions about game models here, or help out others!
User avatar
zaykho
mega-veteran
mega-veteran
Posts: 212
Joined: Fri Dec 03, 2010 1:20 pm
Location: France
Has thanked: 142 times
Been thanked: 33 times

Re: Need help Fixing MAXScript Colin Mcrae Rally 04/05 .P3D

Post by zaykho » Thu Dec 17, 2015 8:22 am

Tagging this great Thread ! 8D

User avatar
MichaelDarkAngel
mega-veteran
mega-veteran
Posts: 267
Joined: Thu Nov 04, 2010 11:25 pm
Location: Somewhere, out there... But, not quite here...
Has thanked: 133 times
Been thanked: 165 times
Contact:

Re: Need help Fixing MAXScript Colin Mcrae Rally 04/05 .P3D

Post by MichaelDarkAngel » Sat Dec 19, 2015 6:37 pm

In an attempt to create a more complete script I've mapped the format.

Code: Select all

All Offsets are absolute

(1)   FILE HEADER
      -----------
      00000000    CHAR[4]      "CP3D"
      00000004    BYTE[4]      Unknown
      00000008    LONG         Offset to (2) Data Header
	
(2)   DATA HEADER (56 bytes)
      -----------
      00000000    BYTE[4]      Unknown
      00000004    LONG         Offset to (3) Node
      00000008    BYTE[8]      Unknown
      00000016    LONG         End of File Data
      00000020    LONG         Offset to (4) Texture Table
      00000024    LONG         Texture Count
      00000028    BYTE[4]      Unknown
      00000032    LONG         Object Count
      00000036    LONG         Offset to (5) Object Table
      00000040    LONG         Count for Unknown Table below
      00000044    LONG         Offset to (6) Unknown Table
      00000048    BYTE[8]      Unknown

(3)   NODE (336 bytes)
      ----
      00000000    BYTE[64]     Unknown
      00000064    FLOAT[16]    Matrix
      00000128    LONG         Offset to (7) Mesh Object Data
      00000132    LONG         Offset to (3) Node (Parent ???)
      00000136    LONG         Offset to (3) Node (Child Node ???)
      00000140    LONG         Offset to (3) Node (Sub-Child Node ???)
      00000144    BYTE[128]    Unknown
      00000272    FLOAT[4]     Bounding Box Min ???
      00000288    FLOAT[4]     Bounding Box Max ???
      00000304    LONG         Unknown
      00000308    BYTE[12]     Unknown
      00000320    LONG         Unknown
      00000324    LONG         Unknown
      00000328    BYTE[8]      Unknown

(4)   TEXTURE TABLE (4 bytes) (Repeat equal to Texture Count)
      -------------
      00000000    LONG         Offset to Texture Name

(5)   OBJECT TABLE (8 bytes) (Repeat equal to Object Count)
      ------------
      00000000    LONG         Offset to Object Header (see below)
      00000004    LONG         Object Type (0 --  (8) Object Header
                                            1 --  (9) Object Header
                                            3 -- (10) Object Header)

(6)   UNKNOWN TABLE (4 bytes) (Repeat equal to Unknown Count)
      -------------
      00000000    LONG         Unknown

(7)   MESH OBJECT DATA (16 bytes ???)
      ----------------
      00000000    BYTE[4]      Unknown
      00000004    LONG         Offset to (10) Object Header
      00000008    LONG         Unknown
      00000012    LONG         Unknown

(8)   OBJECT HEADER (432 bytes) (Object Type 0)
      -------------
      00000000    BYTE[4]      Unknown
      00000004    LONG         Unknown
      00000008    LONG         Object and Texture Count
      00000012    BYTE[8]      Unknown
      00000020    BYTE[4]      Color Information (r, g, b, a) ???
      00000024    BYTE[280]    Unknown

            OBJECT OFFSETS (64 bytes) (Read as Long equal to Child Count, skip remainder)
            --------------            (These are consequetive)
            00000304    LONG         Offset to (9) Object Header
	
            TEXTURE OFFSETS (64 bytes) (Not sure about this one as the material offsets are not in a straight line.)
            ---------------            (These are not consequetive, leads me to believe their position possibly determines the type of texture map)
            00000368    LONG         Offset to (11) Texture Name
	
(9)   OBJECT HEADER (112 bytes) (Object Type 1)
      -------------
      00000000    BYTE[48]     Unknown
      00000048    FLOAT[16]    Matrix

(10)  OBJECT HEADER (208 bytes) (Object Type 3)
      -------------
      00000000    BYTE[8]      Unknown
      00000008    LONG         Mesh Count
      00000012    LONG         Offset to (12) Mesh Table
      00000016    LONG         Offset to (13) Unknown Table
      00000020    BYTE[12]     Unknown
      00000032    LONG         Offset to (14) Vertex Index Table
      00000036    LONG         Offset to (15) Face Index Table
      00000040    LONG         Face Index Count
      00000044    LONG         Unknown
      00000048    BYTE[144]    Unknown
      00000192    LONG         Unknown
      00000196    LONG         Vertex Index Count
      00000200    BYTE[8]      Unknown

(11)  TEXTURE NAME (variable)
      ------------
      00000000    STRING       Null-terminated Texture Name

(12)  MESH TABLE (20 bytes) (Repeat equal to Mesh Count)
      ----------
      00000000    LONG         Offset to (8) Object Header
      00000004    LONG         Unknown
      00000008    LONG         Offset to (16) Mesh Data Table
      00000012    BYTE[8]      Unknown

(13)  UNKNOWN TABLE (12 bytes)
      -------------
      00000000    BYTE[4]      Unknown
      00000004    LONG         Unknown
      00000008    BYTE[4]      Unknown

(14)  VERTEX INDEX TABLE (12 bytes)
      ------------------
      00000000    LONG         Offset to (17) Vertex Data
      00000004    LONG         Unknown
      00000008    BYTE[4]      Unknown

(15)  FACE INDEX TABLE (12 bytes)
      ----------------
      00000000    LONG         Offset to (18) Face Data
      00000004    LONG         Unknown
      00000008    BYTE[4]      Unknown

(16)  MESH DATA TABLE (16 bytes)
      ---------------
      00000000    LONG         Face Index Start at
      00000004    LONG         Face Index Count
      00000008    LONG         Vertex Index Start at
      00000012    LONG         Vertex Index End at

(17)  VERTEX DATA (36 bytes) (Repeat equal to Object Header:Vertex Index Count)
      -----------
      00000000    FLOAT[3]     Vertex Position (x, y, z)
      00000012    FLOAT[3]     Vertex Normal (x, y, z) ???
      00000024    BYTE[4]      Vertex Color (r, g, b, a)
      00000028    FLOAT[2]     Texture Map Co-ordinates (u, v)

(18)  FACE DATA (2 bytes) (Repeat equal to Object Header:Face Index Count)
      ---------
      00000000    USHORT       Face Index
Still working on the script.

--MDA
Image
MDA

Like TBotR on Facebook
ARchive_neXt v4.03.27.0 Now Available!

"I intend to leave a memory of myself in the minds of others."
Leonardo da Vinci,
disciple of experience

huckleberrypie
mega-veteran
mega-veteran
Posts: 309
Joined: Mon Apr 26, 2010 6:51 am
Has thanked: 92 times
Been thanked: 12 times

Re: Need help Fixing MAXScript Colin Mcrae Rally 04/05 .P3D

Post by huckleberrypie » Sun Sep 09, 2018 9:54 am

Was it just me or is the .*tag model format (.STAG, .CTAG, etc.) any similar to the ones found in Colin McRae 3? I took a quick peek at an .STAG model through HxD and the header seems to line up with Mike's documentation.

Post Reply