Debian Codegraph @

editor/hemicube.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 HEMICUBE_H
20 #define HEMICUBE_H
21
22 #include "3d.h"
23 #include "radiosity.h"
24 #include "gr.h"
25
26 struct rad_hemicube {
27 matrix view_matrix;
28 matrix head_matrix;
29 vector view_position;
30 rad_element *shooting_element;
31 rad_surface *shooting_surface;
32
33 grHardwareSurface drawing_surface;
34 grViewport *vport;
35 int *id_grid;
36 float *depth_grid;
37
38 float *top_array;
39 float *side_array;
40
41 int ff_res; // Form factor resolution
42 int grid_dim; // Hemicube top/side array dimension
43 };
44
45 struct hemicube_point {
46 float sx, sy;
47 float z;
48 };
49
50 extern rad_hemicube rad_Hemicube;
51 extern int Hemicube_resolution;
52
53 // Calculates the form factors for a hemicube
54 void CalculateFormFactorsHemiCube();
55
56 // Initializes the hemicube
57 void InitHemicube(int resolution);
58
59 void CloseHemicube();
60
61 // Clears the Zbuffer hemicube grid
62 void ClearHemicubeGrid();
63
64 // Sets the elements we're shooting from
65 void SetElementView(rad_element *ep);
66
67 // Sets the surface we're shooting from
68 void SetSurfaceView(rad_surface *ep);
69
70 // Build transformation matrix for our hemicube
71 void BuildTransform(vector *nu, vector *nv, vector *nn);
72
73 // Gets our view system ready for drawing
74 void StartHemicubeDrawing();
75
76 // Releases the view system
77 void EndHemicubeDrawing(int);
78
79 // Update hemicube view transformation matrix
80 void UpdateView(int face_id);
81
82 // Actually draws the projected polygon onto a hemicube face
83 void ScanRadiosityPoly(g3Point **pl, int nv, int element_id);
84 void DrawRadiosityPoly(int nv, g3Point **pointlist, int id);
85 void GetVertexOrdering(hemicube_point *t, int nv, int *vlt, int *vlb, int *vrt, int *vrb, int *bottom_y_ind);
86 int PrevIndex(int val, int modulus);
87 int NextIndex(int val, int modulus);
88
89 // Sums the delta form factors
90 void SumDeltas(float *ff_array, int face_id);
91
92 float GetTopFactor(int row, int col);
93
94 // Get side face cell form factor
95 float GetSideFactor(int row, int col);
96
97 #endif