- 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.
- Leap Motion Development Essentials
- Visual C++數(shù)字圖像模式識(shí)別技術(shù)詳解
- R語(yǔ)言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- Instant RubyMotion App Development
- Haxe Game Development Essentials
- 自然語(yǔ)言處理Python進(jìn)階
- Elasticsearch Server(Third Edition)
- 深度學(xué)習(xí):Java語(yǔ)言實(shí)現(xiàn)
- 一本書(shū)講透Java線程:原理與實(shí)踐
- Selenium WebDriver Practical Guide
- Python第三方庫(kù)開(kāi)發(fā)應(yīng)用實(shí)戰(zhàn)
- Developing Java Applications with Spring and Spring Boot
- HTML5/CSS3/JavaScript技術(shù)大全
- Cinder:Begin Creative Coding
- HTML5程序開(kāi)發(fā)范例寶典