Sign in to follow this  

Scale texture matrix "around center"

This topic is 2045 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:

[CODE]
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;
};[/CODE]

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
Please ignore, got it working:


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

Share this post


Link to post
Share on other sites

This topic is 2045 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this