HEngine
  • 引擎编译
  • 未来工作
  • 使用文档
    • 代码规范
    • Shader规范
    • config 配置
  • Python脚本系统
    • 技术分析
    • 使用api
  • Cpp脚本系统
    • 技术分析
  • 技术文档 & 心得体会
    • 数学
      • 坐标系、UV与深度范围
      • 行主序 与 列主序
    • 路径管理
    • 构建系统
    • 自定义资源格式
    • UI
      • undo/redo
      • 分辨率处理
    • ECS 系统
    • 插件系统
    • 数学库
    • Ref Counted
    • 音频
    • ChatGPT
    • Mesh、Vertex 等组织关系
    • 编辑器热更新方案
    • Profile
    • NLP
    • RenderDoc
    • CodeGen与反射系统
    • 安装包
    • 物理引擎
      • PhysX集成
      • Bullet集成
    • 动画
  • 图形后端
    • 坐标系差异
    • Feature差异
    • RHI 封装
    • Shader与Constant Buffer
    • DX12
    • Vulkan
    • Render Graph
    • 渲染整体架构
  • 图形Feature
    • 毛发
    • 鼠标拾取
    • 实例化渲染
  • Shader
    • Shader 交叉编译
    • Shader Toy
    • Shader 热更新
    • PBR
  • 打包
    • 打包
  • Bug 记录 & 解决过程
    • 闪退记录汇总
    • 导入图片显示混乱
    • D3D下glfw+imgui失效
  • 其他资料
    • 总结集合
Powered by GitBook
On this page
  • glm
  • DirectXMath
  • hlsl
  • 参考资料
  1. 技术文档 & 心得体会
  2. 数学

行主序 与 列主序

row major 与 column major

glm

glm是列主序矩阵,

首先包含 #include <glm/gtc/type_ptr.hpp>以使用 glm::value_ptr 方法。

测试代码:

glm::vec3 Translation = { 5.0f, 0.0f, 0.0f };
auto matrix = glm::translate(glm::mat4(1.0f), Translation);
const float* val = glm::value_ptr(matrix);
for (int i = 0; i < 16; i++)
    std::cout << val[i] << ", ";

输出结果:

1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1,

DirectXMath

DirectXMath是行主序矩阵,

首先包含#include <DirectXMath.h> 它包含在 Windows sdk 中,vs安装一下即可。

测试代码:

auto matrix = DirectX::XMMatrixTranslationFromVector({5.0, 0.0, 0.0});
float* test = (float*)&matrix;
for (int i = 0; i < 16; i++)
	std::cout << test[i] << ", ";

输出结果:

1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1,

hlsl

参考资料

https://directx11.tech/#/misc/Mul

https://glm.g-truc.net/0.9.5/code.html

Previous坐标系、UV与深度范围Next路径管理

Last updated 1 year ago