Jump to content
  • Advertisement
Sign in to follow this  
Vexator

Scale texture matrix "around center"

This topic is 2354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

I've written the following function to scale texture matrices:


void ScaleMatrix( TextureMatrix *matrix, float scaleSpeed, double deltaTime ) const
{
vec2 scale = 1.0f/scaleSpeed;

matrix->matrix[0][0] *= scale.x;
matrix->matrix[1][1] *= scale.y;

matrix->matrix[0][3] *= scale.x;
matrix->matrix[1][3] *= scale.y;
};


Now there's two things missing and I can't figure out how to do it:
- When a scaled texture is used to scale texture coordinates, the texture is scaled around the origin (0, 0). I would like them to be scaled around the center (0.5, 0.5) instead. How can I achieve this?
- I'd like to include deltaTime in the computation so that the scaling is continous across several frames.

Thank you! Edited by Vexator

Share this post


Link to post
Share on other sites
Advertisement
Please ignore, got it working:



matrix->matrix[3][0] = ( 0.5f - 0.5f * matrix->matrix[0][0] );
matrix->matrix[3][1] = ( 0.5f - 0.5f * matrix->matrix[1][1] );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!