Reflecting laser beams off surfaces

Get help using Construct 2

Post » Fri Jul 19, 2013 12:03 am

Can someone reupload R0J0's example? I'd like to take a look.
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Fri Jul 19, 2013 12:09 am

@Wolod

The link provided stillworks for me..
B
45
S
15
G
9
Posts: 1,096
Reputation: 11,038

Post » 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
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » 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:
https://www.youtube.com/watch?v=3pmQZi5-Ghw

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
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » 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://dl.dropboxusercontent.com/u/542 ... _math.capx
B
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » 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
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Apr 14, 2016 7:32 am

@R0J0hound thanks, good example, like all your works.
ImageImageImage
B
28
S
14
G
3
Posts: 143
Reputation: 4,404

Post » 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
1
Posts: 26
Reputation: 479

Post » 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
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » 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
1
Posts: 26
Reputation: 479

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Renfd, supreme676 and 30 guests