Texture transform matrix

Texture matrix can be used to implement UV animation, we use the two vectors to transform the uv coordinate.  Finally, u' =  u dp2 uvTexMatRow[0,1] + uvTexMatRow[2];
                                     v' =  v dp2 uvTexMatRow[4,5] + uvTexMatRow[6];

var halfRotRad:Number = MathExt.DegreeToRadian( rotUV * 0.5 );
           
            var Rz:Number = Math.sin( halfRotRad );
            var Rw:Number = Math.cos( halfRotRad );
           
            var RwRz2:Number = 2 * Rw * Rz;
            var RzRz2:Number = 2 * Rz * Rz;
           
            // S, R, T
            uvTexMatRow[0] = ( 1 - RzRz2 ) * repU;
            uvTexMatRow[1] = -RwRz2 * repU;   
            uvTexMatRow[2] = ( uvTexMatRow[ 0 ] * offU ) + ( uvTexMatRow[ 1 ] * offV ) + ( 0.5 - 0.5 * (    uvTexMatRow[ 0 ] + uvTexMatRow[ 1 ] ) );
     
            uvTexMatRow[3] = 1.0;
           
            // S, R, T
            uvTexMatRow[4] = RwRz2 * repV;
            uvTexMatRow[5] = ( 1 - RzRz2 ) * repV;   
            uvTexMatRow[6] = ( uvTexMatRow[ 4 ] * offU ) + ( uvTexMatRow[ 5 ] * offV ) + ( 0.5 - 0.5 * ( uvTexMatRow[ 4 ] + uvTexMatRow[ 5 ] ) );
                   uvTexMatRow[7] = 1.0;

Comments

Popular posts from this blog

董事長您好

After reading Steve Jobs Autobiography

Drawing textured cube with Vulkan on Android