Textured Polygons for All!

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by xXxMoNkEyMaNxXx »

Simply do:

tex.quad(image,vercices[1],vercices[2],vercices[3],vercices[4])
tex.quad(image,po[1],po[2],po[3],po[4])

It would have worked before too :P
Attachments
Easy.love
It's that easy...
(48.86 KiB) Downloaded 448 times
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by Ref »

Darn, you're right!
Always seem to things the hard way.
Next thing you know I'll want to just pass the quad rather than the individual vertices.
Thanks!
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by xXxMoNkEyMaNxXx »

So, what will you make? :ultrahappy:
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

OK!
To be consistent - "you're doing it all wrong" - here is some more of the same.

Can't seem to get the hang of the 'op' & 'rep' parameters.
Think these might do what I'm attempting in a more efficient manner but not sure.
I would like to be able to select a portion of an image and apply it to a quad (origin of texture => tex.x, tex.y and size of texture to apply => tex.h & tex.w).

Was successful in attached demo but had to resort to create a separate image for each quad.
(image_data source image=>intermediate image_data=>paste=>convert to image=>apply to quad)
Really ugly and ate up a lot of fps creating 82 separate images.
Mister genius, how would you do it?
Attachments
surface_texturing.love
Add texture to a surface
(19.05 KiB) Downloaded 190 times
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

--= Pre-Version 8 =--
I have some documentation included in the Perspective.lua, that may help as well as this:

texture.setRepeat(origin,size)
'origin' is a vector percentage of where to offset the image to. For example:
origin={0.25,0.5}
Would make the top left of the image slide to 25% across, and 50% down the polygon.

'size' is a vector percentage of the amount of image to capture. For example:
size={0.1,0.2}
Would make the whole image appear in every 10% by 20% size portion of the polygon.

So, texture.setRepeat({0.25,0.25},{0.5,0.5}) would make the texture appear every 50% starting at 25%.

I could change this to better suit your needs by making it image based, would you like me to do that?

EDIT:
Ah, now I see you're using an old version of the pixelEffect :o
The scaling was majorly screwed up in that version :L
Last edited by xXxMoNkEyMaNxXx on Wed Jan 23, 2013 11:35 pm, edited 2 times in total.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

I just made a version that is image based.
origin is where the top left of the polygon starts in on the image (from the top left),
size is how much of the image to display.

These values are still percentages.
Attachments
Perspective.lua
Version 8 - Image based scaling :)
(4.62 KiB) Downloaded 171 times
Last edited by xXxMoNkEyMaNxXx on Wed Jan 23, 2013 11:30 pm, edited 2 times in total.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

Right!
Thanks, sort of how I read it.
Any possibility of translating that into something a mear mortal can grasp.
Like how does tex.x & tex.y map into 'op' (presumably have to do some scaling)
And where does tex.w & text.h go (width & height)?
I know you've said it but could you restate it for chlidren below the age of 5?
Have been thumping keys and got random results.
Know it's something obvious but am overlooking something.
Edit: You're just too fast for me. Will give your new library a go. Thanks!
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

To select a portion from a={x,y} to b={x,y} on an image that is size s={x,y}
origin=a/s
size=(b-a)/s
So basically, divide the location by the image size.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

All's well - almost, I guess!
Got what I asked for and more.
Thanks!
Did noticed that (I guess you would have expected this) that when the texture rolls over, the origin on the repeated images is {0,0} and not what is set by 'op'.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

Did noticed that (I guess you would have expected this) that when the texture rolls over, the origin on the repeated images is {0,0} and not what is set by 'op'.
What do you mean by rolls over, like the limit of the modulus?

*Thinks a bit*

Ah, now I see what you mean.
'p0' and 'rep' are actually repeat options, not scaling, but the way I've got it set up, they can double as both.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests