Hi guys,
I have a small problem. But i cant figure it out.
What i want to create is a ball moving around a world, (Like just a room)
And i want it to bounce correct on all
surfaces.
I have the ball’s possition and direction, and offcourse the Normal of the triangle the Ball collided with.
How can i invert/change the Ball’s Direction? Is it possible to just muliply it with the plan normal?
Thanks.
Bob
2
You have to calculate the reflection vector.
r = reflection vector
n = plane normal
v = velocity vector
- = scalar/vector multiplication
dot = dot product
r = 2 * n * (n dot v) - v
Hey, thanks.
But what is Velocity?
Direction? Direction - possition?
Sorry
/ D
Bob
4
The velocity vector is the direction in which the ball is moving. A more proper word could have been direction, instead of velocity vector.
Hi,
vNormal = [0, 1, 0] Floor
vDirection: [0, -1, -1] // Sphear is moving down/into the screen.
When hiting the floor, i use:
vReflection = vNormal * Dot(vNormal, vDirection) - vDirection;
Then the reflection should be [0, 1, -1] right?
But its [0, 0, 1] any idea why? What am i doing wrong?
/Thanks again.
Bob
7
See my code again, you forgot to multiply by 2.
Also remember that I can’t guarantee that formula is correct. I came up with it in a minute from a piece of paper and a pencil
Hey,
Then the reflection just becomes [0, 0, 2]
Ill stop flooding you with dumb questions, and try to get my hand on some source code
Thanks man
Remember that this is an OpenGL advanced forum?
Yes?
Then, why are you asking non OpenGL questions?
There are many places for your questions, for example
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Please, don’t fill this forum of offtopic noise.
Thanks.