DirectX11 学习笔记5 - D3DXMath 库
directx11 特别推出了一个数学库 用于向量 矩阵的计算。并且使用128位 同一时候计算4条32位数据 (SIMD)
之前基本是用的directx10math.h这个头文件。 这个数学库既然是新出的。肯定在硬件方便处理起来比曾经的快很多,优化了非常多。
技术永无止境嘛。推荐用新的
而如今能够单独用 xnamath.h directx9 10 11 都能够用这个库,非常方便。 以下的表能够高速从曾经的数学库找到替换函数。
对了 昨晚遇到一个坑。攻克了非常久。
原来是因为xnamath 里面的 xmatrix xmvector 等 涉及到一个对齐问题。
假设是 局部变量、全局变量 感觉不到。硬件会自己主动对齐。 可是假设放在类成员变量。就非常easy报错了。 并且你看不出是那的问题。
调试了非常久。
所以我们在用这个库的时候,最后尽量避免设为类成员变量。
下一节我将附上,把之前那个封装程序升级为xnamath库的完整源代码。并实现了绘制一个三角形。
以后的教程都将在这个源代码上演示。
他们的差别高速查询 :
D3DXMath Type DirectXMath Equivalent
D3DXFLOAT16 HALF
D3DXMATRIXA16 XMMATRIX or XMFLOAT4X4A
D3DXQUATERNION D3DXPLANE D3DXCOLOR XMVECTOR is used rather than having unique types, so you will likely need to use an XMFLOAT4
Note D3DXQUATERNION::operator * calls the D3DXQuaternionMultiply function, which multiplies two quaternions. But, unless you explicitly use the XMQuaternionMultiply function, you get an incorrect answer when you use XMVECTOR::operator * on a quaternion. D3DXVECTOR2 XMFLOAT2
D3DXVECTOR2_16F XMHALF2
D3DXVECTOR3 XMFLOAT3
D3DXVECTOR4 XMFLOAT4
(or if you can guarantee the data is 16-byte aligned, XMVECTOR or XMFLOAT4A ) D3DXVECTOR4_16F XMHALF4 Note There is no direct equivalent to D3DXVECTOR3_16F in XNAMath. D3DXMath Macro DirectXMath Equivalent
D3DX_PI XM_PI
D3DX_1BYPI XM_1DIVPI
D3DXToRadian XMConvertToRadians
D3DXToDegree XMConvertToDegrees D3DXMath Function DirectXMath Equivalent
D3DXBoxBoundProbe BoundingBox::Intersects(XMVECTOR, XMVECTOR, float&)
D3DXComputeBoundingBox BoundingBox::CreateFromPoints
D3DXComputeBoundingSphere BoundingSphere::CreateFromPoints
D3DXSphereBoundProbe BoundingSphere::Intersects(XMVECTOR, XMVECTOR, float&)
D3DXIntersectTriFunction TriangleTests::Intersects
D3DXFloat32To16Array XMConvertFloatToHalfStream
D3DXFloat16To32Array XMConvertHalfToFloatStream
D3DXVec2Length XMVector2Length or XMVector2LengthEst
D3DXVec2LengthSq XMVector2LengthSq
D3DXVec2Dot XMVector2Dot
D3DXVec2CCW XMVector2Cross
D3DXVec2Add XMVectorAdd
D3DXVec2Subtract XMVectorSubtract
D3DXVec2Minimize XMVectorMin
D3DXVec2Maximize XMVectorMax
D3DXVec2Scale XMVectorScale
D3DXVec2Lerp XMVectorLerp or XMVectorLerpV
D3DXVec2Normalize XMVector2Normalize or XMVector2NormalizeEst
D3DXVec2Hermite XMVectorHermite or XMVectorHermiteV
D3DXVec2CatmullRom XMVectorCatmullRom or XMVectorCatmullRomV
D3DXVec2BaryCentric XMVectorBaryCentric or XMVectorBaryCentricV
D3DXVec2Transform XMVector2Transform
D3DXVec2TransformCoord XMVector2TransformCoord
D3DXVec2TransformNormal XMVector2TransformNormal
D3DXVec2TransformArray XMVector2TransformStream
D3DXVec2TransformCoordArray XMVector2TransformCoordStream
D3DXVec2TransformNormalArray XMVector2TransformNormalStream
D3DXVec3Length XMVector3Length or XMVector3LengthEst
D3DXVec3LengthSq XMVector3LengthSq
D3DXVec3Dot XMVector3Dot
D3DXVec3Cross XMVector3Cross
D3DXVec3Add XMVectorAdd
D3DXVec3Subtract XMVectorSubtract
D3DXVec3Minimize XMVectorMin
D3DXVec3Maximize XMVectorMax
D3DXVec3Scale XMVectorScale
D3DXVec3Lerp XMVectorLerp or XMVectorLerpV
D3DXVec3Normalize XMVector3Normalize or XMVector3NormalizeEst
D3DXVec3Hermite XMVectorHermite or XMVectorHermiteV
D3DXVec3CatmullRom XMVectorCatmullRom or XMVectorCatmullRomV
D3DXVec3BaryCentric XMVectorBaryCentric or XMVectorBaryCentricV
D3DXVec3Transform XMVector3Transform
D3DXVec3TransformCoord XMVector3TransformCoord
D3DXVec3TransformNormal XMVector3TransformNormal
D3DXVec3TransformArray XMVector3TransformStream
D3DXVec3TransformCoordArray XMVector3TransformCoordStream
D3DXVec3TransformNormalArray XMVector3TransformNormalStream
D3DXVec3Project XMVector3Project
D3DXVec3Unproject XMVector3Unproject
D3DXVec3ProjectArray XMVector3ProjectStream
D3DXVec3UnprojectArray XMVector3UnprojectStream
D3DXVec4Length XMVector4Length or XMVector4LengthEst
D3DXVec4LengthSq XMVector4LengthSq
D3DXVec4Dot XMVector4Dot
D3DXVec4Add XMVectorAdd
D3DXVec4Subtract XMVectorSubtract
D3DXVec4Minimize XMVectorMin
D3DXVec4Maximize XMVectorMax
D3DXVec4Scale XMVectorScale
D3DXVec4Lerp XMVectorLerp or XMVectorLerpV
D3DXVec4Cross XMVector4Cross
D3DXVec4Normalize XMVector4Normalize or XMVector4NormalizeEst
D3DXVec4Hermite XMVectorHermite or XMVectorHermiteV
D3DXVec4CatmullRom XMVectorCatmullRom or XMVectorCatmullRomV
D3DXVec4BaryCentric XMVectorBaryCentric or XMVectorBaryCentricV
D3DXVec4Transform XMVector4Transform
D3DXVec4TransformArray XMVector4TransformStream
D3DXMatrixIdentity XMMatrixIdentity
D3DXMatrixDeterminant XMMatrixDeterminant
D3DXMatrixDecompose XMMatrixDecompose
D3DXMatrixTranspose XMMatrixTranspose
D3DXMatrixMultiply XMMatrixMultiply
D3DXMatrixMultiplyTranspose XMMatrixMultiplyTranspose
D3DXMatrixInverse XMMatrixInverse
D3DXMatrixScaling XMMatrixScaling
D3DXMatrixTranslation XMMatrixTranslation
D3DXMatrixRotationX XMMatrixRotationX
D3DXMatrixRotationY XMMatrixRotationY
D3DXMatrixRotationZ XMMatrixRotationZ
D3DXMatrixRotationAxis XMMatrixRotationAxis
D3DXMatrixRotationQuaternion XMMatrixRotationQuaternion
D3DXMatrixRotationYawPitchRoll XMMatrixRotationRollPitchYaw (Note the order of parameters is different: D3DXMatrixRotationYawPitchRoll takes yaw, pitch, roll, XMMatrixRotationRollPitchYaw takes pitch, yaw, roll)
D3DXMatrixTransformation XMMatrixTransformation
D3DXMatrixTransformation2D XMMatrixTransformation2D
D3DXMatrixAffineTransformation XMMatrixAffineTransformation
D3DXMatrixAffineTransformation2D XMMatrixAffineTransformation2D
D3DXMatrixLookAtRH XMMatrixLookAtRH
D3DXMatrixLookAtLH XMMatrixLookAtLH
D3DXMatrixPerspectiveRH XMMatrixPerspectiveRH
D3DXMatrixPerspectiveLH XMMatrixPerspectiveLH
D3DXMatrixPerspectiveFovRH XMMatrixPerspectiveFovRH
D3DXMatrixPerspectiveFovLH XMMatrixPerspectiveFovLH
D3DXMatrixPerspectiveOffCenterRH XMMatrixPerspectiveOffCenterRH
D3DXMatrixPerspectiveOffCenterLH XMMatrixPerspectiveOffCenterLH
D3DXMatrixOrthoRH XMMatrixOrthographicRH
D3DXMatrixOrthoLH XMMatrixOrthographicLH
D3DXMatrixOrthoOffCenterRH XMMatrixOrthographicOffCenterRH
D3DXMatrixOrthoOffCenterLH XMMatrixOrthographicOffCenterLH
D3DXMatrixShadow XMMatrixShadow
D3DXMatrixReflect XMMatrixReflect
D3DXQuaternionLength XMQuaternionLength
D3DXQuaternionLengthSq XMQuaternionLengthSq
D3DXQuaternionDot XMQuaternionDot
D3DXQuaternionIdentity XMQuaternionIdentity
D3DXQuaternionIsIdentity XMQuaternionIsIdentity
D3DXQuaternionConjugate XMQuaternionConjugate
D3DXQuaternionToAxisAngle XMQuaternionToAxisAngle
D3DXQuaternionRotationMatrix XMQuaternionRotationMatrix
D3DXQuaternionRotationAxis XMQuaternionRotationAxis
D3DXQuaternionRotationYawPitchRoll XMQuaternionRotationRollPitchYaw (Note the order of parameters is different: D3DXQuaternionRotationYawPitchRoll takes yaw, pitch, roll, XMQuaternionRotationRollPitchYaw takes pitch, yaw, roll)
D3DXQuaternionMultiply XMQuaternionMultiply
D3DXQuaternionNormalize XMQuaternionNormalize or XMQuaternionNormalizeEst
D3DXQuaternionInverse XMQuaternionInverse
D3DXQuaternionLn XMQuaternionLn
D3DXQuaternionExp XMQuaternionExp
D3DXQuaternionSlerp XMQuaternionSlerp or XMQuaternionSlerpV
D3DXQuaternionSquad XMQuaternionSquad or XMQuaternionSquadV
D3DXQuaternionSquadSetup XMQuaternionSquadSetup
D3DXQuaternionBaryCentric XMQuaternionBaryCentric or XMQuaternionBaryCentricV
D3DXPlaneDot XMPlaneDot
D3DXPlaneDotCoord XMPlaneDotCoord
D3DXPlaneDotNormal XMPlaneDotNormal
D3DXPlaneScale XMVectorScale
D3DXPlaneNormalize XMPlaneNormalize or XMPlaneNormalizeEst
D3DXPlaneIntersectLine XMPlaneIntersectLine
D3DXPlaneFromPointNormal XMPlaneFromPointNormal
D3DXPlaneFromPoints XMPlaneFromPoints
D3DXPlaneTransform XMPlaneTransform
D3DXPlaneTransformArray XMPlaneTransformStream
D3DXColorNegative XMColorNegative
D3DXColorAdd XMVectorAdd
D3DXColorSubtract XMVectorSubtract
D3DXColorScale XMVectorScale
D3DXColorModulate XMColorModulate
D3DXColorLerp XMVectorLerp or XMVectorLerpV
D3DXColorAdjustSaturation XMColorAdjustSaturation
D3DXColorAdjustContrast XMColorAdjustContrast
D3DXFresnelTerm XMFresnelTerm
DirectX11 学习笔记5 - D3DXMath 库的更多相关文章
- Directx11学习笔记【二十二】 用高度图实现地形
本文由zhangbaochong原创,转载请注明出处http://www.cnblogs.com/zhangbaochong/p/5827714.html 在前面我们曾经实现过简单的地形(Direct ...
- Directx11学习笔记【二】 将HelloWin封装成类
我们把上一个教程的代码封装到一个类中来方便以后的使用. 首先新建一个空工程叫做MyHelloWin,添加一个main.cpp文件,然后新建一个类叫做MyWindow,将于窗体有关的操作封装到里面 My ...
- Directx11学习笔记【一】 最简单的windows程序HelloWin
声明:本系列教程代码有部分来自dx11龙书及dx11游戏编程入门两本书,后面不再说明 首先,在vs2013中创建一个空的解决方案Dx11Demo,以后的工程都会放在这个解决方案下面.然后创建一个win ...
- Directx11学习笔记【二十一】 封装键盘鼠标响应类
原文:Directx11学习笔记[二十一] 封装键盘鼠标响应类 摘要: 本文由zhangbaochong原创,转载请注明出处:http://www.cnblogs.com/zhangbaochong/ ...
- Directx11学习笔记【九】 3D渲染管线
原文:Directx11学习笔记[九] 3D渲染管线 原文地址:http://blog.csdn.net/bonchoix/article/details/8298116 3D图形学研究的基本内容,即 ...
- Directx11学习笔记【八】 龙书D3DApp的实现
原文:Directx11学习笔记[八] 龙书D3DApp的实现 directx11龙书中的初始化程序D3DApp跟我们上次写的初始化程序大体一致,只是包含了计时器的内容,而且使用了深度模板缓冲. D3 ...
- iOS学习笔记16-数据库SQLite
一.数据库 在项目开发中,通常都需要对数据进行离线缓存的处理,如新闻数据的离线缓存等.离线缓存一般都是把数据保存到项目的沙盒中.有以下几种方式: 归档:NSKeyedArchiver 偏好设置:NSU ...
- DirectX11 学习笔记6 - 使用D3DXMATH数学库的一个样例
这个样例是在之前的样例基础上 .把之前d3dx10math数学库换成了最新的d3dxmath.长处就不说了.先上效果图 所有代码.以及效果文件 文件结构 所有代码: 依照上图的文件顺序 #pragma ...
- Directx11学习笔记【十四】 使用最新的Effect框架和SDK
由于之前一直在看directx11龙书学习,因此sdk一直用的Microsoft DirectX SDK (June 2010) 版本,最近在stackoverflow上问dx11相关问题时,一直被大 ...
随机推荐
- 【03】图解原型和原型链by魔芋
[03]图解原型和原型链 一图胜前言 请先结合图解原型和原型链这张图. 可以分为4种情况. 情况1: Object有: constructor:是Function. __pro ...
- Chrome 开发者工具(DevTools)中所有快捷方式列表(已整理)
Chrome 开发者工具(DevTools)中所有快捷方式列表(已整理) 前言 Chrome DevTools提供了一些内置的快捷键,开发者利用这些快捷键可以节省常工作中很多日的开发时间.下面列出了每 ...
- log4j动态日志级别调整
1. 针对root logger的设置 log4j.rootLogger=INFO, CONSOLELogger.getRootLogger().setLevel(org.apache.log4j.L ...
- sql server 2008启动时:已成功与服务器建立连接,但是在登录过程中发生错误。(provider:命名管道提供程序,error:0-管道的另一端上无任何进程。)(Microsoft SQL Server,错误:233) 然后再连接:错误:18456
问题:sql server 2008启动时:已成功与服务器建立连接,但是在登录过程中发生错误.(provider:命名管道提供程序,error:0-管道的另一端上无任何进程.)(Microsoft S ...
- 刷题总结——切蛋糕(ssoj)
题目: 切蛋糕 (cake.cpp/c/pas) [问题描述] BG 有一块细长的蛋糕,长度为�. 有一些人要来BG 家里吃蛋糕, BG把蛋糕切成了若干块(整数长度),然后分给这些人.为了公平,每个人 ...
- 【极角排序+双指针线性扫】2017多校训练七 HDU 6127 Hard challenge
acm.hdu.edu.cn/showproblem.php?pid=6127 [题意] 给定平面直角坐标系中的n个点,这n个点每个点都有一个点权 这n个点两两可以连乘一条线段,定义每条线段的权值为线 ...
- BZOJ 3733 [Pa2013]Iloczyn 模拟爆搜
Description 给定正整数n和k,问能否将n分解为k个不同正整数的乘积 Input 第一行一个数T(T<=4000)表示测试组数 接下来T行每行两个数n(n<=10^9),k(k& ...
- bzoj3874&2832 [Ahoi2014]宅男计划 模拟退火,三分
[Ahoi2014&Jsoi2014]宅男计划 Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 962 Solved: 371[Submit][ ...
- spring boot--常用配置
spring boot 需要引用的依赖项: spring-boot-starter-parent // 所有Spring Boot组件的基础引用 spring-boot-starter-web // ...
- 让Mac OS X专用高速移动硬盘在Linux下也能被读写
MacBook Pro以及iMac等设备都具备雷电接口和USB 3.0接口,配合使用Mac OS X格式化的专用高速移动硬盘读写数据都非常快.那么这种硬盘可以在Linux下被读写吗?其实,Mac OS ...