How to Fill Box2d boxes with vertex buffer and specific color

hey,

i tried to fill box2d bodys with a color. This works fine with a mesh and vertex buffer. But now i wonder how i can give different colors to custom boxes.

In this patch you can create two boxes with diffenrent custom names.
BoxA and BoxB. In the subpatch " farbflaecheCalc " the mesh and the color is defined.

Is it possible, that all BoxA Bodys get one color, and all BoxB Bodys another?

FarbBox.rar (9.7 kB)

Hi
now you got mr hooked on this. I am trying to do it with a Polygon but I find it a bit tricky withe the spreads. My idea is to create the triangles forming the mesh taking 2 consequential vertices then the center of the shape, so I need a way to “nest” together 2 different spreads…
Something like: take a bin of 6 from the vertex buffer, then insert the center, take another 6 and add center again and so on…

as you create a mesh inside the “flaechenfarbeCalc” you just leave the vertices white and replace the DrawFixed with any shader you want to draw your mesh… if its just a color you need then use Constant, but you can use any shading you want…

About the colors something like that? (could be improved)

FarbBoxCustomColor.rar (11.6 kB)

Yeeeeahs man thats excatly what we need!!! Iam so stupid. Sure we have to use BodybyCustom.

But slowly iam learning vvvv :D

Still very intrigued about how to deal with the vertices spread to get a mesh out of a Polygon.
Anybody?

yes, thx io, finally! ^^
The spread vertices works for our project good enough, but i’m also interested in a more flexible solution for polygon.

i’m testing the CarPaint-Shader in combination with this patch. How can I change the lightsetting. At the moment, the light comes from 0/0 and has the direction to -1/-1, so everything above is not visible. how can i define a radial gradient starting from 0/0?

Hello, welcome to the forum

Probably the best solution at the moment for meshing polygons is vux’s ‘Polygon (EX9 Geometry 2d)’ node, it’s in the addonpack. If you just take the ‘vertices xy’ and ‘vertices count’ from the box2d getpolygons node and send them to the polygon mesh node, you will get the mesh you need.

The problem becomes a little more complex when you want to make a mesh that is ‘concave’ as opposed to ‘convex’. Info on convex shapes here:

At the moment there’s only a few good ways to make meshes from ‘concave’ shapes, and unfortunately there’s no plugins for this in vvvv yet.

Regarding the carpaint shader issues, it might be best to start a new thread with some questions about shaders/lighting?

Regards

Hi
thanks, I even had it installed but forgot about it!
At this point the “concave” issue is not really important since Box2d can t handle concave shapes either.
I have never tried but we should be able to obtain concave shapes adding 2 or more non-concave shapes together and calculating the proper rotation center for each object…

Yea, good idea that always works!

yes, i knew vux would have made something to draw the polygons, here a version with the constant shader:

farbBOX2.v4p (29.5 kB)