Discuss Scratch
- Discussion Forums
- » Show and Tell
- » Laser Sandbox: An all-pen 2D raytracer
- Zro716
-
Scratcher
1000+ posts
Laser Sandbox: An all-pen 2D raytracer
Been forever since I posted something worth discussing.
For the past two whole days I have been putting together a new, improved, and awesome replacement to my project Mirrors. Not only have I now perfected reflection and refraction (unlike before), I've made use of a new class prototype library with memory management for Scratch. It's got a lot packed into one sprite (minus the stage), but it very well-built in my standards.
Features of the Laser Sandbox:
- Nearly 100% pen (ask pop-up and variables showing are the only non-pen things)
- Minimal dependency on green flag and a main loop
- Fast, precise laser tracing, updates instantly
- Preset objects: lines, arcs, and polygons, and more
- Easy object interaction, including dragging and resizing
- Keyboard shortcuts
- Exporting and Importing of data
- No ugly pen lines around edges (handled by @DadOfMrLog's off-screen scripts)
- Debugging tools included
1.1
- Improved arc clicking. Depending on which part you click, you can move the center, adjust angles, and change the radius.
- Use WASD keys to move the entire sandbox.
- “Absorb” type, which halts the laser.
1.2
- Copy/Cut/Paste of objects! Options and keyboard shortcuts (x to cut, c to copy, v to paste)
- Bug fixes and optimizations
1.3
- Center of arcs rendered as an X
- Fixed arc click detection
- Context Menu change
- Rectangle preset
- Lens preset
- Dark background show grid setting
1.4
- Improved click vs drag handling
- Fixed stray dot appearing
- Laser color can be white (set color to -1)
- Added circle preset
- Fixed selected object appearing in front of context menu
1.5
- 3D Raycast+Raytrace mode! Uses a panoramic image (1024x141)
- Even faster! Updates and refreshes when necessary, not just when called
1.6:
- Fixed MAJOR bug with 3D mode, raised an error in debug and caused havoc
- Added realistic reflection-ness and shading in 3D mode
What to Discuss:
- Share your sandbox creations! (NOTE: Please put your sandbox data inside [code][/code] tags!)
- Propose features and optimizations
- Report bugs and glitches, how you found one and what happens
- Positive criticism welcome
To-Do/Wishlist:
- Add line endpoint snapping to other line endpoints
- Improve serialization accountability
- Make refraction index unique to each object?
- Spectrum?
Last edited by Zro716 (July 13, 2016 18:54:12)
- Zro716
-
Scratcher
1000+ posts
Laser Sandbox: An all-pen 2D raytracer
109273887 1.0 20 292 30 1.59 Arc[x=-66,y=-17,radius=42.44997055358225,start=-52.69605172201657,end=223.0908475670036,type=2] Line[x1=-92.99999999999997,y1=63,x2=-43.831858048474615,y2=48.323981037705565,type=2] Line[x1=-43.831858048474615,y1=48.323981037705565,x2=-12.680343136252148,y2=7.550523565710918,type=2] Line[x1=-12.680343136252148,y1=7.550523565710918,x2=-11.444275158752376,y2=-43.746297500530346,type=2] Line[x1=-11.444275158752376,y1=-43.746297500530346,x2=-40.59579007097484,y2=-85.97284002853569,type=2] Line[x1=-40.59579007097484,y1=-85.97284002853569,x2=-89.00000000000004,y2=-103,type=2] Line[x1=-89.00000000000004,y1=-103,x2=-138.1681419515254,y2=-88.32398103770556,type=2] Line[x1=-138.1681419515254,y1=-88.32398103770556,x2=-169.31965686374787,y2=-47.55052356571092,type=2] Line[x1=-169.31965686374787,y1=-47.55052356571092,x2=-170.55572484124764,y2=3.7462975005303605,type=2] Line[x1=-170.55572484124764,y1=3.7462975005303605,x2=-141.40420992902514,y2=45.9728400285357,type=2] Line[x1=-141.40420992902514,y1=45.9728400285357,x2=-92.99999999999997,y2=63,type=2] Line[x1=146.42129629629633,y1=24.212962962962962,x2=102.4212962962963,y2=106.21296296296296,type=1]
- Night_Wisp
-
Scratcher
11 posts
Laser Sandbox: An all-pen 2D raytracer
Here's Mine:
109273887 1.2 20 279 30 1.59 Line[x1=-62.999999999999986,y1=101,x2=-83.83475912520193,y2=46.04332672196841,type=0] Line[x1=-83.83475912520193,y1=46.04332672196841,x2=-131.0738946106399,y2=11.074952379115004,type=2] Line[x1=-131.0738946106399,y1=11.074952379115004,x2=-189.7193147154691,y2=7.1970887505692644,type=1] Line[x1=-189.7193147154691,y1=7.1970887505692644,x2=-241.15151292514366,y2=35.64093013871938,type=2] Line[x1=-241.15151292514366,y1=35.64093013871938,x2=-269.04112971063915,y2=87.37575787740725,type=1] Line[x1=-269.04112971063915,y1=87.37575787740725,x2=-264.5334088011763,y2=145.97612970042465,type=2] Line[x1=-264.5334088011763,y1=145.97612970042465,x2=-229.05951973547556,y2=192.83684160440515,type=1] Line[x1=-229.05951973547556,y1=192.83684160440515,x2=-173.88217164537414,y2=213.07994866180331,type=2] Line[x1=-173.88217164537414,y1=213.07994866180331,x2=-116.51978268496761,y2=200.2784074128548,type=1] Line[x1=-116.51978268496761,y1=200.2784074128548,x2=-75.18450604591234,y2=158.49661675273265,type=2] Line[x1=-75.18450604591234,y1=158.49661675273265,x2=-63,y2=100.99999999999994,type=0] Line[x1=-303,y1=-26,x2=-36,y2=-101,type=1] Line[x1=-303,y1=-25,x2=-343.625,y2=237.70833333333334,type=1] Line[x1=-343.625,y1=238.75,x2=68.87500000000003,y2=302.2916666666667,type=1] Line[x1=68.87500000000003,y1=302.2916666666667,x2=93.87500000000003,y2=46.04166666666666,type=1] Line[x1=92.98207826967595,y1=49.18203848379635,x2=-48.303005642361114,y2=-113.29580801504629,type=1] Arc[x=-31.348795572916668,y=86.62258572048616,radius=43.68999932201874,start=104.03624346792645,end=268.02506598911805,type=2] Line[x1=55.77700617283952,y1=-71.14575798128855,x2=104.04940984278551,y2=103.10584551022382,type=1]
- Zro716
-
Scratcher
1000+ posts
Laser Sandbox: An all-pen 2D raytracer
Here's a demonstration of convex and concave lenses that actually illustrate magnification
109273887 1.2 20 92 30 0.6 Line[x1=399.95943898128405,y1=140,x2=479.95943898128405,y2=140,type=2] Line[x1=399.95943898128405,y1=-140,x2=479.95943898128405,y2=-140,type=2] Arc[x=79.95943898128401,y=0,radius=349.28498393145964,start=66.37062226934319,end=113.62937773065681,type=2] Line[x1=179.95943898128402,y1=140,x2=139.95943898128402,y2=140,type=2] Line[x1=179.95943898128402,y1=-140,x2=139.95943898128402,y2=-140,type=2] Arc[x=-300.04056101871595,y=0,radius=500,start=73.73979529168804,end=106.26020470831196,type=2] Arc[x=879.959438981284,y=0,radius=420,start=250.70995378081128,end=-70.70995378081128,type=2] Arc[x=619.959438981284,y=0,radius=500,start=253.73979529168804,end=-73.73979529168804,type=2]
- Reporterguy006
-
Scratcher
8 posts
Laser Sandbox: An all-pen 2D raytracer
whoops
Last edited by Reporterguy006 (July 7, 2016 19:52:25)
- scratch0maker0
-
Scratcher
100+ posts
Laser Sandbox: An all-pen 2D raytracer
Mine:
109273887 1.5 56 186 47 1.51 Arc[x=131.1900505965838,y=-120.1198073378228,radius=72.38673717747058,start=-67.41213031877359,end=-81.04084107101683,type=1] Line[x1=89,y1=8,x2=99,y2=43,type=1] Line[x1=124,y1=-69,x2=131,y2=-89,type=1] Line[x1=-109.01461517837447,y1=107.69031368295902,x2=-92.13580551684635,y2=130.03098924145337,type=1] Line[x1=-19,y1=-83,x2=59,y2=-25,type=1] Line[x1=-117,y1=-67,x2=-148,y2=-31,type=1] Line[x1=3162,y1=-413,x2=3125,y2=-334,type=1] Line[x1=3078,y1=-547,x2=2949.6277171333963,y2=-579.5677920993387,type=1] Line[x1=2949.6277171333963,y1=-579.5677920993387,x2=2844.126382747008,y2=-499.50798612092996,type=1] Line[x1=2844.126382747008,y1=-499.50798612092996,x2=2840.9406534688087,y2=-367.10724888893765,type=1] Line[x1=2840.9406534688087,y1=-367.10724888893765,x2=2942.4694484223173,y2=-282.06603602189625,type=1] Line[x1=2942.4694484223173,y1=-282.06603602189625,x2=3072.2595141975544,y2=-308.42211533329254,type=1] Line[x1=3072.2595141975544,y1=-308.42211533329254,x2=3132.5762840309153,y2=-426.32882153560496,type=1] Line[x1=3132.5762840309153,y1=-426.32882153560496,x2=3078,y2=-547,type=1] Arc[x=3169,y=-504,radius=41.43669871020132,start=160.25316339457387,end=24.993305262259735,type=1] Line[x1=-90.98107877496727,y1=138.45865579760135,x2=-36.80607037228778,y2=66.59024504176506,type=2] Line[x1=-193.19392962771224,y1=61.40975495823495,x2=-139.01892122503273,y2=-10.458655797601352,type=2] Arc[x=-145.54438568989167,y=104.52009444519533,radius=64.25714285714285,start=58.11824820319359,end=-132.13683264266646,type=2] Arc[x=-84.45561431010832,y=23.479905554804674,radius=64.25714285714285,start=238.1182482031936,end=47.86316735733354,type=2] Line[x1=-182,y1=130,x2=-214,y2=92,type=1]
- Harudaichi
-
Scratcher
60 posts
Laser Sandbox: An all-pen 2D raytracer
trapped laser:
109273887 1.6 20 0 100 2 Arc Arc





109273887 1.6 20 0 100 2 Arc Arc





when green flag clicked
forever
change [awesomeness v] effect by (25)
say [something] for (2) secs
end
- Harudaichi
-
Scratcher
60 posts
Laser Sandbox: An all-pen 2D raytracer
trapped laser:
109273887 1.6 20 0 100 2 Arc Arc





109273887 1.6 20 0 100 2 Arc Arc





when green flag clicked
forever
change [awesomeness v] effect by (25)
say [something] for (2) secs
end
- Discussion Forums
- » Show and Tell
-
» Laser Sandbox: An all-pen 2D raytracer
