Jump to content
  • Advertisement
Sign in to follow this  
CIJolly

Faking/Fudging rotations after collisions

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have recently worked through Oliii's collision detections tutorials, up to the point where I can determine collision points. I am starting on Chris Heckers rigid body tutorials now. However, it seems like an awful lot of work when the only thing that the current engine lacks (which I think I need) is applying torque to objects after collisions. At the moment I am using Vtotal = Vtangental * -(friction) + Vnormal * -(1 + elasticity), and VA += Vtotal * (InverseMassA) / (InverseMassA + InverseMassB) for my collision response. Is there a similar "arcade" (eg, not necissarily physically perfect, but good enough for a game) collision response involving rotations which I can use? My first go at it was to to test the angle between the collision normal and the vector formed by ObjectCentre - Collision point. I took a difference of zero degrees to mean a direct hit along an axis of gravity, resulting in no rotation. A difference of 90 degrees was a glancing blow, causing the struck object to spin. Between 0 and 90 the force was split between movement and rotation accordingly. This method has not yielded very good results, and I wouldn't have a clue how to adjust it for different rotational inertias. Does anyone have any bright ideas of how I could go about this?

Share this post


Link to post
Share on other sites
Advertisement
is it in 2d?

if so, the i'd try using the the magnitude of the strikeing objects velocity. then take that and multiply it by the x or y component of the center - the x or y component of the contact point. i say x or y because it would be different depending on wich side was struck. take the value you get from that and use it for the rotation, slow it down over time or whatever.

3d on the other hand, i'd imagine would be about the same except you wouldn't take the speed of the incomming object, you'd use the velocity.


edit:

now that i think about it, you should take the component of the velocity with respect to the normal of the side you hit.

Share this post


Link to post
Share on other sites
I'm not sure I understand where you're coming from. Especially where you suggest using scalar quantities for 2D and vectors for 3D.

Share this post


Link to post
Share on other sites
there's only one way to rotate in 2d so you only need a scaler, but in 3d there are 7 ways to rotate so the angular velocity needs to be a vector with the rotations about the x y and z.

basically i'm takeing the force applied perpendicular to the side hit and multiplying it by the distance from the center. pretty simple, i may of just explained it wierd.

hope that clears things up.

Share this post


Link to post
Share on other sites
Yeah, that was part of my original solution as well. What I was having problems with was dividing the force between that which would act on the rotational inertia to provide rotation, and that which would act on the mass to provide linear velocity.
Also, I think that you need a vector in 2D as well. 2D rotation can be clockwise or anticlockwise, implying a positive or negative directional component. I'm no physicist though.
Thanks for helping out.

Share this post


Link to post
Share on other sites
Quote:
Original post by CIJolly
Yeah, that was part of my original solution as well. What I was having problems with was dividing the force between that which would act on the rotational inertia to provide rotation, and that which would act on the mass to provide linear velocity.


i think you could just compute the change in angular velocity first and then find the change in linear velocity.

Quote:
Also, I think that you need a vector in 2D as well. 2D rotation can be clockwise or anticlockwise, implying a positive or negative directional component.


you could think of it as a 1d vector if you like. a clocwise rotation would be -x rad/sec and counter clocwise would be x rad/sec so all you need is a signed number.

Share this post


Link to post
Share on other sites
Torque can be calculated by a cross product of (the force) and (a vector from the center of mass to where the force is applied). In 2D you can use just the Z for the magnitude and direction of the torque. Then you divide by the moment of inertia to get angular acceleration. In 3D I'm not sure how you determine the direction, but the magnitude of the cross product divided by the moment of interia should still give you the right magnitude.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!