XMVectorPermuteControl
Helper function used by XMVectorPermute.
Syntax
XMVECTOR XMVectorPermuteControl(
UINT ElementIndex0,
UINT ElementIndex1,
UINT ElementIndex2,
UINT ElementIndex3
)
Parameters
- ElementIndex0
[in] Value in the range [0, 7] that is the index of the component to select. Values 0, 1, 2, and 3 refer to the x, y, z, and w components of the first vector. Values 4, 5, 6, and 7 refer to the x, y, z, and w components of the second vector. - ElementIndex1
[in] Value in the range [0, 7] that is the index of the component to select. Values 0, 1, 2, and 3 refer to the x, y, z, and w components of the first vector. Values 4, 5, 6, and 7 refer to the x, y, z, and w components of the second vector. - ElementIndex2
[in] Value in the range [0, 7] that is the index of the component to select. Values 0, 1, 2, and 3 refer to the x, y, z, and w components of the first vector. Values 4, 5, 6, and 7 refer to the x, y, z, and w components of the second vector. - ElementIndex3
[in] Value in the range [0, 7] that is the index of the component to select. Values 0, 1, 2, and 3 refer to the x, y, z, and w components of the first vector. Values 4, 5, 6, and 7 refer the x, y, z, and w components of the second vector.
Return Value
Returns a vector that can be used by the Control parameter of XMVectorPermute.
Remarks
XMVectorPermute is used to combine and permute two vectors. XMVectorPermuteControl is used to generate a vector that controls how those two vectors are combined and permuted.
ElementIndex0 is used to select which component of the two vectors will appear in the first component of the result of XMVectorPermute. ElementIndex0 must be in the range [0, 7]. Values 0, 1, 2, and 3 to refer to the x, y, z, and w components of the first vector. Values 4, 5, 6, and 7 refer the x, y, z, and w components of the second vector. Each of the other parameters of XMVectorPermuteControl is used in the same manner.
Example
Using XMVectorPermute and XMVectorPermuteControl
The following code demonstrates how to use XMVectorPermute and how to set up its control vector using XMVectorPermuteControl. In this example, XMVectorPermuteControl is used to generate a control vector that selects the w component of v1 (40), and the x and y components of v2 (50 and 60). Upon completion of this code, result will be the vector (40, 60, 60, 50).
XMVECTOR v1 = { { 10, 20, 30, 40 } }; XMVECTOR v2 = { { 50, 60, 70, 80 } }; XMVECTOR control = XMVectorPermuteControl( 3, 5, 5, 4 ); XMVECTOR result = XMVectorPermute( v1, v2, control );
Requirements
Header: Declared in xnamath.h.