- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 171字
- 2021-06-30 14:45:57
Adding matrices
Two matrices can be added together by component. To add two matrices together, sum their respective components and store the result in a new matrix. Matrix addition can be used with scalar multiplication to interpolate or blend between multiple matrices. Later, you will learn how to use this property to implement animation skinning.
Implement the matrix addition function in mat4.cpp. Don't forget to add the function declaration to mat4.h:
mat4 operator+(const mat4& a, const mat4& b) {
return mat4(
a.xx+b.xx, a.xy+b.xy, a.xz+b.xz, a.xw+b.xw,
a.yx+b.yx, a.yy+b.yy, a.yz+b.yz, a.yw+b.yw,
a.zx+b.zx, a.zy+b.zy, a.zz+b.zz, a.zw+b.zw,
a.tx+b.tx, a.ty+b.ty, a.tz+b.tz, a.tw+b.tw
);
}
Matrix addition is simple but it will play a big role in displaying an animated mesh. In the next section, you will learn how to scale a matrix by a scalar value.
- OpenStack Cloud Computing Cookbook(Third Edition)
- C語言程序設(shè)計(jì)(第2 版)
- Three.js開發(fā)指南:基于WebGL和HTML5在網(wǎng)頁上渲染3D圖形和動(dòng)畫(原書第3版)
- Python數(shù)據(jù)分析(第2版)
- GeoServer Beginner's Guide(Second Edition)
- Nginx實(shí)戰(zhàn):基于Lua語言的配置、開發(fā)與架構(gòu)詳解
- Java程序設(shè)計(jì)入門
- MySQL程序員面試筆試寶典
- 計(jì)算機(jī)應(yīng)用技能實(shí)訓(xùn)教程
- ASP.NET開發(fā)寶典
- C語言程序設(shè)計(jì)教程
- C/C++代碼調(diào)試的藝術(shù)(第2版)
- Mastering OpenStack
- SCRATCH編程課:我的游戲我做主
- 你好!Java