PHY: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 7: Line 7:
* A main header, which specifies the number of solids
* A main header, which specifies the number of solids
* A series of VPHY/collision data sections, one per solid
* A series of VPHY/collision data sections, one per solid
* A series of textual data sections, one per solid
* A textual data sections, with a solid{} datablock for each


=== Main header ===
=== Main header ===
Line 25: Line 25:
There will be a series of these sections, back-to-back, numbering the same as the header's [code]solidCount[/code].
There will be a series of these sections, back-to-back, numbering the same as the header's [code]solidCount[/code].


{{todo|Document headers for each solid}}
<source lang="cpp">
{
int size;          // Size of the content after this byte
int id; // Generally the ASCII for "VPHY" in newer files
        //TODO fill in remaining data
}</source>
 
{{todo|Document details of each collision section}}


{{todo|Document "old format" if VPHY is not seen}}
{{todo|Document "old format" if VPHY is not seen}}


=== Text sections ===
=== Text section ===
 
{{todo|Document key-value data for each solid}}


The text section occurs near the end of the file, and is one single string with no size header. Here is an *incomplete* sample from the Combine Strider, which only shows details for the first two solids and formatted for readability.


solid {
"index" "0"
"name" "Combine_Strider.Body_Bone"
"mass" "981.994263"
"surfaceprop" "strider"
"damping" "0.000000"
"rotdamping" "0.000000"
"inertia" "1.000000"
"volume" "779936.625000"
}
solid {
"index" "1"
"name" "Combine_Strider.Gun_Bone1"
"parent" "Combine_Strider.Body_Bone"
"mass" "39.125652"
"surfaceprop" "strider"
"damping" "0.000000"
"rotdamping" "0.000000"
"inertia" "1.000000"
"volume" "31075.058594"
}





Revision as of 18:30, 6 August 2010

PHY is the extension for Source's proprietary collision model data format. It stores data for the rigid or jointed (ragdoll) collision model used by the MDL. In addition, it stores prop_data information about a model such as which gib-models to use if destroyed.

File Format

In brief, a PHY file is formed by:

  • A main header, which specifies the number of solids
  • A series of VPHY/collision data sections, one per solid
  • A textual data sections, with a solid{} datablock for each

Main header

The first bytes of the file form the main header:

struct phyheader_t
{
	int		size;           // Size of this header section (generally 16)
	int		id;             // Often zero, unknown purpose.
	int		solidCount;     // Number of solids in file
	long	        checkSum;	// checksum of source .mdl file (4-bytes)
}

Collision data sections

There will be a series of these sections, back-to-back, numbering the same as the header's [code]solidCount[/code].

{
	int		size;           // Size of the content after this byte
	int		id; 		// Generally the ASCII for "VPHY" in newer files
        //TODO fill in remaining data
}
Todo: Document details of each collision section
Todo: Document "old format" if VPHY is not seen

Text section

The text section occurs near the end of the file, and is one single string with no size header. Here is an *incomplete* sample from the Combine Strider, which only shows details for the first two solids and formatted for readability.

solid {
	"index" "0"
	"name" "Combine_Strider.Body_Bone"
	"mass" "981.994263"
	"surfaceprop" "strider"
	"damping" "0.000000"
	"rotdamping" "0.000000"
	"inertia" "1.000000"
	"volume" "779936.625000"
}
solid {
	"index" "1"
	"name" "Combine_Strider.Gun_Bone1"
	"parent" "Combine_Strider.Body_Bone"
	"mass" "39.125652"
	"surfaceprop" "strider"
	"damping" "0.000000"
	"rotdamping" "0.000000"
	"inertia" "1.000000"
	"volume" "31075.058594"
}


See also