Code Monkey home page Code Monkey logo

shadowcast's Introduction

Shadowcast

Lua non recursive implementation of shadowcasting techinque for fast calculation of field of view. Original recursive algorithm by Björn Bergström description at Rogue Basin.

Current implementation allows simple luminance evaluation (not just FOV) and with some effort even light blending, see test example for instance (you will need luabox installed).

Shadowcast.new( absorption, [topology, [directions]] )

Create new luminance object. You must pass absorption 2d array where essentialy 0 means free space and 1 means wall. You can choose topology from the predefined set: Shadowcast.MANHATTAN, Shadowcast.EUCLIDEAN (which is the default) or Shadowcast.CHEBYSHEV. For now directions is limited to Shadowcast.DIRECTIONS_8.

Shadowcast.get( x, y )

Get luminance at the selected location. If x or/and y is/are out of bounds then function returns 0.

Shadowcast.insert( x, y, radius )

Insert new light source. Function returns newly created table, which could be used for the remove method. Note that if you alter the table fields, you must update the whole simulation.

Shadowcast.remove( source )

Remove the source from the simulation. If it's not present then nothing happens.

Shadowcast.update()

Fully update the whole light simulation. Note that when you insert/remove light sources luminance updated automatically and quite efficient, because only connected to the light source computations are made. Unfortunatly, because of the nature of compuataions with floating point after some iterations you will get rounding error. Using update sometimes while somehow expensive negates this error.

shadowcast's People

Contributors

iskolbin avatar

Stargazers

Vadim Galaktionov avatar Daniel Jeffery avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

wolf81

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.