how to create a laser beam

Posted By: pjotr987

how to create a laser beam - 11/07/12 00:17

Hi guys,
i want to create something like laser beam, whose spot size is decreasing the more distant the hit object is. my aim is to create something like a distance measuring simulation. Depending on the beam spot size the distance to an object should be calculated. can me help someone to get a with distance decreasing laser beam spot.

thanks in advance
Posted By: Uhrwerk

Re: how to create a laser beam - 11/07/12 00:36

You can measure the distance with c_trace and create a beam with a particle that got its BEAM flag set. You then need done additional particle at the end of the beam and increase its size with growing distance.
Posted By: pjotr987

Re: how to create a laser beam - 11/09/12 13:05

is there any piece of code that throws a spot (like a spot of a laser) on hit surface?. this spot radius should decrease with the increasing distance of the hit area. like a spot of a torch, that is big if it hits a close wall and gets smaller if the wall is more distant. somehow i dont know how to start. frown

any help will be approciated
thanks in advance
Posted By: Superku

Re: how to create a laser beam - 11/09/12 13:48

It will automatically get smaller because of perspective, but you can do it manually, too (however, this would be unrealistic).
Uhrwerk already told you how to achieve it, check the manual for c_trace(), vec_rotate(), hit.x/ "target" and effect() or ent_decal().
Posted By: pjotr987

Re: how to create a laser beam - 11/12/12 13:51

thanks for replies guys.
finaly i managed to plot a white circle (png sprite) on the c_trace hitted place. the thing now is, that this circle is alleays round. i want to stretch it in one axis according to the angle the beam hits the wall (to make it look more realistic). so now i have to get the angle with which the c_race is hitting the wall.
can someone give me an idea how to get this angle.

thanks in advance
Posted By: Ch40zzC0d3r

Re: how to create a laser beam - 11/12/12 13:56

Originally Posted By: pjotr987
thanks for replies guys.
finaly i managed to plot a white circle (png sprite) on the c_trace hitted place. the thing now is, that this circle is alleays round. i want to stretch it in one axis according to the angle the beam hits the wall (to make it look more realistic). so now i have to get the angle with which the c_race is hitting the wall.
can someone give me an idea how to get this angle.

thanks in advance


Use the normal vector laugh
Posted By: pjotr987

Re: how to create a laser beam - 11/12/12 14:19

so the normalvector seems to be a step in the right direction, but i still dont get the right angle with which the c_trace hits the wall. the code below delivers only angles in 90° steps (90,180 and 270) and not the real angle.

var winkel=my.pan;
vec_to_angle(winkel, normal);

any ideas how to solve it?

thanks for any help
Posted By: Superku

Re: how to create a laser beam - 11/12/12 14:20

You will need to use a (sprite) entity or ent_decal (where the latter is probably the better choice), particles do not support angles.
Posted By: Uhrwerk

Re: how to create a laser beam - 11/12/12 14:22

You cannot use a fixed skalar where an angle is expected. The functions signature is vec_to_angle(ANGLE* ang, VECTOR* dir).
Posted By: Ch40zzC0d3r

Re: how to create a laser beam - 11/12/12 16:05

lol, Change the vel_x, y, z...
© 2024 lite-C Forums