Dark Bit Factory & Gravity
GENERAL => Challenges & Competitions => Topic started by: Tetra on June 12, 2006
-
So i wanted to attempt something 3D. Its only made up of dots and wasnt what I started out to make hehe :whack: <- love this pic
The dots are colored and sized based on the depth and the circles blend together using or.
To get it down in line size I nested the for next loops together. Blitz is happy with this but not sure about the rulez :protest:
Download Latest Code and Exe: 3Din20(3).rar (http://www.tetrahedron.me.uk/3Din20(3).rar)
Download Code and Exe: 3Din20.rar (http://www.tetrahedron.me.uk/3Din20.rar)
Graphics 640,480,32,2
SetBuffer( BackBuffer() )
While Not KeyDown(1)
ax# = (ax# + 0.8 )Mod 360
ay# = (ay# + 0.5 )Mod 360
LockBuffer()
For x = -100 To 100 Step 50 For y = -100 To 100 Step 50 For z = -100 To 100 Step 50
nz# =(((( Sin(ay#) * x) + (-Sin(ax#) * Cos(ay#) * y) + ( Cos(ax#) * Cos(ay#) * z) + 500 ) / 700)Â )
nx =Â (((( Cos(ay#) * x) + ( Sin(ax#) * Sin(ay#) * y) + (-Cos(ax#) * Sin(ay#) * z))+ 130 * Sin(ax) )* nz#) + 320
ny =Â (((( Cos(ax#) * y) + ( Sin(ax#) * z))+ 100 * Cos(ay) )* nz#) + 240
c = 255 * ((nz#Â - 0.45)*1.8)
For i = -10 To 10 For j = -10 To 10
If ( Sqr((i*i) + (j*j)) < (8 * nz#) ) Then WritePixelFast( i+nx, j+ny, (255-c)Shl 16 Or c Shl 8 Or ReadPixelFast( i+nx, j+ny ) )
Next Next
Next Next Next
UnlockBuffer()
Flip
Cls
Wend
(http://www.tetrahedron.me.uk/3Din20ss.png)
(http://www.tetrahedron.me.uk/3Din20(2)ss.png)
:sunny:
-
Like this one too. Heh ;)
-
Tnx Optimus :)
I couldnt leave it alone so I made another variation called 3Din20(2)Â ::)
There are more potential spare lines in this one, so I could compact it down fiuther if the nested loops arent ok.
Download Code and Exe: www.tetrahedron.me.uk/3Din20(2).rar (http://www.tetrahedron.me.uk/3Din20(2).rar)
Graphics 640,480,32,2
SetBuffer( BackBuffer() )
While Not KeyDown(1)
ax# = (ax# + 0.6 )Mod 360
ay# = (ay# + 0.4 )Mod 360
ac# = (ac# + 0.3 )Mod 360
For x = -100 To 100 Step 20 For y = -100 To 100 Step 20 For z = -100 To 100 Step 20
If ( x = -100 Xor x = 100 )Or(y = -100 Xor y = 100)Or(z = -100 Xor z = 100 )
nz# =(((( Sin(ay#) * x) + (-Sin(ax#) * Cos(ay#) * y) + ( Cos(ax#) * Cos(ay#) * z) + 500 ) / 700.0) )
nx = ((((Cos(ay#) * x + Sin(ax#) * Sin(ay#) * y -Cos(ax#) * Sin(ay# ) * z)+ 200 * Sin(ax# + ac#) )* nz#) + 320)
ny = ((((Cos(ax#) * y + Sin(ax#) * z)+ 150 * Cos(ay#+ ac#)) * nz#) + 240)
c = (255 * ((nz# - 0.45)*1.8))
Color Abs(Cos(ac#) * c ),255-c,Abs(Sin(ac#) * c )
Rect nx - 12, ny - 12, 24,24
EndIf
Next Next Next
Flip
Cls
Wend
(http://www.tetrahedron.me.uk/3Din20(2)ss.png)
-
For x = -100 To 100 Step 20 For y = -100 To 100 Step 20 For z = -100 To 100 Step 20
wow didnt know you could do that without the : seperator, could squish down alot more routines into 20 lines doing that :)
-
Wow. I like the last one! It's a nice way to fake a filled vector in few space, sometimes looks like gouraud shading and sometimes like a translucent or depth cube! In fact that's the way some 256b asm intros do 3d polygoned objects which are not really polygons via this way, because it's not really easy to fit a triangle rasterizer in small space. I remember these were blitting smaller boxes and had z-buffer so it wasn't much noticable.
-
The second one is better than the first, but when I saw the fist I was like, WOW! I didn't think anyone would get a 3D cube into 20 lines.
Nice one Tetra :)
Btw, this entry is perfectly legal, nesting loops is a nice way of getting the lines down.
-
:D thanx
(Sorry my host has gone down, will sort it shortly)
-
Hehe, sry to keep bumping my post :D
Another version now that changes the size of the rect based on the z value, which lets me zoom it in and out :||
Still 20 lines :) and i've added some comments
Download Code and Exe: www.tetrahedron.me.uk/3Din20(3).rar (http://www.tetrahedron.me.uk/3Din20(3).rar)
Graphics 640,480,32,2
SetBuffer( BackBuffer() )
While Not KeyDown(1)
ax# = (ax# + 0.6 )Mod 360
ay# = (ay# + 0.4 )Mod 360
ac# = (ac# + 0.3 )Mod 360
; Cube data
For x = -100 To 100 Step 20 For y = -100 To 100 Step 20 For z = -100 To 100 Step 20
; Xor the edges so the interior of the cube does not get filled
If ( x = -100 Xor x = 100 )Or(y = -100 Xor y = 100)Or(z = -100 Xor z = 100 )
; Rotate z and create perspective scale value
nz# =(((( Sin(ay#) * x) + (-Sin(ax#) * Cos(ay#) * y) + ( Cos(ax#) * Cos(ay#) * z ) + 500 ) / 700.0) )
; Set color based on depth
c = (255 * ((nz# - 0.45)*1.8))
; Modify the perspective value to give zoom effect
nz# = (nz# * 0.8) * ( Cos(ac#) + 1.25 )
; Rotate points and apply perspective zoom
nx = ((( Cos(ay#) * x + Sin(ax#) * Sin(ay#) * y -Cos(ax#) * Sin(ay#) * z)+ 200 * Sin(ax#) )* nz#) + 320
ny = ((( Cos(ax#) * y + Sin(ax#) * z )+ 150 * Cos(ay#)) * nz#) + 240
; Set color and scale rect based on the perspective
Color Abs(Cos(ac#) * c ),255-c,Abs(Sin(ac#) * c )
Rect nx - (15 * nz#), ny - (15 * nz#), 30 * nz#, 30 * nz#
EndIf
Next Next Next
Flip
Cls
Wend
-
Nice one, congratulations for doing a 3D effect !
-
Eeekk,. binary bitte! KTHXBYE O0
-
Tetra, that last version is the best of the 3 by far :) You should definately upload an exe of it.
-
:cheers: guys. Exe and code uploaded.