Author Topic: Short Intro Challenge - 3Din20  (Read 6139 times)

0 Members and 1 Guest are viewing this topic.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Short Intro Challenge - 3Din20
« 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
Download Code and Exe: 3Din20.rar


Code: [Select]
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




:sunny:
« Last Edit: June 18, 2006 by Tetra »
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 127
    • View Profile
    • Optimouse Demo Site
Re: Short Intro Challenge - 3Din20
« Reply #1 on: June 12, 2006 »
Like this one too. Heh ;)
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - 3Din20
« Reply #2 on: June 12, 2006 »
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

Code: [Select]
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

« Last Edit: June 12, 2006 by Tetra »
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: Short Intro Challenge - 3Din20
« Reply #3 on: June 12, 2006 »
Code: [Select]
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 :)

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 127
    • View Profile
    • Optimouse Demo Site
Re: Short Intro Challenge - 3Din20
« Reply #4 on: June 12, 2006 »
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.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17374
  • Karma: 497
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - 3Din20
« Reply #5 on: June 12, 2006 »
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.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - 3Din20
« Reply #6 on: June 12, 2006 »
 :D thanx

(Sorry my host has gone down, will sort it shortly)
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - 3Din20
« Reply #7 on: June 12, 2006 »
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

Code: [Select]
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
« Last Edit: June 13, 2006 by Tetra »
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2709
  • Karma: 484
    • View Profile
    • http://www.rbraz.com/
Re: Short Intro Challenge - 3Din20
« Reply #8 on: June 13, 2006 »
Nice one, congratulations for doing a 3D effect !
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2452
  • Karma: 127
    • View Profile
    • Optimouse Demo Site
Re: Short Intro Challenge - 3Din20
« Reply #9 on: June 13, 2006 »
Eeekk,. binary bitte! KTHXBYE  O0
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17374
  • Karma: 497
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - 3Din20
« Reply #10 on: June 13, 2006 »
Tetra, that last version is the best of the 3 by far :) You should definately upload an exe of it.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - 3Din20
« Reply #11 on: June 13, 2006 »
 :cheers: guys. Exe and code uploaded.
Challenge Trophies Won: