Is it possible to tile a triangle like you can with quads?

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.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Is it possible to tile a triangle like you can with quads?

Post by Positive07 »

Then you are using the wrong coordinates, can you post the snippet where you define the mesh? I can help you if you do that
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Dialglex
Prole
Posts: 9
Joined: Tue Feb 07, 2017 6:14 am

Re: Is it possible to tile a triangle like you can with quads?

Post by Dialglex »

Code: Select all

objects.leftramp.meshtable = {{0,0, 0, 10}, {320, -160, 10, 0}, {320, 0, 10, 10}}
objects.leftramp.mesh = love.graphics.newMesh(objects.leftramp.meshtable)
Thanks for your help :)
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Is it possible to tile a triangle like you can with quads?

Post by Positive07 »

UV coordinates go form 0 to 1 so if your image has a width of 10, a U coordinate of 1 means 10 pixels to the right, and a U coordinate of 0.5 means 5 pixels to the right, a U coordinate of 0 means 0 pixels to the right. Same for V.

So your image corners would be:

Code: Select all

0,0 ... 1,0
...     ...
0,1 ... 1,1 
So the following code should give you your desired look:

Code: Select all

objects.leftramp.meshtable = {{0,0, 0, 1}, {320, -160, 1, 0}, {320, 0, 1, 1}}
objects.leftramp.mesh = love.graphics.newMesh(objects.leftramp.meshtable)
I find the negative value a little bit weird but if that works for you it's fine.

If you were using an image with other sprites in it, divide the value you had for U by the width of your atlas, and that should be the value of the U coordinate, divide the value you had for V by the height of your atlas and that should be the value of the V coordinate.

If this doesn't solve your problem I would need some more info like: What are the dimensions of your image? What size do you want the ramp to be? How do you want to orient it? and such.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Dialglex
Prole
Posts: 9
Joined: Tue Feb 07, 2017 6:14 am

Re: Is it possible to tile a triangle like you can with quads?

Post by Dialglex »

I want the image to tile, but using 1 just makes it a single big image. The image is 32x32 by the way.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Is it possible to tile a triangle like you can with quads?

Post by Positive07 »

You mean like appear repeated multiple times inside of the triangle?

Then did you use Image:setWrap("repeat") on the texture you are using with that mesh? (Together with the code you posted before, not the one I posted). Check WrapMode
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Dialglex
Prole
Posts: 9
Joined: Tue Feb 07, 2017 6:14 am

Re: Is it possible to tile a triangle like you can with quads?

Post by Dialglex »

I am setting the wrap in the load function, should I be putting it somewhere else?

Code: Select all

maptileimage = love.graphics.newImage("Images/Map/SandBlock.png") NEWLINE 

maptileimage:setWrap("repeat", "repeat")
I can't make a new line for some reason.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Is it possible to tile a triangle like you can with quads?

Post by Positive07 »

Mmm... I see, your code seems to be right, could you post a .love? Doesn't need to have all the code, just a minor example to replicate (I probably can make one but it's better if it's your own code so you make sure that you are doing the very same thing)
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Dialglex
Prole
Posts: 9
Joined: Tue Feb 07, 2017 6:14 am

Re: Is it possible to tile a triangle like you can with quads?

Post by Dialglex »

BattleCars.love
(88.58 KiB) Downloaded 204 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests