Reflecting laser beams off surfaces

Get help using Construct 2

» Fri Jul 19, 2013 12:03 am

Can someone reupload R0J0's example? I'd like to take a look.
B
65
S
14
G
5
Posts: 265
Reputation: 6,159

» Fri Jul 19, 2013 12:09 am

@Wolod

The link provided stillworks for me..
B
53
S
16
G
10
Posts: 1,098
Reputation: 11,782

» Fri Jul 19, 2013 12:12 am

@spongehammer
It works now. I can swear I've got 404 error few minutes ago. Maybe some issues with the Dropbox.
B
65
S
14
G
5
Posts: 265
Reputation: 6,159

» Fri Apr 08, 2016 1:15 am

Hey @R0J0hound

I was wondering if there are now better alternatives to your examples, I am trying to achieve something like this:

The issue I am facing is finding the right balance between accuracy and speed. I was thinking on maybe using line of sight to pick up the nearest reflecting surface, draw the laser, then move to the next segment. But I have no idea if it's currently the best approach.

Also why are you multiplying sin and cos by 16 in the example?
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

» Fri Apr 08, 2016 6:59 pm

@0plus1
There are probably other ways to do it. One would be to use raycasting by calculating the intersection of two lines. The example here just does it by steps. The 16 is the distance the laser moves per step. It works only with horizontal or vertical walls though.

The problem is basically:
Thinking of the end of a laser as a moving object,
move it till it hits a wall,
using the angle of the wall calculate the new angle of the object and repeat.

If you use raycasting math it can be 100% precise. I did the math for it a while ago and made a quick example here:
https://www.dropbox.com/s/1tzd6emtsbdpx ... .capx?dl=1
/examples32/raycast_math.capx
Last edited by R0J0hound on Fri Apr 27, 2018 5:32 pm, edited 1 time in total.
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

» Mon Apr 11, 2016 12:01 pm

@R0J0hound thank you so much, that really got me going, such an elegant solution!

You are really talented!
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

» Thu Apr 14, 2016 7:32 am

@R0J0hound thanks, good example, like all your works.
B
48
S
18
G
3
Posts: 175
Reputation: 5,388

» Thu Oct 27, 2016 10:11 am

Message: Ken95 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@r0j0hound[
how does this process works? could you please attach a detailed documentation on your algorithm?
B
9
S
2
Posts: 26
Reputation: 629

» Sun Oct 30, 2016 6:25 pm

@Ken95
The process? It's basically just finding the intersection between lines a bunch of times. The objects have a border made up of lines and the ray is a line. You can just place the lines of the objects manually or use math to place them.

It finds all the lines that intersect the ray, then uses the intersection closest to the start of the ray. From there you can calculate the normal of where the lines intersect and in turn calculate the reflection angle. Then it's just a matter of setting the ray to be from the intersection going at the reflection angle and repeating the process a number of times.

The calculating of the line intersections and reflection angles is easily found in a search engine.
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

» Wed Nov 02, 2016 7:16 am

Message: Ken95 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
https://www.dropbox.com/s/cx2l2ex8p31n6 ... .capx?dl=0

here is my capx mr r0j0hound.
there are two laser machines that produces the laser beam.
the problem is that only one of the laser machines produces the beams.
would you please fix my event sheet so that it produces 2 laser beam with each has its own reflecting properties. O would be glad if i fixed that problem. Thanks in advance
B
9
S
2
Posts: 26
Reputation: 629

PreviousNext