Author Topic: 640X480 AA Vecbobs[BB2D]  (Read 5015 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
640X480 AA Vecbobs[BB2D]
« on: May 11, 2006 »
Original Post By Thygrion, taken from the old board.
Quote
640 by 480 anti-aliased vectorbobs!

Here's my attempt at doing fullscreen 640 by 480 anti-aliased vbobs in B2D, it runs VERY fast and also doesn't use any external media. Consider yourselves lucky; I wouldn't have ever posted this if I had an idea for a demo with it.

Here you go!

Code: [Select]
; Anti-Aliased Vectorbobs

AppTitle "Anti-Aliased Vectorbobs"

Const width = 640
Const height = 480

Const width2 = width / 2
Const height2 = height / 2

Graphics width,height,32,1
SetBuffer BackBuffer()

HidePointer

Dim screen(width2,height2,2)
Dim palette(255)
Dim obj#(1,3)
Dim bob(1,1)

Global points
Global distance# = 6
Global size# = 150
Global xan#
Global yan#
Global zan#
Global xani# = .25
Global yani# = .5
Global zani# = .25

Global bobox = width2 / 2
Global boboy = height2 / 2
Global bobw
Global bobh

Global fps = 0
Global fpsc = 0
Global fpss = False
Global fpstime = MilliSecs()
Global fpstimer = 1000

Global intensity# = 3

setuppalette()
loadobj()
loadbob()

While Not KeyDown(1)
Cls

updateobj()
If MouseDown(1) Then drawbob MouseX() Shr 1,MouseY() Shr 1
LockBuffer
aalias()
UnlockBuffer
calcfps()

Flip False
Wend
End

Function setuppalette()
For i = 0 To 85
        r = 0
        g = i * 1.5
        b = i * 3
        palette(i) = (r Shl 16) + (g Shl 8) + b
Next
For i = 1 To 85
        r = i * 1.5
        g = 127 + (i * 1.5)
        b = 255
        palette(85 + i) = (r Shl 16) + (g Shl 8) + b
Next
For i = 1 To 85
        r = 127 + (i * 1.5)
        g = 255
        b = 255
        palette(170 + i) = (r Shl 16) + (g Shl 8) + b
Next
End Function

Function loadobj()
points = 125
Dim obj#(points,3)
For z = 0 To 4
        nz# = Float(z - 2)
        For y = 0 To 4
                ny# = -Float(y - 2)
                For x = 0 To 4
                        nx# = Float(x - 2)
                        i = (z * 25) + (y * 5) + x
                        obj#(i,0) = nx#
                        obj#(i,1) = ny#
                        obj#(i,2) = nz#
                Next
        Next
Next
End Function

Function updateobj()
cx# = Cos(xan#)
sx# = Sin(xan#)
cy# = Cos(yan#)
sy# = Sin(yan#)
cz# = Cos(zan#)
sz# = Sin(zan#)
sxsy# = Float(sx# * sy#)
cxsy# = Float(cx# * sy#)
m00# = Float(cy# * cz#)
m01# = Float(-cy# * sz#)
m02# = sy#
m10# = Float(cx# * sz#) + Float(sxsy# * cz#)
m11# = Float(cx# * cz#) - Float(sxsy# * sz#)
m12# = Float(-sx# * cy#)
m20# = Float(sx# * sz#) - Float(cxsy# * cz#)
m21# = Float(sx# * cz#) + Float(cxsy# * sz#)
m22# = Float(cx# * cy#)
For i = 0 To points - 1
        tx# = obj#(i,0)
        ty# = obj#(i,1)
        tz# = obj#(i,2)
        rx# = Float(tx# * m00#) + Float(ty# * m10#) + Float(tz# * m20#)
        ry# = Float(tx# * m01#) + Float(ty# * m11#) + Float(tz# * m21#)
        rz# = Float(tx# * m02#) + Float(ty# * m12#) + Float(tz# * m22#)
        rz# = Float(distance# + rz#)
        If rz# > 1
                nx = (Float(rx# / rz#) * size#) + bobox
                ny = (-Float(ry# / rz#) * size#) + boboy
                drawbob nx,ny
        EndIf
Next
xan# = xan# + xani#
yan# = yan# + yani#
zan# = zan# + zani#
End Function

Function loadbob()
Restore bobdata
Read bobw
Read bobh
Dim bob(bobw,bobh)
For y = 0 To bobh - 1
        For x = 0 To bobw - 1
                Read bob(x,y)
        Next
Next
End Function

Function drawbob(ox,oy)
For y = 0 To bobh - 1
        ny = (oy - (bobh / 2)) + y
        For x = 0 To bobw - 1
                nx = (ox - (bobw / 2)) + x
                If nx > 0 And nx < width2 - 1 And ny > 0 And ny < height2 - 1
                        c = screen(nx,ny,1) + (bob(x,y) * intensity#)
;                        c = bob(x,y) * 55;intensity#
                        If c > 255 Then c = 255
                        screen(nx,ny,1) = c
                EndIf
        Next
Next
End Function

Function aalias()
For y = 1 To height2 - 2
        For x = 1 To width2 - 2
                screen(x,y,2) = (screen(x - 1,y,1) + screen(x + 1,y,1) + screen(x,y - 1,1) + screen(x,y + 1,1)) Shr 2
        Next
Next
For y = 1 To height2 - 1
        For x = 1 To width2 - 1
                c = screen(x,y,2)
                If c > 0
                        nx = x Shl 1
                        ny = y Shl 1
                        argb = palette(c)
                        WritePixelFast nx,ny,palette(c)
                        WritePixelFast nx + 1,ny,argb
                        WritePixelFast nx,ny + 1,argb
                        WritePixelFast nx + 1,ny + 1,argb
                EndIf
                screen(x,y,1) = c * .9
        Next
Next
End Function

Function calcfps()
If MilliSecs() >= fpstime + fpstimer
        fps = fpsc
        fpsc = 0
        fpstime = MilliSecs()
Else
        fpsc = fpsc + 1
EndIf
Color 255,255,255
Text 2,2,fps + " FPS"
End Function

.bobdata

Data 16,16

Data 0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0
Data 0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0
Data 0,0,2,1,2,2,2,2,2,2,2,2,2,2,0,0
Data 0,3,3,2,2,2,2,2,3,3,3,3,2,2,2,0
Data 0,3,1,2,2,2,2,3,3,5,5,3,3,2,2,0
Data 3,3,1,2,2,2,2,3,5,5,5,5,3,2,2,2
Data 3,1,1,2,2,2,2,3,5,5,5,5,3,2,2,2
Data 3,1,1,2,2,2,2,3,3,5,5,3,3,2,2,2
Data 3,1,1,2,2,2,2,2,3,3,3,3,2,2,2,2
Data 3,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2
Data 3,3,1,1,2,2,2,2,2,2,2,2,2,2,2,2
Data 0,3,1,1,1,2,2,2,2,2,2,2,2,2,2,0
Data 0,3,3,1,1,1,1,2,2,2,2,2,2,3,3,0
Data 0,0,3,3,1,1,1,1,1,1,1,1,3,3,0,0
Data 0,0,0,3,3,3,1,1,1,1,3,3,3,0,0,0
Data 0,0,0,0,0,3,3,3,3,3,3,0,0,0,0,0


Hope you guys like it :)


A wise man once wrote:

   
Print "Hello World!"

Quote

5H0CKW4VE
*Administrator*

Re: 640 by 480 anti-aliased vectorbobs!
Looks good, 42 fps here. :-)


Some are born mad.... Some remain so!
VISIT DARK BIT FACTORY INTERACTIVE! (please!)

Quote
Thygrion
DBF: Coder

Re: 640 by 480 anti-aliased vectorbobs! Thanks, dude!

BTW it was based on the effects in your Amouphous Darkness and Alpha Blur demos. :)


A wise man once wrote:

   
Print "Hello World!"


Quote
rbraz
ATARI 2600

Re: 640 by 480 anti-aliased vectorbobs!

Very cool effect and fast too.
I got 85 FPS with "flip false" and 75 FPS with normal "flip", good job !

Quote
Thygrion
DBF: Coder

Re: 640 by 480 anti-aliased vectorbobs! Lucky! I only got 20 FPS, o well...

Glad you liked the effect :) !


"It is better to have an attention span and not need it, then to need whatever it was I was just talking about"

- Thygrion

Quote
codeman
ZX 81

Re: 640 by 480 anti-aliased vectorbobs! Nice effect

84 fps here :)

Quote
Thygrion
DBF: Coder

Re: 640 by 480 anti-aliased vectorbobs!
thanks :)


"It is better to have an attention span and not need it, then to need whatever it was I was just talking about"

- Thygrion

Quote
tetraHC
DBF: Coder

Re: 640 by 480 anti-aliased vectorbobs!
nice going there!

Looks great :)

50 fps here.

Quote
jimshawx
   
Re: 640 by 480 anti-aliased vectorbobs!
Nice effect. I'm a bit confused as to why you run in 640x480 mode and then write 4x the amount of pixels you need to.
I changed it to run in 320x240 and it goes from 44fps to 90fps and looks exactly the same.

Jim

Quote
zparticle

Re: 640 by 480 anti-aliased vectorbobs! That is excellent, and at 80 FPS too, nice!

Quote
Thygrion
DBF: Coder

Re: 640 by 480 anti-aliased vectorbobs!
Thanks!

@Jim: It drew 4 pixels instead of one because it blurs a 320 by 240 array instead of a 640 by 480 one, hence the speed.


"It is better to have an attention span and not need it, then to need whatever it was I was just talking about"

- Thygrion
« Last Edit: July 21, 2007 by Shockwave »
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: 640X480 AA Vecbobs
« Reply #1 on: May 14, 2006 »
Coool like ya bobs dude :D
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 640X480 AA Vecbobs
« Reply #2 on: May 14, 2006 »
It was a blast coding this one mate :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: 640X480 AA Vecbobs
« Reply #3 on: July 09, 2006 »
Nice source code Shockwave . . . anybody using BlitzMax . . . can't seem to get on with it?  ???
Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 640X480 AA Vecbobs
« Reply #4 on: July 09, 2006 »
Thanks, this source is quite old now.. Probably much better results could be had from Freebasic or C++, I will have to convert it.
As far as I know, I think that Tindragon and Zawran use Bmax, as does Zparticle.. I'm sure that you'll get your query answered if you want to post it :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: 640X480 AA Vecbobs
« Reply #5 on: July 10, 2006 »
It wont directly convert to bmax as it uses WritePixelFast to draw to a locked dx buffer, bmax doesnt have this in the same way. You could change the code to do the drawing to a pixmap but I dont think it would be as fast. Or you could just set the color and plot the pixel but again it wont be very fast. per pixel drawn effects like this arent done the same in bmax due to it using 3d hardware for all drawing operations, but it should probably be possible to set up a directdraw surface and draw to it like tinyptc does, i haven't really looked into it since I didnt get bmax to do pixel pushing ;)

Offline Tormentor

  • ZX 81
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: 640X480 AA Vecbobs
« Reply #6 on: December 20, 2006 »
Nice nice

125 - 150 FPS

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 640X480 AA Vecbobs
« Reply #7 on: December 22, 2006 »
Thanks,glad you liked it and welcome to the board :)
Shockwave ^ Codigos
Challenge Trophies Won: