Debian Codegraph @

editor/editor_lighting.h

raw symbols SCIP
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
19 #ifndef EDITOR_LIGHTING_H
20 #define EDITOR_LIGHTING_H
21
22 #include "3d.h"
23 #include "radiosity.h"
24 #include "room.h"
25 #include "object.h"
26 #include "lightmap_info.h"
27
28 extern vector ScratchCenters[MAX_LIGHTMAP_INFOS];
29 extern vector ScratchRVecs[MAX_LIGHTMAP_INFOS];
30 extern vector ScratchUVecs[MAX_LIGHTMAP_INFOS];
31 extern int AllowCombining;
32
33 extern float Room_multiplier[];
34 extern float Room_ambience_r[], Room_ambience_g[], Room_ambience_b[];
35
36 void DoRadiosityForRooms();
37 void DoRadiosityForTerrain();
38
39 void BuildElementListForRoomFace(int roomnum, int facenum, rad_surface *surf);
40 void BuildElementListForObjectFace(int objnum, int subobj_num, int facenum, rad_surface *surf);
41
42 // Allocates and sets a lightmap based on the surface patches given
43 void AssignRoomSurfaceToLightmap(int roomnum, int facenum, rad_surface *sp);
44
45 // Allocates and sets a lightmap based on the surface patches given
46 void AssignObjectSurfaceToLightmap(int objnum, int sobj_num, int facenum, rad_surface *sp);
47
48 // Goes through all objects int a room and fills in the lightmap data for them
49 void AssignLightmapsToObjectSurfacesForSingleRoom(int surface_index, int roomnum);
50
51 int ClipRadPointList(rad_point **src, rad_point **dest, int *nv, int code);
52
53 // Clips to a specific plane, putting resulting points in dest and returning number of points in dest
54 int ClipRadToPlane(int plane, rad_point *src, rad_point *dest, int nv);
55
56 // Takes two points and a plane, and clips.
57 void ClipRadEdge(int plane_flag, rad_point *on_pnt, rad_point *off_pnt);
58
59 void SetRadClipLines(vector *tp, vector *rp, vector *bp, vector *lp);
60
61 void ClipSurfaceElement(vector *surf_verts, rad_element *ep, vector *clip_verts, int nv);
62
63 void BuildLightmapUVs(int *room_list, int *face_list, int count, vector *lightmap_poly, int nv, int external);
64
65 // Returns number of verts in dest if face a can be safely combined with face b
66 // Returns 0 if not
67 int CombineLightFaces(vector *dest_verts, vector *averts, int nva, vector *norma, vector *bverts, int nvb,
68 vector *normb, int aroom = -1, int broom = -1);
69
70 // Given a roomnumber and a face, goes through the entire mine and checks to see
71 // if this face can share a lightmap with any other face
72 int TestLightAdjacency(int roomnum, int facenum, int external);
73
74 // Sets up radiosity surfaces for objects in a room
75 // Returns the number of new surfaces
76 int ComputeSurfacesForObjectsForSingleRoom(int surface_index, int roomnum);
77
78 // Computes the the mines UVs
79 // Faces can now share one lightmap, so this routine goes through and tries to
80 // combine as many faces as it can into one lightmap
81 void ComputeAllRoomLightmapUVs(int external);
82
83 // Computes lightmap uv sharing for a single room
84 void ComputeRoomLightmapUVs(room *rp);
85
86 // Sets up radiosity surfaces for objects in the mine
87 // Returns the number of new surfaces
88 int ComputeSurfacesForObjects(int surface_index, int terrain);
89
90 // Gets the total number of object faces that exist
91 int GetTotalObjectFaces(int terrain);
92
93 // Gets the total number of object faces that exist in a room
94 int GetTotalObjectFacesForSingleRoom(int roomnum);
95
96 void BuildObjectLightmapUVs(object *obj, int *sublist, int *facelist, int count, vector *lightmap_poly, int nv,
97 int lm_type);
98
99 // Goes through all objects and fills in the lightmap data for them
100 void AssignLightmapsToObjectSurfaces(int surface_index, int terrain);
101
102 void CombineObjectLightmapUVs(object *obj, int lmi_type);
103
104 // Frees memory for specular lighting
105 void CleanupSpecularLighting(int external);
106
107 // Sets up memory usage for specular lighting
108 void SetupSpecularLighting(int external);
109
110 // Calculates radiosity and sets lightmaps for indoor faces only
111 void DoRadiosityForCurrentRoom(room *rp);
112
113 extern rad_surface *Light_surfaces;
114 extern rad_surface *Terrain_light_surfaces;
115
116 extern uint8_t *TerrainLightSpeedup[];
117
118 extern int Square_surfaces;
119 extern int LightSpacing;
120 extern int BestFit;
121 extern float Ambient_red, Ambient_green, Ambient_blue;
122
123 #endif