目录

Chaptor 1

1.1~1.5 都是基础 1.6对针对Dx介绍一些语法细节

1.6.1 Vector Types

1.6.3 Parameter Passing

1.6.4 常量

1.6.5 重载操作符

CodeSet (vs2015)

Chaptor 2

2.8.1

2.8.2

CodeSet (vs2015)

Chaptor 3 Transform


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库的函数转化

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

 

 

 

 

1.6.3 Parameter Passing

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

 

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 存储

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)一般的矩阵的逆矩阵 也会提前算好,不需要实时计算

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

 

2.8.2

matrix有关的function 传入的参数一般是 CXMMATRIX ,而不是 XMMATRIX ,为了适配 xbox360和windows

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

 

但这是书中那时候的,现在和vector类似

一般第一个参数传 FXMMATRIX,后面的传 CXMMATRIX

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

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.

Chaptor1&2&3 Vector&Matrix&Transform (Introduction to 3D Game Programing with DirextX 11)

Chaptor 3 Transform

旋转矩阵推导

可以参考:

https://blog.csdn.net/zsq306650083/article/details/8773996

 

相关文章:

  • 2021-12-20
  • 2021-09-22
  • 2021-04-30
  • 2021-11-29
  • 2021-07-26
  • 2021-07-29
  • 2021-06-17
  • 2021-09-08
猜你喜欢
  • 2021-07-11
  • 2021-09-25
  • 2021-07-27
  • 2022-12-23
  • 2022-01-01
  • 2021-07-20
  • 2021-11-30
相关资源
相似解决方案