3 ms·
When I started working with Flash and learned about color and transformation matrices I was blown away by how clever it is. At a surface level you may think th
by zeroq 2y ago
When I started working with Flash and learned about color and transformation matrices I was blown away by how clever it is.
At a surface level you may think that having to use advanced mathemathics to change something as trivial as position or adding a tint might be an overkill. But matrix math isn't that complicated, been highly optimized and can be relegated to the CPU since forever.
The most illustrative use would be a model of a 3D tank.
You want the whole tank to turn itself 30 degrees to the left, now you want the turret to turn 40 degrees right and you want the gun to be facing 20 degrees upwards. With matrices being applied on every level it's dead simple to calculate what's the actual bearing of the gun in world coordinates.
Same applies to graphics. You have a game character that's been hit. You want to make it flash to indicate the hit by changing it's brightness, but at the same time you want to turn it's eyes to red by adding a tint. Oh, and the whole screen is changing it's saturation during the process. Again, by using matrices, it's really easy to figure out what's the color of the eyes at any given moment of the animation thanks to matrices.