Page 1 of 1

TriangleStrip UV coordinates

Posted: Tue Nov 08, 2016 8:13 pm
by j0nte33
I'm having problem setting up my UV coordinates with my trianglestrip.
here is an image:
Image
(pretty :ultrahappy: )
This image is created by 3 cubes (6 triangles)
I want the middle texture to not be flipped.
I can't seem to get it right, any value i try.

(the positions go from bottom up, then jump to right)
here is how i construct the mesh:

Code: Select all

 
 x:0   y:200 u:0 v:1
 x:0   y:0   u:0 v:0
 x:200 y:200 u:1 v:1
 x:200 y:0   u:1 v:0
 x:400 y:200 u:0 v:1
 x:400 y:0   u:0 v:0
 x:600 y:200 u:1 v:1
 x:600 y:0   u:1 v:0
 

Re: TriangleStrip UV coordinates

Posted: Tue Nov 08, 2016 11:40 pm
by s-ol
j0nte33 wrote:I'm having problem setting up my UV coordinates with my trianglestrip.
here is an image:
Image
(pretty :ultrahappy: )
This image is created by 3 cubes (6 triangles)
I want the middle texture to not be flipped.
I can't seem to get it right, any value i try.

(the positions go from bottom up, then jump to right)
here is how i construct the mesh:

Code: Select all

 
 x:0   y:200 u:0 v:1
 x:0   y:0   u:0 v:0
 x:200 y:200 u:1 v:1
 x:200 y:0   u:1 v:0
 x:400 y:200 u:0 v:1
 x:400 y:0   u:0 v:0
 x:600 y:200 u:1 v:1
 x:600 y:0   u:1 v:0
 
you want just four vertices with

Code: Select all

{ x=0, y=200, u=0, v=1 },
{ x=0, y=0, u=0, v=0 },
{ x=600, y=0, u=3, v=0 },
{ x=600, y=200, u=3, v=1 },
you can of course add the intermediate ones anyway but you still need to increment:

Code: Select all

 
 x:0   y:200 u:0 v:1
 x:0   y:0   u:0 v:0
 x:200 y:200 u:1 v:1
 x:200 y:0   u:1 v:0
 x:400 y:200 u:2 v:1
 x:400 y:0   u:2 v:0
 x:600 y:200 u:3 v:1
 x:600 y:0   u:3 v:0
 
remember to texture:setWrap("repeat", "repeat")!

Re: TriangleStrip UV coordinates

Posted: Wed Nov 09, 2016 12:27 pm
by j0nte33
ah that makes sense!
The reason I'm using more than four vertices is because i want to generate a mesh based of a spline.
I didn't realize i could have the UV coordinates outside the range of 0-1.

It works! thank you!
Image
here is a short video:
http://puu.sh/sbf6N.webm

Re: TriangleStrip UV coordinates

Posted: Wed Nov 09, 2016 1:54 pm
by zorg
j0nte33 wrote:I didn't realize i could have the UV coordinates outside the range of 0-1.
You can, but the behaviour will depend on the [wiki]WrapMode[/wiki] chosen.