How to slide against plane in collision?
#1
Posted 13 October 2005 - 09:13 PM
i have position before collision and after collision. how to determine vector that ll move point parallelly in desired lengh to plane?
#2
Posted 13 October 2005 - 09:22 PM
Let's call A the point after collision, A' its projection on the plane, O some point of the plane, and N the normal. Then you have:
OA'=OA - (OA.N)
#3
Posted 13 October 2005 - 09:41 PM
http://www.devmaster...-trees-physics/
somwhere in the middle is written exactly:
Quote
EndPosition += Polygon.Normal*(CollRadius-EndSideValue)
The effect of this formula will be that objects "slide" against the walls as opposite to get stuck against walls which would be the case if the end position was set to the start position every time a collision was detected.
but i only need to do point vs plane, not object vs polygon, like in article, how to do the "slide"?
how to code this in c ?
sorry, but what is OA' ? how can i get position from this that describes point after collision.
#4
Posted 14 October 2005 - 08:39 AM
-
Currently working on: the 3D engine for Tomb Raider.
#5
Posted 14 October 2005 - 11:55 AM
it not fully works. im using folowing code, this is done on every frame:
//
// pl - D3DXPLANE structure
// lpvOld - old point (camera) pos
// lpvNew - new point (camera) pos
FLOAT fDistOld = D3DXPlaneDotCoord( &pl, lpvOld ); //get distance from plane
FLOAT fDistNew = D3DXPlaneDotCoord( &pl, lpvNew );
// If the two points is on different sides of the plane, multiplying
// the two values will give a negative result, indicating that the
// object passed through the plane.
if( fDistOld * fDistNew < 0 ){
D3DXVECTOR3 vPlNormal = D3DXVECTOR3( pl.a, pl.b, pl.c );
*lpvCorrection = fDistOld * vPlNormal;
return 1;
}
later im adding 'lpvCorrection' to old position to determine final camera position, but when im doing that result is that camera is shaking and sometimes passes thru that plane. what could be wrong in my code ? plz help.
#6
Posted 14 October 2005 - 12:19 PM
Here, take a look at this diagram:

What you're doing is moving the old position onto the plane. That won't give you a sliding sensation since it has nothing to do with the direction you're actually moving in. However, if you project the new position onto the plane, you'll get the feeling that the diagonal movement stops at point of impact, and slides along the plane with the "left-over energy" from the movement (the green arrow).
Note that you might need to change a sign (-fDistNew * vPlNormal), because you need to move toward the plane, not away from the plane.
-
Currently working on: the 3D engine for Tomb Raider.
#7
Posted 14 October 2005 - 12:33 PM
ikk said:
A' is the position after correcting. :-)
Look at .oisyn's the diagram.
#8
Posted 14 October 2005 - 12:33 PM
#9
Posted 14 October 2005 - 01:58 PM
#10
Posted 24 October 2005 - 11:02 PM
Maybe someone else knows of this article, sorry it was a few years ago now.
#11
Posted 24 October 2005 - 11:41 PM
#12
Posted 25 October 2005 - 02:49 AM
http://www.fluidstud..._Ellipsoids.pdf
Dont know if the author started up fluidstudios or what. I hope they dont mind me linking it.
#13
Posted 25 October 2005 - 08:36 AM
#14
Posted 26 October 2005 - 10:09 PM
ok, ive got folowing points: A2, B, D, and plane
How to get A3? or the orange line?
#15
Posted 26 October 2005 - 10:27 PM
Then:
BD.N = A3D (BD projected on N)
But you have BD = BA3 + A3D
So BA3 = BD - BD.N
Do you get it?
#16
Posted 26 October 2005 - 10:30 PM
Simply take the (normalized) normal vector for your plane multiply it with the distance from D to the plane and then add it to the point D. That’s the new position (A3).
#17
Posted 28 October 2005 - 07:18 PM
you should told me about that normalization earlier :yes:
#18
Posted 01 November 2005 - 09:55 AM
-
Currently working on: the 3D engine for Tomb Raider.
#19
Posted 01 November 2005 - 10:23 AM
.oisyn said:
Actually the definition of normal is that it is perpendicular to a plane
normalized means that it has been made into a unit vector.
http://en.wikipedia....8mathematics%29
#20
Posted 01 November 2005 - 10:45 AM
('norm' means 'length')
-
Currently working on: the 3D engine for Tomb Raider.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












