sin wave surface in 3D
Author |
Message |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: 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
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Sat Apr 03, 2004 5:24 pm Post subject: (No subject) |
|
|
omg thats crazy, its like when I first saw runescape, and thought it was crazy being done with java applet lol
|
|
|
|
|
![](images/spacer.gif) |
recneps
![](http://www.fcpocanada.com/canada1.gif)
|
Posted: Sat Apr 03, 2004 8:03 pm Post subject: (No subject) |
|
|
OMG that amazing. Teach us! lol +bits
|
|
|
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Sun Apr 04, 2004 4:18 pm Post subject: (No 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
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
3d_001.t |
Filesize: |
2.28 KB |
Downloaded: |
359 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Catalyst
![](http://catalyze.mine.nu/jack_of_spades+100.jpg)
|
Posted: Sun Apr 04, 2004 5:19 pm Post subject: (No subject) |
|
|
i like both of them
very creative
have ... 83 bits
|
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Sun Apr 04, 2004 6:35 pm Post subject: (No subject) |
|
|
holy!!! that is just amazing? that second one, were you trying to achieve a 3D effect? cause thats what I see...
|
|
|
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Sun Apr 04, 2004 6:39 pm Post subject: (No subject) |
|
|
wow thanks, nuf bits there catalyst
and yeah, i was trying to make it 3D
[edit] well it is 3D[/edit]
-zylum
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
valor
|
Posted: Wed Apr 07, 2004 2:33 pm Post subject: (No 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
|
|
|
|
|
![](images/spacer.gif) |
|
|