UFO: Alien Invasion
Loading...
Searching...
No Matches
r_material.h
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9Copyright (C) 1997-2001 Id Software, Inc.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26*/
27
28#pragma once
29
30/* flags will persist on the stage structures but may also bubble
31 * up to the material flags to determine render eligibility */
32#define STAGE_TEXTURE (1 << 0)
33#define STAGE_ENVMAP (1 << 1)
34#define STAGE_BLEND (1 << 2)
35#define STAGE_COLOR (1 << 3)
36#define STAGE_PULSE (1 << 4)
37#define STAGE_STRETCH (1 << 5)
38#define STAGE_ROTATE (1 << 6)
39#define STAGE_SCROLL_S (1 << 7)
40#define STAGE_SCROLL_T (1 << 8)
41#define STAGE_SCALE_S (1 << 9)
42#define STAGE_SCALE_T (1 << 10)
43#define STAGE_TERRAIN (1 << 11)
44#define STAGE_TAPE (1 << 12)
45#define STAGE_LIGHTMAP (1 << 13)
46#define STAGE_ANIM (1 << 14)
47#define STAGE_DIRTMAP (1 << 15)
48#define STAGE_FLARE (1 << 16)
49#define STAGE_GLOWMAPLINK (1 << 17)
50
51/* set on stages eligible for static, dynamic, and per-pixel lighting */
52#define STAGE_LIGHTING (1 << 30)
53
54/* set on stages with valid render passes */
55#define STAGE_RENDER (1 << 31)
56
57/* composite mask for simplifying state management */
58#define STAGE_TEXTURE_MATRIX ( \
59 STAGE_STRETCH | STAGE_ROTATE | STAGE_SCROLL_S | STAGE_SCROLL_T | \
60 STAGE_SCALE_S | STAGE_SCALE_T \
61)
62
63/* frame based animation, lerp between consecutive images */
64#define MAX_ANIM_FRAMES 16
65
66#define UPDATE_THRESHOLD 0.02
67
68typedef struct dirt_s {
69 float intensity;
70} dirt_t;
71
72typedef struct rotate_s {
73 float hz, deg;
74} rotate_t;
75
76typedef struct blendmode_s {
77 unsigned int src, dest;
79
80typedef struct pulse_s {
81 float hz, dhz;
82 float dutycycle;
83} pulse_t;
84
85typedef struct stretch_s {
86 float hz, dhz;
87 float amp, damp;
88} stretch_t;
89
90typedef struct scroll_s {
91 float s, t;
92 float ds, dt;
93} scroll_t;
94
95typedef struct scale_s {
96 float s, t;
97} scale_t;
98
99typedef struct terrain_s {
100 float floor;
101 float ceil;
102 float height;
103} terrain_t;
104
105typedef struct tape_s {
106 float floor;
107 float ceil;
108 float height;
109 float min;
110 float max;
111 float center;
112} tape_t;
113
122
123typedef struct anim_s {
126 struct image_s* images[MAX_ANIM_FRAMES];
127 float fps;
128 float dtime;
130} anim_t;
131
149
150#define DEFAULT_BUMP 1.0f
151#define DEFAULT_PARALLAX 1.0f
152#define DEFAULT_SPECULAR 0.2f
153#define DEFAULT_HARDNESS 0.2f
154#define DEFAULT_GLOWSCALE 1.0f
155
156typedef struct material_s {
157 unsigned flags;
158 float time;
159 float bump;
160 float parallax;
161 float hardness;
162 float specular;
166} material_t;
167
169
170void R_LoadMaterials(const char* map);
171void R_UpdateDefaultMaterial(const char* cvarName, const char* oldValue, const char* newValue, void* data);
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
material_t defaultMaterial
#define MAX_ANIM_FRAMES
Definition r_material.h:64
void R_UpdateDefaultMaterial(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Change listener callback for material value cvars.
void R_LoadMaterials(const char *map)
Load material definitions for each map that has one.
animLoop_t
Definition r_material.h:114
@ ANIM_BACKWARDS
Definition r_material.h:117
@ ANIM_NORMAL
Definition r_material.h:115
@ ANIM_RANDOM
Definition r_material.h:118
@ ANIM_ALTERNATE
Definition r_material.h:116
@ ANIM_RANDOMFORCE
Definition r_material.h:119
int num_frames
Definition r_material.h:124
float dtime
Definition r_material.h:128
struct image_s * images[MAX_ANIM_FRAMES]
Definition r_material.h:126
animLoop_t type
Definition r_material.h:125
int dframe
Definition r_material.h:129
float fps
Definition r_material.h:127
unsigned int dest
Definition r_material.h:77
unsigned int src
Definition r_material.h:77
float intensity
Definition r_material.h:69
materialStage_t * stages
Definition r_material.h:164
float glowscale
Definition r_material.h:163
float parallax
Definition r_material.h:160
float hardness
Definition r_material.h:161
float specular
Definition r_material.h:162
unsigned flags
Definition r_material.h:157
scroll_t scroll
Definition r_material.h:140
struct image_s * image
Definition r_material.h:134
rotate_t rotate
Definition r_material.h:139
stretch_t stretch
Definition r_material.h:138
blendmode_t blend
Definition r_material.h:135
struct materialStage_s * next
Definition r_material.h:147
terrain_t terrain
Definition r_material.h:142
float dutycycle
Definition r_material.h:82
float dhz
Definition r_material.h:81
float hz
Definition r_material.h:81
float deg
Definition r_material.h:73
float hz
Definition r_material.h:73
float s
Definition r_material.h:96
float t
Definition r_material.h:96
float ds
Definition r_material.h:92
float dt
Definition r_material.h:92
float t
Definition r_material.h:91
float s
Definition r_material.h:91
float hz
Definition r_material.h:86
float amp
Definition r_material.h:87
float dhz
Definition r_material.h:86
float damp
Definition r_material.h:87
float height
Definition r_material.h:108
float center
Definition r_material.h:111
float floor
Definition r_material.h:106
float ceil
Definition r_material.h:107
float max
Definition r_material.h:110
float min
Definition r_material.h:109
float floor
Definition r_material.h:100
float ceil
Definition r_material.h:101
float height
Definition r_material.h:102
vec_t vec3_t[3]
Definition ufotypes.h:39