Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by the_chaoz
pawn Code:
IsPointInPlayerScreen(playerid, Float:x, Float:y, Float:z) { new Float:P[3], Float:Dist; GetPlayerPos(playerid, P[0], P[1], P[2]); if(z-P[2]>15.0 || P[2]-z>15.0)return 0; Dist = floatsqroot(floatpower((P[0]-x), 2)+floatpower((P[1]-y), 2)+floatpower((P[2]-z), 2)); if(Dist>100.0)return 0; new Float:cV[3], Float:cP[3], Float:T[3], Float:Ar; GetPlayerCameraPos(playerid, cP[0], cP[1], cP[2]); GetPlayerCameraFrontVector(playerid, cV[0], cV[1], cV[2]); T[0] = cV[0]*Dist+cP[0]; T[1] = cV[1]*Dist+cP[1]; T[2] = cV[2]*Dist+cP[2]; if(z-T[2]>10.5 || T[2]-z>10.5)return 0; if(Dist<7.0)return 1; Ar=atan2((P[1]-T[1]), (P[0]-T[0])); if(Ar-45.0<(atan2((P[1]-y), (P[0]-x)))<Ar+45.0)return 1; return 0; }
|
RyDeR` or anyone thinking of improving this function?