Quaternion values and 2.x: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
In WoW 2.0+ Blizzard are now storing rotation data in 16bit values instead of 32bit. I don't really understand why as its only a very minor saving in model sizes and adds extra overhead in processing the models. Need this structure to read the data into. | In WoW 2.0+ Blizzard are now storing rotation data in 16bit values instead of 32bit. I don't really understand why as its only a very minor saving in model sizes and adds extra overhead in processing the models. Need this structure to read the data into. | ||
The conversion is done with these two functions: | |||
inline float stf(short Short) { | |||
} | return (Short > 0 ? Short-32767 : Short+32767)/32767.0; | ||
} | |||
inline short fts(float Float) { | |||
return (short)(Float > 0 ? Float * 32767.0 - 32768 : Float * 32767.0 + 32768); | |||
} | |||
Doing it for a whole Quaternion is like this: | |||
struct Quat16 { | |||
__int16 x,y,z,w; | |||
}; | |||
struct Quat32 { | |||
float x,y,z,w; | |||
}; | |||
static const Quat32 Quat16ToQuat32(const Quat16 t) | |||
{ | |||
return Quaternion( | |||
float(t.x < 0? t.x + 32768 : t.x - 32767)/ 32767.0f, | |||
float(t.y < 0? t.y + 32768 : t.y - 32767)/ 32767.0f, | |||
float(t.z < 0? t.z + 32768 : t.z - 32767)/ 32767.0f, | |||
float(t.w < 0? t.w + 32768 : t.w - 32767)/ 32767.0f); | |||
} | |||
-- WoWModelViewer | -- partly from WoWModelViewer's source. |
Revision as of 03:53, 19 August 2008
In WoW 2.0+ Blizzard are now storing rotation data in 16bit values instead of 32bit. I don't really understand why as its only a very minor saving in model sizes and adds extra overhead in processing the models. Need this structure to read the data into.
The conversion is done with these two functions:
inline float stf(short Short) { return (Short > 0 ? Short-32767 : Short+32767)/32767.0; }
inline short fts(float Float) { return (short)(Float > 0 ? Float * 32767.0 - 32768 : Float * 32767.0 + 32768); }
Doing it for a whole Quaternion is like this:
struct Quat16 { __int16 x,y,z,w; }; struct Quat32 { float x,y,z,w; }; static const Quat32 Quat16ToQuat32(const Quat16 t) { return Quaternion( float(t.x < 0? t.x + 32768 : t.x - 32767)/ 32767.0f, float(t.y < 0? t.y + 32768 : t.y - 32767)/ 32767.0f, float(t.z < 0? t.z + 32768 : t.z - 32767)/ 32767.0f, float(t.w < 0? t.w + 32768 : t.w - 32767)/ 32767.0f); }
-- partly from WoWModelViewer's source.