目录
Chaptor 1
1.1~1.5 都是基础 1.6对针对Dx介绍一些语法细节
1.6.1 Vector Types
In XNA Math, the core vector type is XMVECTOR, which maps to SIMD hardware registers. This is a 128-bit type that can process four 32-bit floats with a single SIMD instruction. When SSE2 is available, it is defined like so: typedef __m128 XMVECTOR;
注意选择使用XMVECTOR 还是 XMVECTOR* ,既要利用SIMD的计算优势,又要利用 XMVECTOR* 的少占用内存和内存对齐的优势,因此计算用 XMVECTOR ,存储用XMVECTOR* ,中间用math库的函数转化
1.6.3 Parameter Passing
32bit和63bit的区别还是能不能传引用,但是和xna相比,新的math库,形参前三位还是用FXMVECTOR,,但4567位还多了GXMVECTOR,HXMVECTOR,CXMVECTOR,这个是和书中不一样的
1.6.4 常量
XMVECTORF32
1.6.5 重载操作符
可以使用XM_NO_OPERATOR_OVERLOADS 禁掉操作符重载,提升效率
CodeSet (vs2015)
改一下math库的引用就行,用
#include <DirectXMath.h>
using namespace DirectX;
Chaptor 2
For transforming points and vectors, we use 1 × 4 row vectors and 4 × 4 matrices. The reason for this will be explained in the next chapter. For now, we concentrate on the XNA math types used to represent 4 × 4 matrices.
一般使用行向量 计算
2.8.1
和vector类似,用 XMMATRIX 计算,用 XMFLOAT4X4 存储
一般的矩阵的逆矩阵 也会提前算好,不需要实时计算
2.8.2
matrix有关的function 传入的参数一般是 CXMMATRIX ,而不是 XMMATRIX ,为了适配 xbox360和windows
但这是书中那时候的,现在和vector类似
一般第一个参数传 FXMMATRIX,后面的传 CXMMATRIX
CodeSet (vs2015)
改一下math库的引用就行,用
#include <DirectXMath.h>
using namespace DirectX;
另外,重载 << 操作符,改一下输出,还有matrix 记得传引用,否则会报错
formal parameter with requested alignment of 16 won't be aligned
这是因为
From Microsoft's documentation on that error:
The align __declspec modifier is not permitted on function parameters.
Don't copy the parameter to an unaligned location. Pass a constant reference to the existing, aligned data.
Chaptor 3 Transform
旋转矩阵推导
可以参考:
https://blog.csdn.net/zsq306650083/article/details/8773996