Jump to content

  • Log In with Google      Sign In   
  • Create Account


ardmax1

Member Since 14 Sep 2010
Offline Last Active May 16 2013 11:12 AM
-----

Topics I've Started

Impulse based collision response (friction)

20 March 2013 - 01:30 PM

I'm trying to implement impulse response with friction and I can't get it to work. I have compared other implementations that I found but I can't find any errors in my code. So what happens is as soon as object stops bouncing (bouncing works) it starts to slide and accelerate indefinitely. I'm testing this using sphere and plane.

 



e0->pos += e0->getVel() * info->getContactTime();
e1->pos += e1->getVel() * info->getContactTime();

vec3 n = info->getNormal();
vec3 r0 = info->getContactPoint() - e0->pos;
vec3 r1 = info->getContactPoint() - e1->pos;

vec3 v0 = e0->getVel() + cross( r0, e0->angVel );
vec3 v1 = e1->getVel() + cross( r1, e1->angVel );

vec3 dv = v1 - v0;

float e = 0.5;
float f = 0.1;
float num = (1+e) * dot(dv,n);
float denom = e0->massInv + e1->massInv + dot( e0->getWorldInertiaInv() * cross(cross(r0,n),r0) + e1->getWorldInertiaInv() * cross(cross(r1,n),r1) ,n );
float jr = num / denom;

e0->applyImpulse( r0, n * jr );
e1->applyImpulse( r1, -n * jr );

vec3 t = normalize( cross( n, cross( dv, n ) ) );

num = -dot(dv,t);
denom = e0->massInv + e1->massInv + dot( e0->getWorldInertiaInv() * cross(cross(r0,t),r0) + e1->getWorldInertiaInv() * cross(cross(r1,t),r1) ,t );
float jf = num / denom;
jf = clamp( jf, -jr * f, jr * f );

e0->applyImpulse( r0, jf * t );
e1->applyImpulse( r1, -jf * t );

 

 

 

Other implementations I've tried:

http://www.gamedev.net/topic/465248-calculating-impulse-due-to-rigid-body-collision-with-friction/

http://en.wikipedia.org/wiki/Collision_response#Impulse-Based_Reaction_Model

 

 

 


Space partitioning for flocking

04 July 2012 - 03:43 PM

Hi,
I'm looking for space partitioning structure which will be good for moving points and will enable fast fixed radius near neighbors search.

GLSL - pixel color based on alpha

12 June 2012 - 06:09 AM

Hi,
is it possible to write GLSL shader such that it will change each texture pixel color based on its alpha value ?
Something like:
[source lang="cpp"]vec4 pixel = texture2D( texture, pos );if( pixel.a > 0.5f ){ pixel = vec4( 0.0, 1.0, 0.0, 1.0 );}else{ pixel = vec4( 1.0, 0.0, 0.0, 1.0 );}[/source]
If it is, could you guys give me tips on how to make it ?

Concave + SAT + Tringulation

14 September 2010 - 08:38 AM

Hi,
Im working on my 2d physics engine, its working quite well as for first engine, im using convex polygons only but now i want to add concave ones. So i create new concave polygon, i tringulate it, and heres part i dont know how to solve. I was using SAT for convex polygon collision detection, but now i dont know how to test both tringulated polygons with SAT.

Can it be done with SAT, or i need other technique ?

PARTNERS