Debian Codegraph @

editor/LightingDialog.cpp

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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/LightingDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:38 $
23 * $Author: kevinb $
24 *
25 * Lighting keypad dialog
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 67 9/13/99 12:24p Matt
30 * Changed the copy-light-multiple function to work either in the whole
31 * mine or the current room.
32 *
33 * 66 8/17/99 4:09p Matt
34 * Added some accelerator keys, and a function to copy face light
35 * multiples.
36 *
37 * 65 5/05/99 12:58a Matt
38 * Added button to clear the lightmaps on a level.
39 *
40 * 64 4/18/99 5:42a Chris
41 * Added the FQ_IGNORE_RENDER_THROUGH_PORTALS flag
42 *
43 * 63 4/03/99 7:55p Matt
44 * Use new keypad update system instead of timer to update.
45 *
46 * 62 3/24/99 5:53p Jason
47 * added per room ambience settings
48 *
49 * 61 3/23/99 5:13p Jason
50 * fixed counting of invisible terrain cells
51 *
52 * 60 2/18/99 12:32p Jason
53 * added room multiplier
54 *
55 * 59 2/05/99 4:54p Jason
56 * added extra option to reset multiples
57 *
58 * 58 1/21/99 12:22p Jason
59 * adding strobing and flickering
60 *
61 * 57 1/20/99 10:50a Jason
62 * added new terrain
63 *
64 * 56 1/15/99 3:15p Jason
65 * fixed global multilier bug
66 *
67 * 55 1/15/99 2:33p Jason
68 * added global multiplier
69 *
70 * 54 10/06/98 11:48a Jason
71 * fixed bug with last rev
72 *
73 * 53 10/06/98 11:45a Jason
74 * added extra feature for Sean
75 *
76 * 52 8/04/98 11:52a Jason
77 * fixed stupid bug
78 *
79 * 51 8/04/98 11:52a Jason
80 * added reverse corona check
81 *
82 * 50 7/24/98 4:44p Jason
83 * added corona button functionality
84 *
85 * 49 6/22/98 12:00p Chris
86 * Working on sound system to make it in a nice shape.
87 *
88 * 48 6/16/98 3:48p Chris
89 * Updated the sound system and added the start of sound streaming
90 *
91 * 47 6/05/98 5:22p Jason
92 * added volumetric fog
93 *
94 * 46 5/26/98 5:56p Jason
95 * only render coronas which are flagged
96 *
97 * 45 5/22/98 3:28p Jason
98 * added specular lighting
99 *
100 * 44 5/20/98 5:44p Jason
101 * incremental checkin for bumpmapping
102 *
103 * 43 4/29/98 2:19p Jason
104 * added yes/no question to confirm lighting
105 *
106 * 42 4/24/98 12:58p Jason
107 * added functions to resave all bitmaps
108 *
109 * 41 4/21/98 2:36p Jason
110 * added some lighting options
111 *
112 * 40 4/02/98 12:23p Jason
113 * trimmed some fat from our structures
114 *
115 * 39 3/24/98 10:40p Jason
116 * made closer lightmap spacing
117 *
118 * 38 3/16/98 9:55p Chris
119 * Working on optimizing fvi
120 *
121 * 37 2/26/98 10:48a Jason
122 * fixed floating point/int problem in inputting face light multiplier
123 *
124 * 36 2/23/98 7:35p Chris
125 * Made the rad. floating point
126 *
127 * 35 2/16/98 2:12p Jason
128 * fixed bug with lightmaps and door shells
129 *
130 * 34 2/13/98 12:57p Jason
131 * changes for adjusting light multiples
132 *
133 * 33 2/10/98 5:09p Jason
134 * added a SetRoomPulse function for settinng pulse parameters for an
135 * entire room
136 *
137 * 32 2/10/98 3:50p Jason
138 * added pulsing walls
139 *
140 * 31 2/04/98 8:25p Jason
141 * added light multiplier for faces
142 *
143 * 30 2/04/98 6:23p Matt
144 * Changed object room number to indicate a terrain cell via a flag. Got
145 * rid of the object flag which used to indicate terrain.
146 *
147 * 29 1/15/98 7:34p Matt
148 * Revamped error checking when computing face normals
149 *
150 * 28 1/02/98 5:32p Chris
151 * More radical changes to the sound system
152 *
153 * 27 12/31/97 12:51p Jason
154 * debugged and implementd BSP tree for lighting
155 *
156 * 26 12/18/97 12:24p Chris
157 * Turned off sound system while doing casting rays.
158 *
159 * 25 12/16/97 4:17p Jason
160 * added ignore_satellites and ignore terrain
161 *
162 * 24 12/10/97 12:23p Jason
163 * added "SuperDetail"
164 *
165 *
166 * 23 12/05/97 12:34p Jason
167 * added ambient light to the terrain
168 *
169 * 22 11/28/97 6:41p Jason
170 * added functions to blur lightmaps - not very helpful though
171 *
172 * 21 11/25/97 12:28p Jason
173 * another pass at shadows
174 *
175 * 20 11/19/97 12:39p Jason
176 * added dynamic terrain button
177 *
178 * 19 11/14/97 6:38p Jason
179 * added ability to do lighting on a single room
180 *
181 * 18 11/14/97 1:13p Jason
182 * added better light counting
183 *
184 * 17 10/28/97 3:41p Jason
185 * added "use hemicubes" option
186 *
187 * 16 10/10/97 2:34p Jason
188 * tweaked volumetrics
189 *
190 * 15 10/10/97 1:10p Jason
191 * more support for volumetrics
192 *
193 * 14 10/10/97 11:38a Jason
194 * put in better volumetric support
195 *
196 * 13 9/26/97 11:51a Jason
197 * tweaked terrain radiosity
198 *
199 * 12 9/25/97 4:47p Jason
200 * update alpha edit box via timer
201 *
202 * 11 9/23/97 5:53p Jason
203 * added more custom options to radiosity
204 *
205 * 10 9/09/97 12:22p Matt
206 * Renamed a flag
207 *
208 * 9 9/04/97 2:54p Jason
209 * fixed small radiosity bug that wasn't flagging invisible elements
210 *
211 * 8 9/04/97 12:12p Jason
212 * added lightmap visibility
213 *
214 * 7 9/02/97 12:54p Jason
215 * classify faces as alphaed or not
216 *
217 * 6 9/02/97 11:47a Jason
218 * Got alpha per vertex working
219 *
220 * 5 8/28/97 2:59p Jason
221 * added confirmation for terrain radiosity
222 *
223 * 4 8/27/97 5:19p Jason
224 * added "Count lights"
225 *
226 * 3 8/26/97 4:36p Jason
227 * added terrain radiosity
228 *
229 * 2 8/12/97 1:10a Jason
230 * added code to support radiosity lighting
231 *
232 * 8 6/03/97 4:55p Mark
233 *
234 * 8 6/03/97 4:53p Jeff
235 * Added Context Sensitive Help
236 *
237 * 7 5/30/97 5:45p Jason
238 * changes to support user-definable lighting parameters
239 *
240 * 6 5/23/97 10:48a Jason
241 * checked in for safekeeping...
242 *
243 * 5 2/20/97 2:37p Mark
244 *
245 * 4 1/27/97 11:38a Samir
246 * Added horizontal scrolling of keypad modeless dialog.
247 *
248 * $NoKeywords: $
249 */
250
251 #include "stdafx.h"
252 #include "editor.h"
253 #include "LightingDialog.h"
254 #include "editor_lighting.h"
255 #include "gametexture.h"
256 #include "radiosity.h"
257 #include "hemicube.h"
258 #include "findintersection.h"
259 #include "erooms.h"
260 #include "vecmat.h"
261 #include "polymodel.h"
262 #include "lightmap_info.h"
263 #include "hlsoundlib.h"
264 #include "lighting.h"
265 #include "bsp.h"
266 #include "ddio.h"
267 #include "vclip.h"
268
269 #ifdef _DEBUG
270 #define new DEBUG_NEW
271 #undef THIS_FILE
272 static char THIS_FILE[] = __FILE__;
273 #endif
274
275 /////////////////////////////////////////////////////////////////////////////
276 // CLightingDialog dialog
277
278 CLightingDialog::CLightingDialog(CWnd *pParent /*=NULL*/) : CKeypadDialog(CLightingDialog::IDD, pParent) {
279 //{{AFX_DATA_INIT(CLightingDialog)
280 // NOTE: the ClassWizard will add member initialization here
281 //}}AFX_DATA_INIT
282 }
283
284 void CLightingDialog::DoDataExchange(CDataExchange *pDX) {
285 CDialog::DoDataExchange(pDX);
286 //{{AFX_DATA_MAP(CLightingDialog)
287 // NOTE: the ClassWizard will add DDX and DDV calls here
288 //}}AFX_DATA_MAP
289 }
290
291 BEGIN_MESSAGE_MAP(CLightingDialog, CDialog)
292 //{{AFX_MSG_MAP(CLightingDialog)
293 ON_WM_SIZE()
294 ON_WM_VSCROLL()
295 ON_WM_HSCROLL()
296 ON_BN_CLICKED(IDC_LITEPAD_SETDEFAULT, OnLitepadSetdefault)
297 ON_BN_CLICKED(IDC_LITEPAD_SMOOTHALL, OnLitepadSmoothall)
298 ON_EN_KILLFOCUS(IDC_LIGHT_ITERATION_EDIT, OnKillfocusLightIterationEdit)
299 ON_WM_HELPINFO()
300 ON_BN_CLICKED(IDC_LITEPAD_TERRAIN_RADIOSITY, OnLitepadTerrainRadiosity)
301 ON_BN_CLICKED(IDC_LITEPAD_COUNT_LIGHTS, OnLitepadCountLights)
302 ON_BN_CLICKED(IDC_LITEPAD_NEXTVERTEX, OnLitepadNextvertex)
303 ON_WM_PAINT()
304 ON_EN_KILLFOCUS(IDC_ALPHA_EDIT, OnKillfocusAlphaEdit)
305 ON_BN_CLICKED(IDC_SHOW_LIGHTMAPS, OnShowLightmaps)
306 ON_EN_KILLFOCUS(IDC_HEMICUBE_RES_EDIT, OnKillfocusHemicubeResEdit)
307 ON_EN_KILLFOCUS(IDC_LIGHT_SPACING_EDIT, OnKillfocusLightSpacingEdit)
308 ON_BN_CLICKED(IDC_BESTFIT_CHECK, OnBestfitCheck)
309 ON_BN_CLICKED(IDC_CREATE_VOLUME_CONE, OnCreateVolumeCone)
310 ON_BN_CLICKED(IDC_CLEAR_VOLUMETRIC_ROOM, OnClearVolumetricRoom)
311 ON_BN_CLICKED(IDC_FILL_VOLUME_TEXTURE, OnFillVolumeTexture)
312 ON_EN_KILLFOCUS(IDC_ANGLE_EDIT, OnKillfocusAngleEdit)
313 ON_EN_KILLFOCUS(IDC_START_ALPHA_EDIT, OnKillfocusStartAlphaEdit)
314 ON_EN_KILLFOCUS(IDC_RESOLUTION_EDIT, OnKillfocusResolutionEdit)
315 ON_BN_CLICKED(IDC_EDGE_VOLUMETRIC, OnEdgeVolumetric)
316 ON_EN_KILLFOCUS(IDC_FALLOFF_EDIT, OnKillfocusFalloffEdit)
317 ON_BN_CLICKED(IDC_FARTHEST_POINT, OnFarthestPoint)
318 ON_EN_KILLFOCUS(IDC_PITCH_ANGLE_EDIT, OnKillfocusPitchAngleEdit)
319 ON_EN_KILLFOCUS(IDC_HEADING_ANGLE_EDIT, OnKillfocusHeadingAngleEdit)
320 ON_BN_CLICKED(IDC_HEMICUBE_CHECK, OnHemicubeCheck)
321 ON_BN_CLICKED(IDC_COUNT_TERRAIN_LIGHTS, OnCountTerrainLights)
322 ON_BN_CLICKED(IDC_CURROOM_RADIOSITY, OnCurroomRadiosity)
323 ON_BN_CLICKED(IDC_DYNAMIC_TERRAIN, OnDynamicTerrain)
324 ON_BN_CLICKED(IDC_BLUR_LIGHTMAPS, OnBlurLightmaps)
325 ON_EN_KILLFOCUS(IDC_IGNORE_LIMIT_EDIT, OnKillfocusIgnoreLimitEdit)
326 ON_EN_KILLFOCUS(IDC_RED_AMBIENT_EDIT, OnKillfocusRedAmbientEdit)
327 ON_EN_KILLFOCUS(IDC_GREEN_AMBIENT_EDIT, OnKillfocusGreenAmbientEdit)
328 ON_EN_KILLFOCUS(IDC_BLUE_AMBIENT_EDIT, OnKillfocusBlueAmbientEdit)
329 ON_BN_CLICKED(IDC_ELEMENT_CHECK, OnElementCheck)
330 ON_BN_CLICKED(IDC_IGNORE_TERRAIN, OnIgnoreTerrain)
331 ON_BN_CLICKED(IDC_IGNORE_SATELLITES, OnIgnoreSatellites)
332 ON_BN_CLICKED(IDC_USE_BSP_CHECK, OnUseBspCheck)
333 ON_EN_KILLFOCUS(IDC_LIGHT_MULTIPLY_EDIT, OnKillfocusLightMultiplyEdit)
334 ON_EN_KILLFOCUS(IDC_PULSE_TIME_EDIT, OnKillfocusPulseTimeEdit)
335 ON_EN_KILLFOCUS(IDC_PULSE_OFFSET_EDIT, OnKillfocusPulseOffsetEdit)
336 ON_BN_CLICKED(IDC_PULSE_ROOM, OnPulseRoom)
337 ON_BN_CLICKED(IDC_RESET_MULTIPLES, OnResetMultiples)
338 ON_BN_CLICKED(IDC_DESTROY_BSP, OnDestroyBsp)
339 ON_BN_CLICKED(IDC_COMBINE_FACES, OnCombineFaces)
340 ON_BN_CLICKED(IDC_VOLUME_LIGHTS, OnVolumeLights)
341 ON_BN_CLICKED(IDC_CORONA_CHECK, OnCoronaCheck)
342 ON_BN_CLICKED(IDC_FOG_CHECK, OnFogCheck)
343 ON_EN_KILLFOCUS(IDC_FOG_DENSITY, OnKillfocusFogDensity)
344 ON_EN_KILLFOCUS(IDC_FOG_RED, OnKillfocusFogRed)
345 ON_EN_KILLFOCUS(IDC_FOG_GREEN, OnKillfocusFogGreen)
346 ON_EN_KILLFOCUS(IDC_FOG_BLUE, OnKillfocusFogBlue)
347 ON_BN_CLICKED(IDC_ROOM_CORONAS, OnRoomCoronas)
348 ON_BN_CLICKED(IDC_MINE_CORONAS, OnMineCoronas)
349 ON_BN_CLICKED(IDC_REVERSE_CORONA, OnReverseCorona)
350 ON_EN_KILLFOCUS(IDC_GLOBAL_MULTIPLIER_EDIT, OnKillfocusGlobalMultiplierEdit)
351 ON_BN_CLICKED(IDC_STROBE_CHECK, OnStrobeCheck)
352 ON_BN_CLICKED(IDC_FLICKER_CHECK, OnFlickerCheck)
353 ON_EN_KILLFOCUS(IDC_ROOM_MULTIPLIER_EDIT, OnKillfocusRoomMultiplierEdit)
354 ON_EN_KILLFOCUS(IDC_ROOM_AMRED, OnKillfocusRoomAmred)
355 ON_EN_KILLFOCUS(IDC_ROOM_AMGREEN, OnKillfocusRoomAmgreen)
356 ON_EN_KILLFOCUS(IDC_ROOM_AMBLUE, OnKillfocusRoomAmblue)
357 ON_BN_CLICKED(IDC_CLEAR_LIGHTMAPS, OnClearLightmaps)
358 ON_BN_CLICKED(IDC_COPY_MULTIPLIER, OnCopyMultiplier)
359 //}}AFX_MSG_MAP
360 END_MESSAGE_MAP()
361
362 /////////////////////////////////////////////////////////////////////////////
363 // CLightingDialog message handlers
364
365 void CLightingDialog::OnSize(UINT nType, int cx, int cy) { CKeypadDialog::OnSize(nType, cx, cy); }
366
367 void CLightingDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
368 // TODO: Add your message handler code here and/or call default
369
370 CKeypadDialog::OnVScroll(nSBCode, nPos, pScrollBar);
371 }
372
373 void CLightingDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
374 // TODO: Add your message handler code here and/or call default
375
376 CKeypadDialog::OnHScroll(nSBCode, nPos, pScrollBar);
377 }
378
379 void CLightingDialog::OnLitepadSetdefault() {
380 int i, alphaed = 0;
381
382 Curroomp->faces[Curface].face_uvls[Curvert].alpha = 255;
383
384 for (i = 0; i < Curroomp->faces[Curface].num_verts; i++)
385 if (Curroomp->faces[Curface].face_uvls[i].alpha != 255)
386 alphaed = 1;
387
388 if (alphaed)
389 Curroomp->faces[Curface].flags |= FF_VERTEX_ALPHA;
390 else
391 Curroomp->faces[Curface].flags &= ~FF_VERTEX_ALPHA;
392
393 World_changed = 1;
394 UpdateDialog();
395 }
396
397 void CLightingDialog::OnLitepadSmoothall() {
398 int answer =
399 MessageBox("Are you sure you wish to calculate lighting on the indoor mine?", "Light Question", MB_YESNO);
400 if (answer == IDNO)
401 return;
402
403 MessageBox("I will now calculate radiosity for the indoor engine. You may prematurely break out by pressing any key "
404 "during the calculations",
405 "Message", MB_OK);
406
407 DoRadiosityForRooms();
408 World_changed = 1;
409 }
410
411 void CLightingDialog::OnKillfocusLightIterationEdit() {
412 CEdit *ebox;
413 char str[20];
414
415 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_ITERATION_EDIT);
416 ebox->GetWindowText(str, 20);
417
418 rad_MaxStep = atoi(str);
419 }
420
421 BOOL CLightingDialog::OnInitDialog() {
422 CDialog::OnInitDialog();
423
424 m_angle = 30;
425 m_resolution = 50;
426 m_start_alpha = 1.0;
427 m_falloff = 20;
428 m_pitch_angle = 0;
429 m_heading_angle = 0;
430 UpdateDialog();
431
432 return TRUE; // return TRUE unless you set the focus to a control
433 // EXCEPTION: OCX Property Pages should return FALSE
434 }
435
436 BOOL CLightingDialog::OnHelpInfo(HELPINFO *pHelpInfo) {
437 // TODO: Add your message handler code here and/or call default
438 WinHelp(HID_LIGHTINGTAB, HELP_CONTEXT);
439 return TRUE;
440 // return CDialog::OnHelpInfo(pHelpInfo);
441 }
442
443 void CLightingDialog::OnLitepadTerrainRadiosity() {
444 int answer = MessageBox("Are you sure you wish to calculate lighting on the terrain?", "Light Question", MB_YESNO);
445 if (answer == IDNO)
446 return;
447
448 Sound_system.KillSoundLib(false);
449
450 MessageBox("I will now calculate radiosity for the terrain engine. You may prematurely break out by pressing any "
451 "key during the calculations",
452 "Message", MB_OK);
453 DoRadiosityForTerrain();
454 World_changed = 1;
455
456 Sound_system.InitSoundLib(Descent, Sound_mixer, Sound_quality, false);
457 }
458
459 void CLightingDialog::OnLitepadCountLights() {
460 int lightcount, i, t;
461 char str[1000];
462
463 for (lightcount = 0, i = 0; i < MAX_ROOMS; i++) {
464 if (Rooms[i].used && !(Rooms[i].flags & RF_EXTERNAL)) {
465 for (t = 0; t < Rooms[i].num_faces; t++) {
466 int texnum = Rooms[i].faces[t].tmap;
467 if (GameTextures[texnum].r > 0 || GameTextures[texnum].g > 0 || GameTextures[texnum].b > 0)
468 lightcount++;
469 }
470 }
471 }
472
473 for (i = 0; i <= Highest_object_index; i++) {
474 if (OBJECT_OUTSIDE(&Objects[i]))
475 continue;
476
477 if (Objects[i].type != OBJ_NONE && Objects[i].lighting_render_type == LRT_LIGHTMAPS) {
478 poly_model *po = &Poly_models[Objects[i].rtype.pobj_info.model_num];
479
480 if (!po->new_style)
481 continue;
482
483 for (t = 0; t < po->n_models; t++) {
484 bsp_info *sm = &po->submodel[t];
485
486 if (IsNonRenderableSubmodel(po, t))
487 continue;
488
489 for (int j = 0; j < sm->num_faces; j++) {
490 if (sm->faces[j].texnum == -1)
491 continue;
492
493 int texnum = po->textures[sm->faces[j].texnum];
494 if (GameTextures[texnum].r > 0 || GameTextures[texnum].g > 0 || GameTextures[texnum].b > 0)
495 lightcount++;
496 }
497 }
498 }
499 }
500
501 sprintf(str,
502 "There are %d lights present in the mine. Do you wish for me to set the 'light iterations' control to match "
503 "this number?",
504 lightcount);
505 int answer = MessageBox(str, "Light Question", MB_YESNO);
506 if (answer == IDNO)
507 return;
508
509 CEdit *ebox;
510
511 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_ITERATION_EDIT);
512 sprintf(str, "%d", lightcount);
513 ebox->SetWindowText(str);
514
515 rad_MaxStep = lightcount;
516 }
517
518 void CLightingDialog::OnLitepadNextvertex() {
519 if (++Curvert >= Curroomp->faces[Curface].num_verts)
520 Curvert = 0;
521
522 EditorStatus("Vertex %d selected.", Curvert);
523 UpdateDialog();
524
525 State_changed = 1;
526 }
527
528 extern float GlobalMultiplier;
529 void CLightingDialog::UpdateDialog() {
530 CEdit *ebox;
531 float aval;
532 char str[100];
533
534 // Do volumetrics
535 if (Curroomp && Curroomp->used) {
536 aval = Ubyte_to_float[Curroomp->faces[Curface].face_uvls[Curvert].alpha];
537
538 ebox = (CEdit *)GetDlgItem(IDC_ALPHA_EDIT);
539 sprintf(str, "%f", aval);
540 ebox->SetWindowText(str);
541
542 uint8_t pval = Curroomp->pulse_time;
543
544 ebox = (CEdit *)GetDlgItem(IDC_PULSE_TIME_EDIT);
545 sprintf(str, "%d", pval);
546 ebox->SetWindowText(str);
547
548 pval = Curroomp->pulse_offset;
549
550 ebox = (CEdit *)GetDlgItem(IDC_PULSE_OFFSET_EDIT);
551 sprintf(str, "%d", pval);
552 ebox->SetWindowText(str);
553
554 ebox = (CEdit *)GetDlgItem(IDC_FOG_DENSITY);
555 sprintf(str, "%f", Curroomp->fog_depth);
556 ebox->SetWindowText(str);
557
558 ebox = (CEdit *)GetDlgItem(IDC_FOG_RED);
559 sprintf(str, "%f", Curroomp->fog_r);
560 ebox->SetWindowText(str);
561
562 ebox = (CEdit *)GetDlgItem(IDC_FOG_GREEN);
563 sprintf(str, "%f", Curroomp->fog_g);
564 ebox->SetWindowText(str);
565
566 ebox = (CEdit *)GetDlgItem(IDC_FOG_BLUE);
567 sprintf(str, "%f", Curroomp->fog_b);
568 ebox->SetWindowText(str);
569 } else {
570 ebox = (CEdit *)GetDlgItem(IDC_ALPHA_EDIT);
571 ebox->SetWindowText("No room selected");
572 }
573
574 // Set element check
575 CheckDlgButton(IDC_ELEMENT_CHECK, Shoot_from_patch ? 0 : 1);
576 CheckDlgButton(IDC_COMBINE_FACES, AllowCombining);
577 CheckDlgButton(IDC_IGNORE_TERRAIN, Ignore_terrain);
578 CheckDlgButton(IDC_IGNORE_SATELLITES, Ignore_satellites);
579 CheckDlgButton(IDC_USE_BSP_CHECK, UseBSP);
580 CheckDlgButton(IDC_VOLUME_LIGHTS, UseVolumeLights);
581
582 if (Curroomp == NULL) {
583 CheckDlgButton(IDC_CORONA_CHECK, 0);
584 CheckDlgButton(IDC_FOG_CHECK, 0);
585 CheckDlgButton(IDC_STROBE_CHECK, 0);
586 CheckDlgButton(IDC_FLICKER_CHECK, 0);
587
588 } else {
589 CheckDlgButton(IDC_CORONA_CHECK, (Curroomp->faces[Curface].flags & FF_CORONA) ? 1 : 0);
590 CheckDlgButton(IDC_FOG_CHECK, (Curroomp->flags & RF_FOG) ? 1 : 0);
591 CheckDlgButton(IDC_STROBE_CHECK, (Curroomp->flags & RF_STROBE) ? 1 : 0);
592 CheckDlgButton(IDC_FLICKER_CHECK, (Curroomp->flags & RF_FLICKER) ? 1 : 0);
593
594 ebox = (CEdit *)GetDlgItem(IDC_ROOM_MULTIPLIER_EDIT);
595 sprintf(str, "%f", Room_multiplier[Curroomp - Rooms]);
596 ebox->SetWindowText(str);
597
598 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMRED);
599 sprintf(str, "%f", Room_ambience_r[Curroomp - Rooms]);
600 ebox->SetWindowText(str);
601
602 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMGREEN);
603 sprintf(str, "%f", Room_ambience_g[Curroomp - Rooms]);
604 ebox->SetWindowText(str);
605
606 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMBLUE);
607 sprintf(str, "%f", Room_ambience_b[Curroomp - Rooms]);
608 ebox->SetWindowText(str);
609 }
610
611 // Do Global multiplier
612 ebox = (CEdit *)GetDlgItem(IDC_GLOBAL_MULTIPLIER_EDIT);
613 sprintf(str, "%f", GlobalMultiplier);
614 ebox->SetWindowText(str);
615
616 // Do maxsteps for radiosity
617 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_ITERATION_EDIT);
618 sprintf(str, "%d", rad_MaxStep);
619 ebox->SetWindowText(str);
620
621 ebox = (CEdit *)GetDlgItem(IDC_HEMICUBE_RES_EDIT);
622 sprintf(str, "%d", Hemicube_resolution);
623 ebox->SetWindowText(str);
624
625 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_SPACING_EDIT);
626 sprintf(str, "%d", LightSpacing);
627 ebox->SetWindowText(str);
628
629 ebox = (CEdit *)GetDlgItem(IDC_ANGLE_EDIT);
630 sprintf(str, "%d", m_angle);
631 ebox->SetWindowText(str);
632
633 ebox = (CEdit *)GetDlgItem(IDC_RESOLUTION_EDIT);
634 sprintf(str, "%d", m_resolution);
635 ebox->SetWindowText(str);
636
637 ebox = (CEdit *)GetDlgItem(IDC_START_ALPHA_EDIT);
638 sprintf(str, "%f", m_start_alpha);
639 ebox->SetWindowText(str);
640
641 ebox = (CEdit *)GetDlgItem(IDC_FALLOFF_EDIT);
642 sprintf(str, "%f", m_falloff);
643 ebox->SetWindowText(str);
644
645 ebox = (CEdit *)GetDlgItem(IDC_PITCH_ANGLE_EDIT);
646 sprintf(str, "%d", m_pitch_angle);
647 ebox->SetWindowText(str);
648
649 ebox = (CEdit *)GetDlgItem(IDC_HEADING_ANGLE_EDIT);
650 sprintf(str, "%d", m_heading_angle);
651 ebox->SetWindowText(str);
652
653 ebox = (CEdit *)GetDlgItem(IDC_IGNORE_LIMIT_EDIT);
654 sprintf(str, "%f", Ignore_limit);
655 ebox->SetWindowText(str);
656
657 ebox = (CEdit *)GetDlgItem(IDC_RED_AMBIENT_EDIT);
658 sprintf(str, "%.2f", Ambient_red);
659 ebox->SetWindowText(str);
660
661 ebox = (CEdit *)GetDlgItem(IDC_GREEN_AMBIENT_EDIT);
662 sprintf(str, "%.2f", Ambient_green);
663 ebox->SetWindowText(str);
664
665 ebox = (CEdit *)GetDlgItem(IDC_BLUE_AMBIENT_EDIT);
666 sprintf(str, "%.2f", Ambient_blue);
667 ebox->SetWindowText(str);
668
669 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_MULTIPLY_EDIT);
670 sprintf(str, "%.2f", (Curroomp->faces[Curface].light_multiple) / 4.0);
671 ebox->SetWindowText(str);
672 }
673
674 void CLightingDialog::OnPaint() {
675 CPaintDC dc(this); // device context for painting
676
677 UpdateDialog();
678
679 // Do not call CDialog::OnPaint() for painting messages
680 }
681
682 void CLightingDialog::OnKillfocusAlphaEdit() {
683 CEdit *ebox;
684 char str[40];
685 float aval;
686 int i, alphaed = 0;
687
688 ebox = (CEdit *)GetDlgItem(IDC_ALPHA_EDIT);
689 ebox->GetWindowText(str, 20);
690
691 aval = atof(str);
692 if (aval < 0)
693 aval = 0;
694 if (aval > 1.0)
695 aval = 1.0;
696
697 Curroomp->faces[Curface].face_uvls[Curvert].alpha = Float_to_ubyte(aval);
698
699 for (i = 0; i < Curroomp->faces[Curface].num_verts; i++)
700 if (Curroomp->faces[Curface].face_uvls[i].alpha != 255)
701 alphaed = 1;
702
703 if (alphaed)
704 Curroomp->faces[Curface].flags |= FF_VERTEX_ALPHA;
705 else
706 Curroomp->faces[Curface].flags &= ~FF_VERTEX_ALPHA;
707
708 UpdateDialog();
709 World_changed = 1;
710 }
711
712 extern bool Outline_lightmaps;
713 void CLightingDialog::OnShowLightmaps() {
714 int c = IsDlgButtonChecked(IDC_SHOW_LIGHTMAPS);
715
716 if (c)
717 Outline_lightmaps = 1;
718 else
719 Outline_lightmaps = 0;
720
721 State_changed = 1;
722 }
723
724 void CLightingDialog::OnKillfocusHemicubeResEdit() {
725 CEdit *ebox;
726 char str[20];
727 int val;
728
729 ebox = (CEdit *)GetDlgItem(IDC_HEMICUBE_RES_EDIT);
730 ebox->GetWindowText(str, 20);
731
732 val = atoi(str);
733
734 if (val < 50)
735 val = 50;
736 if (val > 2048)
737 val = 2048;
738
739 if ((val % 2) == 1)
740 val++;
741
742 Hemicube_resolution = val;
743 UpdateDialog();
744 }
745
746 void CLightingDialog::OnKillfocusLightSpacingEdit() {
747 CEdit *ebox;
748 char str[20];
749 int val;
750
751 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_SPACING_EDIT);
752 ebox->GetWindowText(str, 20);
753
754 val = atoi(str);
755
756 if (val < 1)
757 val = 1;
758 if (val > 20)
759 val = 20;
760
761 LightSpacing = val;
762 UpdateDialog();
763 }
764
765 void CLightingDialog::OnBestfitCheck() {
766 int c = IsDlgButtonChecked(IDC_BESTFIT_CHECK);
767
768 BestFit = c;
769
770 State_changed = 1;
771 }
772
773 void CLightingDialog::UpdateKeypad(int mask) {
774 if (mask & (KUF_CURROOM_CHANGED + KUF_CURFACE_CHANGED + KUF_CURPORTAL_CHANGED))
775 UpdateDialog();
776 }
777
778 void CLightingDialog::ShootRayForLighting(vector *dest, vector *from, vector *to, int startseg) {
779 fvi_info hit_info;
780 fvi_query fq;
781
782 // shoot a ray from the light position to the current vertex
783 fq.p0 = from;
784 fq.p1 = to;
785 fq.startroom = startseg;
786
787 fq.rad = 0.0f;
788 fq.flags = FQ_CHECK_OBJS | FQ_IGNORE_NON_LIGHTMAP_OBJECTS | FQ_NO_RELINK | FQ_IGNORE_RENDER_THROUGH_PORTALS;
789 fq.thisobjnum = -1;
790 fq.ignore_obj_list = NULL;
791
792 fvi_FindIntersection(&fq, &hit_info);
793
794 *dest = hit_info.hit_pnt;
795 }
796
797 #define MAX_VOLUMETRIC_DISTANCE 5000
798
799 // Creates a volumetric cone of light that casts from the center of the current face
800 void CLightingDialog::OnCreateVolumeCone() {
801 int i, t;
802
803 ASSERT(Curface < Curroomp->num_faces);
804 int resolution = m_resolution;
805 int first_vert_index, first_face_index, center_index;
806
807 vector faceverts[MAX_VERTS_PER_FACE];
808 vector center;
809 matrix face_matrix;
810
811 vector fvec = Curroomp->faces[Curface].normal;
812
813 float pitch_increment = 65536 / resolution;
814 float heading_increment = 65536 / resolution;
815 float desired_angle = m_angle;
816 float pitch, heading;
817
818 // Fixup angle for our system
819 desired_angle = (desired_angle / 360.0) * 65536;
820
821 // Get face matrix
822 vm_VectorToMatrix(&face_matrix, &fvec, NULL, NULL);
823 vm_TransposeMatrix(&face_matrix);
824
825 // Get polygon center
826 face *fp = &Curroomp->faces[Curface];
827 for (i = 0; i < fp->num_verts; i++)
828 faceverts[i] = Curroomp->verts[fp->face_verts[i]];
829 vm_GetCentroid(&center, faceverts, fp->num_verts);
830
831 // Add vertices to room
832 center_index = Curroomp->num_verts;
833 RoomAddVertices(Curroomp, resolution + 1);
834 Curroomp->verts[center_index] = center;
835 first_vert_index = center_index + 1;
836
837 for (i = 0; i < resolution; i++) {
838 vector dest_vec;
839 vector hit_vec;
840
841 matrix tempm;
842
843 // Get our direction
844 heading = FixCos(heading_increment * i);
845 pitch = FixSin(pitch_increment * i);
846
847 vm_AnglesToMatrix(&tempm, pitch * desired_angle, heading * desired_angle, 0);
848 vm_MatrixMulVector(&dest_vec, &tempm.fvec, &face_matrix);
849
850 dest_vec *= m_falloff;
851 dest_vec += center;
852
853 // Now shoot a ray out
854 ShootRayForLighting(&hit_vec, &center, &dest_vec, Curroomp - Rooms);
855
856 Curroomp->verts[first_vert_index + i] = hit_vec;
857 }
858
859 // Add faces to room
860 first_face_index = Curroomp->num_faces;
861 RoomAddFaces(Curroomp, resolution);
862
863 for (i = 0; i < resolution; i++) {
864 int a = center_index;
865 int b = first_vert_index + i;
866 int c = first_vert_index + ((i + 1) % resolution);
867
868 // First do front face
869 fp = &Curroomp->faces[first_face_index + i];
870
871 InitRoomFace(fp, 3);
872 fp->flags |= FF_VOLUMETRIC;
873 fp->tmap = D3EditState.texdlg_texture;
874
875 fp->face_verts[0] = a;
876 fp->face_verts[1] = b;
877 fp->face_verts[2] = c;
878
879 if (!ComputeFaceNormal(Curroomp, first_face_index + i))
880 Int3(); // Get Jason
881
882 AssignDefaultUVsToRoomFace(Curroomp, first_face_index + i);
883
884 // Now assign appropriate alpha
885
886 fp->face_uvls[0].alpha = Float_to_ubyte(m_start_alpha);
887 for (t = 1; t < 3; t++) {
888 vector subvec = Curroomp->verts[fp->face_verts[t]] - center;
889 float mag = vm_GetMagnitude(&subvec);
890 float norm = 1 - (mag / m_falloff);
891 if (norm < 0)
892 norm = 0;
893 fp->face_uvls[t].alpha = Float_to_ubyte(norm * m_start_alpha);
894 }
895 }
896 World_changed = 1;
897 }
898
899 void CLightingDialog::OnClearVolumetricRoom() {
900 int i;
901
902 StartOver:
903 for (i = 0; i < Curroomp->num_faces; i++) {
904 face *fp = &Curroomp->faces[i];
905 if (fp->flags & FF_VOLUMETRIC) {
906 DeleteRoomFace(Curroomp, i);
907 goto StartOver;
908 }
909 }
910
911 World_changed = 1;
912 }
913
914 void CLightingDialog::OnFillVolumeTexture() {
915 int i;
916
917 for (i = 0; i < Curroomp->num_faces; i++) {
918 face *fp = &Curroomp->faces[i];
919 if (fp->flags & FF_VOLUMETRIC)
920 Curroomp->faces[i].tmap = D3EditState.texdlg_texture;
921 }
922
923 World_changed = 1;
924 }
925
926 void CLightingDialog::OnKillfocusAngleEdit() {
927 CEdit *ebox;
928 char str[20];
929 int val;
930
931 ebox = (CEdit *)GetDlgItem(IDC_ANGLE_EDIT);
932 ebox->GetWindowText(str, 20);
933
934 val = atoi(str);
935
936 if (val < 0)
937 val = 0;
938 if (val > 90)
939 val = 70;
940
941 m_angle = val;
942 UpdateDialog();
943 }
944
945 void CLightingDialog::OnKillfocusStartAlphaEdit() {
946 CEdit *ebox;
947 char str[20];
948 float val;
949
950 ebox = (CEdit *)GetDlgItem(IDC_START_ALPHA_EDIT);
951 ebox->GetWindowText(str, 20);
952
953 val = atof(str);
954
955 if (val < 0)
956 val = 0;
957 if (val > 1)
958 val = 1;
959
960 m_start_alpha = val;
961 UpdateDialog();
962 }
963
964 void CLightingDialog::OnKillfocusResolutionEdit() {
965 CEdit *ebox;
966 char str[20];
967 int val;
968
969 ebox = (CEdit *)GetDlgItem(IDC_RESOLUTION_EDIT);
970 ebox->GetWindowText(str, 20);
971
972 val = atoi(str);
973
974 if (val < 1)
975 val = 1;
976 if (val > 200)
977 val = 200;
978
979 m_resolution = val;
980 UpdateDialog();
981 }
982
983 void CLightingDialog::OnEdgeVolumetric() {
984 int i, t;
985 float rad, mytan, tan_table[360];
986
987 ASSERT(Curface < Curroomp->num_faces);
988 int resolution = m_resolution;
989 int first_vert_index, first_face_index, index, face_index;
990 face *cur_fp = &Curroomp->faces[Curface];
991 vector subvec;
992 int total_face_verts, num_new_verts;
993
994 float falloff_distance = 0;
995 vector nvec = Curroomp->faces[Curface].normal;
996 vector fvec;
997
998 vector faceverts[MAX_VERTS_PER_FACE];
999 vector center;
1000 int pitch = m_pitch_angle;
1001 int heading = m_heading_angle;
1002
1003 if (pitch < 0)
1004 pitch += 360;
1005 if (heading < 0)
1006 heading += 360;
1007
1008 int desired_pitch = pitch * (65536.0 / 360.0);
1009 int desired_heading = heading * (65536.0 / 360.0);
1010 matrix tempm, face_matrix;
1011
1012 // Get facematrix
1013 vm_VectorToMatrix(&face_matrix, &nvec, NULL, NULL);
1014 vm_TransposeMatrix(&face_matrix);
1015
1016 // Get adjusted angle of direction
1017 vm_AnglesToMatrix(&tempm, desired_pitch, desired_heading, 0);
1018 vm_MatrixMulVector(&fvec, &tempm.fvec, &face_matrix);
1019
1020 // Build tan table
1021 for (i = 0; i < 360; i++) {
1022 rad = (float)(3.14 * (float)i / 180.0);
1023 mytan = tan(rad);
1024 tan_table[i] = mytan;
1025 }
1026
1027 // Get polygon center
1028 face *fp = &Curroomp->faces[Curface];
1029 for (i = 0; i < fp->num_verts; i++)
1030 faceverts[i] = Curroomp->verts[fp->face_verts[i]];
1031 vm_GetCentroid(&center, faceverts, fp->num_verts);
1032
1033 // Add vertices to room
1034 total_face_verts = cur_fp->num_verts;
1035 first_vert_index = Curroomp->num_verts;
1036 RoomAddVertices(Curroomp, cur_fp->num_verts * resolution * 2);
1037 num_new_verts = cur_fp->num_verts * resolution * 2;
1038 index = first_vert_index;
1039
1040 // Compute the rays
1041 for (i = 0; i < total_face_verts; i++) {
1042 vector vec_a = Curroomp->verts[cur_fp->face_verts[i]];
1043 vector vec_b = Curroomp->verts[cur_fp->face_verts[(i + 1) % total_face_verts]];
1044 subvec = vec_b - vec_a;
1045 vector add_vec = subvec / resolution;
1046
1047 for (t = 0; t < resolution; t++, index += 2) {
1048 vector dest_vec;
1049 vector hit_vec;
1050 vector src_vec;
1051 vector norm_vec;
1052 vector subvec;
1053 float cone_distance, mag;
1054
1055 src_vec = vec_a + (add_vec * t);
1056 src_vec += (cur_fp->normal / 64.0);
1057 dest_vec = src_vec + (fvec * m_falloff);
1058
1059 cone_distance = tan_table[m_angle] * m_falloff;
1060 norm_vec = center + (fvec * m_falloff);
1061 subvec = dest_vec - norm_vec;
1062 mag = vm_GetMagnitude(&subvec);
1063 if (mag < cone_distance) {
1064 vm_NormalizeVector(&subvec);
1065 dest_vec = norm_vec + (subvec * cone_distance);
1066 }
1067
1068 // Now shoot a ray out
1069 ShootRayForLighting(&hit_vec, &src_vec, &dest_vec, Curroomp - Rooms);
1070
1071 Curroomp->verts[index] = src_vec;
1072 Curroomp->verts[index + 1] = hit_vec;
1073 }
1074 }
1075
1076 // Add faces to room
1077 first_face_index = Curroomp->num_faces;
1078 RoomAddFaces(Curroomp, resolution * total_face_verts);
1079 index = first_vert_index;
1080 face_index = first_face_index;
1081
1082 for (i = 0; i < total_face_verts; i++) {
1083 for (t = 0; t < resolution; t++, index += 2, face_index++) {
1084 int a = index;
1085 int b = (index + 2);
1086 int c = (index + 3);
1087 int d = index + 1;
1088
1089 if ((b - first_vert_index) >= num_new_verts)
1090 b -= num_new_verts;
1091 if ((c - first_vert_index) >= num_new_verts)
1092 c -= num_new_verts;
1093
1094 // First do front face
1095 face *fp = &Curroomp->faces[face_index];
1096
1097 InitRoomFace(fp, 4);
1098 fp->flags |= FF_VOLUMETRIC;
1099 fp->tmap = D3EditState.texdlg_texture;
1100
1101 fp->face_verts[0] = a;
1102 fp->face_verts[1] = b;
1103 fp->face_verts[2] = c;
1104 fp->face_verts[3] = d;
1105
1106 if (!ComputeFaceNormal(Curroomp, face_index))
1107 Int3(); // Get Jason
1108
1109 AssignDefaultUVsToRoomFace(Curroomp, face_index);
1110
1111 // Now assign appropriate alpha
1112
1113 fp->face_uvls[0].alpha = Float_to_ubyte(m_start_alpha);
1114 fp->face_uvls[1].alpha = Float_to_ubyte(m_start_alpha);
1115
1116 subvec = Curroomp->verts[c] - Curroomp->verts[b];
1117 float mag = vm_GetMagnitude(&subvec);
1118 float norm = 1 - (mag / m_falloff);
1119 if (norm < 0)
1120 norm = 0;
1121 fp->face_uvls[2].alpha = Float_to_ubyte(norm * m_start_alpha);
1122
1123 subvec = Curroomp->verts[d] - Curroomp->verts[a];
1124 mag = vm_GetMagnitude(&subvec);
1125 norm = 1 - (mag / m_falloff);
1126 if (norm < 0)
1127 norm = 0;
1128 fp->face_uvls[3].alpha = Float_to_ubyte(norm * m_start_alpha);
1129 }
1130 }
1131 World_changed = 1;
1132 }
1133
1134 void CLightingDialog::OnKillfocusFalloffEdit() {
1135 CEdit *ebox;
1136 char str[20];
1137 int val;
1138
1139 ebox = (CEdit *)GetDlgItem(IDC_FALLOFF_EDIT);
1140 ebox->GetWindowText(str, 20);
1141
1142 val = atoi(str);
1143
1144 if (val < 2)
1145 val = 2;
1146 if (val > 2000)
1147 val = 2000;
1148
1149 m_falloff = val;
1150 UpdateDialog();
1151 }
1152
1153 void CLightingDialog::OnFarthestPoint() {
1154 face *fp = &Curroomp->faces[Curface];
1155 float max_distance = 0;
1156 char str[255];
1157 int i;
1158
1159 for (i = 0; i < fp->num_verts; i++) {
1160 vector dest_vec;
1161 vector hit_vec;
1162 vector src_vec;
1163 vector subvec;
1164
1165 src_vec = Curroomp->verts[fp->face_verts[i]];
1166 src_vec += (fp->normal / 64.0);
1167 dest_vec = src_vec + (fp->normal * MAX_VOLUMETRIC_DISTANCE);
1168
1169 // Now shoot a ray out
1170 ShootRayForLighting(&hit_vec, &src_vec, &dest_vec, Curroomp - Rooms);
1171
1172 subvec = hit_vec - src_vec;
1173 float mag = vm_GetMagnitude(&subvec);
1174 if (mag > max_distance)
1175 max_distance = mag;
1176 }
1177
1178 sprintf(str, "The farthest point is %f units away. Do you wish to set the falloff rate to this value?",
1179 max_distance);
1180 int answer = MessageBox(str, "Light Question", MB_YESNO);
1181 if (answer == IDNO)
1182 return;
1183
1184 m_falloff = max_distance;
1185 UpdateDialog();
1186 }
1187
1188 void CLightingDialog::OnKillfocusPitchAngleEdit() {
1189 CEdit *ebox;
1190 char str[20];
1191 int val;
1192
1193 ebox = (CEdit *)GetDlgItem(IDC_PITCH_ANGLE_EDIT);
1194 ebox->GetWindowText(str, 20);
1195
1196 val = atoi(str);
1197
1198 if (val < -70)
1199 val = -70;
1200 if (val > 70)
1201 val = 70;
1202
1203 m_pitch_angle = val;
1204 UpdateDialog();
1205 }
1206
1207 void CLightingDialog::OnKillfocusHeadingAngleEdit() {
1208 CEdit *ebox;
1209 char str[20];
1210 int val;
1211
1212 ebox = (CEdit *)GetDlgItem(IDC_HEADING_ANGLE_EDIT);
1213 ebox->GetWindowText(str, 20);
1214
1215 val = atoi(str);
1216
1217 if (val < -70)
1218 val = -70;
1219 if (val > 70)
1220 val = 70;
1221
1222 m_heading_angle = val;
1223 UpdateDialog();
1224 }
1225
1226 void CLightingDialog::OnHemicubeCheck() {
1227 int c = IsDlgButtonChecked(IDC_HEMICUBE_CHECK);
1228
1229 if (c)
1230 D3EditState.hemicube_radiosity = 1;
1231 else
1232 D3EditState.hemicube_radiosity = 0;
1233 }
1234
1235 void CLightingDialog::OnCountTerrainLights() {
1236 int lightcount, i, t;
1237 char str[1000];
1238
1239 for (lightcount = 0, i = 0; i < TERRAIN_WIDTH * TERRAIN_DEPTH; i++) {
1240 if (Terrain_seg[i].flags & TF_INVISIBLE)
1241 continue;
1242
1243 int texnum = Terrain_tex_seg[Terrain_seg[i].texseg_index].tex_index;
1244 if (GameTextures[texnum].r > 0 || GameTextures[texnum].g > 0 || GameTextures[texnum].b > 0)
1245 lightcount += 2;
1246 }
1247
1248 lightcount += Terrain_sky.num_satellites;
1249
1250 for (i = 0; i <= Highest_object_index; i++) {
1251 if (!OBJECT_OUTSIDE(&Objects[i]))
1252 continue;
1253
1254 if (Objects[i].type != OBJ_NONE && Objects[i].lighting_render_type == LRT_LIGHTMAPS) {
1255 poly_model *po = &Poly_models[Objects[i].rtype.pobj_info.model_num];
1256
1257 if (!po->new_style)
1258 continue;
1259
1260 for (t = 0; t < po->n_models; t++) {
1261 bsp_info *sm = &po->submodel[t];
1262
1263 if (IsNonRenderableSubmodel(po, t))
1264 continue;
1265
1266 for (int j = 0; j < sm->num_faces; j++) {
1267 if (sm->faces[j].texnum == -1)
1268 continue;
1269
1270 int texnum = po->textures[sm->faces[j].texnum];
1271 if (GameTextures[texnum].r > 0 || GameTextures[texnum].g > 0 || GameTextures[texnum].b > 0)
1272 lightcount++;
1273 }
1274 }
1275 }
1276 }
1277
1278 // Count rooms
1279 for (i = 0; i < MAX_ROOMS; i++) {
1280 if (Rooms[i].used && (Rooms[i].flags & RF_EXTERNAL)) {
1281 for (t = 0; t < Rooms[i].num_faces; t++) {
1282 int texnum = Rooms[i].faces[t].tmap;
1283 if (GameTextures[texnum].r > 0 || GameTextures[texnum].g > 0 || GameTextures[texnum].b > 0)
1284 lightcount++;
1285 }
1286 }
1287 }
1288
1289 sprintf(str,
1290 "There are %d lights present on the terrain. Do you wish for me to set the 'light iterations' control to "
1291 "match this number?",
1292 lightcount);
1293 int answer = MessageBox(str, "Light Question", MB_YESNO);
1294 if (answer == IDNO)
1295 return;
1296
1297 CEdit *ebox;
1298
1299 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_ITERATION_EDIT);
1300 sprintf(str, "%d", lightcount);
1301 ebox->SetWindowText(str);
1302
1303 rad_MaxStep = lightcount;
1304 }
1305
1306 void CLightingDialog::OnCurroomRadiosity() {
1307 MessageBox("I will now calculate radiosity for the current room. You may prematurely break out by pressing any key "
1308 "during the calculations",
1309 "Message", MB_OK);
1310
1311 DoRadiosityForCurrentRoom(Curroomp);
1312 World_changed = 1;
1313 }
1314
1315 void DoTerrainDynamicTable();
1316 void CLightingDialog::OnDynamicTerrain() {
1317 if ((MessageBox("Are you sure you wish to do dynamic lighting on the terrain. The reason I ask is that this "
1318 "procedure takes a long time, and I don't want to upset you.",
1319 "Question", MB_YESNO)) == IDYES)
1320 DoTerrainDynamicTable();
1321 }
1322
1323 void CLightingDialog::OnBlurLightmaps() {
1324
1325 if ((MessageBox("Are you sure you wish to blur all lightmaps? This operation cannot be undone...", "Question",
1326 MB_YESNO)) == IDYES) {
1327 BlurLightmapInfos(LMI_ROOM);
1328 BlurLightmapInfos(LMI_ROOM_OBJECT);
1329 BlurLightmapInfos(LMI_EXTERNAL_ROOM);
1330 BlurLightmapInfos(LMI_TERRAIN_OBJECT);
1331
1332 OutrageMessageBox("Blurring complete.");
1333 }
1334 }
1335
1336 void CLightingDialog::OnKillfocusIgnoreLimitEdit() {
1337 CEdit *ebox;
1338 char str[20];
1339 float val;
1340
1341 ebox = (CEdit *)GetDlgItem(IDC_IGNORE_LIMIT_EDIT);
1342 ebox->GetWindowText(str, 20);
1343
1344 val = atof(str);
1345
1346 if (val < 0 || val > .5) {
1347 OutrageMessageBox("Invalid value. Must be in the range 0 to .5!");
1348 return;
1349 }
1350
1351 Ignore_limit = val;
1352 UpdateDialog();
1353 }
1354
1355 void CLightingDialog::OnKillfocusRedAmbientEdit() {
1356 CEdit *ebox;
1357 char str[20];
1358 float val;
1359
1360 ebox = (CEdit *)GetDlgItem(IDC_RED_AMBIENT_EDIT);
1361 ebox->GetWindowText(str, 20);
1362
1363 val = atof(str);
1364
1365 if (val < 0 || val > 1.0) {
1366 OutrageMessageBox("Invalid value. Must be in the range 0 to 1.0!");
1367 return;
1368 }
1369
1370 Ambient_red = val;
1371 UpdateDialog();
1372 }
1373
1374 void CLightingDialog::OnKillfocusGreenAmbientEdit() {
1375 CEdit *ebox;
1376 char str[20];
1377 float val;
1378
1379 ebox = (CEdit *)GetDlgItem(IDC_GREEN_AMBIENT_EDIT);
1380 ebox->GetWindowText(str, 20);
1381
1382 val = atof(str);
1383
1384 if (val < 0 || val > 1.0) {
1385 OutrageMessageBox("Invalid value. Must be in the range 0 to 1.0!");
1386 return;
1387 }
1388
1389 Ambient_green = val;
1390 UpdateDialog();
1391 }
1392
1393 void CLightingDialog::OnKillfocusBlueAmbientEdit() {
1394 CEdit *ebox;
1395 char str[20];
1396 float val;
1397
1398 ebox = (CEdit *)GetDlgItem(IDC_BLUE_AMBIENT_EDIT);
1399 ebox->GetWindowText(str, 20);
1400
1401 val = atof(str);
1402
1403 if (val < 0 || val > 1.0) {
1404 OutrageMessageBox("Invalid value. Must be in the range 0 to 1.0!");
1405 return;
1406 }
1407
1408 Ambient_blue = val;
1409 UpdateDialog();
1410 }
1411
1412 void CLightingDialog::OnElementCheck() {
1413 int c = IsDlgButtonChecked(IDC_ELEMENT_CHECK);
1414
1415 if (c)
1416 Shoot_from_patch = 0;
1417 else
1418 Shoot_from_patch = 1;
1419 }
1420
1421 void CLightingDialog::OnIgnoreTerrain() {
1422 int c = IsDlgButtonChecked(IDC_IGNORE_TERRAIN);
1423
1424 if (c)
1425 Ignore_terrain = 1;
1426 else
1427 Ignore_terrain = 0;
1428 }
1429
1430 void CLightingDialog::OnIgnoreSatellites() {
1431 int c = IsDlgButtonChecked(IDC_IGNORE_SATELLITES);
1432
1433 if (c)
1434 Ignore_satellites = 1;
1435 else
1436 Ignore_satellites = 0;
1437 }
1438
1439 void CLightingDialog::OnUseBspCheck() {
1440 int c = IsDlgButtonChecked(IDC_USE_BSP_CHECK);
1441
1442 if (c)
1443 UseBSP = 1;
1444 else
1445 UseBSP = 0;
1446 }
1447
1448 void CLightingDialog::OnKillfocusLightMultiplyEdit() {
1449 if (Curroomp == NULL)
1450 return;
1451
1452 CEdit *ebox;
1453 char str[20];
1454 float val;
1455
1456 ebox = (CEdit *)GetDlgItem(IDC_LIGHT_MULTIPLY_EDIT);
1457 ebox->GetWindowText(str, 20);
1458
1459 val = atof(str);
1460
1461 if (val < .25 || val > 63.75) {
1462 OutrageMessageBox("Invalid value, setting to one!");
1463 val = 1.0;
1464 }
1465
1466 Curroomp->faces[Curface].light_multiple = (val * 4.0);
1467 UpdateDialog();
1468 }
1469
1470 void CLightingDialog::OnKillfocusPulseTimeEdit() {
1471 CEdit *ebox;
1472 char str[20];
1473 int aval;
1474
1475 ebox = (CEdit *)GetDlgItem(IDC_PULSE_TIME_EDIT);
1476 ebox->GetWindowText(str, 20);
1477
1478 aval = atol(str);
1479 if (aval < 0)
1480 aval = 0;
1481 if (aval > 255)
1482 aval = 255;
1483
1484 Curroomp->pulse_time = aval;
1485
1486 UpdateDialog();
1487 World_changed = 1;
1488 }
1489
1490 void CLightingDialog::OnKillfocusPulseOffsetEdit() {
1491 CEdit *ebox;
1492 char str[20];
1493 int aval;
1494
1495 ebox = (CEdit *)GetDlgItem(IDC_PULSE_OFFSET_EDIT);
1496 ebox->GetWindowText(str, 20);
1497
1498 aval = atol(str);
1499 if (aval < 0)
1500 aval = 0;
1501 if (aval > 255)
1502 aval = 255;
1503
1504 Curroomp->pulse_offset = aval;
1505
1506 UpdateDialog();
1507 World_changed = 1;
1508 }
1509
1510 void CLightingDialog::OnPulseRoom() {
1511 int ptime = Curroomp->pulse_time;
1512 int poffset = Curroomp->pulse_offset;
1513
1514 SetRoomPulse(Curroomp, ptime, poffset);
1515 UpdateDialog();
1516 World_changed = 1;
1517 }
1518
1519 void CLightingDialog::OnResetMultiples() {
1520 int testroom;
1521 int answer = MessageBox("Are you sure you wish to reset all light multiples?", "Light Question", MB_YESNO);
1522 if (answer == IDNO)
1523 return;
1524
1525 answer = MessageBox("Just for this room? (Answering no does it for the entire mine)", "Light Question", MB_YESNO);
1526
1527 if (answer == IDNO)
1528 testroom = -1;
1529 else
1530 testroom = Curroomp - Rooms;
1531
1532 int i;
1533
1534 for (i = 0; i <= Highest_room_index; i++) {
1535 if (Rooms[i].used) {
1536 if (testroom != -1 && i != testroom)
1537 continue;
1538
1539 for (int t = 0; t < Rooms[i].num_faces; t++) {
1540 Rooms[i].faces[t].light_multiple = 4;
1541 }
1542 }
1543 }
1544
1545 OutrageMessageBox("Light multiples reset!");
1546 }
1547
1548 void CLightingDialog::OnDestroyBsp() {
1549 int answer = MessageBox("Are you sure you wish to destroy the BSP tree?", "Light Question", MB_YESNO);
1550 if (answer == IDNO)
1551 return;
1552
1553 if (BSP_initted) {
1554 DestroyBSPTree(&MineBSP);
1555 }
1556
1557 OutrageMessageBox("BSP tree destroyed!");
1558 }
1559
1560 void CLightingDialog::OnCombineFaces() {
1561 int c = IsDlgButtonChecked(IDC_COMBINE_FACES);
1562
1563 if (c)
1564 AllowCombining = 1;
1565 else
1566 AllowCombining = 0;
1567 }
1568
1569 // Takes a bitmap name and resaves it
1570 void ResaveBitmap(char *name) {
1571 int bm_handle = bm_FindBitmapName(name);
1572 if (bm_handle >= 0) {
1573 char search[256];
1574
1575 // Make sure its paged in
1576 bm_data(bm_handle, 0);
1577
1578 ddio_MakePath(search, LocalD3Dir, "data", "graphics", GameBitmaps[bm_handle].name, NULL);
1579 mprintf(0, "Resaving bitmap %s.\n", search);
1580
1581 bm_SaveFileBitmap(search, bm_handle);
1582 } else {
1583 char search[256];
1584
1585 ddio_MakePath(search, LocalD3Dir, "data", "graphics", name, NULL);
1586
1587 bm_handle = bm_AllocLoadFileBitmap(search, 0);
1588 if (bm_handle >= 0) {
1589 // Make sure its paged in
1590 bm_data(bm_handle, 0);
1591
1592 mprintf(0, "Resaving bitmap %s.\n", search);
1593
1594 bm_SaveFileBitmap(search, bm_handle);
1595 } else
1596 Int3();
1597 }
1598 }
1599
1600 // Takes a vclip name and resaves it
1601 void ResaveVClip(char *name) {
1602 int bm_handle = FindVClipName(name);
1603 if (bm_handle >= 0) {
1604 char search[256];
1605
1606 ddio_MakePath(search, LocalD3Dir, "data", "graphics", GameVClips[bm_handle].name, NULL);
1607 mprintf(0, "Resaving vclip %s.\n", search);
1608
1609 SaveVClip(search, bm_handle);
1610 } else {
1611 char search[256];
1612
1613 ddio_MakePath(search, LocalD3Dir, "data", "graphics", name, NULL);
1614
1615 bm_handle = AllocLoadVClip(search, NOT_TEXTURE, 0);
1616 if (bm_handle >= 0) {
1617 mprintf(0, "Resaving vclip %s.\n", search);
1618
1619 SaveVClip(search, bm_handle);
1620 } else
1621 Int3();
1622 }
1623 }
1624
1625 void ResaveAllBitmaps() {
1626 char buffer[_MAX_PATH];
1627 char search[256];
1628
1629 ddio_MakePath(search, LocalD3Dir, "data", "graphics", "*.ogf", NULL);
1630
1631 if (ddio_FindFileStart(search, buffer)) {
1632 ResaveBitmap(buffer);
1633
1634 while ((ddio_FindNextFile(buffer))) {
1635 ResaveBitmap(buffer);
1636 }
1637 }
1638
1639 ddio_FindFileClose();
1640
1641 ddio_MakePath(search, LocalD3Dir, "data", "graphics", "*.oaf", NULL);
1642
1643 if (ddio_FindFileStart(search, buffer)) {
1644 ResaveVClip(buffer);
1645
1646 while ((ddio_FindNextFile(buffer))) {
1647 ResaveVClip(buffer);
1648 }
1649 }
1650
1651 ddio_FindFileClose();
1652 }
1653
1654 void CLightingDialog::OnVolumeLights() {
1655 int c = IsDlgButtonChecked(IDC_VOLUME_LIGHTS);
1656
1657 if (c)
1658 UseVolumeLights = 1;
1659 else
1660 UseVolumeLights = 0;
1661 }
1662
1663 void CLightingDialog::OnCoronaCheck() {
1664 if (Curroomp == NULL)
1665 return;
1666
1667 int c = IsDlgButtonChecked(IDC_CORONA_CHECK);
1668
1669 if (c)
1670 Curroomp->faces[Curface].flags |= FF_CORONA;
1671 else
1672 Curroomp->faces[Curface].flags &= ~FF_CORONA;
1673 }
1674
1675 void CLightingDialog::OnFogCheck() {
1676 if (Curroomp == NULL)
1677 return;
1678
1679 int c = IsDlgButtonChecked(IDC_FOG_CHECK);
1680
1681 if (c)
1682 Curroomp->flags |= RF_FOG;
1683 else
1684 Curroomp->flags &= ~RF_FOG;
1685 }
1686
1687 void CLightingDialog::OnKillfocusFogDensity() {
1688
1689 CEdit *ebox;
1690 char str[20];
1691 float aval;
1692
1693 ebox = (CEdit *)GetDlgItem(IDC_FOG_DENSITY);
1694 ebox->GetWindowText(str, 20);
1695
1696 aval = atof(str);
1697 if (aval < 0)
1698 aval = 5;
1699 if (aval > 5000)
1700 aval = 5000;
1701
1702 Curroomp->fog_depth = aval;
1703
1704 UpdateDialog();
1705 World_changed = 1;
1706 }
1707
1708 void CLightingDialog::OnKillfocusFogRed() {
1709 CEdit *ebox;
1710 char str[20];
1711 float aval;
1712
1713 ebox = (CEdit *)GetDlgItem(IDC_FOG_RED);
1714 ebox->GetWindowText(str, 20);
1715
1716 aval = atof(str);
1717 if (aval < 0)
1718 aval = 0;
1719 if (aval > 1.0)
1720 aval = 1;
1721
1722 Curroomp->fog_r = aval;
1723
1724 UpdateDialog();
1725 World_changed = 1;
1726 }
1727
1728 void CLightingDialog::OnKillfocusFogGreen() {
1729 CEdit *ebox;
1730 char str[20];
1731 float aval;
1732
1733 ebox = (CEdit *)GetDlgItem(IDC_FOG_GREEN);
1734 ebox->GetWindowText(str, 20);
1735
1736 aval = atof(str);
1737 if (aval < 0)
1738 aval = 0;
1739 if (aval > 1.0)
1740 aval = 1;
1741
1742 Curroomp->fog_g = aval;
1743
1744 UpdateDialog();
1745 World_changed = 1;
1746 }
1747
1748 void CLightingDialog::OnKillfocusFogBlue() {
1749 CEdit *ebox;
1750 char str[20];
1751 float aval;
1752
1753 ebox = (CEdit *)GetDlgItem(IDC_FOG_BLUE);
1754 ebox->GetWindowText(str, 20);
1755
1756 aval = atof(str);
1757 if (aval < 0)
1758 aval = 0;
1759 if (aval > 1.0)
1760 aval = 1;
1761
1762 Curroomp->fog_b = aval;
1763
1764 UpdateDialog();
1765 World_changed = 1;
1766 }
1767
1768 void CLightingDialog::OnRoomCoronas() {
1769 int rev, answer, only_cur_texture;
1770
1771 rev = IsDlgButtonChecked(IDC_REVERSE_CORONA);
1772
1773 if (rev)
1774 answer = MessageBox("Are you sure you wish to remove all coronas in the current room?", "Light Question", MB_YESNO);
1775 else
1776 answer = MessageBox("Are you sure you wish to make all lights in the current room have coronas?", "Light Question",
1777 MB_YESNO);
1778
1779 if (answer == IDNO)
1780 return;
1781
1782 only_cur_texture = MessageBox(
1783 "Do you wish to do this operation only on the faces that have the same texture as the currently selected face?",
1784 "Light Question", MB_YESNO);
1785
1786 int i;
1787
1788 for (i = 0; i < Curroomp->num_faces; i++) {
1789 if (only_cur_texture == IDYES) {
1790 if (Curroomp->faces[i].tmap != Curroomp->faces[Curface].tmap)
1791 continue;
1792 }
1793
1794 if (rev)
1795 Curroomp->faces[i].flags &= ~FF_CORONA;
1796 else
1797 Curroomp->faces[i].flags |= FF_CORONA;
1798 }
1799
1800 World_changed = 1;
1801
1802 OutrageMessageBox("Operation complete!");
1803 UpdateDialog();
1804 }
1805
1806 void CLightingDialog::OnMineCoronas() {
1807 int answer, only_cur_texture;
1808 int rev;
1809
1810 rev = IsDlgButtonChecked(IDC_REVERSE_CORONA);
1811
1812 if (rev)
1813 answer = MessageBox("Are you sure you wish to remove all coronas in this level?", "Light Question", MB_YESNO);
1814 else
1815 answer =
1816 MessageBox("Are you sure you wish to make all lights in the mine have coronas?", "Light Question", MB_YESNO);
1817
1818 if (answer == IDNO)
1819 return;
1820
1821 only_cur_texture = MessageBox(
1822 "Do you wish to do this operation only on the faces that have the same texture as the currently selected face?",
1823 "Light Question", MB_YESNO);
1824
1825 int i, t;
1826
1827 for (i = 0; i <= Highest_room_index; i++) {
1828 if (!Rooms[i].used)
1829 continue;
1830 if ((Rooms[i].flags & RF_EXTERNAL))
1831 continue;
1832
1833 for (t = 0; t < Rooms[i].num_faces; t++) {
1834 if (only_cur_texture == IDYES) {
1835 if (Rooms[i].faces[t].tmap != Curroomp->faces[Curface].tmap)
1836 continue;
1837 }
1838
1839 if (!rev)
1840 Rooms[i].faces[t].flags |= FF_CORONA;
1841 else
1842 Rooms[i].faces[t].flags &= ~FF_CORONA;
1843 }
1844 }
1845
1846 World_changed = 1;
1847
1848 OutrageMessageBox("Operation complete!");
1849 UpdateDialog();
1850 }
1851
1852 void CLightingDialog::OnReverseCorona() {
1853 // TODO: Add your control notification handler code here
1854 }
1855
1856 void CLightingDialog::OnKillfocusGlobalMultiplierEdit() {
1857 CEdit *ebox;
1858 char str[20];
1859 float aval;
1860
1861 ebox = (CEdit *)GetDlgItem(IDC_GLOBAL_MULTIPLIER_EDIT);
1862 ebox->GetWindowText(str, 20);
1863
1864 aval = atof(str);
1865 if (aval < 0)
1866 aval = 0;
1867
1868 GlobalMultiplier = aval;
1869
1870 UpdateDialog();
1871 }
1872
1873 void CLightingDialog::OnStrobeCheck() {
1874 if (Curroomp == NULL)
1875 return;
1876
1877 int c = IsDlgButtonChecked(IDC_STROBE_CHECK);
1878
1879 if (c)
1880 Curroomp->flags |= RF_STROBE;
1881 else
1882 Curroomp->flags &= ~RF_STROBE;
1883 }
1884
1885 void CLightingDialog::OnFlickerCheck() {
1886 if (Curroomp == NULL)
1887 return;
1888
1889 int c = IsDlgButtonChecked(IDC_FLICKER_CHECK);
1890
1891 if (c)
1892 Curroomp->flags |= RF_FLICKER;
1893 else
1894 Curroomp->flags &= ~RF_FLICKER;
1895 }
1896
1897 void CLightingDialog::OnKillfocusRoomMultiplierEdit() {
1898 CEdit *ebox;
1899 char str[20];
1900 float aval;
1901
1902 ebox = (CEdit *)GetDlgItem(IDC_ROOM_MULTIPLIER_EDIT);
1903 ebox->GetWindowText(str, 20);
1904
1905 aval = atof(str);
1906 if (aval < 0)
1907 aval = 0;
1908
1909 Room_multiplier[Curroomp - Rooms] = aval;
1910
1911 UpdateDialog();
1912 }
1913
1914 void CLightingDialog::OnKillfocusRoomAmred() {
1915 CEdit *ebox;
1916 char str[20];
1917 float aval;
1918
1919 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMRED);
1920 ebox->GetWindowText(str, 20);
1921
1922 aval = atof(str);
1923 if (aval < 0)
1924 aval = 0;
1925
1926 Room_ambience_r[Curroomp - Rooms] = aval;
1927
1928 UpdateDialog();
1929 }
1930
1931 void CLightingDialog::OnKillfocusRoomAmgreen() {
1932 CEdit *ebox;
1933 char str[20];
1934 float aval;
1935
1936 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMGREEN);
1937 ebox->GetWindowText(str, 20);
1938
1939 aval = atof(str);
1940 if (aval < 0)
1941 aval = 0;
1942
1943 Room_ambience_g[Curroomp - Rooms] = aval;
1944
1945 UpdateDialog();
1946 }
1947
1948 void CLightingDialog::OnKillfocusRoomAmblue() {
1949 CEdit *ebox;
1950 char str[20];
1951 float aval;
1952
1953 ebox = (CEdit *)GetDlgItem(IDC_ROOM_AMBLUE);
1954 ebox->GetWindowText(str, 20);
1955
1956 aval = atof(str);
1957 if (aval < 0)
1958 aval = 0;
1959
1960 Room_ambience_b[Curroomp - Rooms] = aval;
1961
1962 UpdateDialog();
1963 }
1964
1965 #include "object_lighting.h"
1966
1967 void CLightingDialog::OnClearLightmaps() {
1968 if (OutrageMessageBox(
1969 MBOX_YESNO,
1970 "Are you sure you want to clear the lightmaps? If you say yes, your level will have no lighting.") != IDYES)
1971 return;
1972
1973 ClearAllRoomLightmaps(0);
1974 ClearAllObjectLightmaps(0);
1975 }
1976
1977 int CopyFaceLightMultipleRoom(room *rp, int tmap, float multiple) {
1978 int n_changed = 0;
1979
1980 for (int f = 0; f < rp->num_faces; f++)
1981 if (rp->faces[f].tmap == tmap) {
1982 rp->faces[f].light_multiple = multiple;
1983 n_changed++;
1984 }
1985
1986 return n_changed;
1987 }
1988
1989 void CopyFaceLightMultiple(room *rp, int facenum) {
1990 int answer = OutrageMessageBox(
1991 MBOX_YESNOCANCEL,
1992 "Do you want to copy the light multiple from face %d to all faces in the mine that have the same texture?\n\n"
1993 "YES means copy to faces in the whole mine.\n"
1994 "NO means copy just to faces in the same room.\n"
1995 "CANCEL will abort this operation.",
1996 facenum);
1997
1998 if (answer == IDCANCEL)
1999 return;
2000
2001 int n_changed = 0;
2002 if (answer == IDNO)
2003 n_changed = CopyFaceLightMultipleRoom(rp, rp->faces[facenum].tmap, rp->faces[facenum].light_multiple);
2004 else {
2005 for (int r = 0; r <= Highest_room_index; r++) {
2006 if (Rooms[r].used)
2007 n_changed += CopyFaceLightMultipleRoom(&Rooms[r], rp->faces[facenum].tmap, rp->faces[facenum].light_multiple);
2008 }
2009 }
2010
2011 n_changed--; // don't count the source face
2012
2013 if (n_changed) {
2014 EditorStatus("The light multiple has been changed for %d faces.", n_changed);
2015 World_changed = 1;
2016 } else
2017 EditorStatus("No faces had the same texture as face %d.", facenum);
2018 }
2019
2020 void CLightingDialog::OnCopyMultiplier() { CopyFaceLightMultiple(Curroomp, Curface); }