A 4D vector for storing unsigned, normalized integer values as 10 bit unsigned x-, y-, and z-components and a 2-bit unsigned w-component.
If you are programming in C++, you can use the constructors and operator methods of this structure.
Note See DirectXMath Library Type Equivalences for information about equivalent D3DDECLTYPE, D3DFORMAT, and DXGI_FORMAT objects.
struct XMUDECN4
The fields in the XMUDECN4 structure are declared as follows:
struct XMUDECN4
{
union
{
struct
{
uint32_t x : 10; // Unsigned integer value in the range [0, 1023]
// describing the x-coordinate of the vector.
uint32_t y : 10; // Unsigned integer value in the range [0, 1023]
// describing the y-coordinate of the vector.
uint32_t z : 10; // Unsigned integer value in the range [0, 1023]
// describing the z-coordinate of the vector.
uint32_t w : 2; // Unsigned integer value in the range [0, 3]
// describing the w-coordinate of the vector.
};
uint32_t v; // Unsigned 32-bit integer representing the 4D vector.
};
Those XMUDECN4 constructors using floating point arguments require normalized input, which must be in the range of [0.-1.0]. During instantiation, the inputs specifying the x-, y-, and z-components are multiplied by 1023.0f, and the w-component are multiplied by 3.0f. The results are rounded, and then assigned to the appropriate members of XMUDECN4.
You can use XMUDECN4 to load instances of XMVECTOR from normalized values by using XMLoadUDecN4, which divides the x-, y-, and z-components by 1023.0f, divides the w-component by 3.0f, rounds the result, and then assigns the components to an XMVECTOR instance.
XMVECTOR instances containing normalized values can be stored into XMUDECN4 using XMStoreUDecN4, which multiplies the x-, y-, and z-components by 1023.0f, multiplies the w-component by 3.0f, and rounds the result before assigning the values to the appropriate XMUDECN4 members.
Namespace: Use DirectX::PackedVector
Header: Declared in directxpackedvector.h.