Page 1 of 1

Superformulas

Posted: Fri Jun 20, 2008 7:20 pm
by kattle87
A little gift for jph_wacheski :)

I have never heard before of superformulas, but HEY! THEY ARE GREAT :D

Just bitmap for now, but 3D should be easy if you just need a "Bumped" 2D image.

Have fun :D

supercool!

Posted: Fri Jun 20, 2008 8:43 pm
by jph_wacheski
Hay that is wicked! I knew you could implement that equation in ZGE with way more speed and eloquence than I.., amazing.

This looks to b very usefull indeed,. so many uses for these shapes,. particles, mesh textures, level designs,. etc.
We should post some nice values in this thread,. or wait, there where a bunch on the wikipedia post,.I going to go try those,. . brb

yup these work fine; http://en.wikipedia.org/wiki/Superformula

2111 for an eye,. sweet PGC, tasty.

the minimized ver of the above

Posted: Mon Nov 24, 2008 3:22 am
by jph_wacheski
Here is the ver. of this as I am using it now,.

Code: Select all

// GielisSuperformula  - thanks kattle!
float R, T, Xp, Yp, N1, N2, N3, M, Tp, S, Z;
M=5; N1=1; N2=7; N3=8; S=.8; Z=14;
if (this.X!=0 || this.Y!=0) {
    Xp=(this.X-0.5)*Z; Yp=(this.Y-0.5)*Z;
    T=atan2(Yp,Xp); R=sqrt(Xp*Xp + Yp*Yp);
    Tp=R-pow(pow(abs(cos(M*T/4)/1),N2)+pow(abs(sin(M*T/4)/1),N3),-1/N1);
 if (Tp<0) {
 this.Pixel.r=Tp*(0-S);
 this.Pixel.g=Tp*(0-S);
 this.Pixel.b=Tp*(0-S);
 this.Pixel.a=Tp*(0-S);
 }
}
I was trying to fold it into a Library Component to reuse the formula but I'm just cuting and pasting this when I need another,. simple enouph.

How about a 3d mesh ver. ?

Posted: Sun Jan 11, 2009 8:59 pm
by kattle87
Updated to use the "float" keyword inside the ZExpressions, and added 3D code 8)
However, I'm still working on the Normals, since it might be a little tricky to fix them. However you can just toggle autonormals to get a nice effect.

PS: you can use my "Better Sphere" ZExpression before the 3D one to get a better "upper" surface;

nicely done.

Posted: Sun Jan 11, 2009 10:16 pm
by jph_wacheski
Very very cool!

lov the 3d!,. will be great for all sorts of nicely organic primatives to build stuff from,. here is a few minuets of testing,. ;)

thnks bro,. you roc.