| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/gametexture.h $ |
| 21 | * $Revision: 47 $ |
| 22 | * $Date: 9/13/01 2:30p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Header for gametexture.cpp |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/gametexture.h $ |
| 28 | * |
| 29 | * 47 9/13/01 2:30p Matt |
| 30 | * Increased MAX_TEXTURES from 2800 to 3100. |
| 31 | * |
| 32 | * 46 3/21/00 1:17p Matt |
| 33 | * Increased MAX_TEXTURES to 2800 for PC and Mac, so add-on developers |
| 34 | * could add more of their own textures. |
| 35 | * |
| 36 | * 45 3/20/00 12:09p Matt |
| 37 | * Merge of Duane's post-1.3 changes. |
| 38 | * Lower MAX_TEXTURES for Mac (Mac only) |
| 39 | * |
| 40 | * 44 10/17/99 6:06p Chris |
| 41 | * We ran out of texture handles... |
| 42 | * |
| 43 | * 43 5/05/99 5:03a Gwar |
| 44 | * renamed ned_GameTextures array to GameTextures in new editor to make |
| 45 | * game code happy; 3D texture view still does not display textures |
| 46 | * |
| 47 | * 42 4/30/99 12:56p Kevin |
| 48 | * Lowered values for MAX_SOUNDS, MAX_ROOMS, MAX_TEXTURES and MAX_OBJIDS. |
| 49 | * Talk to me before changing any of these again. |
| 50 | * |
| 51 | * 41 4/20/99 9:26p Matt |
| 52 | * Added breakable flag for glass |
| 53 | * |
| 54 | * 40 4/09/99 7:04p Jason |
| 55 | * changed some texture defines |
| 56 | * |
| 57 | * 39 3/30/99 6:06p Jason |
| 58 | * added new procedural effect |
| 59 | * |
| 60 | * 38 3/10/99 7:12p Jason |
| 61 | * added smooth specular shading for curved surfaces |
| 62 | * |
| 63 | * 37 2/20/99 2:17p Matt |
| 64 | * Added texture sounds |
| 65 | * |
| 66 | * 36 1/29/99 6:29p Jason |
| 67 | * first pass at adding bumpmaps |
| 68 | * |
| 69 | * 35 1/26/99 4:04p Jason |
| 70 | * added some more texture flags |
| 71 | * |
| 72 | * 34 1/22/99 3:59p Jason |
| 73 | * added 256x256 textures to help with terrain skies |
| 74 | * |
| 75 | * 33 12/23/98 4:59p Jason |
| 76 | * some new texture features added |
| 77 | * |
| 78 | * 32 11/30/98 5:50p Jason |
| 79 | * added 4444 bitmap support |
| 80 | * |
| 81 | * 31 10/07/98 5:03p Jason |
| 82 | * more options for textures |
| 83 | * |
| 84 | * 30 10/01/98 2:47p Jason |
| 85 | * added timed procedurals |
| 86 | * |
| 87 | * 29 8/31/98 1:35p Keneta |
| 88 | * Made some use count unsigned shorts |
| 89 | * |
| 90 | * 28 8/13/98 11:57a Jason |
| 91 | * added water procedurals |
| 92 | * |
| 93 | * 27 7/14/98 6:50p Jason |
| 94 | * made procedurals save out to the table file |
| 95 | * |
| 96 | * 26 7/09/98 7:30p Jason |
| 97 | * more procedural stuff |
| 98 | * |
| 99 | * 25 7/07/98 4:12p Jason |
| 100 | * checkin for procedurals |
| 101 | * |
| 102 | * 24 7/06/98 12:55p Jason |
| 103 | * added first pass at procedurals |
| 104 | * |
| 105 | * 23 6/10/98 12:21p Matt |
| 106 | * Revamped system that controls what textures are displayed on the |
| 107 | * texture tab. Should work correctly now, and will now save the settings |
| 108 | * to the registry. Also, textures now default to no type set, not all |
| 109 | * types set. |
| 110 | * |
| 111 | * 22 6/02/98 6:03p Jason |
| 112 | * added specular lightmaps |
| 113 | * |
| 114 | * 21 5/20/98 5:44p Jason |
| 115 | * incremental checkin for bumpmapping |
| 116 | * |
| 117 | * 20 5/20/98 1:08p Jason |
| 118 | * more stuff for adding bumpmaps |
| 119 | * |
| 120 | * 19 5/19/98 3:19p Jason |
| 121 | * cleaned up some texture flags |
| 122 | * |
| 123 | * 18 5/03/98 10:24p Matt |
| 124 | * Renamed some unused constants |
| 125 | * |
| 126 | * 17 4/15/98 12:22p Jason |
| 127 | * lots of miscellaneous stuff pertaining to lighting and vis effects |
| 128 | * |
| 129 | * 16 4/06/98 4:41p Jason |
| 130 | * added texture alpha change |
| 131 | * |
| 132 | * 15 3/17/98 4:33p Jason |
| 133 | * Added size changing to bitmaps/textures |
| 134 | * |
| 135 | * 14 2/13/98 12:40p Jason |
| 136 | * added functions to touch all data in a level when the level is loaded |
| 137 | * |
| 138 | * 13 2/10/98 11:38a Matt |
| 139 | * Ripped out the obsolete merge stuff |
| 140 | * |
| 141 | * 12 2/03/98 3:15p Jason |
| 142 | * added the ability to specify saturation textures for models |
| 143 | * |
| 144 | * 11 1/13/98 3:09p Jason |
| 145 | * added glow effect for engines |
| 146 | * |
| 147 | * 10 1/06/98 2:58p Mark |
| 148 | * upped texture limit to 3000. |
| 149 | * |
| 150 | * 9 12/19/97 2:46p Jason |
| 151 | * implemented bitmap paging routines |
| 152 | * |
| 153 | * 8 11/21/97 2:02p Jason |
| 154 | * made light textures on model render that model face fully bright |
| 155 | * |
| 156 | * 7 10/15/97 5:20p Jason |
| 157 | * did a HUGE overhaul of the bitmap system |
| 158 | * |
| 159 | * 6 8/19/97 1:57a Jason |
| 160 | * made rgb lighting take floats |
| 161 | * |
| 162 | * 5 8/12/97 1:10a Jason |
| 163 | * added code to support radiosity lighting |
| 164 | * |
| 165 | * 4 8/08/97 12:59p Jason |
| 166 | * got texture sliding and pingponging working |
| 167 | * |
| 168 | * 3 8/05/97 4:27p Chris |
| 169 | * Added two flags for fly thru and fly by |
| 170 | * |
| 171 | * 2 8/04/97 3:28p Jason |
| 172 | * added alpha blending per texture |
| 173 | * |
| 174 | * 11 6/24/97 12:45p Jason |
| 175 | * checked in for safety |
| 176 | * |
| 177 | * 9 6/06/97 3:57p Jason |
| 178 | * implemented changes for small textures and automatic tmap2 recognition |
| 179 | * |
| 180 | * 8 5/30/97 5:46p Jason |
| 181 | * added colored light functionality on a vertex level |
| 182 | * |
| 183 | * 7 5/23/97 7:07p Matt |
| 184 | * Added code, data, & dialogs to keep track of what a texture is used for |
| 185 | * (mine, terrain, object) so we can display in the texture dialog only |
| 186 | * the ones we're interested in. |
| 187 | * |
| 188 | * $NoKeywords: $ |
| 189 | */ |
| 190 | |
| 191 | #ifndef GAMETEXTURE_H |
| 192 | #define GAMETEXTURE_H |
| 193 | |
| 194 | #ifdef NEWEDITOR /* only include tablefile header (manage stuff for NEWEDITOR) */ |
| 195 | #include "..\neweditor\ned_TableFile.h" |
| 196 | #include "..\neweditor\ned_GameTexture.h" |
| 197 | #else |
| 198 | |
| 199 | #include "manage.h" |
| 200 | |
| 201 | #define TF_VOLATILE 1 |
| 202 | #define TF_WATER (1 << 1) |
| 203 | #define TF_METAL (1 << 2) // Shines like metal |
| 204 | #define TF_MARBLE (1 << 3) // Shines like marble |
| 205 | #define TF_PLASTIC (1 << 4) // Shines like plastic |
| 206 | #define TF_FORCEFIELD (1 << 5) |
| 207 | #define TF_ANIMATED (1 << 6) |
| 208 | #define TF_DESTROYABLE (1 << 7) |
| 209 | #define TF_EFFECT (1 << 8) |
| 210 | #define TF_HUD_COCKPIT (1 << 9) |
| 211 | #define TF_MINE (1 << 10) |
| 212 | #define TF_TERRAIN (1 << 11) |
| 213 | #define TF_OBJECT (1 << 12) |
| 214 | #define TF_TEXTURE_64 (1 << 13) |
| 215 | #define TF_TMAP2 (1 << 14) |
| 216 | #define TF_TEXTURE_32 (1 << 15) |
| 217 | #define TF_FLY_THRU (1 << 16) |
| 218 | #define TF_PASS_THRU (1 << 17) |
| 219 | #define TF_PING_PONG (1 << 18) |
| 220 | #define TF_LIGHT (1 << 19) |
| 221 | #define TF_BREAKABLE (1 << 20) // Breakable (as in glass) |
| 222 | #define TF_SATURATE (1 << 21) |
| 223 | #define TF_ALPHA (1 << 22) |
| 224 | #define TF_DONTUSE (1 << 23) |
| 225 | #define TF_PROCEDURAL (1 << 24) |
| 226 | #define TF_WATER_PROCEDURAL (1 << 25) |
| 227 | #define TF_FORCE_LIGHTMAP (1 << 26) |
| 228 | #define TF_SATURATE_LIGHTMAP (1 << 27) |
| 229 | #define TF_TEXTURE_256 (1 << 28) |
| 230 | #define TF_LAVA (1 << 29) |
| 231 | #define TF_RUBBLE (1 << 30) |
| 232 | #define TF_SMOOTH_SPECULAR (1 << 31) |
| 233 | |
| 234 | #define TF_TEXTURE_TYPES (TF_MINE + TF_TERRAIN + TF_OBJECT + TF_EFFECT + TF_HUD_COCKPIT + TF_LIGHT) |
| 235 | |
| 236 | #define TF_SPECULAR (TF_METAL + TF_MARBLE | TF_PLASTIC) |
| 237 | |
| 238 | #define NOT_TEXTURE 0 |
| 239 | #define NORMAL_TEXTURE 1 // a normal size texture |
| 240 | #define SMALL_TEXTURE 2 // 1/4 of a normal texture |
| 241 | #define TINY_TEXTURE 3 // 1/8 of a normal texture |
| 242 | #define HUGE_TEXTURE 4 // Double the size of a normal texture |
| 243 | |
| 244 | #define MAX_TEXTURES 3100 |
| 245 | |
| 246 | #define PROC_MEMORY_TYPE_NONE 0 |
| 247 | #define PROC_MEMORY_TYPE_FIRE 1 |
| 248 | #define PROC_MEMORY_TYPE_WATER 2 |
| 249 | |
| 250 | struct static_proc_element { |
| 251 | uint8_t type; |
| 252 | |
| 253 | uint8_t frequency; |
| 254 | uint8_t speed; |
| 255 | uint8_t color; |
| 256 | uint8_t size; |
| 257 | |
| 258 | uint8_t x1, y1, x2, y2; |
| 259 | |
| 260 | }; |
| 261 | |
| 262 | struct proc_struct { |
| 263 | int16_t dynamic_proc_elements; // list of dynamic procedural texture elements |
| 264 | void *proc1; // pointer for procedural page |
| 265 | void *proc2; // back page of procedural |
| 266 | int16_t procedural_bitmap; // handle to the bitmap holding the finished procedural |
| 267 | |
| 268 | uint16_t *palette; |
| 269 | static_proc_element *static_proc_elements; |
| 270 | uint16_t num_static_elements; |
| 271 | |
| 272 | uint8_t memory_type; |
| 273 | |
| 274 | uint8_t heat; |
| 275 | uint8_t thickness; |
| 276 | uint8_t light; |
| 277 | |
| 278 | float last_evaluation_time; |
| 279 | float evaluation_time; |
| 280 | float osc_time; |
| 281 | uint8_t osc_value; |
| 282 | |
| 283 | int last_procedural_frame; // last frame a procedural was calculated for this texture |
| 284 | }; |
| 285 | |
| 286 | struct texture { |
| 287 | char name[PAGENAME_LEN]; // this textures name |
| 288 | int flags; // values defined above |
| 289 | int bm_handle; // handle which shows what this texture looks like |
| 290 | int destroy_handle; // handle which denotes the destroyed image |
| 291 | |
| 292 | int damage; |
| 293 | float reflectivity; |
| 294 | float r, g, b; // colored lighting (0 to 100%) |
| 295 | |
| 296 | float slide_u, slide_v; // How many times this texture slides during a second |
| 297 | float alpha; // alpha value (from 0 to 1) |
| 298 | float speed; // how fast this texture animates |
| 299 | |
| 300 | proc_struct *procedural; |
| 301 | |
| 302 | int sound; // The sound this texture makes |
| 303 | float sound_volume; // The volume for this texture's sound |
| 304 | |
| 305 | int16_t bumpmap; // The bumpmap for this texture, or -1 if there is none |
| 306 | uint8_t corona_type; // what type of corona this thing uses |
| 307 | uint8_t used; // is this texture free to be allocated? |
| 308 | |
| 309 | }; |
| 310 | |
| 311 | extern texture GameTextures[MAX_TEXTURES]; |
| 312 | extern int Num_textures; |
| 313 | |
| 314 | // Inits the texture system, returning 1 if successful |
| 315 | int InitTextures(); |
| 316 | void ShutdownTextures(); |
| 317 | |
| 318 | // Set aside a texture for use |
| 319 | int AllocTexture(void); |
| 320 | |
| 321 | // Frees a texture for future use |
| 322 | void FreeTexture(int); |
| 323 | |
| 324 | // Given current index, gets index of next texture in use |
| 325 | int GetNextTexture(int n); |
| 326 | |
| 327 | // Given current index, gets index of prev texture in use |
| 328 | int GetPreviousTexture(int n); |
| 329 | |
| 330 | // Searches thru all textures for a specific name, returns -1 if not found |
| 331 | // or index of texture with name |
| 332 | int FindTextureName(const char *name); |
| 333 | |
| 334 | // Searches thru all textures for a bitmap of a specific name, returns -1 if not found |
| 335 | // or index of texture with name |
| 336 | int FindTextureBitmapName(const char *name); |
| 337 | |
| 338 | // Given a texture handle, returns that textures bitmap |
| 339 | // If the texture is animated, returns framenum mod num_of_frames in the animation |
| 340 | int GetTextureBitmap(int handle, int framenum, bool force = false); |
| 341 | |
| 342 | // Given a filename, loads either the bitmap or vclip found in that file. If type |
| 343 | // is not NULL, sets it to 1 if file is animation, otherwise sets it to zero |
| 344 | int LoadTextureImage(const char *filename, int *type, int texture_size, int mipped, int pageable = 0, int format = 0); |
| 345 | |
| 346 | // Goes through and marks a texture as a tmap2 if its bitmap(s) have transparency |
| 347 | bool CheckIfTextureIsTmap2(int texnum); |
| 348 | |
| 349 | // Touches a texture, makes sure its in memory |
| 350 | void TouchTexture(int n); |
| 351 | |
| 352 | // Builds the bumpmaps for the texture |
| 353 | void BuildTextureBumpmaps(int texhandle); |
| 354 | |
| 355 | // Allocates the memory needed for static elements for a procedural texture |
| 356 | void AllocateStaticProceduralsForTexture(int handle, int num_elements); |
| 357 | |
| 358 | // Frees the memory used by static procedural elements |
| 359 | void FreeStaticProceduralsForTexture(int handle); |
| 360 | |
| 361 | // Frees all the procedural memory for a texture |
| 362 | void FreeProceduralForTexture(int n); |
| 363 | |
| 364 | // Allocates memory for a procedural that is attached to a texture |
| 365 | int AllocateProceduralForTexture(int handle); |
| 366 | |
| 367 | #endif |
| 368 | |
| 369 | #endif |