Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Questions about a scaling up, down, and resetting using a scale matrix

$
0
0
Hey I have a quick question about a scale matrices I have my matrices in column major order and I know a scale matrix looks like: // Column order matrix. Data arragned in an array: 0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15 //Scale Matrix x 0 0 0 0 y 0 0 0 0 z 0 0 0 0 1 And I know I need to multiple my matrix by the scale matrix in order to scale by the x, y, z values. But how am I supposed to actually scale my matrix back down/set it to a scale factor? I have this code that is to scale my matrix the along the X access //Scale the current matrix by X amount void Matrix4::scaleX(float x) { data[0] *= x; data[1] *= x; data[2] *= x; data[3] *= x; } And if I were to do something like this I could scale my matrix along the X axis by 2 //Scale the matrix along the x axis by 2 myMatrix.scaleX(2.0f); But I'm honestly not sure how I'm supposed to scale back down from this point. I was hoping for something like: //Scale the matrix along the x axis by 2 myMatrix.scaleX(2.0f); //Scale the matrix down along the x axis by 2 myMatrix.scaleX(-2.0f); But based on the current math that is not how it works Also how should I go about "resetting/setting" a scale matrix to a certain value? Say I have a matrix that is at scale factor 1. Then over time I want to scale it up until it hits a scale factor of 5. Then later after some other conditions are met I want to reset/set the scale factor to 2

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>