3d Collision Response
i''m working on collision response between an initial vector and a plane. the difficulty i''m having is rotating the direction vector to the new direction vector, AND transforming the other two axes that are associated with the direction vector, (yaw and pitch axes).
theoretically, i''m thinking:
given: new direction vector (normalized)
find the euler angles of this vector (with respect to World Coord system z - axis, in this case, the rollaxis).
Convert to Matrix
transform the two other axes with this Matrix (from WCS again).
i''m assuming this is the algorithm, but any other suggestions, ideas?
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Er, that''s a lot of work a2k. What you could do is do what I did. Ok here it goes. I just get the original vector and the destination vector right? After that I check if it collides with a poly correctly. If it collided with the poly, it moves the destination vector in 100 units front of the plane. It''s quite hard to explain, but think really hard about it and it will come to you.
------------------------
Captured Reality.
------------------------
Captured Reality.
um, actually, this is how i''m interpreting yours, nes8bit: instead of actually having the object rotate and continue on another path, the collision response algorithm merely moves the object way from the plane, in the direction of the reflected vector. in this way, the direction vector will still travel towards the plane, but momentarily, for the instant of collision, it is moved away from the plane.
if this is not what it is, then i''m misreading your post. i actually have it implemented the way above, but see, what i want to do is, if an object drifts towards a wall, it starts traveling in the reflected direction on collision, rather than "dragging" on the wall. this requires rotating all three axes w.r.t. the resultant vector rotation.
what a mouthful. anyway, i hope this makes sense. thanks for the help, and correct me if i''m wrong.
a2k
if this is not what it is, then i''m misreading your post. i actually have it implemented the way above, but see, what i want to do is, if an object drifts towards a wall, it starts traveling in the reflected direction on collision, rather than "dragging" on the wall. this requires rotating all three axes w.r.t. the resultant vector rotation.
what a mouthful. anyway, i hope this makes sense. thanks for the help, and correct me if i''m wrong.
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
You lost me. My example was to tell you how to do quake like collisions. In other words, the player will slide if it collides with the wall at an angle.
------------------------
Captured Reality.
------------------------
Captured Reality.
actually, i guess it''d be okay to do it that way, with sliding, but i''m still having difficulty figuring it out. does your algorithm take care of collisions at any orientation against planes of any orientation? my game is similar to Descent, so i''m gonna need the most general case.
a2k
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
If you want an object to bounce in off of a wall just reverse the signs for the object''s X, Y, and Z vectors. Example: If object A''s translation matrix is (0, 0, -1) (Forward in OpenGL) and object A hits a wall straight on, its new vector will be (0, 0, 1). Am I right in this?
i would think if you reverse the sign of the ship's yaw vector, the ship would end up upside-down.
i mean, it should work for position. meaning, yes, for that instant in the code, the object will travel in the opposite direction, but what happens when it passes through the code again, and sees that the yaw, pitch, and roll axes are STILL oriented towards the wall? that's why i want to change the ship's orientation, rather than just it's position.
a2k
Edited by - a2k on June 7, 2000 2:13:04 PM
i mean, it should work for position. meaning, yes, for that instant in the code, the object will travel in the opposite direction, but what happens when it passes through the code again, and sees that the yaw, pitch, and roll axes are STILL oriented towards the wall? that's why i want to change the ship's orientation, rather than just it's position.
a2k
Edited by - a2k on June 7, 2000 2:13:04 PM
------------------General Equation, this is Private Function reporting for duty, sir!a2k
a2k: I''ll post my collision response on my page. Keep checking this page
http://members.xoom.com/deadstranger/download/collresponse.txt
I''ll put it up later.
------------------------
Captured Reality.
http://members.xoom.com/deadstranger/download/collresponse.txt
I''ll put it up later.
------------------------
Captured Reality.
acw83: switching the signs of the velocity of an object for a collision is only applicable in a few special cases, i.e. perfectly vertical or horizontal walls.
a2k: I've never used matrices to handle physics, but I'll try to explain how I'd do this anyway.
First, your craft has a 3D velocity vector (you can probably derive this from your craft's yaw, pitch, and speed). You should also have a 3D normal vector (normalized) for the wall that you're bouncing off of.
Find the magnitude of the craft's velocity in the direction of the wall normal. This is the dot product of these two, and it represents how 'hard' you're hitting the wall.
Upon collision, the wall applies a force to the craft in the direction of its normal. In other words, you'll be adding a scaled version of the wall's normal vector to your craft's velocity vector.
As far as what scale to use, it depends on what type of collision you want. If you want a perfectly elastic one, where the craft rebounds w/out losing speed, do:
craft velocity += wall normal * ( magnitude * 2 )
If you want the craft to slide (perfectly inelastic), just do:
craft velocity += wall normal * magnitude
If you want to craft to rebound but w/ reduced speed, use magnitude * 1.5 (or 1.2, or 1.8, or whatever).
Edited by - Eric on June 9, 2000 3:06:48 AM
a2k: I've never used matrices to handle physics, but I'll try to explain how I'd do this anyway.
First, your craft has a 3D velocity vector (you can probably derive this from your craft's yaw, pitch, and speed). You should also have a 3D normal vector (normalized) for the wall that you're bouncing off of.
Find the magnitude of the craft's velocity in the direction of the wall normal. This is the dot product of these two, and it represents how 'hard' you're hitting the wall.
Upon collision, the wall applies a force to the craft in the direction of its normal. In other words, you'll be adding a scaled version of the wall's normal vector to your craft's velocity vector.
As far as what scale to use, it depends on what type of collision you want. If you want a perfectly elastic one, where the craft rebounds w/out losing speed, do:
craft velocity += wall normal * ( magnitude * 2 )
If you want the craft to slide (perfectly inelastic), just do:
craft velocity += wall normal * magnitude
If you want to craft to rebound but w/ reduced speed, use magnitude * 1.5 (or 1.2, or 1.8, or whatever).
Edited by - Eric on June 9, 2000 3:06:48 AM
no way. i've got to try it. if it's really that easy, i'm sorry to everyone for whom i have wasted their time. =)
thanks.
holy shiznit! vector addition! i'm stupid! no, but wait a sec, i still need to reorient the other two vectors (yaw and pitch) so that i can orient my craft properly.. hence, rotation matrix, right? but wait, if i introduce a velocity vector, which is different than the roll axis, i can add powerslides and ugly crashes and stuff....right? hmmm. okay, time to reimplement a few things..
a2k
Edited by - a2k on June 9, 2000 3:33:30 AM
thanks.
holy shiznit! vector addition! i'm stupid! no, but wait a sec, i still need to reorient the other two vectors (yaw and pitch) so that i can orient my craft properly.. hence, rotation matrix, right? but wait, if i introduce a velocity vector, which is different than the roll axis, i can add powerslides and ugly crashes and stuff....right? hmmm. okay, time to reimplement a few things..
a2k
Edited by - a2k on June 9, 2000 3:33:30 AM
------------------General Equation, this is Private Function reporting for duty, sir!a2k
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement