Page 2 of 2

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

Posted: Wed Feb 08, 2017 7:06 pm
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

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

Posted: Wed Feb 08, 2017 10:57 pm
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 :)

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

Posted: Thu Feb 09, 2017 7:56 am
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.

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

Posted: Thu Feb 09, 2017 8:38 am
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.

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

Posted: Thu Feb 09, 2017 10:35 pm
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

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

Posted: Fri Feb 10, 2017 5:45 am
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.

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

Posted: Fri Feb 10, 2017 7:53 am
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)

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

Posted: Fri Feb 10, 2017 8:46 pm
by Dialglex
BattleCars.love
(88.58 KiB) Downloaded 205 times