Is it possible to tile a triangle like you can with quads?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- 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?
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Is it possible to tile a triangle like you can with quads?
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)
- 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?
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:
So the following code should give you your desired look:
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.
So your image corners would be:
Code: Select all
0,0 ... 1,0
... ...
0,1 ... 1,1
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)
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Is it possible to tile a triangle like you can with quads?
I want the image to tile, but using 1 just makes it a single big image. The image is 32x32 by the way.
- 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?
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
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Is it possible to tile a triangle like you can with quads?
I am setting the wrap in the load function, should I be putting it somewhere else?
I can't make a new line for some reason.
Code: Select all
maptileimage = love.graphics.newImage("Images/Map/SandBlock.png") NEWLINE
maptileimage:setWrap("repeat", "repeat")
- 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?
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: Bing [Bot] and 2 guests