View Single Post
Re: Finding angle at which a grenade hits a wall
Old
  (#11)
two_masks
Guest
 
Status:
Posts: n/a
Default Re: Finding angle at which a grenade hits a wall - 12-05-2004

Hey everyone,

Thanks for the responses. I'm feeling kind of dumb, but I'm still having a lot of trouble getting a proper angle. I think a big part of the problem is that I'm not really familiar with the info that's made available by Half Life/CS. Could someone show the code necessary to get the angle of incidence? Here's what I've been doing once I have the grenade entity (pTargetEdict):

Code:
 if (pTargetEdict->v.oldorigin.x != 0 && pTargetEdict->v.oldorigin.y != 0 && pTargetEdict->v.oldorigin.z != 0)
 			{
 		    	UTIL_TraceLine(pTargetEdict->v.oldorigin, (pTargetEdict->v.origin * 1000), ignore_monsters, pTargetEdict->v.pContainingEntity, &tr);	
 		    	LOG_CONSOLE(PLID, "TraceLine hit entity with normal (%f, %f, %f)", tr.vecPlaneNormal.x, tr.vecPlaneNormal.y, tr.vecPlaneNormal.z);
 		    	fTemp = DotProduct((pTargetEdict->v.origin - pTargetEdict->v.oldorigin).Make2D().Normalize(), tr.vecPlaneNormal.Make2D());
 		    	LOG_CONSOLE(PLID, "Incidence angle = %f", (180 * acos(fTemp)) / 3.14159 );
 			}
 			
 			pTargetEdict->v.oldorigin = pTargetEdict->v.origin;
This gives me angles, but they don't seem to remain steady as I'd like them to, leading me to believe something is wrong, probably in my calculation of the dot product. Any LA gurus want to tell me my obvious mistake?
  
Reply With Quote