News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Reflectance Angles???

Started by Scott_Bro, December 08, 2021, 07:42:31 AM

Previous topic - Next topic

Scott_Bro

This code fragment works but I was wondering how else this could be done?

It states that the incident angle of the incoming collision is the balls movement then
get the difference between the surface normal and ball then reflectance angle is now normal plus positive/negative angle diff + 180

Which works but I would like to see (how) others do this?  If anyone could show be what is a more streamlined/common way of working with this?

Incident_Angle = Ball_Angle_1
Angle_Difference = Surface_Angle - Incident_Angle
Reflectance_Angle = WrapValue(Surface_Angle + Angle_Difference + 180,0,360)

Ball_Angle_1 = Reflectance_Angle

Steve, You've been gracious explaining other formulus could you explain to me how you would go about calculating reflectance angles?  A more universal way other figure this one out???

Thanks,
Scott_Bro
   

stevmjon

i actually haven't done reflectance angle in this way before. you would think i would have after all these years, lol.

the only thing i have done is to detect a collision then 'push' the objects apart.
one thing i have done in 3D is to look at a collision box (player) and check this with a 3D object polygon surface then 'partially reflect' the player away from the polygon face it collided with. so the player was pushed in the direction of the polygon face it collided with, a distance where there is no more collision. normally the player would just get pushed back the direction it came from, but i did this differently, so you could say it is partially reflectance....

kev will know this question better than myself.

going by what you wrote above it looks good to me.

   stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


aren't there examples of this on the board already..    i know there's one in the help files somewhere..