• Welcome to Dark Bit Factory & Gravity.
 

Floor Casting With Xor Texture

Started by rain_storm, January 17, 2008

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

rain_storm

28 lines of code (not including white spaces or comments) fast and interesting. Not a bad effort if I say myself


' 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


Challenge Trophies Won:

Shockwave

Shockwave ^ Codigos
Challenge Trophies Won:

Shockwave

Shockwave ^ Codigos
Challenge Trophies Won:

rain_storm

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:

Shockwave

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:

benny!

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:

Jim

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:

Jim

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:

rain_storm

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:

Jim

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:

Shockwave

Quote from: rain_storm on January 17, 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:

mind

#11
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)
Challenge Trophies Won:

rain_storm

Thanks mind thats a great improvement. Worth some good karma I think

Challenge Trophies Won:

mind

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:

va!n

#14
@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:

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...


; your source...

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



; 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
- 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:

Rbz

@va!n: be careful with division by zero --> w  = -yres / y 
Variable "y" really should start by 1.
Challenge Trophies Won:

mind

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:

rain_storm

Or you could simply update ptc at bufer(1) instead of buffer(0) like se


  ptc_update@buffer(1)


Challenge Trophies Won: