Nuclide
Software Development Kit for id Tech
NSDecal.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
24class
26{
27public:
28 void NSDecal(void);
29
30#ifdef SERVER
31 virtual float SendEntity(entity, float);
32#else
33 virtual void ReceiveEntity(void);
34 virtual float predraw(void);
35 virtual void BuildShader(void);
36#endif
37
39 virtual void Place(vector, string);
40
41private:
42 string m_strShader;
43 string m_strTexture;
44};
45
46typedef struct
47{
48 float fraction;
49 vector normal;
50 vector endpos;
51} traced_t;
52
54
55void
56decal_pickwall(entity dself, vector vpos)
57{
58 traced_t tmp[6];
59 float frac = 1.0f;
60
62 g_tracedDecal.endpos = [0,0,0];
63 g_tracedDecal.normal = [0,0,0];
64
65 /* unrolled, trace against walls in all 6 directions */
66 makevectors([0, 0, 0]);
67 traceline(vpos + (v_forward * -1), vpos + (v_forward * 128), 0, dself);
68 tmp[0].fraction = trace_fraction;
69 tmp[0].normal = trace_plane_normal;
70 tmp[0].endpos = trace_endpos;
71 traceline(vpos + (v_forward * 1), vpos + (v_forward * -128), 0, dself);
72 tmp[1].fraction = trace_fraction;
73 tmp[1].normal = trace_plane_normal;
74 tmp[1].endpos = trace_endpos;
75 traceline(vpos + (v_right * -1), vpos + (v_right * 128), 0, dself);
76 tmp[2].fraction = trace_fraction;
77 tmp[2].normal = trace_plane_normal;
78 tmp[2].endpos = trace_endpos;
79 traceline(vpos + (v_right * 1), vpos + (v_right * -128), 0, dself);
80 tmp[3].fraction = trace_fraction;
81 tmp[3].normal = trace_plane_normal;
82 tmp[3].endpos = trace_endpos;
83 traceline(vpos + (v_up * -1), vpos + (v_up * 128), 0, dself);
84 tmp[4].fraction = trace_fraction;
85 tmp[4].normal = trace_plane_normal;
86 tmp[4].endpos = trace_endpos;
87 traceline(vpos + (v_up * 1), vpos + (v_up * -128), 0, dself);
88 tmp[5].fraction = trace_fraction;
89 tmp[5].normal = trace_plane_normal;
90 tmp[5].endpos = trace_endpos;
91
92 /* pick whatever wall is closest */
93 for (int i = 0; i < 6; i++) {
94 if (tmp[i].fraction < frac) {
95 frac = tmp[i].fraction;
99 }
100 }
101}
102
103void Decals_Init(void);
104NSDecal Decals_Next(vector pos);
105
107void Decals_Place(vector pos, string dname);
108
109#ifdef CLIENT
110string Decal_Precache(string decalTex);
111void Decal_Parse(void);
112void Decal_Reload(void);
113void Decal_Shutdown(void);
114#endif
NSDecal Decals_Next(vector pos)
Definition: NSDecal.qc:240
void Decal_Parse(void)
Definition: NSDecal.qc:300
void Decals_Place(vector pos, string dname)
Places a desired decal at the specified position.
Definition: NSDecal.qc:257
void decal_pickwall(entity dself, vector vpos)
Definition: NSDecal.h:56
traced_t g_tracedDecal
Definition: NSDecal.h:53
void Decals_Init(void)
Definition: NSDecal.qc:211
void Decal_Reload(void)
Definition: NSDecal.qc:287
void Decal_Shutdown(void)
Definition: NSDecal.qc:311
string Decal_Precache(string decalTex)
Definition: NSDecal.qc:277
This entity class represents decals
Definition: NSDecal.h:26
vector v_up
Definition: math.h:46
vector v_right
Definition: math.h:47
vector v_forward
Definition: math.h:45
void makevectors(vector angles)
Definition: math.h:48
__wrap void traceline(vector v1, vector v2, float flags, entity ent)
Definition: defs.h:379
Definition: NSDecal.h:47
vector endpos
Definition: NSDecal.h:50
vector normal
Definition: NSDecal.h:49
float fraction
Definition: NSDecal.h:48