Re: Textured Polygons for All!
Posted: Wed Jun 28, 2017 9:58 pm
Also please use [ code ] [ /code ] blocks, otherwise the posted code is a bit unreadable.
Code: Select all
texture.setVertices( v[1],v[2],v[3],v[4] ) --same as mesh vertices now
texture.preload(true)
love.graphics.translate(120, 100)
love.graphics.draw( mesh, 0, 200, 0, 1, 1)
texture.preload(false)
Code: Select all
vec2 positionData = vec2( TransformMatrix[3][0], TransformMatrix[3][1] );
vec2 screen = screen_coords-positionData;
Code: Select all
vec2 screen = (screen_coords-positionData)/3;
Code: Select all
vec2 scaleData = vec2( TransformMatrix[0][0] );
vec2 screen = (screen_coords-positionData)/scaleData;
Code: Select all
//position
vec2 positionData = vec2( TransformMatrix[3][0], TransformMatrix[3][1] );
vec2 screenA = (screen_coords-positionData);
//rotation
float rotX = -TransformMatrix[1][0];
float rotY = TransformMatrix[1][1];
float dir = atan( rotX, rotY );
float sin_factor = -sin( dir );
float cos_factor = cos( dir );
vec2 screenB = vec2( screenA.x*cos_factor, screenA.y*cos_factor ) * mat2(cos_factor, -sin_factor, sin_factor, cos_factor);
//scale
vec2 scaleData = vec2( TransformMatrix[0][0], TransformMatrix[1][1] );
vec2 screen = screenB / scaleData;