PHY: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Better example text)
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 single text data section, with the appropriate number of solid{} block elements
* A single text data section, variously-ordered block elements that specify which solid they apply to


=== Main header ===
=== Main header ===
Line 38: Line 38:
=== Text section ===
=== 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 only the first two solids and is formatted for readability.
The text section occurs near the end of the file, and is one single string with no size header.


* <code>solid</code> blocks define solids, using an <code>index</code> value to distinguish which set of collision data they refer to.
* <code>ragdollconstraint</code> blocks define relationships between <code>parent</code> and <code>child</code> solids.
* An <code>editparams</code> block with general information about the entire object.
* Various <code>break</code> blocks with information about gib/ragdoll models.
Here is an ''incomplete'' sample from the Combine Strider, formatted for readability.
  solid {
  solid {
  "index" "0"
  "index" "8"
  "name" "Combine_Strider.Body_Bone"
  "name" "Combine_Strider.Leg_Hind_Bone1"
  "mass" "981.994263"
"parent" "Combine_Strider.Leg_Hind_Bone"
  "mass" "137.739014"
  "surfaceprop" "strider"
  "surfaceprop" "strider"
  "damping" "0.000000"
  "damping" "0.000000"
  "rotdamping" "0.000000"
  "rotdamping" "1.000000"
  "inertia" "1.000000"
  "inertia" "1.000000"
  "volume" "779936.625000"
  "volume" "109397.476563"
}
ragdollconstraint {
"parent" "7"
"child" "8"
"xmin" "0.000000"
"xmax" "0.000000"
"xfriction" "2.000000"
"ymin" "0.000000"
"ymax" "0.000000"
"yfriction" "2.000000"
"zmin" "-32.000000"
"zmax" "138.000000"
"zfriction" "0.200000"
  }
  }
  solid {
  editparams {
  "index" "1"
  "rootname" "combine_strider.body_bone"
  "name" "Combine_Strider.Gun_Bone1"
  "totalmass" "2000.000000"
  "parent" "Combine_Strider.Body_Bone"
}
  "mass" "39.125652"
break {
  "surfaceprop" "strider"
  "model" "Gibs/Strider_Gib1"  
  "damping" "0.000000"
  "health" "0"  
  "rotdamping" "0.000000"
  "fadetime" "0"  
  "inertia" "1.000000"
  "placementbone" "Combine_strider.body_bone"
  "volume" "31075.058594"
}
break {
  "ragdoll" "Gibs/Strider_Head"  
  "health" "0"  
  "fadetime" "0"
  }
  }


{{todo|Link to other articles to provide information about what this sample means}}
{{todo|Link keys other articles to provide context about what this sample means}}


== See also ==
== See also ==

Revision as of 18:49, 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 some $keyvalues 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 single text data section, variously-ordered block elements that specify which solid they apply to

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.

  • solid blocks define solids, using an index value to distinguish which set of collision data they refer to.
  • ragdollconstraint blocks define relationships between parent and child solids.
  • An editparams block with general information about the entire object.
  • Various break blocks with information about gib/ragdoll models.

Here is an incomplete sample from the Combine Strider, formatted for readability.

solid {
	"index" "8"
	"name" "Combine_Strider.Leg_Hind_Bone1"
	"parent" "Combine_Strider.Leg_Hind_Bone"
	"mass" "137.739014"
	"surfaceprop" "strider"
	"damping" "0.000000"
	"rotdamping" "1.000000"
	"inertia" "1.000000"
	"volume" "109397.476563"
} 
ragdollconstraint {
	"parent" "7"
	"child" "8"
	"xmin" "0.000000"
	"xmax" "0.000000"
	"xfriction" "2.000000"
	"ymin" "0.000000"
	"ymax" "0.000000"
	"yfriction" "2.000000"
	"zmin" "-32.000000"
	"zmax" "138.000000"
	"zfriction" "0.200000"
}
editparams {
	"rootname" "combine_strider.body_bone"
	"totalmass" "2000.000000"
} 
break {
	"model" "Gibs/Strider_Gib1" 
	"health" "0" 
	"fadetime" "0" 
	"placementbone" "Combine_strider.body_bone"
}
break {
	"ragdoll" "Gibs/Strider_Head" 
	"health" "0" 
	"fadetime" "0"  
}
Todo: Link keys other articles to provide context about what this sample means

See also