UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_material.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, 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 
68 typedef struct dirt_s {
69  float intensity;
70 } dirt_t;
71 
72 typedef struct rotate_s {
73  float hz, deg;
74 } rotate_t;
75 
76 typedef struct blendmode_s {
77  unsigned int src, dest;
78 } blendmode_t;
79 
80 typedef struct pulse_s {
81  float hz, dhz;
82  float dutycycle;
83 } pulse_t;
84 
85 typedef struct stretch_s {
86  float hz, dhz;
87  float amp, damp;
88 } stretch_t;
89 
90 typedef struct scroll_s {
91  float s, t;
92  float ds, dt;
93 } scroll_t;
94 
95 typedef struct scale_s {
96  float s, t;
97 } scale_t;
98 
99 typedef struct terrain_s {
100  float floor;
101  float ceil;
102  float height;
103 } terrain_t;
104 
105 typedef 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 
114 typedef enum {
121 } animLoop_t;
122 
123 typedef struct anim_s {
127  float fps;
128  float dtime;
129  int dframe;
130 } anim_t;
131 
132 typedef struct materialStage_s {
133  unsigned flags;
134  struct image_s* image;
146  float glowscale;
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 
156 typedef struct material_s {
157  unsigned flags;
158  float time;
159  float bump;
160  float parallax;
161  float hardness;
162  float specular;
163  float glowscale;
166 } material_t;
167 
169 
170 void R_LoadMaterials(const char* map);
171 void R_UpdateDefaultMaterial(const char* cvarName, const char* oldValue, const char* newValue, void* data);
float min
Definition: r_material.h:109
float s
Definition: r_material.h:91
float t
Definition: r_material.h:96
struct dirt_s dirt_t
unsigned flags
Definition: r_material.h:133
float hz
Definition: r_material.h:86
struct rotate_s rotate_t
struct tape_s tape_t
animLoop_t
Definition: r_material.h:114
struct anim_s anim_t
float max
Definition: r_material.h:110
stretch_t stretch
Definition: r_material.h:138
float floor
Definition: r_material.h:106
unsigned int src
Definition: r_material.h:77
void R_LoadMaterials(const char *map)
Load material definitions for each map that has one.
Definition: r_material.cpp:920
float bump
Definition: r_material.h:159
float t
Definition: r_material.h:91
float intensity
Definition: r_material.h:69
float floor
Definition: r_material.h:100
animLoop_t type
Definition: r_material.h:125
float ceil
Definition: r_material.h:101
int dframe
Definition: r_material.h:129
float center
Definition: r_material.h:111
float deg
Definition: r_material.h:73
struct scale_s scale_t
unsigned int dest
Definition: r_material.h:77
float amp
Definition: r_material.h:87
float dhz
Definition: r_material.h:81
struct blendmode_s blendmode_t
struct material_s material_t
materialStage_t * stages
Definition: r_material.h:164
float dt
Definition: r_material.h:92
float hz
Definition: r_material.h:81
scroll_t scroll
Definition: r_material.h:140
struct image_s * images[MAX_ANIM_FRAMES]
Definition: r_material.h:126
blendmode_t blend
Definition: r_material.h:135
float dutycycle
Definition: r_material.h:82
float height
Definition: r_material.h:102
#define MAX_ANIM_FRAMES
Definition: r_material.h:64
unsigned flags
Definition: r_material.h:157
float ds
Definition: r_material.h:92
float specular
Definition: r_material.h:162
struct materialStage_s materialStage_t
struct pulse_s pulse_t
struct scroll_s scroll_t
struct terrain_s terrain_t
float fps
Definition: r_material.h:127
float dtime
Definition: r_material.h:128
float parallax
Definition: r_material.h:160
void R_UpdateDefaultMaterial(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Change listener callback for material value cvars.
int num_stages
Definition: r_material.h:165
float damp
Definition: r_material.h:87
float s
Definition: r_material.h:96
terrain_t terrain
Definition: r_material.h:142
vec_t vec3_t[3]
Definition: ufotypes.h:39
material_t defaultMaterial
Definition: r_material.cpp:34
float dhz
Definition: r_material.h:86
float hz
Definition: r_material.h:73
GLsizei const GLvoid * data
Definition: r_gl.h:152
rotate_t rotate
Definition: r_material.h:139
float height
Definition: r_material.h:108
float glowscale
Definition: r_material.h:163
float time
Definition: r_material.h:158
struct stretch_s stretch_t
struct image_s * image
Definition: r_material.h:134
int num_frames
Definition: r_material.h:124
float ceil
Definition: r_material.h:107
float hardness
Definition: r_material.h:161
struct materialStage_s * next
Definition: r_material.h:147