Nuclide
Software Development Kit for id Tech
decals.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2022 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17class decal
18{
19 string m_strShader;
20 string m_strTexture;
21
22 void(void) decal;
23
24#ifdef SERVER
25 virtual float(entity, float) SendEntity;
26#else
27 virtual void(void) ReceiveEntity;
28 virtual float() predraw;
29 virtual void(void) BuildShader;
30#endif
31 virtual void(vector, string) Place;
32};
33
34typedef struct
35{
36 float fraction;
39} traced_t;
40
42
43void
45{
46 traced_t tmp[6];
47 float frac = 1.0f;
48
50 g_tracedDecal.endpos = [0,0,0];
51 g_tracedDecal.normal = [0,0,0];
52
53 /* unrolled, trace against walls in all 6 directions */
54 makevectors([0, 0, 0]);
55 traceline(vpos + (v_forward * -1), vpos + (v_forward * 128), 0, dself);
56 tmp[0].fraction = trace_fraction;
57 tmp[0].normal = trace_plane_normal;
58 tmp[0].endpos = trace_endpos;
59 traceline(vpos + (v_forward * 1), vpos + (v_forward * -128), 0, dself);
60 tmp[1].fraction = trace_fraction;
61 tmp[1].normal = trace_plane_normal;
62 tmp[1].endpos = trace_endpos;
63 traceline(vpos + (v_right * -1), vpos + (v_right * 128), 0, dself);
64 tmp[2].fraction = trace_fraction;
65 tmp[2].normal = trace_plane_normal;
66 tmp[2].endpos = trace_endpos;
67 traceline(vpos + (v_right * 1), vpos + (v_right * -128), 0, dself);
68 tmp[3].fraction = trace_fraction;
69 tmp[3].normal = trace_plane_normal;
70 tmp[3].endpos = trace_endpos;
71 traceline(vpos + (v_up * -1), vpos + (v_up * 128), 0, dself);
72 tmp[4].fraction = trace_fraction;
73 tmp[4].normal = trace_plane_normal;
74 tmp[4].endpos = trace_endpos;
75 traceline(vpos + (v_up * 1), vpos + (v_up * -128), 0, dself);
76 tmp[5].fraction = trace_fraction;
77 tmp[5].normal = trace_plane_normal;
78 tmp[5].endpos = trace_endpos;
79
80 /* pick whatever wall is closest */
81 for (int i = 0; i < 6; i++) {
82 if (tmp[i].fraction < frac) {
83 frac = tmp[i].fraction;
87 }
88 }
89}
90
92void Decals_Place(vector pos, string dname);
93
94#ifdef CLIENT
95string Decal_Precache(string decalTex);
96#endif
Definition: decals.h:18
void Decals_Place(vector pos, string dname)
Definition: decals.qc:257
decal Decals_Next(vector pos)
Definition: decals.qc:240
void decal_pickwall(entity dself, vector vpos)
Definition: decals.h:44
traced_t g_tracedDecal
Definition: decals.h:41
string Decal_Precache(string decalTex)
Definition: decals.qc:277
vector(vector) normalize
entity() spawn
get __int i
Definition: fteextensions.qc:3826
vector v_up
Definition: math.h:40
vector v_right
Definition: math.h:41
vector v_forward
Definition: math.h:39
void makevectors(vector angles)
Definition: math.h:42
__wrap void traceline(vector v1, vector v2, float flags, entity ent)
Definition: defs.h:307
Definition: decals.h:35
vector endpos
Definition: decals.h:38
vector normal
Definition: decals.h:37
float fraction
Definition: decals.h:36