Previous topicNext topic

Z-Order Sort for 4 Polygons

Questions, comments, feedback, etc.
Post Reply
blackdot
Posts: 528
Joined: Sun Jul 06, 2014 10:18 pm

Re: Z-Order Sort for 4 Polygons

Post by blackdot »

artnik wrote:@Blackdot. Cool. Can you throw up a quick screenshot of what that looks like?
i wanted to make a little animation of an object that deforms in a certain way when i press different midi inputs. so i did a little test with 3 inputs. to "fake" the object behaving differently i made animations for every possible solution and triggered t hem depending on the inputs i pressed.
so with 3 buttons, you get 7 solutions:
A, B, C, AB, AC, BC and ABC (the order does not matter). so i rendered 7 image sequences and hooked them up like this:
Untitled.jpg
Untitled.jpg (95.7 KiB) Viewed 13684 times
i hope this is understandable :).

the values for 1.1, 1.2 and 1.35 i chose pretty randomly, hoping they would result in unique different numbers if they're added.
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: Z-Order Sort for 4 Polygons

Post by artnik »

Thanks Blackdot! That's clever summing the inputs.

That makes total sense. I was having trouble with the syntax, and this makes it crystal clear.

Have you used CASE?
blackdot
Posts: 528
Joined: Sun Jul 06, 2014 10:18 pm

Re: Z-Order Sort for 4 Polygons

Post by blackdot »

artnik wrote:Thanks Blackdot! That's clever summing the inputs.

That makes total sense. I was having trouble with the syntax, and this makes it crystal clear.

Have you used CASE?
well i dont know if we can use it :D. that would surely make it more easy instead of using 7 different modifiers. can we use that?
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: Z-Order Sort for 4 Polygons

Post by artnik »

Well, if not perhaps in the future? It looks like that library supports more than single line code. It would be like adding scripting. :-)
blackdot
Posts: 528
Joined: Sun Jul 06, 2014 10:18 pm

Re: Z-Order Sort for 4 Polygons

Post by blackdot »

woah, switch is actually working.

https://github.com/ArashPartow/exprtk/b ... e.txt#L514

i tried it with

Code: Select all

switch
{
	case x == 1.1 : 10;
	case x == 1.3 : 30;
	case x == 1.5 : 50;
	default : x;
}
and just copied the whole thing into t he expression modifier. it works. awesome :D.
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: Z-Order Sort for 4 Polygons

Post by artnik »

Awesome!
damstraversaz
Posts: 176
Joined: Tue Aug 26, 2014 11:22 am

Re: Z-Order Sort for 4 Polygons

Post by damstraversaz »

what a great work, thanks a lot !
skarabee
Posts: 131
Joined: Fri Aug 28, 2015 3:11 am

Re: Z-Order Sort for 4 Polygons

Post by skarabee »

Thank you for this topic, I've learned a lot. I was afraid to use expressions. Now you have cleared the way a bit: I'm still afraid but I have some example to cut my teeth ;-)

Very clever and elegant solution for the Z sorting, hats off!
arash
Posts: 1
Joined: Mon Apr 17, 2017 11:45 pm

Re: Z-Order Sort for 4 Polygons

Post by arash »

@blockdot if the variable x is never exactly assigned the values (1.1, 1.3, 1.5), it's be better to use the 'equal' function which uses a quantized epsilon approach to determining equality between the floating point values.

For example 1.3 and 1.2999999999 (potential value of x) wont be considered equal in the original expression code, however in following code they will be:

Code: Select all

switch
{
   case equal(x,1.1) : 10;
   case equal(x,1.3) : 30;
   case equal(x,1.5) : 50;
   default : x;
}
Post Reply