| 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 | * Lighting functions and variables |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #ifndef _LIGHTING_H |
| 25 | #define _LIGHTING_Hcxx . . $ `Descent3/lighting.h:25:9`! |
| 26 | |
| 27 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 28 | #include "room.h"cxx . . $ `<file>/Descent3/room.h`/ |
| 29 | #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/ |
| 30 | |
| 31 | #define MAX_LIGHTcxx . . $ `Descent3/lighting.h:31:9`! 1.0 |
| 32 | #define LIGHTMAP_SPACINGcxx . . $ `Descent3/lighting.h:32:9`! 5.0 |
| 33 | |
| 34 | #define VOLUME_SPACINGcxx . . $ `Descent3/lighting.h:34:9`! 10.0 |
| 35 | |
| 36 | #define INVISIBLE_VOLUME_ELEMENTcxx . . $ `Descent3/lighting.h:36:9`! 0x01 |
| 37 | |
| 38 | #define MAX_SPECULAR_INCREMENTScxx . . $ `Descent3/lighting.h:38:9`! 4096 |
| 39 | |
| 40 | extern float Specular_tablescxx . . $ Specular_tables.[3][MAX_SPECULAR_INCREMENTScxx . . $ `Descent3/lighting.h:38:9`!]; |
| 41 | |
| 42 | struct dynamic_lightmapcxx . . $ dynamic_lightmap# { |
| 43 | uint16_tcxx . . $ uint16_t# *mem_ptrcxx . . $ dynamic_lightmap#mem_ptr.; |
| 44 | uint8_tcxx . . $ uint8_t# usedcxx . . $ dynamic_lightmap#used.; |
| 45 | }; |
| 46 | |
| 47 | struct dynamic_facecxx . . $ dynamic_face# { |
| 48 | uint16_tcxx . . $ uint16_t# lmi_handlecxx . . $ dynamic_face#lmi_handle.; |
| 49 | }; |
| 50 | |
| 51 | struct dynamic_cellcxx . . $ dynamic_cell# { |
| 52 | uint16_tcxx . . $ uint16_t# cellnumcxx . . $ dynamic_cell#cellnum.; |
| 53 | uint8_tcxx . . $ uint8_t# rcxx . . $ dynamic_cell#r., gcxx . . $ dynamic_cell#g., bcxx . . $ dynamic_cell#b.; |
| 54 | }; |
| 55 | |
| 56 | // Sets up our dynamic lighting maps |
| 57 | void InitDynamicLightingcxx . . $ InitDynamicLighting(49f6e7a06ebc5aa8).(); |
| 58 | |
| 59 | // Returns the class index of a specified lightmap resolution |
| 60 | int GetLightmapClasscxx . . $ GetLightmapClass(7864480464b09eea).(int res); |
| 61 | |
| 62 | // Returns an index into the Dynamic_lightmaps array. Index returned is marked as unused |
| 63 | int FindFreeDynamicLightmapcxx . . $ FindFreeDynamicLightmap(7864480464b09eea).(int cl); |
| 64 | |
| 65 | // Applies dynamic lighting to the room faces based on the light coming from |
| 66 | // an object |
| 67 | void ApplyLightingToRoomscxx . . $ ApplyLightingToRooms(31a30e6d6b9dd744).(vectorcxx . . $ vector# *, int, float, float, float, float, vectorcxx . . $ vector# *light_direction = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, |
| 68 | float dot_range = 0); |
| 69 | |
| 70 | // Clears the used flag for the dynamic lightmaps |
| 71 | void ClearDynamicLightmapscxx . . $ ClearDynamicLightmaps(49f6e7a06ebc5aa8).(); |
| 72 | |
| 73 | // Changes the terrain shading to approximate lighting |
| 74 | void ApplyLightingToTerraincxx . . $ ApplyLightingToTerrain(31a30e6d6b9dd744).(vectorcxx . . $ vector# *pos, int cellnum, float light_dist, float red_scale, float green_scale, |
| 75 | float blue_scale, vectorcxx . . $ vector# *light_direction = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, float dot_range = 0); |
| 76 | |
| 77 | // Gets the viewable lightmap elements |
| 78 | void FindValidLightmapElementscxx . . $ FindValidLightmapElements(96f84c2960e5a6f5).(facecxx . . $ face# *fp, dynamic_facecxx . . $ dynamic_face# *dynamic_fp, vectorcxx . . $ vector# *light_pos, float light_dist); |
| 79 | // Does a quad tree algo to find what lightmap elements are viewable from our lightsource |
| 80 | int SearchLightQuadTreecxx . . $ SearchLightQuadTree(3a6e059ad9981b38).(facecxx . . $ face# *fp, vectorcxx . . $ vector# *rvec, vectorcxx . . $ vector# *uvec, dynamic_facecxx . . $ dynamic_face# *dynamic_fp, vectorcxx . . $ vector# *light_pos, |
| 81 | float light_dist); |
| 82 | |
| 83 | // Given a float, returns the index into the Ubyte_float_table that this number |
| 84 | // corresponds to |
| 85 | uint8_tcxx . . $ uint8_t# Float_to_ubytecxx . . $ Float_to_ubyte(ed6d3b1f37918c01).(float fnum); |
| 86 | |
| 87 | extern float Ubyte_to_floatcxx . . $ Ubyte_to_float.[]; |
| 88 | |
| 89 | // Draws the shadows that happen to be falling on a particular face |
| 90 | void DoShadowsForFacecxx . . $ DoShadowsForFace(5c94b6ab436d91cf).(roomcxx . . $ room# *rp, int facenum); |
| 91 | |
| 92 | // Sets the num_timer_faces field in Room structure to correspond to the number of faces |
| 93 | // that have flickering lights |
| 94 | void CountFaceLightscxx . . $ CountFaceLights(49f6e7a06ebc5aa8).(); |
| 95 | |
| 96 | // Goes through all rooms and all faces and lights any faces that have their timer values |
| 97 | // set |
| 98 | void DoFaceLightingcxx . . $ DoFaceLighting(49f6e7a06ebc5aa8).(); |
| 99 | |
| 100 | // Sets pulse parameters for an entire room |
| 101 | void SetRoomPulsecxx . . $ SetRoomPulse(f9b30ad62dfb5929).(roomcxx . . $ room# *rp, uint8_tcxx . . $ uint8_t# pulse_time, uint8_tcxx . . $ uint8_t# pulse_offset); |
| 102 | |
| 103 | // Returns the total number of bytes needed for volume lighting in this room |
| 104 | int GetVolumeSizeOfRoomcxx . . $ GetVolumeSizeOfRoom(bbc96c603c40b693).(roomcxx . . $ room# *rp, int *w = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, int *h = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, int *d = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!); |
| 105 | |
| 106 | // Returns a lightmap that can be applied for specular lighting |
| 107 | int GetSpecularLightmapForFacecxx . . $ GetSpecularLightmapForFace(d2bcc5c4687c2edc).(vectorcxx . . $ vector# *pos, roomcxx . . $ room# *rp, facecxx . . $ face# *fp); |
| 108 | |
| 109 | // Kills the lighting that a face casts and dampens all the faces that light influences |
| 110 | void DestroyLightcxx . . $ DestroyLight(3e454b8ccf442868).(int roomnum, int facenum); |
| 111 | |
| 112 | // Adds to our list of destroyable lights that got destroyed this frame |
| 113 | void AddToDestroyableLightListcxx . . $ AddToDestroyableLightList(3e454b8ccf442868).(int roomnum, int facenum); |
| 114 | |
| 115 | // Goes through our destroyable light list and actually kills all the lights |
| 116 | void DoDestroyedLightsForFramecxx . . $ DoDestroyedLightsForFrame(49f6e7a06ebc5aa8).(); |
| 117 | |
| 118 | // Blends all the edges that need blending for this frame |
| 119 | void BlendAllLightingEdgescxx . . $ BlendAllLightingEdges(49f6e7a06ebc5aa8).(); |
| 120 | |
| 121 | #endif |