Common Types

From wowdev
Revision as of 13:09, 23 February 2016 by Mjollna (talk | contribs) (→‎stringref)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This page lists types commonly used in WoW, but not specific to a file format.

foreign_key

A reference into a DBC or DB2 database file. E.g.

foreign_key<uint16_t, &LiquidTypeRec::m_spellID> liquid_spell_id;
            ^ type of reference
                       ^ table referenced
                                      ^ variable referenced

stringref

A reference into the string block of a DBC or DB2 database file. See DBC#String_Block.

using stringref = uint32_t;

C2Vector

A two component float vector.

struct C2Vector
{
  float x;
  float y;
};

C3Vector

A three component float vector.

struct C3Vector
{
  float x;
  float y;
  float z;
};

C4Vector

A four component float vector.

struct C4Vector
{
  float x;
  float y;
  float z;
  float w;
};

C33Matrix

A three by three matrix.

struct C33Matrix // todo: row or column?
{
  C3Vector columns[3];
};

C44Matrix

A four by four matrix.

struct C44Matrix // todo: row or column?
{
  C4Vector columns[4];
};

C4Plane

A 3D plane defined by four floats.

struct C4Plane // todo: verify
{
  C3Vector normal;
  float distance;
};

C4Quaternion

A quaternion.

struct C4Quaternioin
{
  float x;
  float y;
  float z;
  float w; // todo: w first?
};

CRange

A one dimensional range defined by the bounds.

struct Range
{
  float min;
  float max;
};

CAaBox

An axis aligned box described by the minimum and maximum point.

struct CAaBox
{
  C3Vector min;
  C3Vector max;
};

CAaSphere

An axis aligned sphere described by position and radius.

struct CAaSphere
{
  C3Vector position;
  float radius;
};

CArgb

A color given in values of red, green, blue and alpha. Either

using CArgb = uint32_t;

or

struct CArgb // todo: verify, add CRgba, ..?
{
  unsigned char r;
  unsigned char g;
  unsigned char b;
  unsigned char a;
};

fixed_point

A fixed point real number, opposed to a floating point.

template<typename Base, size_t integer_bits, size_t decimal_bits> struct fixed_point
{
  Base decimal : decimal_bits;
  Base integer : integer_bits;
  Base sign : 1;
  float to_float() const { return (sign ? -1.0f : 1.0f) * (integer + decimal / float (1 << decimal_bits)); }
};

fixed16

A fixed point number without integer part.

using fixed16 = short; // divide by 0x7fff to get float value

or semantically (0 is not a valid bit size in bitfields) equivalent to

using fixed16 = fixed_point<uint16_t, 0, 15>;