bounce for c_trace

Posted By: Gumby22don

bounce for c_trace - 05/22/09 04:41

Hi,

Could someone help me setting up a manual bounce calculation - only just realised the bounce isn't set by c_trace, only by c_move. normal is still set, and the following is my guess at how bounce is calculated, but my head hurts so I can't think :P

note tempGun is the speed of the fired weapon. so "speed" in the manual's decription.
Code:
//bounce = speed + 2*dot(normal,-speed)*normal, while speed = distance vector to target, normal = target surface normal. 
vec_set(tempV1, tempGun);
vec_scale(tempV1, -1);
tempV2 = vec_dot(normal, tempV1);
vec_set(tempBounce, normal);
vec_scale(tempBounce, tempV2 * 2);  //new Bounce


Is this even remotely close to correct?

Thanks,

Don
have a great day

Posted By: Gumby22don

Re: bounce for c_trace - 05/23/09 11:36

Ok - figured it out in about 5 mins with coffee...

I didn't add the original speed vector to it, - real code now looks like this:
Code:
vec_set(tempV1, tempGun);
vec_scale(tempV1, -1);
tempV2 = vec_dot(normal, tempV1);
vec_set(tempBounce, normal);
vec_scale(tempBounce, tempV2 * 2);  
vec_scale(tempV1, -1);	//back to speed
vec_add(tempBounce, tempV1); //add speed to 2*dot*normal.  //new Bounce


Hope this helps someone.
© 2024 lite-C Forums