Client: add helper function drawpic3d. Which instead of a screen position takes a 3d-world position as an argument.

This commit is contained in:
Marco Cawthorne 2022-05-26 17:43:22 -07:00
parent 0f7d4fd214
commit 00364ad476
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 29 additions and 0 deletions

View File

@ -110,6 +110,35 @@ void drawrect(vector pos, vector sz, float thickness, vector rgb, float al, opti
drawfill(pos + [sz[0] - thickness, thickness], [thickness, sz[1] - (thickness * 2)], rgb, al, dfl);
}
void
drawpic3d(vector worldpos, string mat, vector sz, vector rgb, float alpha)
{
static bool
drawpic3d_visible(vector p1) {
vector delta;
float fov;
vector p2 = getproperty(VF_ORIGIN);
vector ang = getproperty(VF_CL_VIEWANGLES);
makevectors(ang);
delta = normalize (p1 - p2);
fov = delta * v_forward;
if (fov > (getproperty(VF_AFOV)/180)) {
traceline(p2, p1, MOVE_WORLDONLY, self);
if (trace_fraction == 1.0) {
return (1);
}
}
return (0);
}
if (drawpic3d_visible(worldpos) == true) {
vector vecProj = project(worldpos) - (sz/2);
drawpic(vecProj, mat, sz, rgb, alpha);
}
}
void
precache_cubemap(string path)
{