Computer Science Canada sin wave surface in 3D

Author:  zylum [ Sat Apr 03, 2004 5:18 pm ]
Post subject:  sin wave surface in 3D

well, i was looking through the best of turing submissions thread and saw a few particle systems and thought i'd mak one in 3d... anyways, one thing lead to another and i came up with this.... sorry it's a bit slow but it has a lot of points to calculate.

 code: setscreen ("offscreenonly,graphics:1000;700,nobuttonbar,position:middle;middle") type _3D :     record         x : real         y : real         z : real     end record const xs := 30 const zs := 30 const perspective := 400 const spread := 10 const amplitude := 12 const wavelength := 2 var coords : array 1 .. xs * zs of _3D var depth : int var n : int := 0 var x, y, oldx, oldy : int var angX, angY : real := 45 var a : real := 0 const colors := 220 var clr : array - colors div 2 .. colors div 2 of int for i : 1 .. colors     clr (i - colors div 2) := RGB.AddColor (i / colors, i / colors, i / colors) end for var COS, SIN : array 0 .. 360 of real for i : 0 .. 360     COS (i) := cos (i * (Math.PI / 180))     SIN (i) := sin (i * (Math.PI / 180)) end for procedure rotate (xpp, ypp, zpp, ax, ay, az : real)     var temp : real     var xp, yp, zp : real     yp := ypp * COS (round (ax)) - zpp * SIN (round (ax))     zp := zpp * COS (round (ax)) + ypp * SIN (round (ax))     temp := zp     zp := zp * COS (round (ay)) - xpp * SIN (round (ay))     xp := xpp * COS (round (ay)) + temp * SIN (round (ay))     temp := xp     xp := xp * COS (round (az)) - yp * SIN (round (az))     yp := yp * COS (round (az)) + temp * SIN (round (az))     depth := round (zp)     x := round (xp / (1 - zp / perspective)) + maxx div 2     y := round (yp / (1 - zp / perspective)) + maxy div 2 end rotate for _x : 1 .. xs     for _z : 1 .. zs         n += 1         coords (n).x := _x * spread - (xs / 2) * spread         coords (n).z := _z * spread - (zs / 2) * spread         coords (n).y := (cos (_x / wavelength) * amplitude) + (sin (_z / wavelength) * amplitude)     end for end for loop     n := 0     a += 0.05     angX := sin (a) * 35 + 90     angY += 2     for _x : 1 .. xs         for _z : 1 .. zs             n += 1             rotate (coords (n).x, coords (n).y, coords (n).z, angX mod 360, 1, angY mod 360)             if _z > 1 then                 Draw.ThickLine (oldx, oldy, x, y, (depth + 250) div 15, clr (depth * -1))             end if             oldx := x             oldy := y         end for     end for     View.Update     cls end loop

-zylum Author: Tony [ Sat Apr 03, 2004 5:23 pm ] Post subject: nice looks good, too bad it runs slow +20Bits

 Author: Paul [ Sat Apr 03, 2004 5:24 pm ] Post subject: omg thats crazy, its like when I first saw runescape, and thought it was crazy being done with java applet lol Author: recneps [ Sat Apr 03, 2004 8:03 pm ] Post subject: OMG that amazing. Teach us! lol +bits

 Author: zylum [ Sun Apr 04, 2004 4:18 pm ] Post subject: i'm glad you guys like it! here's another similar effect... make sure you dont draw for too long cuz it will get lagy. -zylum

 Author: Catalyst [ Sun Apr 04, 2004 5:19 pm ] Post subject: i like both of them very creative have ... 83 bits

 Author: Paul [ Sun Apr 04, 2004 6:35 pm ] Post subject: holy!!! that is just amazing? that second one, were you trying to achieve a 3D effect? cause thats what I see...

 Author: zylum [ Sun Apr 04, 2004 6:39 pm ] Post subject: wow thanks, nuf bits there catalyst and yeah, i was trying to make it 3D  well it is 3D[/edit] -zylum

 Author: valor [ Wed Apr 07, 2004 2:33 pm ] Post subject: wow the day i learn how to do that is when Micheal Jackson isnt a Child Malester i dont have much but here +10 bits

 :