AS3 Raycaster

November 2nd, 2005

A fast implementation of a raycaster. You can move forward by pressing the mouse button. This version also provides a camera roll and height, ceil and floor tiles. To boost up the code, I'm using a lookup table for sin, cos, tan and massive bitshifting. The code is accordingly unreadable. What I'm really missing is a typed Array with simple bytes to write faster code, just reading RGB values. I have the feeling, that the getPixel method is too slow. This causes the small stage (240x160px).

as3 raycaster flashplayer 8.5 needed
[leaving the map causes missing walls]

raycasting as3

Filed under: actionscript

20 Responses to “AS3 Raycaster”

  1. Jon B Says:
    November 2nd, 2005 at 8:35 pm

    awesome

  2. blog.je2050.de Says:
    November 2nd, 2005 at 8:58 pm

    [...] led under:misc — joa @ 9:58 pm

    André Michelle released not just a very fast raycaster today but also made a very interesting post on the Flashforum. It is [...]

  3. icio Says:
    November 2nd, 2005 at 9:06 pm

    Absolutely awesome, Andre.
    Great work :)

  4. Paul Neave Says:
    November 2nd, 2005 at 11:01 pm

    Wow, that really is very cool (even considering the limitations).

  5. Jensa Says:
    November 3rd, 2005 at 10:19 pm

    Brilliant stuff! When I ran the SWF directly as fullscreen 1024×768, I still had more than 30 fps!

    J

  6. bitwize Says:
    November 4th, 2005 at 3:35 pm

    Brilliant work Andre.

    “What I’m really missing is a typed Array with simple bytes to write faster code, just reading RGB values. I have the feeling, that the getPixel method is too slow.”

    hmm. if i’m understanding correctly, does this help?

    BitmapData.getPixels()

    “No, longer do you have to loop through every pixel in a bitmap, one at a time with getPixel… This method returns a ByteArray containing the hexadecimal color value of each of the pixels in the specified rectangular region of a bitmap.”

    (source: http://www.flashguru.co.uk/actionscript-3-new-capabilities/ )

  7. André Michelle Says:
    November 4th, 2005 at 3:42 pm

    @bitwize:

    Unfortunatley reading ByteArrays is much slower than reading from an Array.

    What I mean is an Array, where all entries are typed to ‘int’. In Java, most grafic application read the pixels and stores them to a char[] Array. It is very fast to read an entry from.

  8. kiroukou Says:
    November 4th, 2005 at 6:06 pm

    Impressive Andre !!
    Is bitshifting really faster in AS3 because in AS2 there’s no real difference :S

    About your types Array, did you think about creating a List? I mean it cans be compute like a structure owning a reference to the next node and a int value.
    Don’t think it can be faster, but you can give it a try ;)
    ++

  9. mh Says:
    November 4th, 2005 at 11:46 pm

    andre you should write a book about all this, im sure it would sell, and its the only way the rest of us have a chance of catching up.

  10. Ralph Hauwert Says:
    November 7th, 2005 at 5:35 pm

    Very impressive andre. Think you could speed up the whole thing alot more by adding fog maybe ?

  11. franto Says:
    November 8th, 2005 at 9:26 am

    awesome!

  12. nTeract » The Official Last MAX Post Says:
    November 11th, 2005 at 3:44 am

    [...] ;s amazing what people have done already… from Fourier waveform analysis of audio to realtime 3d raycasting - the capabilities of the new language and player are just now beginnin [...]

  13. Franto.com Flash blog » Collected links to ActionScript 3.0 examples Says:
    November 14th, 2005 at 9:20 am

    [...] Max file and render it) AS3 Pixelbased raycasting engine AS3 vector 3D class (source code) AS3 Raycaster Andre Michelle ActionScript 3.0 Sound >> 5 sites Sound Spe [...]

  14. Arul Prasad Says:
    February 1st, 2006 at 5:08 pm

    Bhooo :-(

    This doesnt work with the latest alpha release of Flash Player 8.5!!

    Somethings changed, you got to fix ur app!!

  15. Andrew Says:
    February 5th, 2006 at 3:09 am

    Yeah im also having problems getting any thing to show up. Maybe there is an issue with the latest alpha release. Its to bad cuz i really want to see these AS3 demos :(

  16. thopol Says:
    February 14th, 2006 at 8:39 am

    strange… i’ve installed flash player 8.5 for IE and FF as well and all I can see is cyan background, the same with other as3 demos.

  17. Richard Says:
    March 6th, 2007 at 1:12 am

    Very nice work. Thanks Andre.

  18. Chris Says:
    March 17th, 2007 at 11:32 am

    NOOOO!!! Why can’t I write a textured raycaster in Flash that runs more than 15 fps?! I might just kill myself Q_Q.

  19. Nick Says:
    June 23rd, 2008 at 8:56 pm

    Erm, your link to the Raycaster is broken, pity as I’d love to see it.

    See http://www.visualharmonics.co.uk for a grand compilation of AS2/3 optimisation tips.

  20. DeCabeza.net » Colección de link útiles sobre ActionScript 3 - desarrollo web, tutoriales, video tutoriales, videotutoriales, flash, photoshop, php, mysql, dreamweaver Says:
    June 27th, 2008 at 4:34 pm

    [...] AS3 Raycaster Andre Michelle [...]

Leave a Reply