Page 1 of 2

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

Posted: Tue Feb 07, 2017 6:49 am
by Dialglex
I am making a platformer map with slopes but I am not sure how to give a triangle a tile effect.

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

Posted: Tue Feb 07, 2017 9:45 am
by Positive07
Have you checked the wiki on [wiki]Mesh[/wiki]es? They have a lot of arguments but they basically allow you to create some weird [wiki]Quad[/wiki]s using UV coordinates (the coordinate in the image) and coordinates (the coordinate in screen) for each vertex. And you get the extra benefit of per-vertex attributes like colors and whatever you may add

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

Posted: Tue Feb 07, 2017 4:23 pm
by peterrust
Dialglex, I haven't done it myself, but my impression is that people typically create a rectangular tile image, where half of the image is transparent and the other half is "painted" with the triangle image. But an actual triangle is input into the physics system (I don't think the bump collision library has support for triangles/slopes, so hardon-collider or box2d/physics is probably used). But others with more knowledge can probably correct me and give more details.

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

Posted: Wed Feb 08, 2017 5:52 am
by Dialglex
peterrust, how would I make half of it transparent? I already had the idea, but I just didn't know how to do it.

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

Posted: Wed Feb 08, 2017 6:51 am
by Positive07
You edit it with a software like GIMP, Photoshop or other image editor

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

Posted: Wed Feb 08, 2017 7:23 am
by peterrust
Dialglex wrote:how would I make half of it transparent?
Positive07 wrote:You edit it with a software like GIMP, Photoshop or other image editor
Right... gimp and Photoshop are so powerful, they can be hard to figure out. There are plenty of smaller image editors out there, I really like aseprite, which is designed for pixel art, but it's not free. http://www.piskelapp.com/ is an online one that's free, I'm sure there are others. You'll probably want to save in the PNG format, which has good support for transparency. How exactly to make half the pixels transparent depends on the editor, sometimes there will be a "Background Color" property that you can set to a fully transparent color, other times you can just use an eraser tool to clear out the pixels that you want to be transparent.

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

Posted: Wed Feb 08, 2017 8:43 am
by Positive07
I didn't want to recommend a pixel art oriented tool for the simple reason that he may not be using those kind of graphics, and editting real graphics with a pixel art tool is not really what you want. The magic wand in both GIMP and Photoshop is really simple to use and you can easily remove everything that is made of the same (or similar) color

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

Posted: Wed Feb 08, 2017 10:04 am
by Dialglex
Thanks for the replies, I have used meshes and it is almost done but it is stretching the image because it is it is not a square shaped triangle. How would I make it not stretch?

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

Posted: Wed Feb 08, 2017 10:31 am
by raidho36
You need to use proper UV coordinates, is all.

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

Posted: Wed Feb 08, 2017 11:13 am
by Dialglex
I am but all it is doing is tilting the image.