Page 3 of 15

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

Posted: Mon Jan 21, 2013 7:54 pm
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

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

Posted: Mon Jan 21, 2013 11:57 pm
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!

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

Posted: Tue Jan 22, 2013 12:04 am
by xXxMoNkEyMaNxXx
So, what will you make? :ultrahappy:

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 10:24 pm
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?

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:07 pm
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

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:17 pm
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.

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:19 pm
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!

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:24 pm
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.

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:45 pm
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'.

Re: Textured Polygons for All!

Posted: Wed Jan 23, 2013 11:51 pm
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.