Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, 7th_zorro, dr_panther), 1,297 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
reflecting a laser from wall #408291
09/28/12 18:47
09/28/12 18:47
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Hi,
seems i havent understood something correctly.

Ok, imagine we have a laser for a weapon i want to reflect from walls.

first, i calculate start/endvec for my laser.
do the trace
if i hit something:
i substract start from endvec(to get the direction, saved in BVec)
vec_to_angle for hit.nx
and rotate my BVec by the angle, add hit.x and trace again from hit.x to BVec.

Okay but the reflection seems to be wrong(as a laser hiting a surface isnt reflected straight back)

mh, maybe someone has an idea?

Greetings
Rackscha


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: reflecting a laser from wall [Re: Rackscha] #408292
09/28/12 19:00
09/28/12 19:00
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
you could use bounce variable of 3DGS, there are better ways, but its a start^^

Re: reflecting a laser from wall [Re: Ch40zzC0d3r] #408293
09/28/12 19:15
09/28/12 19:15
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
bounce is not used on c_trace


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: reflecting a laser from wall [Re: Rackscha] #408295
09/28/12 20:28
09/28/12 20:28
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
add to the reflect vector an inverse of the difference between the normal and the initial vector?

Re: reflecting a laser from wall [Re: lostclimate] #408297
09/28/12 21:31
09/28/12 21:31
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
is the normalvector normalized between -1 to 1
if its normalized, a difference is not directly possible, right?


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: reflecting a laser from wall [Re: Rackscha] #408300
09/28/12 22:36
09/28/12 22:36
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
trace -> if hit, scale normal vector with -2*vec_dot(dir,normal), add normal vector to dir (and add dir to your target vector for the new trace target location). You can search wikipedia ("reflection") for details on this formula.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: reflecting a laser from wall [Re: Superku] #408304
09/28/12 23:49
09/28/12 23:49
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
thanks superku.
But i noticed that bounce is set in c_trace, too.
Now it seems to work.

Code:
vec_to_angle(LAng, bounce);
					vec_set(BVec, vector(200, 0, 0));
					vec_rotate(BVec, LAng);
					vec_add(BVec, hit.x);



MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1