0XDE57 / SpaceProject

An arcadey physics based top-down 2D, procedurally generated asteroid miner sandbox game using libGDX.
Apache License 2.0
40 stars 10 forks source link

new weapon: laser #7

Open 0XDE57 opened 1 year ago

0XDE57 commented 1 year ago

Laser component: a raycast with reflection off objects.

Asteroid could be given a reflective index (albedo) from [0 to 1] Where 0 does not reflect, and 1 reflects 100% of the beam. 0.5 would reflect 50% of the beam, beam dims accordingly.

Asteroid heats up with laser exposure, based on % not reflected?

0XDE57 commented 1 year ago

Image

Image

0XDE57 commented 1 year ago

http://www.iforce2d.net/b2dtut/raycasting

0XDE57 commented 1 year ago

https://asawicki.info/news_1301_reflect_and_refract_functions.html

0XDE57 commented 1 year ago

https://phet.colorado.edu/sims/html/bending-light/latest/bending-light_en.html

reflections and refractions! https://github.com/phetsims/bending-light/blob/main/js/prisms/model/PrismsModel.ts https://github.com/phetsims/bending-light/blob/main/js/common/model/DispersionFunction.ts

https://en.wikipedia.org/wiki/Refractive_index https://en.wikipedia.org/wiki/Sellmeier_equation

https://www.youtube.com/watch?v=KTzGBJPuJwM

0XDE57 commented 1 year ago

ooh pretty colors https://www.youtube.com/watch?v=-VjbYI-eaTQ https://www.youtube.com/watch?v=nVjGzmTURUk

0XDE57 commented 1 year ago

Slice: we get the entry point from the first raycast, but how do we get the exit point for the laser? Answer: perform another raycast! but flip the start and end point, so the ray is cast from the end point of the laser towards the caster. eg:

world.rayCast(callback,p1,p2); //entry point world.rayCast(callback,p2,p1); //exit point

https://www.emanueleferonato.com/2021/04/22/slicing-splitting-and-cutting-html5-box2d-physics-bodies-using-phaser-planck-js-and-polyk/

0XDE57 commented 8 months ago

another simulator https://phydemo.app/ray-optics/simulator/ https://github.com/ricktu288/ray-optics