Hi all!
I've made small tool: it checks where is the first nearest point on the line (https://love2d.org/wiki/love.graphics.line) from given ray source.
Small Ray Tracing (or RayCasting)
Small Ray Tracing (or RayCasting)
- Attachments
-
- RayTracing_1-01.love
- (2.59 KiB) Downloaded 426 times
Last edited by darkfrei on Tue May 18, 2021 3:14 pm, edited 2 times in total.
Re: Small ray tracing
My implementation ray tracing as a lib;
Please help me to fix it, I'm bad with objects. If possible, without metatables, I cannot understand them.
Please help me to fix it, I'm bad with objects. If possible, without metatables, I cannot understand them.
- Attachments
-
- RayTracing_1-03.love
- (3.41 KiB) Downloaded 425 times
Re: Small ray tracing
Where were you three months ago when my game needed you? Good work!
Re: Small ray tracing
I need that tool for my project too, that's why I wrote that.
Where are you need it?
Re: Small ray tracing
This game I recently finished. Had to manually assign co-ordinates for each laser and it's respective collision point.
https://mwasanje.itch.io/the-squarehouse
- Attachments
-
- The Squarehouse.love
- (268.38 KiB) Downloaded 400 times
Re: Small ray tracing
Tested and fixed version from https://love2d.org/forums/viewtopic.php ... 92#p237207
- Attachments
-
- RayTracing_1-04.love
- (2.63 KiB) Downloaded 370 times
Re: Small Ray Tracing (or RayCasting)
Trying to adapt rays.lua into my own project. The example here has two lines - line1 and line2 as two distinct lines. I have about 50 lines (all about 50 pixels short) so would like to adapt to call a table of lines ... I guess.
I have a line defined, not surprisingly, as x1,y1,x2,y2. So, I guess I might have:
line[1] = x1,y1,x2,y2
line[2] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
line[3] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
line[4] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
They are not continuous like in the example in this thread. They all have exactly two xy pairs - but - I have an undefined number of lines. How to adjust rays.lua?
I have a line defined, not surprisingly, as x1,y1,x2,y2. So, I guess I might have:
line[1] = x1,y1,x2,y2
line[2] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
line[3] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
line[4] = x1,y1,x2,y2 -- different values for x1,y1,x2,y2
They are not continuous like in the example in this thread. They all have exactly two xy pairs - but - I have an undefined number of lines. How to adjust rays.lua?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
Re: Small Ray Tracing (or RayCasting)
Maybe table required?
Code: Select all
line[1] = {x1,y1,x2,y2}
Who is online
Users browsing this forum: No registered users and 1 guest