·本次提供变换函数的应用:
#include "iostream"
#include "windows.h"
#include "DirectXMath.h"
#include "DirectXPackedVector.h"
using namespace std;
using namespace DirectX;
using namespace DirectX::PackedVector;
//重载<<运算符
ostream& XM_CALLCONV operator<<(ostream& os, FXMVECTOR v)
{
XMFLOAT3 dest;
XMStoreFloat3(&dest, v);
os << "(" << dest.x << "," << dest.y << "," << dest.z << ")";
return os;
}
//本次只展示相关的变换函数
//缩放矩阵
XMMATRIX XM_CALLCONV XMMatrixScaling(float ScaleX, float ScaleY, float ScaleZ);
//用一个3D向量中的分量来构建缩放矩阵
XMMATRIX XM_CALLCONV XMMatrixScalingFromVector(FXMVECTOR Scale);
//构建一个绕x轴旋转的矩阵Rx,yz轴类似
XMMATRIX XM_CALLCONV XMMatrixRotationX(float Angle);
//构建一个绕任意轴旋转的矩阵Rn
XMMATRIX XM_CALLCONV XMMatrixRotationAxis(FXMMATRIX Axis, float Angle);
//构建一个平移矩阵
XMMATRIX XM_CALLCONV XMMatrixTranslation(float OffsetX, float OffsetY, float OffsetZ);
//用一个3D向量中的分量来构建平移矩阵
XMMATRIX XM_CALLCONV XMMatrixTranslationFromVector(FXMVECTOR Offset);
//计算向量与矩阵的乘积,默认Vw=1,还有点矩阵乘积Vm=0
XMMATRIX XM_CALLCONV XMVector3Transform(FXMVECTOR V, CXMMATRIX M);
XMMATRIX XM_CALLCONV XMVector3TransformNormal(FXMVECTOR V, CXMMATRIX M);