The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::EternalLands::Binary::Unitvec16 - 16-bit quantized unit vectors as used by Eternal Lands

SYNOPSIS

  use Games::EternalLands::Binary::Unitvec16 qw(pack_unitvec16 unpack_unitvec16);

  # Pack to an unsigned short (i.e. a 16-bit unsigned number)
  $short = pack_unitvec16([1, 0, 0]);

  # Unpack from an unsigned short
  $vector = unpack_unitvec16($short);

  ...

ABSTRACT

This module provides functions to pack and unpack 16-bit quantized unit vectors as used in certain game data files by Eternal Lands.

FUNCTIONS

pack_unitvec16

Takes a reference to an array of length 3 and returns a packed 16-bit integer.

unpack_unitvec16

Takes a 16-bit integer and returns a reference to an array with 3 floating-point elements in it.

NOTE

Be sure to use the correct byte order if you are reading the 16-bit integers from a file or network packets. For Eternal Lands data, this will almost certainly be in little-endian byte order. So if your machine is not little-endian, remember to convert the data appropriately (see pack).

SEE ALSO

http://www.gamedev.net/page/resources/_/technical/math-and-physics/higher-accuracy-quantized-normals-r1252

AUTHOR

Cole Minor, <coleminor at hush.ai>

LICENSE AND COPYRIGHT

Copyright (C) 2012 Cole Minor. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.