Skip to main content
gamedev.net
🔒 Locked

CollisionResponse x angular_velocity

Started by Agemaniac 0 replies 250+ views
Original Post
Agemaniac
Agemaniac
Hello ....i have implemented my simple collision response rotine (thanks everyone that help me in the other post). It seens to work perfectly. But sometimes it doestn''t work. I thought that my angular_velocity is beeing calculated in the wrong way. There is a test in the function that calculate the relative velocity between the objects and using the normal_collision test if the objects are really converging. I have put an exit() int the else clause because i thought that it should never fall into that condition. If the objects collide than i think that they are converging. But..........sometimes the program exit because it fall into the else clause....it''s really sucks... i''m using spheres to test the collision and the angular velocity didn''t appear in the visual effects...so i thought that they are calculate in the wrong way. Can someone help me plz................................sorry...my engligh is poor. cVETOR3D r1 = collision_point - source1.position; cVETOR3D r2 = collision_point - source2.position; cVETOR3D velocity1 = source1.lin_velocity + Cross(source1.velocidade_angular, r1); cVETOR3D velocity2 = source2.lin_velocity + Cross(source2.velocidade_angular, r2); float relat_velocity = Dot(velocity1, normal_collision1); velat_velocity - = Dot(velocity2, normal_collision1); //i don''t know which normal i have to take......so: (i use the normal that return relat_velocity>0) //normal_collision1 is the normal_collison of the first object and so on. if (relat_velocity>0) //test if the objects are really converging. { velocidader = 0; normal_collision2 = normal_collison1; relat_velocity = Dot(velocidade1,normal_collison2); relat_velocity - = Dot(velocidade2, normal_collison2); } if (velocidader>0) exit(1); // i thought that it is not a problem because would never hit this point. but somethimes it hits. //calculate the impulse //then i update the velocities like this: //in both case i can''t figure out which velocity i have to aply minus impulse: source1.lin_velocity (+= or - =) impulse * obj1->OneOverMass; source2.lin_velocity (+= or - =) impulse * obj2->OneOverMass; source1.angular_momentum (+= or - =) Cross(r1, impulse); source2.angular_momentum (+= or - =) Cross(r2, impulse); //should i use + = here too? i''m using just = source1.angular_velocity = source1.invworld_inertia_tensor * source1.angular_momentum; source2.angular_velocity = source2.invworld_inertia_tensor * source2.angular_momentum; In the integrate function i use target.position = source.position + (source.velocity * delta_time); target.velocity = source.velocity + source.force * (delta_time * objeto->OneOverMass) ; target.orientation = source.orientation + (cMATRIX(source.angular_velocity) * source.orientation) * delta_time; target.orientacao.Ortho_Normalize (); target.invworld_inertia_tensor = target.orientation * objeto.invb_inertia_tensor * Tranpose(target.orientation); target.angular_velocity = target.invw_inertia_tensor * target.angular_momentum; Is everything right??? i think the problem is the angular_velocity but if someone figure out that i''m in the wrong, plz..let me know..........thanks!!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.