r_material.h

Go to the documentation of this file.
00001 
00006 /*
00007 All original material Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 Copyright (C) 1997-2001 Id Software, Inc.
00010 
00011 This program is free software; you can redistribute it and/or
00012 modify it under the terms of the GNU General Public License
00013 as published by the Free Software Foundation; either version 2
00014 of the License, or (at your option) any later version.
00015 
00016 This program is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00019 
00020 See the GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025 
00026 */
00027 
00028 #ifndef R_MATERIAL_H
00029 #define R_MATERIAL_H
00030 
00031 /* flags will persist on the stage structures but may also bubble
00032  * up to the material flags to determine render eligibility */
00033 #define STAGE_TEXTURE           (1 << 0)
00034 #define STAGE_ENVMAP            (1 << 1)
00035 #define STAGE_BLEND             (1 << 2)
00036 #define STAGE_COLOR             (1 << 3)
00037 #define STAGE_PULSE             (1 << 4)
00038 #define STAGE_STRETCH           (1 << 5)
00039 #define STAGE_ROTATE            (1 << 6)
00040 #define STAGE_SCROLL_S          (1 << 7)
00041 #define STAGE_SCROLL_T          (1 << 8)
00042 #define STAGE_SCALE_S           (1 << 9)
00043 #define STAGE_SCALE_T           (1 << 10)
00044 #define STAGE_TERRAIN           (1 << 11)
00045 #define STAGE_TAPE  (1 << 12)
00046 #define STAGE_LIGHTMAP          (1 << 13)
00047 #define STAGE_ANIM              (1 << 14)
00048 #define STAGE_DIRTMAP           (1 << 15)
00049 #define STAGE_FLARE             (1 << 16)
00050 #define STAGE_GLOWMAPLINK       (1 << 17)
00051 
00052 /* set on stages eligible for static, dynamic, and per-pixel lighting */
00053 #define STAGE_LIGHTING      (1 << 30)
00054 
00055 /* set on stages with valid render passes */
00056 #define STAGE_RENDER        (1 << 31)
00057 
00058 /* composite mask for simplifying state management */
00059 #define STAGE_TEXTURE_MATRIX ( \
00060     STAGE_STRETCH | STAGE_ROTATE | STAGE_SCROLL_S | STAGE_SCROLL_T | \
00061     STAGE_SCALE_S | STAGE_SCALE_T \
00062 )
00063 
00064 /* frame based animation, lerp between consecutive images */
00065 #define MAX_ANIM_FRAMES 16
00066 
00067 #define UPDATE_THRESHOLD 0.02
00068 
00069 typedef struct dirt_s {
00070     float intensity;        
00071 } dirt_t;
00072 
00073 typedef struct rotate_s {
00074     float hz, deg;
00075 } rotate_t;
00076 
00077 typedef struct blendmode_s {
00078     unsigned int src, dest; 
00079 } blendmode_t;
00080 
00081 typedef struct pulse_s {
00082     float hz, dhz;
00083 } pulse_t;
00084 
00085 typedef struct stretch_s {
00086     float hz, dhz;
00087     float amp, damp;
00088 } stretch_t;
00089 
00090 typedef struct scroll_s {
00091     float s, t;
00092     float ds, dt;
00093 } scroll_t;
00094 
00095 typedef struct scale_s {
00096     float s, t;
00097 } scale_t;
00098 
00099 typedef struct terrain_s {
00100     float floor;    
00101     float ceil;     
00102     float height;   
00103 } terrain_t;
00104 
00105 typedef struct tape_s {
00106     float floor;    
00107     float ceil;     
00108     float height;   
00109     float min;      
00110     float max;      
00111     float center;   
00112 } tape_t;
00113 
00114 typedef enum {
00115     ANIM_NORMAL,    
00116     ANIM_ALTERNATE, 
00117     ANIM_BACKWARDS, 
00118     ANIM_RANDOM,        
00119     ANIM_RANDOMFORCE,   
00121 } animLoop_t;
00122 
00123 typedef struct anim_s {
00124     int num_frames;
00125     animLoop_t type;
00126     struct image_s *images[MAX_ANIM_FRAMES];
00127     float fps;
00128     float dtime;
00129     int dframe;
00130 } anim_t;
00131 
00132 typedef struct materialStage_s {
00133     unsigned flags;
00134     struct image_s *image;
00135     blendmode_t blend;
00136     vec3_t color;
00137     pulse_t pulse;
00138     stretch_t stretch;
00139     rotate_t rotate;
00140     scroll_t scroll;
00141     scale_t scale;
00142     terrain_t terrain;
00143     tape_t tape;
00144     dirt_t dirt;
00145     anim_t anim;
00146     float glowscale;
00147     struct materialStage_s *next;
00148 } materialStage_t;
00149 
00150 #define DEFAULT_BUMP 1.0
00151 #define DEFAULT_PARALLAX 1.0
00152 #define DEFAULT_SPECULAR 1.0
00153 #define DEFAULT_HARDNESS 1.0
00154 #define DEFAULT_GLOWSCALE 1.0
00155 
00156 typedef struct material_s {
00157     unsigned flags;
00158     float time;
00159     float bump;
00160     float parallax;
00161     float hardness;
00162     float specular;
00163     float glowscale;
00164     materialStage_t *stages;
00165     int num_stages;
00166 } material_t;
00167 
00168 void R_LoadMaterials(const char *map);
00169 
00170 #endif

Generated by  doxygen 1.6.2