PHYS: Difference between revisions

From wowdev
Jump to navigation Jump to search
No edit summary
No edit summary
Line 41: Line 41:
   int shapes_base; // starting at shapes[shapes_base]
   int shapes_base; // starting at shapes[shapes_base]
   int shapes_count; // shapes_count shapes are in this body.
   int shapes_count; // shapes_count shapes are in this body.
#if version > 2
#if version >= 2
   float _x1c; // default 1.0
   float _x1c; // default 1.0
#endif
#endif
Line 55: Line 55:
   float restitution;
   float restitution;
   float density;
   float density;
#if version > 2
#if version >= 2
   uint32_t _x14; // default 0
   uint32_t _x14; // default 0
   float _x18; // default 1.0
   float _x18; // default 1.0
Line 111: Line 111:
   float frequency;
   float frequency;
   float dampingRatio;
   float dampingRatio;
#if version > 2
#if version >= 2
   uint32_t _x68; // default 0
   uint32_t _x68; // default 0
   uint32_t _x6c; // default 0
   uint32_t _x6c; // default 0
Line 134: Line 134:
   float coneAngle;
   float coneAngle;
  } shoulderJoints[];
  } shoulderJoints[];
=PRSJ (version 2+)=
struct
{
  char _unk[0x78];
} prismaticJoints[];
=REVJ (version 2+)=
struct
{
  char _unk[0x70];
} revoluteJoints[];
=DSTJ (version 2+)=
struct
{
  char _unk[0x1c];
} distanceJoints[];
=PHYV (version 2+)=
struct
{
  char _unk[0x18];
} phyv[];
=PHYT (version 2+)=
uint32_t phyt;


[[Category:Format]]
[[Category:Format]]

Revision as of 02:02, 28 January 2016

.phys files are chunked. The files are used by Blizzard's Domino physics engine which got added to WoW in the fourth expansion (MoP). In build 15464, there is one .phys file "item/objectcomponents/waist/buckle_panstart_a_01.phys". .phys files are an extension to M2s. The M2 requests a .phys file to be loaded by having GlobalModelFlags & 0x20 set.

The main PHYS chunk is followed by an unordered sequence of unique chunks of the other types.

// vec*: * floats
// mat*x*: * times * floats.
  • 1 phys
  • n body
    • n shapes
      • 1 box
      • 1 capsule
      • 1 sphere
      • 1 (tree mesh [*])
      • 1 (height field [*])
  • n joints
    • 1 weld
    • 1 spherical
    • 1 shoulder
    • 1 (mouse [*])
    • 1 distance (version 2+)
    • 1 revolute (version 2+)
    • 1 prismatic (version 2+)

[*] supported by domino, but not available in wow

One body is connected to one bone. Bodies are connected via joints. A joint is of type weld, spherical or shoulder. A body is constructed out of shapes. A shape is a box, capsule or sphere.

PHYS

 short version; // MoP: 0. 7.0.1.20979(?)+: 2

Loading is backwards compatible and fills up with default values if loading older versions.

BODY

struct BODYEntry
{
  unsigned short type; // maps to dmBodyDef type enum. 0 -> 1, 1 -> 0 = dm_dynamicBody, * -> 2. Only one should be of type 0 (root). possibly only 0 and 1.
  char PADDING_a[2];
  vec3 position;
  unsigned short modelBoneIndex;
  char PADDING_b[2];
  int shapes_base; // starting at shapes[shapes_base]
  int shapes_count; // shapes_count shapes are in this body.
  1. if version >= 2
  float _x1c; // default 1.0
  1. endif
} bodies[];

SHAP

struct SHAPEntry
{
  short shapeType; // 0 -> box, 1 -> capsule, 2 -> sphere
  short shapeIndex; // into the corresponding chunk
  char unk[4];
  float friction;
  float restitution;
  float density;
  1. if version >= 2
  uint32_t _x14; // default 0
  float _x18; // default 1.0
  uint16_t _x1c; // default 0
  uint16_t _x1e; // no default, padding?
  1. endif
} shapes[];

BOXS

struct BOXSEntry
{
  mat3x4 a;
  vec3 c;
} boxShapes[];

CAPS

struct CAPSEntry
{
  vec3 localPosition1;
  vec3 localPosition2;
  float radius;
} capsuleShapes[];

SPHS

struct SPHSEntry
{
  vec3 localPosition;
  float radius;
} sphereShapes[];

JOIN

struct JOINEntry
{
  unsigned int bodyAIdx;
  unsigned int bodyBIdx;
  char unk[4];
  enum
  {
    sphericalJoint = 0,
    shoulderJoint = 1,
    weldJoint = 2,
    revoluteJoint = 3, // version 2+
    prismaticJoint = 4, // version 2+
    distanceJoint = 5, // version 2+
  };
  short jointType;
  short jointId; // reference into the corresponding chunk entries.
} joints[];

WELJ

struct WELJEntry
{
  mat3x4 frameA;
  mat3x4 frameB;
  float frequency;
  float dampingRatio;
  1. if version >= 2
  uint32_t _x68; // default 0
  uint32_t _x6c; // default 0
  1. endif
} weldJoints[];

SPHJ

struct SPHJEntry
{
  vec3 anchorA;
  vec3 anchorB;
  float frictionTorque;
} sphericalJointEntries[];

SHOJ

struct SHOJEntry
{
  mat3x4 frameA;
  mat3x4 frameB;
  float lowerTwistAngle;
  float upperTwistAngle;
  float coneAngle;
} shoulderJoints[];

PRSJ (version 2+)

struct
{
  char _unk[0x78];
} prismaticJoints[];

REVJ (version 2+)

struct
{
  char _unk[0x70];
} revoluteJoints[];

DSTJ (version 2+)

struct
{
  char _unk[0x1c];
} distanceJoints[];

PHYV (version 2+)

struct
{
  char _unk[0x18];
} phyv[];

PHYT (version 2+)

uint32_t phyt;