PDA

View Full Version : Question Vector and QAngle help



copymark
02-11-2010, 03:42 PM
I want to show a line from each enemy in direction where he is aiming on
origin should be the head of course.


void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b,bool noDepthTest, float duration)

To make it more clear:
http://img694.imageshack.us/img694/9633/vectord.jpg (http://img694.imageshack.us/i/vectord.jpg/)

i need the vector point x. (distance may be 2000 units)

i can get the origin with:

pBaseEntity->EyePosition()

and the EyeAngles:

pBaseEntity->EyeAngles()

But unfortionally i dont know how to calculate with vectors and QAngles

Im sure a lot of people here can help me
Mfg Mark

bobbysing
02-11-2010, 03:47 PM
You can use the SDK-supplied function AngleVectors to convert the EyeAngles to a vector, you can then (normalize) and multiply that vector by the desired line-length.
After that you add the resulting vector to the eye-position. Then you convert both the line-start ( eye-pos ) and line-end ( the resulting vector + eye-pos ) to screen-coordinates and draw your line.

See: http://developer.valvesoftware.com/wiki/Vector http://developer.valvesoftware.com/wiki/QAngle

wav
02-11-2010, 03:48 PM
AngleVectors ( pBaseEntity->EyeAngles(), &vecForward );

VectorNormalize ( vecForward );

vecEnd = pBaseEntity->EyePosition() + vecForward * 2000;

AddLineOverlay ( pBaseEntity->EyePosition(), vecEnd, 255, 255, 255, true, g_pGlobals->curtime + 0.5 );

copymark
02-11-2010, 05:32 PM
ok thx for this bit of math
this link from valvedeveloper about vectors helped a lot

but BaseEnt->GetAbsAngles() and BaseEnt->EyeAngles() seem to return (0 0 0), because my rays are always aiming this direction :-(
Is there an other function i have to use?
its for cs:s

wav
02-12-2010, 03:01 AM
pBasePlayer->EyeAngles()

if that doesn't resolve:



QAngle QEyeAngles = *( QAngle* )( ( DWORD )pBaseEntity + 0x101C );

AngleVectors ( QEyeAngles, &vecForward );

VectorNormalize ( vecForward );

vecEnd = pBaseEntity->EyePosition() + vecForward * 2000;

AddLineOverlay ( pBaseEntity->EyePosition(), vecEnd, 255, 255, 255, true, g_pGlobals->curtime + 0.5 );

copymark
02-12-2010, 06:57 PM
already did it like that
but anyways thanks for your help

The problem is probably my sdk, its 5 years old (omg)^^
but i hate updating, its such as annoying