TriangleStrip UV coordinates

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
j0nte33
Prole
Posts: 3
Joined: Tue Nov 08, 2016 8:00 pm

TriangleStrip UV coordinates

Post 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
 
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: TriangleStrip UV coordinates

Post 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")!

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
j0nte33
Prole
Posts: 3
Joined: Tue Nov 08, 2016 8:00 pm

Re: TriangleStrip UV coordinates

Post 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
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: TriangleStrip UV coordinates

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest