We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In processing there is this cool tool called PShape that if you don't know about, you should learn, it is extremly powerful when it comes to complicated graphics (3d graphics in my case), and makes even unthinkable concepts managable. But I ran into a problem with it, processing provides a variaty of cool built-in shapes you can use, in my case things like triangle fans, triangle strips, and just a bunch of triangles, but they lack some functionality I wish it had, changing single triangle colors. When you use a GROUP shape it can have many children shapes which consist of it, and the best part is you still can use each child as an individual shape, and you would think triangle strips and fans should be the same, it is a big shape made from many little triangles, so I should be able to control each triangle individually, and to some level it is, you can get how many vertices make the shape, and even move them, but when it comes to color you can control only the color of the entire shape, and not each triangle by itself. Is there any way around this? Can I somehow change the color of a single triangle without the rest in a built-in shape?
Answers
https://forum.Processing.org/two/discussions/tagged?Tag=setfill()
https://forum.Processing.org/two/discussions/tagged?Tag=setstroke()
GoToLoop thanks but setFill() and setStroke() are the problem, they change all of the triangles as a collective in built-in shapes while I need individual triangles.
Maybe make clones of your PShape, so each 1 can have its own color attribs.? :-?
Well, I was trying to avoid making my own shapes and just use the built-in shapes (assuming it would have better prformance), but I have considered it, and if there is no way around this problem I will probebly just do it...
Would this do the trick?
https://processing.org/reference/vertex_.html
Kf
kfrajer great example, but as I said to GoToLoop, I was trying to avoid creating my own shapes for triangle fans strips and lists (which I rely on with my project), since I am afraid it will impact my preformance, but I am getting a vibe that eventually this is what I will have to do... thanks anyway...:)
Well eventually I gave up on the built-in shapes and managed single triangles individualy from the start, it was a bit of work and I am not really sure what preformance I would have got otherwise but for my purposes it is good enough. And by the way if you were wanderring what I was making it was a spherical screen in which every triangle is a pixel, all of the pixels are about the same shape and size and evenly distributed, and this is how it looks: GoToLoop and kfrajer, thanks for your advice!
did you use children in the end?
if you use TRIANGLES then you can happily use different fills for each triangle
you can also do per-vertex colours
Yes koogs, I have used children, but your suggestion isn't the right thing for this project, I want to be able to animate the triangles changing colors as efficiently possible, and as far as my understanding the best way of doing so in processing is to create a pshape with all of the triangles of the sphere and changing each color of each triangle without changing the shape, that way processing can do its magic and draw the shape on the screen faster.