Superformulas

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Superformulas

Post 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
Attachments
superformula.zgeproj
(1.73 KiB) Downloaded 572 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

supercool!

Post 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.
iterationGAMES.com
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

the minimized ver of the above

Post 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. ?
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post 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;
Attachments
superformula.zgeproj
(2.45 KiB) Downloaded 497 times
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

nicely done.

Post 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.
Attachments
superformula_3D_jan1109.zip
plant life, .. .exe
(33.31 KiB) Downloaded 588 times
iterationGAMES.com
Post Reply