forked from eu07/maszyna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorld.cpp
2908 lines (2796 loc) · 135 KB
/
World.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
/*
MaSzyna EU07 locomotive simulator
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/
#include "system.hpp"
#include "classes.hpp"
#include "opengl/glew.h"
#include "opengl/glut.h"
#pragma hdrstop
#include "Timer.h"
#include "mtable.hpp"
#include "Sound.h"
#include "World.h"
#include "Logs.h"
#include "Globals.h"
#include "Camera.h"
#include "ResourceManager.h"
#include "Event.h"
#include "Train.h"
#include "Driver.h"
#include "Console.h"
#define TEXTURE_FILTER_CONTROL_EXT 0x8500
#define TEXTURE_LOD_BIAS_EXT 0x8501
//---------------------------------------------------------------------------
#pragma package(smart_init)
typedef void(APIENTRY *FglutBitmapCharacter)(void *font, int character); // typ funkcji
FglutBitmapCharacter glutBitmapCharacterDLL = NULL; // deklaracja zmiennej
HINSTANCE hinstGLUT32 = NULL; // wskaŸnik do GLUT32.DLL
// GLUTAPI void APIENTRY glutBitmapCharacterDLL(void *font, int character);
TDynamicObject *Controlled = NULL; // pojazd, który prowadzimy
using namespace Timer;
const double fTimeMax = 1.00; //[s] maksymalny czas aktualizacji w jednek klatce
TWorld::TWorld()
{
// randomize();
// Randomize();
Train = NULL;
// Aspect=1;
for (int i = 0; i < 10; ++i)
KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi
Global::iSlowMotion = 0;
// Global::changeDynObj=NULL;
OutText1 = ""; // teksty wyœwietlane na ekranie
OutText2 = "";
OutText3 = "";
iCheckFPS = 0; // kiedy znów sprawdziæ FPS, ¿eby wy³¹czaæ optymalizacji od razu do zera
pDynamicNearest = NULL;
fTimeBuffer = 0.0; // bufor czasu aktualizacji dla sta³ego kroku fizyki
fMaxDt = 0.01; //[s] pocz¹tkowy krok czasowy fizyki
fTime50Hz = 0.0; // bufor czasu dla komunikacji z PoKeys
}
TWorld::~TWorld()
{
Global::bManageNodes = false; // Ra: wy³¹czenie wyrejestrowania, bo siê sypie
TrainDelete();
// Ground.Free(); //Ra: usuniêcie obiektów przed usuniêciem dŸwiêków - sypie siê
TSoundsManager::Free();
TModelsManager::Free();
TTexturesManager::Free();
glDeleteLists(base, 96);
if (hinstGLUT32)
FreeLibrary(hinstGLUT32);
}
void TWorld::TrainDelete(TDynamicObject *d)
{ // usuniêcie pojazdu prowadzonego przez u¿ytkownika
if (d)
if (Train)
if (Train->Dynamic() != d)
return; // nie tego usuwaæ
delete Train; // i nie ma czym sterowaæ
Train = NULL;
Controlled = NULL; // tego te¿ ju¿ nie ma
mvControlled = NULL;
Global::pUserDynamic = NULL; // tego te¿ nie ma
};
GLvoid TWorld::glPrint(const char *txt) // custom GL "Print" routine
{ // wypisywanie tekstu 2D na ekranie
if (!txt)
return;
if (Global::bGlutFont)
{ // tekst generowany przez GLUT
int i, len = strlen(txt);
for (i = 0; i < len; i++)
glutBitmapCharacterDLL(GLUT_BITMAP_8_BY_13, txt[i]); // funkcja linkowana dynamicznie
}
else
{ // generowanie przez Display Lists
glPushAttrib(GL_LIST_BIT); // pushes the display list bits
glListBase(base - 32); // sets the base character to 32
glCallLists(strlen(txt), GL_UNSIGNED_BYTE, txt); // draws the display list text
glPopAttrib(); // pops the display list bits
}
}
/* Ra: do opracowania: wybor karty graficznej ~Intel gdy s¹ dwie...
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
{
FARPROC EnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[33]; // 32 + 1 for the null-terminator
BOOL bRet = TRUE;
HRESULT hr;
hInstUser32 = LoadLibrary("c:\\windows\User32.DLL");
if (!hInstUser32) return FALSE;
// Get the address of the EnumDisplayDevices function
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
if (!EnumDisplayDevices) {
FreeLibrary(hInstUser32);
return FALSE;
}
ZeroMemory(&DispDev, sizeof(DispDev));
DispDev.cb = sizeof(DispDev);
// After the first call to EnumDisplayDevices,
// DispDev.DeviceString is the adapter name
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0))
{
hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName);
if (FAILED(hr))
{
// TODO: write error handler
}
// After second call, DispDev.DeviceString is the
// monitor name for that device
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
// In the following, lpszMonitorInfo must be 128 + 1 for
// the null-terminator.
hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString);
if (FAILED(hr))
{
// TODO: write error handler
}
} else {
bRet = FALSE;
}
FreeLibrary(hInstUser32);
return bRet;
}
*/
bool TWorld::Init(HWND NhWnd, HDC hDC)
{
double time = (double)Now();
Global::hWnd = NhWnd; // do WM_COPYDATA
Global::pCamera = &Camera; // Ra: wskaŸnik potrzebny do likwidacji drgañ
Global::detonatoryOK = true;
WriteLog("Starting MaSzyna rail vehicle simulator.");
WriteLog(Global::asVersion);
#if sizeof(TSubModel) != 256
Error("Wrong sizeof(TSubModel) is " + AnsiString(sizeof(TSubModel)));
return false;
#endif
WriteLog("Online documentation and additional files on http://eu07.pl");
WriteLog("Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx_EU, OLO_EU, Bart, Quark-t, "
"ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter and others");
WriteLog("Renderer:");
WriteLog((char *)glGetString(GL_RENDERER));
WriteLog("Vendor:");
// Winger030405: sprawdzanie sterownikow
WriteLog((char *)glGetString(GL_VENDOR));
AnsiString glver = ((char *)glGetString(GL_VERSION));
WriteLog("OpenGL Version:");
WriteLog(glver);
if ((glver == "1.5.1") || (glver == "1.5.2"))
{
Error("Niekompatybilna wersja openGL - dwuwymiarowy tekst nie bedzie wyswietlany!");
WriteLog("WARNING! This OpenGL version is not fully compatible with simulator!");
WriteLog("UWAGA! Ta wersja OpenGL nie jest w pelni kompatybilna z symulatorem!");
Global::detonatoryOK = false;
}
else
Global::detonatoryOK = true;
// Ra: umieszczone w EU07.cpp jakoœ nie chce dzia³aæ
while (glver.LastDelimiter(".") > glver.Pos("."))
glver = glver.SubString(1, glver.LastDelimiter(".") - 1); // obciêcie od drugiej kropki
double ogl;
try
{
ogl = glver.ToDouble();
}
catch (...)
{
ogl = 0.0;
}
if (Global::fOpenGL > 0.0) // jeœli by³a wpisane maksymalna wersja w EU07.INI
{
if (ogl > 0.0) // zak³adaj¹c, ¿e siê odczyta³o dobrze
if (ogl < Global::fOpenGL) // a karta oferuje ni¿sz¹ wersjê ni¿ wpisana
Global::fOpenGL = ogl; // to przyj¹c to z karty
}
else if (ogl < 1.3) // sprzêtowa deompresja DDS zwykle wymaga 1.3
Error("Missed OpenGL 1.3+ drivers!"); // b³¹d np. gdy wersja 1.1, a nie ma wpisu w EU07.INI
Global::bOpenGL_1_5 = (Global::fOpenGL >= 1.5); // s¹ fragmentaryczne animacje VBO
WriteLog("Supported extensions:");
WriteLog((char *)glGetString(GL_EXTENSIONS));
if (glewGetExtension("GL_ARB_vertex_buffer_object")) // czy jest VBO w karcie graficznej
{
if (AnsiString((char *)glGetString(GL_VENDOR))
.Pos("Intel")) // wymuszenie tylko dla kart Intel
{ // karty Intel nie nadaj¹ siê do grafiki 3D, ale robimy wyj¹tek, bo to w koñcu symulator
Global::iMultisampling =
0; // to robi problemy na "Intel(R) HD Graphics Family" - czarny ekran
if (Global::fOpenGL >=
1.4) // 1.4 mia³o obs³ugê VBO, ale bez opcji modyfikacji fragmentu bufora
Global::bUseVBO = true; // VBO w³¹czane tylko, jeœli jest obs³uga oraz nie ustawiono
// ni¿szego numeru
}
if (Global::bUseVBO)
WriteLog("Ra: The VBO is found and will be used.");
else
WriteLog("Ra: The VBO is found, but Display Lists are selected.");
}
else
{
WriteLog("Ra: No VBO found - Display Lists used. Graphics card too old?");
Global::bUseVBO = false; // mo¿e byæ w³¹czone parametrem w INI
}
if (Global::bDecompressDDS) // jeœli sprzêtowa (domyœlnie jest false)
WriteLog("DDS textures support at OpenGL level is disabled in INI file.");
else
{
Global::bDecompressDDS =
!glewGetExtension("GL_EXT_texture_compression_s3tc"); // czy obs³ugiwane?
if (Global::bDecompressDDS) // czy jest obs³uga DDS w karcie graficznej
WriteLog("DDS textures are not supported.");
else // brak obs³ugi DDS - trzeba w³¹czyæ programow¹ dekompresjê
WriteLog("DDS textures are supported.");
}
if (Global::iMultisampling)
WriteLog("Used multisampling of " + AnsiString(Global::iMultisampling) + " samples.");
{ // ograniczenie maksymalnego rozmiaru tekstur - parametr dla skalowania tekstur
GLint i;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &i);
if (i < Global::iMaxTextureSize)
Global::iMaxTextureSize = i;
WriteLog("Max texture size: " + AnsiString(Global::iMaxTextureSize));
}
/*-----------------------Render Initialization----------------------*/
if (Global::fOpenGL >= 1.2) // poni¿sze nie dzia³a w 1.1
glTexEnvf(TEXTURE_FILTER_CONTROL_EXT, TEXTURE_LOD_BIAS_EXT, -1);
GLfloat FogColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer
glLoadIdentity();
// WriteLog("glClearColor (FogColor[0], FogColor[1], FogColor[2], 0.0); ");
// glClearColor (1.0, 0.0, 0.0, 0.0); // Background Color
// glClearColor (FogColor[0], FogColor[1], FogColor[2], 0.0); // Background
// Color
glClearColor(0.2, 0.4, 0.33, 1.0); // Background Color
WriteLog("glFogfv(GL_FOG_COLOR, FogColor);");
glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color
WriteLog("glClearDepth(1.0f); ");
glClearDepth(1.0f); // ZBuffer Value
// glEnable(GL_NORMALIZE);
// glEnable(GL_RESCALE_NORMAL);
// glEnable(GL_CULL_FACE);
WriteLog("glEnable(GL_TEXTURE_2D);");
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
WriteLog("glShadeModel(GL_SMOOTH);");
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
WriteLog("glEnable(GL_DEPTH_TEST);");
glEnable(GL_DEPTH_TEST);
// McZapkie:261102-uruchomienie polprzezroczystosci (na razie linie) pod kierunkiem Marcina
// if (Global::bRenderAlpha) //Ra: wywalam tê flagê
{
WriteLog("glEnable(GL_BLEND);");
glEnable(GL_BLEND);
WriteLog("glEnable(GL_ALPHA_TEST);");
glEnable(GL_ALPHA_TEST);
WriteLog("glAlphaFunc(GL_GREATER,0.04);");
glAlphaFunc(GL_GREATER, 0.04);
WriteLog("glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);");
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
WriteLog("glDepthFunc(GL_LEQUAL);");
glDepthFunc(GL_LEQUAL);
}
/*
else
{
WriteLog("glEnable(GL_ALPHA_TEST);");
glEnable(GL_ALPHA_TEST);
WriteLog("glAlphaFunc(GL_GREATER,0.5);");
glAlphaFunc(GL_GREATER,0.5);
WriteLog("glDepthFunc(GL_LEQUAL);");
glDepthFunc(GL_LEQUAL);
WriteLog("glDisable(GL_BLEND);");
glDisable(GL_BLEND);
}
*/
/* zakomentowanie to co bylo kiedys mieszane
WriteLog("glEnable(GL_ALPHA_TEST);");
glEnable(GL_ALPHA_TEST);//glGetIntegerv()
WriteLog("glAlphaFunc(GL_GREATER,0.5);");
// glAlphaFunc(GL_LESS,0.5);
glAlphaFunc(GL_GREATER,0.5);
// glBlendFunc(GL_SRC_ALPHA,GL_ONE);
WriteLog("glDepthFunc(GL_LEQUAL);");
glDepthFunc(GL_LEQUAL);//EQUAL);
// The Type Of Depth Testing To Do
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
*/
WriteLog("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);");
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
WriteLog("glPolygonMode(GL_FRONT, GL_FILL);");
glPolygonMode(GL_FRONT, GL_FILL);
WriteLog("glFrontFace(GL_CCW);");
glFrontFace(GL_CCW); // Counter clock-wise polygons face out
WriteLog("glEnable(GL_CULL_FACE); ");
glEnable(GL_CULL_FACE); // Cull back-facing triangles
WriteLog("glLineWidth(1.0f);");
glLineWidth(1.0f);
// glLineWidth(2.0f);
WriteLog("glPointSize(2.0f);");
glPointSize(2.0f);
// ----------- LIGHTING SETUP -----------
// Light values and coordinates
vector3 lp = Normalize(vector3(-500, 500, 200));
Global::lightPos[0] = lp.x;
Global::lightPos[1] = lp.y;
Global::lightPos[2] = lp.z;
Global::lightPos[3] = 0.0f;
// Ra: œwiat³a by sensowniej by³o ustawiaæ po wczytaniu scenerii
// Ra: szcz¹tkowe œwiat³o rozproszone - ¿eby by³o cokolwiek widaæ w ciemnoœci
WriteLog("glLightModelfv(GL_LIGHT_MODEL_AMBIENT,darkLight);");
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::darkLight);
// Ra: œwiat³o 0 - g³ówne œwiat³o zewnêtrzne (S³oñce, Ksiê¿yc)
WriteLog("glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);");
glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight);
WriteLog("glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);");
glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight);
WriteLog("glLightfv(GL_LIGHT0,GL_SPECULAR,specularLight);");
glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight);
WriteLog("glLightfv(GL_LIGHT0,GL_POSITION,lightPos);");
glLightfv(GL_LIGHT0, GL_POSITION, Global::lightPos);
WriteLog("glEnable(GL_LIGHT0);");
glEnable(GL_LIGHT0);
// glColor() ma zmieniaæ kolor wybrany w glColorMaterial()
WriteLog("glEnable(GL_COLOR_MATERIAL);");
glEnable(GL_COLOR_MATERIAL);
WriteLog("glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);");
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
// WriteLog("glMaterialfv( GL_FRONT, GL_AMBIENT, whiteLight );");
// glMaterialfv( GL_FRONT, GL_AMBIENT, Global::whiteLight );
WriteLog("glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, whiteLight );");
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Global::whiteLight);
/*
WriteLog("glMaterialfv( GL_FRONT, GL_SPECULAR, noLight );");
glMaterialfv( GL_FRONT, GL_SPECULAR, Global::noLight );
*/
WriteLog("glEnable(GL_LIGHTING);");
glEnable(GL_LIGHTING);
WriteLog("glFogi(GL_FOG_MODE, GL_LINEAR);");
glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode
WriteLog("glFogfv(GL_FOG_COLOR, FogColor);");
glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color
// glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The
//Fog
// Be
// glHint(GL_FOG_HINT, GL_NICEST); // Fog Hint Value
WriteLog("glFogf(GL_FOG_START, 1000.0f);");
glFogf(GL_FOG_START, 10.0f); // Fog Start Depth
WriteLog("glFogf(GL_FOG_END, 2000.0f);");
glFogf(GL_FOG_END, 200.0f); // Fog End Depth
WriteLog("glEnable(GL_FOG);");
glEnable(GL_FOG); // Enables GL_FOG
// Ra: ustawienia testowe
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
/*--------------------Render Initialization End---------------------*/
WriteLog("Font init"); // pocz¹tek inicjacji fontów 2D
if (Global::bGlutFont) // jeœli wybrano GLUT font, próbujemy zlinkowaæ GLUT32.DLL
{
UINT mode = SetErrorMode(SEM_NOOPENFILEERRORBOX); // aby nie wrzeszcza³, ¿e znaleŸæ nie mo¿e
hinstGLUT32 = LoadLibrary(TEXT("GLUT32.DLL")); // get a handle to the DLL module
SetErrorMode(mode);
// If the handle is valid, try to get the function address.
if (hinstGLUT32)
glutBitmapCharacterDLL =
(FglutBitmapCharacter)GetProcAddress(hinstGLUT32, "glutBitmapCharacter");
else
WriteLog("Missed GLUT32.DLL.");
if (glutBitmapCharacterDLL)
WriteLog("Used font from GLUT32.DLL.");
else
Global::bGlutFont = false; // nie uda³o siê, trzeba spróbowaæ na Display List
}
if (!Global::bGlutFont)
{ // jeœli bezGLUTowy font
HFONT font; // Windows Font ID
base = glGenLists(96); // storage for 96 characters
font = CreateFont(-15, // height of font
0, // width of font
0, // angle of escapement
0, // orientation angle
FW_BOLD, // font weight
FALSE, // italic
FALSE, // underline
FALSE, // strikeout
ANSI_CHARSET, // character set identifier
OUT_TT_PRECIS, // output precision
CLIP_DEFAULT_PRECIS, // clipping precision
ANTIALIASED_QUALITY, // output quality
FF_DONTCARE | DEFAULT_PITCH, // family and pitch
"Courier New"); // font name
SelectObject(hDC, font); // selects the font we want
wglUseFontBitmapsA(hDC, 32, 96, base); // builds 96 characters starting at character 32
WriteLog("Display Lists font used."); //+AnsiString(glGetError())
}
WriteLog("Font init OK"); //+AnsiString(glGetError())
Timer::ResetTimers();
hWnd = NhWnd;
glColor4f(1.0f, 3.0f, 3.0f, 0.0f);
// SwapBuffers(hDC); // Swap Buffers (Double Buffering)
// glClear(GL_COLOR_BUFFER_BIT);
// glFlush();
SetForegroundWindow(hWnd);
WriteLog("Sound Init");
glLoadIdentity();
// glColor4f(0.3f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0f, 0.0f, -0.50f);
// glRasterPos2f(-0.25f, -0.10f);
glDisable(GL_DEPTH_TEST); // Disables depth testing
glColor3f(3.0f, 3.0f, 3.0f);
GLuint logo;
logo = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "logo", 6);
glBindTexture(GL_TEXTURE_2D, logo); // Select our texture
glBegin(GL_QUADS); // Drawing using triangles
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-0.28f, -0.22f, 0.0f); // bottom left of the texture and quad
glTexCoord2f(1.0f, 0.0f);
glVertex3f(0.28f, -0.22f, 0.0f); // bottom right of the texture and quad
glTexCoord2f(1.0f, 1.0f);
glVertex3f(0.28f, 0.22f, 0.0f); // top right of the texture and quad
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-0.28f, 0.22f, 0.0f); // top left of the texture and quad
glEnd();
//~logo; Ra: to jest bez sensu zapis
glColor3f(0.0f, 0.0f, 100.0f);
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.09f);
glPrint("Uruchamianie / Initializing...");
glRasterPos2f(-0.25f, -0.10f);
glPrint("Dzwiek / Sound...");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
glEnable(GL_LIGHTING);
/*-----------------------Sound Initialization-----------------------*/
TSoundsManager::Init(hWnd);
// TSoundsManager::LoadSounds( "" );
/*---------------------Sound Initialization End---------------------*/
WriteLog("Sound Init OK");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.11f);
glPrint("OK.");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
int i;
Paused = true;
WriteLog("Textures init");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.12f);
glPrint("Tekstury / Textures...");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
TTexturesManager::Init();
WriteLog("Textures init OK");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.13f);
glPrint("OK.");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
WriteLog("Models init");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.14f);
glPrint("Modele / Models...");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
// McZapkie: dodalem sciezke zeby mozna bylo definiowac skad brac modele ale to malo eleganckie
// TModelsManager::LoadModels(asModelsPatch);
TModelsManager::Init();
WriteLog("Models init OK");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.15f);
glPrint("OK.");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
WriteLog("Ground init");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.16f);
glPrint("Sceneria / Scenery (please wait)...");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
Ground.Init(Global::szSceneryFile, hDC);
// Global::tSinceStart= 0;
Clouds.Init();
WriteLog("Ground init OK");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.17f);
glPrint("OK.");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
// TTrack *Track=Ground.FindGroundNode("train_start",TP_TRACK)->pTrack;
// Camera.Init(vector3(2700,10,6500),0,M_PI,0);
// Camera.Init(vector3(00,40,000),0,M_PI,0);
// Camera.Init(vector3(1500,5,-4000),0,M_PI,0);
// McZapkie-130302 - coby nie przekompilowywac:
// Camera.Init(Global::pFreeCameraInit,0,M_PI,0);
Camera.Init(Global::pFreeCameraInit[0], Global::pFreeCameraInitAngle[0]);
char buff[255] = "Player train init: ";
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.18f);
glPrint("Przygotowanie kabiny do sterowania...");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
strcat(buff, Global::asHumanCtrlVehicle.c_str());
WriteLog(buff);
TGroundNode *nPlayerTrain = NULL;
if (Global::asHumanCtrlVehicle != "ghostview")
nPlayerTrain = Ground.DynamicFind(Global::asHumanCtrlVehicle); // szukanie w tych z obsad¹
if (nPlayerTrain)
{
Train = new TTrain();
if (Train->Init(nPlayerTrain->DynamicObject))
{
Controlled = Train->Dynamic();
mvControlled = Controlled->ControlledFind()->MoverParameters;
Global::pUserDynamic = Controlled; // renerowanie pojazdu wzglêdem kabiny
WriteLog("Player train init OK");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.19f);
glPrint("OK.");
}
FollowView();
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
else
{
Error("Player train init failed!");
FreeFlyModeFlag = true; // Ra: automatycznie w³¹czone latanie
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.20f);
glPrint("Blad inicjalizacji sterowanego pojazdu!");
}
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
Controlled = NULL;
mvControlled = NULL;
Camera.Type = tp_Free;
}
}
else
{
if (Global::asHumanCtrlVehicle != "ghostview")
{
Error("Player train not exist!");
if (Global::detonatoryOK)
{
glRasterPos2f(-0.25f, -0.20f);
glPrint("Wybrany pojazd nie istnieje w scenerii!");
}
}
FreeFlyModeFlag = true; // Ra: automatycznie w³¹czone latanie
SwapBuffers(hDC); // swap buffers (double buffering)
Controlled = NULL;
mvControlled = NULL;
Camera.Type = tp_Free;
}
glEnable(GL_DEPTH_TEST);
// Ground.pTrain=Train;
// if (!Global::bMultiplayer) //na razie w³¹czone
{ // eventy aktywowane z klawiatury tylko dla jednego u¿ytkownika
KeyEvents[0] = Ground.FindEvent("keyctrl00");
KeyEvents[1] = Ground.FindEvent("keyctrl01");
KeyEvents[2] = Ground.FindEvent("keyctrl02");
KeyEvents[3] = Ground.FindEvent("keyctrl03");
KeyEvents[4] = Ground.FindEvent("keyctrl04");
KeyEvents[5] = Ground.FindEvent("keyctrl05");
KeyEvents[6] = Ground.FindEvent("keyctrl06");
KeyEvents[7] = Ground.FindEvent("keyctrl07");
KeyEvents[8] = Ground.FindEvent("keyctrl08");
KeyEvents[9] = Ground.FindEvent("keyctrl09");
}
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //{Texture blends with object
// background}
light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga.tga");
// Camera.Reset();
ResetTimers();
WriteLog("Load time: " + FloatToStrF((86400.0 * ((double)Now() - time)), ffFixed, 7, 1) +
" seconds");
if (DebugModeFlag) // w Debugmode automatyczne w³¹czenie AI
if (Train)
if (Train->Dynamic()->Mechanik)
Train->Dynamic()->Mechanik->TakeControl(true);
return true;
};
void TWorld::OnKeyDown(int cKey)
{ //(cKey) to kod klawisza, cyfrowe i literowe siê zgadzaj¹
// Ra 2014-09: tu by mo¿na dodaæ tabelê konwersji: 256 wirtualnych kodów w kontekœcie dwóch
// prze³¹czników [Shift] i [Ctrl]
// na ka¿dy kod wirtualny niech przypadaj¹ 4 bajty: 2 dla naciœniêcia i 2 dla zwolnienia
// powtórzone 256 razy da 1kB na ka¿dy stan prze³¹czników, ³¹cznie bêdzie 4kB pierwszej tabeli
// przekodowania
if (!Global::iPause)
{ // podczas pauzy klawisze nie dzia³aj¹
AnsiString info = "Key pressed: [";
if (Console::Pressed(VK_SHIFT))
info += "Shift]+[";
if (Console::Pressed(VK_CONTROL))
info += "Ctrl]+[";
if (cKey > 192) // coœ tam jeszcze ciekawego jest?
{
if (cKey < 255) // 255 to [Fn] w laptopach
WriteLog(info + AnsiString(char(cKey - 128)) + "]");
}
else if (cKey >= 186)
WriteLog(info + AnsiString(";=,-./~").SubString(cKey - 185, 1) + "]");
else if (cKey > 123) // coœ tam jeszcze ciekawego jest?
WriteLog(info + AnsiString(cKey) + "]"); // numer klawisza
else if (cKey >= 112) // funkcyjne
WriteLog(info + "F" + AnsiString(cKey - 111) + "]");
else if (cKey >= 96)
WriteLog(info + "Num" + AnsiString("0123456789*+?-./").SubString(cKey - 95, 1) + "]");
else if (((cKey >= '0') && (cKey <= '9')) || ((cKey >= 'A') && (cKey <= 'Z')) ||
(cKey == ' '))
WriteLog(info + AnsiString(char(cKey)) + "]");
else if (cKey == '-')
WriteLog(info + "Insert]");
else if (cKey == '.')
WriteLog(info + "Delete]");
else if (cKey == '$')
WriteLog(info + "Home]");
else if (cKey == '#')
WriteLog(info + "End]");
else if (cKey > 'Z') //¿eby nie logowaæ kursorów
WriteLog(info + AnsiString(cKey) + "]"); // numer klawisza
}
if ((cKey <= '9') ? (cKey >= '0') : false) // klawisze cyfrowe
{
int i = cKey - '0'; // numer klawisza
if (Console::Pressed(VK_SHIFT))
{ // z [Shift] uruchomienie eventu
if (!Global::iPause) // podczas pauzy klawisze nie dzia³aj¹
if (KeyEvents[i])
Ground.AddToQuery(KeyEvents[i], NULL);
}
else // zapamiêtywanie kamery mo¿e dzia³aæ podczas pauzy
if (FreeFlyModeFlag) // w trybie latania mo¿na przeskakiwaæ do ustawionych kamer
if ((Global::iTextMode != VK_F12) &&
(Global::iTextMode != VK_F3)) // ograniczamy u¿ycie kamer
{
if ((!Global::pFreeCameraInit[i].x && !Global::pFreeCameraInit[i].y &&
!Global::pFreeCameraInit[i].z))
{ // jeœli kamera jest w punkcie zerowym, zapamiêtanie wspó³rzêdnych i k¹tów
Global::pFreeCameraInit[i] = Camera.Pos;
Global::pFreeCameraInitAngle[i].x = Camera.Pitch;
Global::pFreeCameraInitAngle[i].y = Camera.Yaw;
Global::pFreeCameraInitAngle[i].z = Camera.Roll;
// logowanie, ¿eby mo¿na by³o do scenerii przepisaæ
WriteLog(
"camera " + FloatToStrF(Global::pFreeCameraInit[i].x, ffFixed, 7, 3) + " " +
FloatToStrF(Global::pFreeCameraInit[i].y, ffFixed, 7, 3) + " " +
FloatToStrF(Global::pFreeCameraInit[i].z, ffFixed, 7, 3) + " " +
FloatToStrF(RadToDeg(Global::pFreeCameraInitAngle[i].x), ffFixed, 7, 3) +
" " +
FloatToStrF(RadToDeg(Global::pFreeCameraInitAngle[i].y), ffFixed, 7, 3) +
" " +
FloatToStrF(RadToDeg(Global::pFreeCameraInitAngle[i].z), ffFixed, 7, 3) +
" " + AnsiString(i) + " endcamera");
}
else // równie¿ przeskakiwanie
{ // Ra: to z t¹ kamer¹ (Camera.Pos i Global::pCameraPosition) jest trochê bez sensu
Global::SetCameraPosition(
Global::pFreeCameraInit[i]); // nowa pozycja dla generowania obiektów
Ground.Silence(Camera.Pos); // wyciszenie wszystkiego z poprzedniej pozycji
Camera.Init(Global::pFreeCameraInit[i],
Global::pFreeCameraInitAngle[i]); // przestawienie
}
}
// bêdzie jeszcze za³¹czanie sprzêgów z [Ctrl]
}
else if ((cKey >= VK_F1) ? (cKey <= VK_F12) : false)
{
switch (cKey)
{
case VK_F1: // czas i relacja
case VK_F3:
case VK_F5: // przesiadka do innego pojazdu
case VK_F8: // FPS
case VK_F9: // wersja, typ wyœwietlania, b³êdy OpenGL
case VK_F10:
if (Global::iTextMode == cKey)
Global::iTextMode =
(Global::iPause && (cKey != VK_F1) ? VK_F1 :
0); // wy³¹czenie napisów, chyba ¿e pauza
else
Global::iTextMode = cKey;
break;
case VK_F2: // parametry pojazdu
if (Global::iTextMode == cKey) // jeœli kolejne naciœniêcie
++Global::iScreenMode[cKey - VK_F1]; // kolejny ekran
else
{ // pierwsze naciœniêcie daje pierwszy (tzn. zerowy) ekran
Global::iTextMode = cKey;
Global::iScreenMode[cKey - VK_F1] = 0;
}
break;
case VK_F12: // coœ tam jeszcze
if (Console::Pressed(VK_CONTROL) && Console::Pressed(VK_SHIFT))
DebugModeFlag = !DebugModeFlag; // taka opcjonalna funkcja, mo¿e siê czasem przydaæ
/* //Ra 2F1P: teraz w³¹czanie i wy³¹czanie klawiszami cyfrowymi po u¿yciu [F12]
else if (Console::Pressed(VK_SHIFT))
{//odpalenie logu w razie "W"
if ((Global::iWriteLogEnabled&2)==0) //nie by³o okienka
{//otwarcie okna
AllocConsole();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN);
}
Global::iWriteLogEnabled|=3;
} */
else
Global::iTextMode = cKey;
break;
case VK_F4:
InOutKey();
break;
case VK_F6:
if (DebugModeFlag)
{ // przyspieszenie symulacji do testowania scenerii... uwaga na FPS!
// Global::iViewMode=VK_F6;
if (Console::Pressed(VK_CONTROL))
Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 10.0 : 5.0);
else
Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 2.0 : 1.0);
}
break;
}
// if (cKey!=VK_F4)
return; // nie s¹ przekazywane do pojazdu wcale
}
if (Global::iTextMode == VK_F10) // wyœwietlone napisy klawiszem F10
{ // i potwierdzenie
Global::iTextMode = (cKey == 'Y') ? -1 : 0; // flaga wyjœcia z programu
return; // nie przekazujemy do poci¹gu
}
else if ((Global::iTextMode == VK_F12) ? (cKey >= '0') && (cKey <= '9') : false)
{ // tryb konfiguracji debugmode (przestawianie kamery ju¿ wy³¹czone
if (!Console::Pressed(VK_SHIFT)) // bez [Shift]
{
if (cKey == '1')
Global::iWriteLogEnabled ^= 1; // w³¹cz/wy³¹cz logowanie do pliku
else if (cKey == '2')
{ // w³¹cz/wy³¹cz okno konsoli
Global::iWriteLogEnabled ^= 2;
if ((Global::iWriteLogEnabled & 2) == 0) // nie by³o okienka
{ // otwarcie okna
AllocConsole(); // jeœli konsola ju¿ jest, to zwróci b³¹d; uwalniaæ nie ma po
// co, bo siê od³¹czy
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
}
}
// else if (cKey=='3') Global::iWriteLogEnabled^=4; //wypisywanie nazw torów
}
}
else if (cKey == 3) //[Ctrl]+[Break]
{ // hamowanie wszystkich pojazdów w okolicy
Ground.RadioStop(Camera.Pos);
}
else if (!Global::iPause) //||(cKey==VK_F4)) //podczas pauzy sterownaie nie dzia³a, F4 tak
if (Train)
if (Controlled)
if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == 'Q'))
Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny
if (FreeFlyModeFlag) // aby nie odluŸnia³o wagonu za lokomotyw¹
{ // operacje wykonywane na dowolnym pojeŸdzie, przeniesione tu z kabiny
if (cKey == Global::Keys[k_Releaser]) // odluŸniacz
{ // dzia³a globalnie, sprawdziæ zasiêg
TDynamicObject *temp = Global::DynamicNearest();
if (temp)
{
if (GetAsyncKeyState(VK_CONTROL) < 0) // z ctrl odcinanie
{
temp->MoverParameters->BrakeStatus ^= 128;
}
else if (temp->MoverParameters->BrakeReleaser(1))
{
// temp->sBrakeAcc->
// dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX);
// dsbPneumaticRelay->Play(0,0,0); //temp->Position()-Camera.Pos //???
}
}
}
else if (cKey == Global::Keys[k_Heating]) // Ra: klawisz nie jest najszczêœliwszy
{ // zmiana pró¿ny/³adowny; Ra: zabrane z kabiny
TDynamicObject *temp = Global::DynamicNearest();
if (temp)
{
if (Console::Pressed(VK_SHIFT) ? temp->MoverParameters->IncBrakeMult() :
temp->MoverParameters->DecBrakeMult())
if (Train)
{ // dŸwiêk oczywiœcie jest w kabinie
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
Train->dsbSwitch->Play(0, 0, 0);
}
}
}
else if (cKey == Global::Keys[k_EndSign])
{ // Ra 2014-07: zabrane z kabiny
TDynamicObject *tmp = Global::CouplerNearest(); // domyœlnie wyszukuje do 20m
if (tmp)
{
int CouplNr = (LengthSquared3(tmp->HeadPosition() - Camera.Pos) >
LengthSquared3(tmp->RearPosition() - Camera.Pos) ?
1 :
-1) *
tmp->DirectionGet();
if (CouplNr < 0)
CouplNr = 0; // z [-1,1] zrobiæ [0,1]
int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jak¹œ idiotyczn¹ zmianê
// tapety pulpitu :/
if (GetAsyncKeyState(VK_SHIFT) < 0) // z [Shift] zapalanie
set = mask = 64; // bez [Ctrl] za³o¿yæ tabliczki
else if (GetAsyncKeyState(VK_CONTROL) < 0)
set = mask = 2 + 32; // z [Ctrl] zapaliæ œwiat³a czerwone
else
mask = 2 + 32 + 64; // wy³¹czanie œci¹ga wszystko
if (((tmp->iLights[CouplNr]) & mask) != set)
{
tmp->iLights[CouplNr] = (tmp->iLights[CouplNr] & ~mask) | set;
if (Train)
{ // Ra: ten dŸwiêk z kabiny to przegiêcie, ale na razie zostawiam
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
Train->dsbSwitch->Play(0, 0, 0);
}
}
}
}
else if (cKey == Global::Keys[k_IncLocalBrakeLevel])
{ // zahamowanie dowolnego pojazdu
TDynamicObject *temp = Global::DynamicNearest();
if (temp)
{
if (GetAsyncKeyState(VK_CONTROL) < 0)
if ((temp->MoverParameters->LocalBrake == ManualBrake) ||
(temp->MoverParameters->MBrake == true))
temp->MoverParameters->IncManualBrakeLevel(1);
else
;
else if (temp->MoverParameters->LocalBrake != ManualBrake)
if (temp->MoverParameters->IncLocalBrakeLevelFAST())
if (Train)
{ // dŸwiêk oczywiœcie jest w kabinie
Train->dsbPneumaticRelay->SetVolume(-80);
Train->dsbPneumaticRelay->Play(0, 0, 0);
}
}
}
else if (cKey == Global::Keys[k_DecLocalBrakeLevel])
{ // odhamowanie dowolnego pojazdu
TDynamicObject *temp = Global::DynamicNearest();
if (temp)
{
if (GetAsyncKeyState(VK_CONTROL) < 0)
if ((temp->MoverParameters->LocalBrake == ManualBrake) ||
(temp->MoverParameters->MBrake == true))
temp->MoverParameters->DecManualBrakeLevel(1);
else
;
else if (temp->MoverParameters->LocalBrake != ManualBrake)
if (temp->MoverParameters->DecLocalBrakeLevelFAST())
if (Train)
{ // dŸwiêk oczywiœcie jest w kabinie
Train->dsbPneumaticRelay->SetVolume(-80);
Train->dsbPneumaticRelay->Play(0, 0, 0);
}
}
}
}
// switch (cKey)
//{case 'a': //ignorowanie repetycji
// case 'A': Global::iKeyLast=cKey; break;
// default: Global::iKeyLast=0;
//}
}
void TWorld::OnKeyUp(int cKey)
{ // zwolnienie klawisza; (cKey) to kod klawisza, cyfrowe i literowe siê zgadzaj¹
if (!Global::iPause) // podczas pauzy sterownaie nie dzia³a
if (Train)
if (Controlled)
if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == 'Q'))
Train->OnKeyUp(cKey); // przekazanie zwolnienia klawisza do kabiny
};
void TWorld::OnMouseMove(double x, double y)
{ // McZapkie:060503-definicja obracania myszy
Camera.OnCursorMove(x * Global::fMouseXScale, -y * Global::fMouseYScale);
}
void TWorld::InOutKey()
{ // prze³¹czenie widoku z kabiny na zewnêtrzny i odwrotnie
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
if (FreeFlyModeFlag)
{ // je¿eli poza kabin¹, przestawiamy w jej okolicê - OK
Global::pUserDynamic = NULL; // bez renderowania wzglêdem kamery
if (Train)
{ // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0));
Train->Silence(); // wy³¹czenie dŸwiêków kabiny
Train->Dynamic()->bDisplayCab = false;
DistantView();
}
}
else
{ // jazda w kabinie
if (Train)
{
Global::pUserDynamic = Controlled; // renerowanie wzglêdem kamery
Train->Dynamic()->bDisplayCab = true;