PHYS: Difference between revisions

From wowdev
Jump to navigation Jump to search
m (→‎BODY: fix type)
m (add missing ts)
Line 76: Line 76:
   short jointType; // 0 == sphericalJoint, 1 == shoulderJoint, 2 == weldJoint
   short jointType; // 0 == sphericalJoint, 1 == shoulderJoint, 2 == weldJoint
   short jointId; // reference into the corresponding chunk entries.
   short jointId; // reference into the corresponding chunk entries.
  } joins[];
  } joints[];


=WELJ=
=WELJ=
Line 85: Line 85:
   float a;
   float a;
   float b;
   float b;
  } weldJoins[];
  } weldJoints[];


=SPHJ=
=SPHJ=

Revision as of 05:08, 11 August 2014

.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 [*])
    • 1 (revolute [*])

[*] 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 must_be_null; // PhysData::Load fails otherwise. (if (phys->token != 'PHYS' || phys->must_be_null) return false;)

BODY

struct BODYEntry
{
  short type; // maps to dmBodyDef type enum. 0 -> 1, 1 -> 0, 2 -> 2. Only one should be of type 0 (root)
  short a;
  vec3 b;
  short bone; // the bone this body is representing in the model.
  short f;
  int shapes_base; // starting at shapes[shapes_base]
  int shapes_count; // shapes_count shapes are in this body.
} bodies[];

SHAP

struct SHAPEntry
{
  short shapeType; // 0 -> box, 1 -> capsule, 2 -> sphere
  short shapeIndex; // into the corresponding chunk
  vec3 position?;
  float weight;
} shapes[];

BOXS

struct BOXSEntry
{
  mat3x3 a;
  vec3 b;
  vec3 c;
} boxShapes[];

CAPS

struct CAPSEntry
{
  int a;
  int b;
  int c;
  vec4 d;
} capsuleShapes[];

SPHS

struct SPHSEntry
{
  char a[0x10];
} sphereShapes[];

JOIN

struct JOINEntry
{
  int body_1;
  int body_2;
  int unk;
  short jointType; // 0 == sphericalJoint, 1 == shoulderJoint, 2 == weldJoint
  short jointId; // reference into the corresponding chunk entries.
} joints[];

WELJ

struct WELJEntry
{
  mat3x4 matrix;
  mat3x4 matrix2;
  float a;
  float b;
} weldJoints[];

SPHJ

struct SPHJEntry
{
  vec3 a;
  vec3 b;
  float c;
} sphericalJointEntries[];

SHOJ

struct SHOJEntry
{
  mat3x4 matrix;
  mat3x4 matrix2;
  float m_lowerTwistAngle;
  float m_upperTwistAngle;
  float c;
} shoulderJoints[];