Author Topic: Floor Casting With Xor Texture  (Read 8068 times)

0 Members and 1 Guest are viewing this topic.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Floor Casting With Xor Texture
« on: January 17, 2008 »
28 lines of code (not including white spaces or comments) fast and interesting. Not a bad effort if I say myself

Code: [Select]
' Floor Casting
const resX = 640
const resY = 480
const xres = 320
const yres = 240

#include once "tinyptc.bi"
if (ptc_open("FLOOR CASTING", resX, resY) = 0) then end -1
dim shared as integer buffer(resX*resY)
dim as single u, v, w, camX, camY
dim as integer c, b

while (inkey$ = "")
  camY += 1
  camX = xres*sin(camY*3.14159/180)
  b = 0
  for y = 1 to resY
    w  = -yres / y
    v =  resX*w - camY
    u = -xres*w + camX
    for x = 1 to resX
      c = (u xor v) and 255
      buffer(b+x) = rgb(c,c,c)
      u = u + w
    next
    b = b + resX
  next
  ptc_update@buffer(1)
wend
ptc_close
end 0
« Last Edit: January 18, 2008 by rain_storm »

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Floor Casting With Xor Texture
« Reply #1 on: January 17, 2008 »
The requested URL http://dbfinteractive.com/index.php?action=dlattach;topic=2816.0;attach=2749 is infected with Virus.Win32.Virut.av virus
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Floor Casting With Xor Texture
« Reply #2 on: January 17, 2008 »
False Alert?
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Floor Casting With Xor Texture
« Reply #3 on: January 17, 2008 »
I hope so maybe there is a virus on my system that infected that program please remove it. I will post only the source

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Floor Casting With Xor Texture
« Reply #4 on: January 17, 2008 »
It's a great program :)
Have some good karma.

I hope your system is ok.
I use Kaspersky here, Kaspersky detected the threat, I have had flase alerts in the past though especially if the file is crunched with something unusual.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Floor Casting With Xor Texture
« Reply #5 on: January 17, 2008 »
Virus alert here, too. Maybe you can post a uncrunched version!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Floor Casting With Xor Texture
« Reply #6 on: January 17, 2008 »
AVG claims it's a virus too, one with a built in IRC server for stealing stuff off your PC :(  AVG doesn't warn about kkrunchy any more, so this might be the real deal.

Jim
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Floor Casting With Xor Texture
« Reply #7 on: January 17, 2008 »
I have replaced the zip with an uninfected one - there's definitely something wrong with the original exe 'cos when I rebuild it's 8kB smaller than the original.  I've PMd rain_storm.

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Floor Casting With Xor Texture
« Reply #8 on: January 18, 2008 »
Kaspersky found a lot of infected files on my system its still runnin but it runs very slow I would be glad if someone could recompile for me and upload

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Floor Casting With Xor Texture
« Reply #9 on: January 18, 2008 »
I've already replaced the archive in the original post with an uninfected one.
Let us know how you get on with the clean-up operation, or if you need any help!
Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Floor Casting With Xor Texture
« Reply #10 on: January 18, 2008 »
Kaspersky found a lot of infected files on my system its still runnin but it runs very slow

:(

At least you will have the problem fixed, even if it takes some time to do a full scan it will be well worth it.
Kaspersky is a great virus killer.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Floor Casting With Xor Texture
« Reply #11 on: January 18, 2008 »
nifty.. looks like complete shit at the top though due to no interpolation etc, but thats easily fixed by adding a few bytes to the color calculation accordingly: c = (((u xor v) and 255)/resY)*y

and boom, you have something like this:            compared to this:


(wouldnt be too hard to add fog instead though, but i'll leave that up to you)
« Last Edit: January 18, 2008 by mind »
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Floor Casting With Xor Texture
« Reply #12 on: January 18, 2008 »
Thanks mind thats a great improvement. Worth some good karma I think

Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Floor Casting With Xor Texture
« Reply #13 on: January 18, 2008 »
glad you liked it :)

i found this to be extremely useful tbh, for testing different procedural functions in realtime.

so, i will be tossing you some karma aswell..
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Floor Casting With Xor Texture
« Reply #14 on: January 19, 2008 »
@rain_storm:
very great work! Thanks and K++ for sharing this great old skool demo effect source!
Here is the PB converted version available... http://dbfinteractive.com/index.php?topic=2824.0 ;)

Btw, i did not manged to get this line work in the PB version:
Code: [Select]
c = (((u xor v) and 255)/resY)*y



[Edited]
@rain_storm:
i am not sure how FreeBasic handles pixel coordinates but i think the first pixel will start at 0 instead of 1... if so, i think you have to change your code, else you probaly write diretly somewhere into memory...

Code: [Select]
; your source...

 for y = 1 to resY
    w  = -yres / y
    v =  resX*w - camY
    u = -xres*w + camX
    for x = 1 to resX

Code: [Select]
; change to...

 for y = 0 to resY -1     ; FIXED
    w  = -yres / y
    v =  resX*w - camY
    u = -xres*w + camX
    for x = 0 to resX -1     ; FIXED
« Last Edit: January 19, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Floor Casting With Xor Texture
« Reply #15 on: January 19, 2008 »
@va!n: be careful with division by zero --> w  = -yres / y 
Variable "y" really should start by 1.
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Floor Casting With Xor Texture
« Reply #16 on: January 21, 2008 »
not really a problem, the division by zero can be avoided by adding a simple " if y < 1 then w = -yres / (y + 1) else w = -yres / y;"

but pointing it out to him should teach him to read the code more next time :P
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Floor Casting With Xor Texture
« Reply #17 on: January 21, 2008 »
Or you could simply update ptc at bufer(1) instead of buffer(0) like se

Code: [Select]
  ptc_update@buffer(1)

Challenge Trophies Won: