5 ms·
In case someone is interested in the design: https://bbcdn.githack.com/rmsundaram/tryouts/raw/e06259fffad9231172a65b66ed99406df4e051d1/CG/WebGL/FoV/design.html
by legends2k 10y ago
In case someone is interested in the design:
https://bbcdn.githack.com/rmsundaram/tryouts/raw/e06259fffad9231172a65b66ed99406df4e051d1/CG/WebGL/FoV/design.html https://bbcdn.githack.com/rmsundaram/tryouts/raw/e06259fffad...
Devising the algorithm took around a month; did it in my free time. The implementation took a week, in HTML5 Canvas/JavaScript. Doing a 360°, not-bound-by-distance FoV would have been simpler, but FoV limited by both angle and distance took time.
The idea is to find the field of view of an observer on a map with blocking buildings (polygons) and also to service a line of sight query, to know if a given point is visible to the observer.
The code contains enough comments including citations and references to articles and books. Here's the actual repo from where the above page is served:
http://bitbucket.org/rmsundaram/tryouts/src/master/CG/WebGL/FoV http://bitbucket.org/rmsundaram/tryouts/src/master/CG/WebGL/...
- Eun 10y agoGot a bug here: http://pasteboard.co/1vhAc3yM.png http://pasteboard.co/1vhAc3yM.png
- legends2k 10y agoThanks! Seems to be a failing corner case, will look into it.
- peter-slovak 10y agoPun fully intended? :)
- feiss 10y agoWell done! It's almost the same algorithm I came up with in one sleepless night, 7 years ago. I used it in a game that was not finished: http://feiss.be/games/luxi http://feiss.be/games/luxi (shameless Show HN)
- legends2k 10y agoWow, the visuals look stunning, I like the noir theme!
- feiss 10y agoThanks! :) It's a shame we didn't finished it..
- tobinfricke 10y agoIt's beautiful.
- Mahn 10y agoThis looks like something that could do well comercially today, you guys should pick it back up.
- BasDirks 10y agoThe code is very well commented! Great learning resource for anybody interested.
- jasonkester 10y agoCool. Verifying the old Engineering adage about a month in the lab saving you a day in the library. Or 10 minutes on Google these days. Still, sounds like a fun time. I have my own version of this sitting around on a floppy disk somewhere, done at a point in time where floppy disks existed (possibly even 5 1/4" ones).
- legends2k 10y agoThanks! Spent quite some time searching for the algorithm in Google, DDG, what-have-you, but didn't find something that does exactly what I want and also none that explains it lucidly for anyone who wants to understand it.
- shurcooL 10y agoI've also done something similar about 10 years ago. I'm curious if you've ever seen my (unfinished) project: https://vimeo.com/62844255 https://vimeo.com/62844255 https://github.com/shurcooL/eX0 https://github.com/shurcooL/eX0
- legends2k 10y agoNo, I have not come across it until now but from the screenshot it looks nice.