570 posts
Posted 13 April 2014 - 05:34 PM
ccLightSim v1.2As the name suggests, this program simulates light.
It is not designed to have a real purpose but instead it's designed to be reused by other people in their own programs (more likely games). Thusly you may copy
parts of its code without limitations.
Screenshots: Spoiler
Installation:Type this in CraftOS:
pastebin get LTcF5ZDP cclightsim
The program requires
Gopher's redirect API.
You can install it with this (has to be in the same directory as cclightsim!):
pastebin get fU9Kj9zr redirect
Usage:Everything is explained in the program's interface. In other words: I'm lazy.
Custom Maps:To make a custom map, create an image file in paint. Colour areas white that you wish to be solid, all other colours are ignored for now.
Then instead of starting cclightsim regularly, use this command:
cclightsim <map filename>
NOTE: Since ComputerCraft runs in Minecraft, it performs poorly. This is especially true for this program, so I recommend running it in an emulator for best results.
Edited on 16 April 2014 - 01:10 PM
570 posts
Posted 14 April 2014 - 11:02 AM
Updated to version 1.1:There are directional lights now. They will always have a light cone of 90°, although you can modify the code to change that.
Use the middle mouse button to place a point for the light to point at, which will also enable directional light mode. You can press R to switch back to full illumination. Besides that there's a bigger map to mess around on now.
I'm planning reflective surfaces for version 1.2.
Obligatory screenshots:Spoiler
1610 posts
Posted 14 April 2014 - 03:11 PM
Very nice job on this!
570 posts
Posted 14 April 2014 - 04:03 PM
Very nice job on this!
Thanks, man!
197 posts
Location
Czech Republic
Posted 14 April 2014 - 04:15 PM
Really nice! It would be awesome on 3D as well.
Also, what about different colors? Not only of the light but also of the surface it reflects on (only the background in 2D). Imagine fading light as the distance grow bigger… O.o :DD
570 posts
Posted 14 April 2014 - 04:31 PM
Really nice! It would be awesome on 3D as well.
Also, what about different colors? Not only of the light but also of the surface it reflects on (only the background in 2D). Imagine fading light as the distance grow bigger… O.o :DD
Sadly, I can't really make the light fade because of ComputerCraft's limitations, although I'd love to (actually… maybe dithering?). However I can try making the border of the produced light orange (or vice-versa).
If by 3D you mean
this, I don't think that's possible.
Anyway… I'll look into the colours after I've finished reflection which I'll work on tomorrow.
314 posts
Location
Glass/UX/main.lua
Posted 15 April 2014 - 04:40 PM
I love this.Great thing to do when I'm bored. Maybe it's the first scientific program on these forums :o/>
1610 posts
Posted 15 April 2014 - 04:56 PM
I love this.Great thing to do when I'm bored. Maybe it's the first scientific program on these forums :o/>/>
It's not :P/>
It's certainly an interesting one though :3
570 posts
Posted 15 April 2014 - 06:32 PM
Updated to version 1.2:No reflection! :(/>. Sorry, I haven't had the time to do reflection nor advanced light colouring so I just made a quick update that I think you'll enjoy anyway.
Changes:- New test map.
- You can make a map in paint (white = solid, other colours = nothing) and load it by providing it as an argument (i.e. cclightsim <map file>).
- Organized the instructions a little bit to reserve space for later additions.
- Press + or - respectively to change the light cone angle in directional light mode.
- Changed the light source colour to orange.
288 posts
Location
The trashcan where all Undertale trash is
Posted 19 April 2014 - 10:55 PM
I know it's only a light simulation program, but it's pretty interesting! What kind of things did you do to calculate the angles where light cuts off?
570 posts
Posted 20 April 2014 - 08:05 AM
What kind of things did you do to calculate the angles where light cuts off?
I'm not quite sure what you're asking here but perhaps a full explanation of the program will help you:
The program draws a line at every angle as far out as possible. It's usually a very expensive way of rendering light but it seems to work well with ComputerCraft's low resolution.
To do directional lighting it only draws lines from a start angle to an end angle. To make it point to a certain point in the map it calculates the angle between the light emitter and the direction point. After it's got that it can get the start and end angles by adding/subtracting half of the cone angle to/from the previously calculated angle respectively.
Edited on 20 April 2014 - 06:14 AM