SynthMaker

Convex filled polygons

Archive · 2010 21 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

mwvdlee ·

Here's a really, really slow example of how to draw filled convex polygons using S|M.

It uses a horizontal scanline method; draw the outline using standard primitives, find first and last pixel in a row, draw all pixels inbetween. Should be stable, albeit slow, for any convex polygon. I'm pretty sure there's room for performance improvement, so please go ahead and try 😉 Make sure you only use convex (or understand the algorithm) polygons that fit inside (or understand the algorithm) the margins of the view.

MegaHurtz ·

cool. 😍

Je onderschrift is ook errug inspirerend, mss van de winter wat bèèta`s.

trogluddite ·

Nice work. Taking inspiration from your nested draw loops, here's one for drawing a regular polygon with any number of sides...

MegaHurtz ·

wow 😍 Me like hexagons 😀 Into the toolkit they go.. pom pom

mwvdlee ·

trogluddite wrote: Nice work. Taking inspiration from your nested draw loops, here's one for drawing a regular polygon with any number of sides...

Nice! I like "cheating" like this 🙂 It's a bit faster without visual difference if you disable AA for the "fill", increase the inner loops' step size and decrease the pen thickness multiplier. I tried step 2 pixels with 1.5x and can see no artifacts. I guess you could draw any irregular convex polygon like this too, if you could determine a point inside the shape.In the case of S|M it'd probably be faster than my scanline version. Come to think of it, in a convex polygon you could take any of the given vertices as the center and skip the lines connected to the vertice. An interresting idea.

Jay ·

Great demonstration mwvdlee! thanks! and I really love that one Trogg, got me so exited i nearly coughed my good lung up! 😀 i have been trying to do shapes for ages but i am to thick for the maths to get anywhere 😉

very cool guys

Best Regards

mwvdlee ·

Based on trogludite's line trick; a new, much faster irregular convex filled polygon renderrer. Actually, it's a triangle renderer in a loop.

There IS an issue, which seem to stem from timing issues. The coordinates can get mangled when rendering multiple triangles and when the view is big. You could fix if by increasing the step size and/or line-width, but it seems there is just a physical limit to the number of iterations you can do with a draw loop.

This is "proof-of-concept"; I'm sure trogludite or others will quickly improve upon it.

The only benefit my original scanline version had, is that you're not restricted to straight edges of the shape; if you set the curve to TRUE in the point array module, you'd get a filled curvy polygon. But curves have the slight risk of becoming concave.

MichaelBenjamin ·

pretty cool, i like these shapes. do you think something like this is possible?

mwvdlee ·

MichaelBenjamin wrote: pretty cool, i like these shapes. do you think something like this is possible?

Short answer: Yes. Long answer; these shapes are irregular, Trog's version specializes in regular polygons only, so you'd have to use either of my versions. None of the versions can handle transparency by itself, but you could render to a bitmap, the scan the bitmap's pixels and do the transparency yourself. Also remember to calculate rotation for all vertices and sort them along the Z axis. It'll work, but not usably fast. Also, that animation is lighted, which you'd have to calculate too. S|M has all the facilities to do all of this, but it will be sheer masochism to even try.

Using solid surfaces makes it a lot easier: - Calculate all the triangles (store x/y/z triads in an array). - Cull back faces (integrate with previous step and only store front faces). - Calculate lighting (if you can recognize back faces, you've already done most of the work for this). - Render all triangles in a loop.

It may be a lot easier with solid surfaces, but I'm sure as hell not going to try doing it in S|M 😉

MichaelBenjamin ·

can you recommend an easy to use 3d program that can draw, texture, light and animate a simple shape like that?

Nu Audio Science ·

Blender is about your best bet MB There are a hell of a lot of tutorials to learn from and it's free

Myself i use Silo and Lightwave but they would be over the top for something like this

But anyway try HERE

That place has the links to pretty much every app made

NAS

Acrobat ·

mwvdlee wrote: Here's ....

...one of the coolest things seen in the graphic department this year! Thanks mwvdlee and Trog for the regular mods! 😀

philter5 ·

Acrobat wrote: mwvdlee wrote: Here's ....

...one of the coolest things seen in the graphic department this year! Thanks mwvdlee and Trog for the regular mods! 😀

Ohh Yeeeeees thx to our graphic-specialists 😍

mwvdlee ·

Based on this: Swing / SickTheramin

Here's another regular polygon renderer. It should be a lot faster (and spare a lot of the limited loop draws). Only drawback is that it only works for 4 sides or more. Preferably 5 or more, because you could make a much more efficient renderer for 4 sides without loop. For convenience, I included the optimized one for 4 sides (a.k.a. squares) too :P; it requires no loop and can use transparent colors.

aliasant ·

mwvdlee wrote: Based on this: Swing / SickTheramin

Here's another regular polygon renderer. It should be a lot faster (and spare a lot of the limited loop draws). Only drawback is that it only works for 4 sides or more. Preferably 5 or more, because you could make a much more efficient renderer for 4 sides without loop. For convenience, I included the optimized one for 4 sides (a.k.a. squares) too :P; it requires no loop and can use transparent colors.

That IS COOL. Making knobs maybe 🙂

trogluddite ·

mwvdlee wrote: Here's another regular polygon renderer

Excellent bit of lateral (or should that be radial?) thinking - just one line draw per vertex, I'd be very surprised if there's a faster way than that!

mwvdlee ·

trogluddite wrote: I'd be very surprised if there's a faster way than that!

Depends on how expensive the Arc primitive is compared to two Line primitives; you could use it to draw two edges with one operation.

mwvdlee ·

Well, here's all my basic shape primitives pulled together from several different topics. All of them work with alpha color now through the use of a bitmap cache where required. These will probably go unchanged in my next MissingLinks release.

rl ·

cool technique - 'never thought about doing it this way...

MegaHurtz ·

Yep cool it can be done, and quite quick indeed.

Jay ·

cool stuff! will use these no end! 🙂

Thanks mwvdlee!

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.