Rise
The Vieneo Province
Loading...
Searching...
No Matches
Viewscreen.cpp
Go to the documentation of this file.
1//#define VISIBLEGRIDDUMP
2
3#include "Viewscreen.h"
5#include "LampContact.h"
6#include "SkyRingRenderer.h"
7
8#include "../GameClass.h"
9#include "../MathUtilities.h"
13
14#include <fcntl.h>
15#include <io.h>
16#include <share.h>
17#include <sys/stat.h>
18
19void Viewscreen::LogCurbDiagnostic(const char* text)
20{
21 static int curbLog = -1;
22 if (curbLog == -1)
23 _sopen_s(&curbLog, "curb.log", _O_WRONLY | O_TEXT | _O_CREAT | _O_TRUNC,
24 _SH_DENYWR, _S_IWRITE);
25
26 if (curbLog != -1)
27 {
28 char line[2048];
29 sprintf_s(line, sizeof(line), "%7.3f VT%u CT%i VID%u %s\n",
31 static_cast<unsigned int>(playerships[0].type),
32 static_cast<int>(ourcockpit.texturelib),
33 static_cast<unsigned int>(playerships[0].vehicleId),
34 text);
35 _write(curbLog, line, static_cast<unsigned int>(strlen(line)));
36 }
37}
38
40 : cityCampaignLogos([g](const char* message) { g->logger->Log(message, Logger::Level::Info); })
41{
42 gameclass = g;
43 logger = g->logger.get();
44 logger->AddToCallStack("Viewscreen::ctor");
45
46
47 ptrGrid = std::make_unique<grid>(this);
48 ptrWeapon = std::make_unique<weapon>(this);
49 ptrBuildings = std::make_unique<buildings>(this);
50 ptrKeyboard = std::make_unique<keyboard>(this);
51 ptrJoystick = std::make_unique<joystick>(this);
52 ptrFreeTrack = std::make_unique<FreeTrack>(this);
53 ptrPropulsion = std::make_unique<propulsion>(this);
54 ptrRenderer = std::make_unique<renderer>(this);
55 ptrWeather = std::make_unique<weather>(this);
56 ptrCockpit = std::make_unique<cockpit>(this);
57 ptrInstruments = std::make_unique<instruments>(this);
58 ptrWaypoints = std::make_unique<waypoints>(gameclass);
59
60 // lateraltime = 4.0f; //Do we need to set this to a constant or something ?
61// verticaltime = 4.0f;
62
63 lateralmod = false;
64 verticalmod = false;
65 yawmod = false;
66 //Initialize some variables
67 pitchInput = 0.0f; rollInput = 0.0f; yawInput = 0.0f;
68 cloudpos = centerC;
69 BCLoffsetu = BCLoffsetv = 0; // for cloud animation
70 H2Ooffsetu = 0.0f; // for water animation
71
72 position = centerC; // centerC is defined in globals.h
73 posnorml = centerC;
74
75 lateralincr = 0.1f;
76 verticalincr = 0.1f;
77
78 //Here comes all the initializing that happened in WinMain first
79 short t = 0;
80
81 flicker = 0;
82 interlace = 0.0f;
85
86 //Initialize all vars
87 g_pDI = nullptr; // The DirectInput interface
88
89 m_pFont = nullptr; // A font to output text
90 m_pFontLicense = nullptr;
91 m_pFontNamePlate = nullptr;
92 m_pFontHull = nullptr;
93
94 // Static VB, doesn't change every frame
95 m_avStaticStars = nullptr;
96 m_avCone = nullptr;
97 m_avBillboardVertices = nullptr;
98 m_avRunningLights = nullptr; // For the running lights
99 m_aiCloudGrid = nullptr;
100 m_avCloudGrid = nullptr;
101 //m_aiLocalGrid = nullptr;
102 m_avLocalGrid = nullptr;
103
104 // Dynamic VB, changes every frame
105 m_avRainDrops = nullptr;
106 m_avSkyDome = nullptr;
107 m_avSkyRing = nullptr;
108 m_avScreen = nullptr; // Alpha blended viewscreen
109 m_avInstrument = nullptr; // Instrumentation
110
111 // Static Textures
112 //m_pddsDetail1 = nullptr;
113 m_pddsWorld2a1 = nullptr; // Iomere
114 m_pddsCloudBaseMap = nullptr; // Clouds
115 m_pddsCloudDetailAbove = nullptr; // Clouds
116 m_pddsCloudDetailBelow = nullptr; // Clouds
117 m_pddsBinoculars = nullptr;
118 m_pddsNightVision = nullptr;
119 m_pddsBinocularsCompass = nullptr;
120 m_pddsBinocularsArrow = nullptr;
121 m_pddsNightVisionCompass = nullptr;
122 m_pddsNightVisionArrow = nullptr;
123 m_pddsSunglasses = nullptr;
124 m_pddsSunTexture = nullptr; // Yonmara
125 m_pddsStarTexture = nullptr;
126 m_pddsHolidayTexture = nullptr;
127
128 // arrays
129 for (t = 0; t < weaponanimateC; t++)
130 m_pddsWeapon[t] = m_pddsSinker[t] = nullptr;
131 m_pddsFuzerX = nullptr;
132 m_pddsSinkerX = nullptr;
133 m_pddsBlastX = nullptr;
134 for (t = 0; t < firework1C; t++)
135 m_pddsFirework1[t] = nullptr;
136 for (t = 0; t < firework2C; t++)
137 m_pddsFirework2[t] = nullptr;
138 for (t = 0; t < firework3C; t++)
139 m_pddsFirework3[t] = nullptr;
140 for (t = 0; t < elmoAnimateC; t++)
141 m_pddsElmo[t] = nullptr;
142#ifdef smoketestC
143 for (t = 0; t < smoketrailC; t++)
144 m_pddsSmoke[t] = nullptr;
145#endif
146 for (t = 0; t < dihvanimateC; t++)
147 m_pddsDIHV[t] = nullptr;
148 for (t = 0; t < heartanimateC; t++)
149 m_pddsHeart[t] = nullptr;
150 m_pddsFlame = nullptr;
151
152 // Cockpit dashes
153 m_pddsGVDialSmall = nullptr; // must be separate, rotates
154 m_pddsGVBackground = nullptr; // could be combined
155 m_pddsNamePlate = nullptr; // could be combined
156 m_pddsGVCompass = nullptr; // must be separate, wraps
157 m_pddsGVDirection = nullptr; // could be combined
158 m_pddsLightsCruiseIcons = nullptr; // could be combined
159 m_pddsFuelIcon = nullptr; // could be combined
160 for (t = 0; t < 3; t++)
161 m_pddsAOA[t] = nullptr;
162 for (t = 0; t < cockpittextureC; t++)
163 m_pddsCockpitTexture[t] = m_pddsCockpitLights[t] = nullptr;
164 //m_pddsVector = nullptr; // could be combined
165 //m_pddsAGLtape = nullptr; // could be combined
166 for (t = 0; t < 2; t++)
167 m_pddsInterlace[t] = nullptr;
168
169 // Interface
170 // m_pddsCardioscan = nullptr;
171 // m_pddsMenu = nullptr;
172 // m_pddsHelp = nullptr;
173 m_pddsLetters = nullptr;
174
175 m_pddsAtmosphere = nullptr;
176 for (t = 0; t < shiptextureC; t++)
177 m_pddsShipTexture[t] = m_pddsShipLights[t] = nullptr;
178 for (t = 0; t < docktextureC; t++)
179 m_pddsDockTexture[t] = m_pddsDockLights[t] = nullptr;
180 for (t = 0; t < RTStextureC; t++)
181 m_pddsRTSTexture[t] = m_pddsRTSLights[t] = nullptr;
182 for (t = 0; t < citytextureC; t++)
183 m_pddsCityTexture[t] = m_pddsCityLights[t] = nullptr;
184 for (t = 0; t < landformtextureC; t++)
185 m_pddsLandform[t] = nullptr;
186 for (t = 0; t < transitiontextureC; t++)
187 m_pddsTransition[t] = nullptr;
188 m_pddsWaterNormal = nullptr;
189 m_pddsMarston1 = nullptr;
190 m_pddsRunwayEdgeLight1 = nullptr;
191 m_pddsRoad = nullptr;
192 m_pddsIntersection = nullptr;
193
194 // Dynamic Textures
195 m_pddsDynamicTexture = nullptr;
196 m_pddsDynamicSurface = nullptr;
197 m_pddsProjectionTexture = nullptr;
198 m_pddsProjectionSurface = nullptr;
199 m_pRenderToSurface = nullptr;
200 m_pRenderToSurfaceNextGen = nullptr;
201 m_pHullRender2Surface = nullptr;
202
203 logger->Log("Viewscreen::ctor Initializing vehicles array!");
204
205 for (t = 0; t < MAX_SCAN; t++)
206 {
207 // These guys were found not to be initialized in the legacy Viewscreen as part of the integration
208 gameclass->bus->scanslot[t] = t;
209 gameclass->bus->scandist[t] = 0.0f;
210
211 playerships[t].active = false;
212 playerships[t].visible = false;
213 playerships[t].isOnScanner = false;
214 playerships[t].isSimulator = false;
216 playerships[t].clientinit = true;
217 playerships[t].logolight = false;
218 playerships[t].docked = false;
219 playerships[t].vehicleId = 0;
220 playerships[t].headlight = false;
221 playerships[t].geardown = false;
222 playerships[t].domelight = false;
224 playerships[t].wipers = {};
225 playerships[t].brakelight = false;
226 playerships[t].alarm = false;
227 playerships[t].police = false;
228 playerships[t].specialight = false;
229 playerships[t].reference = -127;
230 playerships[t].inarray = -1;
233 playerships[t].cloaking = 1.0f;
234 playerships[t].speed = 0.0f;
235 playerships[t].type = 0; // unassigned
236 playerships[t].bound = 0.0f;
237 playerships[t].flapdown = 0.0f;
238 playerships[t].spoilersUp = 0.0f;
242
243 // all this in case we don't get a packet
247 playerships[t].precisionx = 0.0;
248 playerships[t].precisiony = 0.0;
249 playerships[t].precisionz = 0.0;
255 playerships[t].IVR[0] = playerships[t].hullname[0] = 0;
256 playerships[t].componentarray = nullptr;
257 playerships[t].components = 0;
258 RiseMath::MatrixTranslation(&playerships[t].matrixWorld, 500.0f, 0.0f, 0.0f);
259 RiseMath::MatrixIdentity(&playerships[t].matrixWorld);
260 RiseMath::MatrixIdentity(&playerships[t].matrixExterior);
263 RiseMath::MatrixIdentity(&playerships[t].matrixInvOrientation);
264 }
265
266 //for (t = 0; t < MAX_ONLINEPLAYERS; t++)
267 //{
268 // player[t].frame=-2;
269 // player[t].queueani=player[t].ani=7; // ready
270 // player[t].anitime=0.0f;
271 //}
272
273 weapontimer[0] = weapontimer[1] = 0.0f;
274
276
278 for (t = 0; t < PlotType::PlotTypeEnum; t++)
279 {
280 citystuff.compare[t] = maxcompareC >> rand() % maxcomparebitC; // start somewhere in sequence at random
281 citystuff.timer[t] = RandomFloat(); // start somewhere within sequence at random
282
283 // higher is slower
284 switch (t)
285 {
286 case PlotType::DeoisFinancial: citystuff.speed[t] = 0.523832f; break;
287 case PlotType::DeoisIndustrial: citystuff.speed[t] = 0.364829f; break;
288 case PlotType::DeoisCityCenter: citystuff.speed[t] = 0.316228f; break;
289 case PlotType::DeoisTransit: citystuff.speed[t] = 0.270000f; break;
290 case PlotType::DeoisPort: citystuff.speed[t] = 0.028284f; break;
291 case PlotType::UserAirfield: citystuff.speed[t] = 0.03125f; break; // cycles 1 per second (1/32)
292 default: citystuff.speed[t] = 0.0f; break;
293 }
294 }
295
296 for (t = 0; t < fireworksC; t++)
297 fireworks[t].inuse = false;
298
299 // These guys were found not to be initialized in the legacy Viewscreen as part of the integration
300 for (t = 0; t < MAX_SCAN; t++)
301 m_pddsHullDynamicTexture[t] = nullptr;
302
303 lookhdg = 0.0f;
304 verticaltime = lateraltime = 0.0f;
305 deathinhibit = 0.0f;
306 //teleminhibit = 0.0f;
307 waterloop = 0;
308 heartloop = 0.0f;
309
310 reentryDamageIntensity = 0.f;
311
312 turbTime = RandomFloat() * 1000.0f;
313 turbLow = 0.0f; // heave ... used for both wind gusts and in-cloud visibility
314 turbEnergy = 0.0f; // smoothed turbulence scalar (memory)
315}
316
318{
319 logger->AddToCallStack("Viewscreen::dtor");
320
321 // A failed replacement device can leave only CPU model state alive.
324 for (auto& ship : playerships)
325 {
326 SAFE_DELETE_ARRAY(ship.componentarray);
327 ship.components = 0;
328 }
330 ptrGrid.reset();
331 ptrWeapon.reset();
332 ptrBuildings.reset();
333 ptrKeyboard.reset();
334 ptrJoystick.reset();
335 // DirectInput lives with the application, independently of the D3D device.
337 ptrPropulsion.reset();
338 ptrFreeTrack.reset();
339 ptrRenderer.reset();
340 ptrWeather.reset();
341 ptrCockpit.reset();
342 ptrInstruments.reset();
343 ptrWaypoints.reset();
344
345 logger->AddToCallStack("Viewscreen::dtor DONE");
346}
347
349{
350 logger->AddToCallStack("Viewscreen::Initialize");
351 logger->Log("Viewscreen Initialize() Called!");
352
353 _controlfp_s(nullptr, _PC_64, MCW_PC);
354
355 // -----------------------------------------------------------------------------------------
356 // Load the dynamic universe objects
357 // -----------------------------------------------------------------------------------------
358 int universe;
359 _sopen_s(&universe, "universe.dat", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE); // | _SH_DENYNO
360 if (universe == -1)
361 {
362 logger->Log("Viewscreen Initialize() failed to load \"universe.dat\"...", Logger::Level::Info);
363 char strerr[99];
364 strerror_s(strerr, 99, errno);
366 }
367
368 for (long t = 0; t < maxstarC; t++)
369 {
370 allobjects[t].componentarray = nullptr;
371 allobjects[t].components = 0;
372
373 _lseek(universe, t * 1000 + 999 + 0, SEEK_SET); // To 0
374 _read(universe, &allobjects[t].type, 2);
375 // Server overwrites this value for the docks
376 _lseek(universe, t * 1000 + 999 + 2, SEEK_SET); // To 2
377 _read(universe, &allobjects[t].revoffset, 4);
378 // Unused for the docks
379 _lseek(universe, t * 1000 + 999 + 6, SEEK_SET); // To 6
380 _read(universe, &allobjects[t].rotoffset, 4);
381 _lseek(universe, t * 1000 + 999 + 10, SEEK_SET); // To 10
382 _read(universe, &allobjects[t].inclination, 4);
383 _lseek(universe, t * 1000 + 999 + 14, SEEK_SET); // To 14
384 _read(universe, &allobjects[t].range, 4);
385 _lseek(universe, t * 1000 + 999 + 18, SEEK_SET); // To 18
386 _read(universe, &allobjects[t].rotation, 4);
387 _lseek(universe, t * 1000 + 999 + 22, SEEK_SET); // To 22
388 _read(universe, &allobjects[t].revolution, 4);
389 _lseek(universe, t * 1000 + 999 + 26, SEEK_SET); // To 26
390 _read(universe, &allobjects[t].scale, 4);
391 _lseek(universe, t * 1000 + 999 + 30, SEEK_SET); // To 30
392 _read(universe, &allobjects[t].tilt, 4);
393 _lseek(universe, t * 1000 + 999 + 64, SEEK_SET); // To 30
394 _read(universe, &allobjects[t].bound, 4);
395
397 allobjects[t].speed = 0.09f + RandomFloat() * 0.02f; // 45-55
399 allobjects[t].powered = false;
400 }
401
402 _close(universe);
403
404 // -----------------------------------------------------------------------------------------
405 // Sort the dynamic universe objects
406 // -----------------------------------------------------------------------------------------
407 bool swapflag;
408 s_universe_object tempobject;
409 do
410 {
411 swapflag = false;
412 for (short t = 0; t < maxstarC - 1; t++)
413 {
414 if (allobjects[t].type < allobjects[t + 1].type)
415 {
416 tempobject = allobjects[t];
417 allobjects[t] = allobjects[t + 1];
418 allobjects[t + 1] = tempobject;
419 swapflag = true;
420 }
421 }
422 } while (swapflag);
423
424
425 strcpy_s(msg, sizeof msg, "Types in sort order:");
426 for (short t = 0; t < maxstarC; t++)
427 {
428 sprintf_s(msg, sizeof msg, "%s %i", msg, allobjects[t].type);
429
430 if (allobjects[t].type == -1) // Vieneo
431 ourmoonC = static_cast<unsigned char>(t);
432 if (allobjects[t].type == -11) // Lower cloud layer
433 cloudBaseObjC = static_cast<unsigned char>(t);
434 if (allobjects[t].type == -2) // Upper cloud layer
435 {
436 UCLobjC = static_cast<unsigned char>(t);
438 }
439 if (allobjects[t].type == -7) // Sun
440 ourstarC = static_cast<unsigned char>(t);
441 if (allobjects[t].type == -3) // Iomere
442 ourplanetC = static_cast<unsigned char>(t);
443 }
444 logger->Log(msg);
445
446 logger->Log("Viewscreen Initialize() Done!");
447}
448
450{
451 logger->AddToCallStack("Viewscreen::OnCreateDevice");
452
453 sprintf_s(msg, sizeof msg, "Viewscreen OnCreateDevice() DS %i", gameclass->displaystage);
454 logger->Log(msg);
455
456 RiseMath::Vector3 tempnormal;
457
458 sprintf_s(msg, sizeof msg, "Version: %i.%i.%i.%i Mode: %S", gameclass->GUI->major, gameclass->GUI->minor, gameclass->GUI->build, gameclass->GUI->revision, Rendering::ClientDeviceStats());
459 logger->Log(msg);
460
461 HRESULT hr;
462
463 // this is used on legacy cockpit monitors which don't vary DPI
464 // we are also using this now for the "loading" page WHICH IS A PROBLEM @bug https://jira.risetvp.com/view.php?id=1344
465 // also used for FLIGHT FREEZE on projection screen
466 // Courier New is a default Windows font
467 AddFontResourceEx(L"Fonts\\cour.ttf", FR_PRIVATE, nullptr);
468 int nHeight = -9 * 96 / 72;
469 if (FAILED(hr = Rendering::CreateFontW(pd3dDevice, nHeight, 0, FW_MEDIUM, 1, false, DEFAULT_CHARSET,
470 OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
471 TEXT("Courier New"), &m_pFont)))
472 {
473 logger->Log("Error creating font for monitors...", Logger::Level::Error);
474 return hr;
475 }
476 gameclass->AddTrackedResource("m_pFont", Rendering::ResourcePool::Device); // really adds just 1, now 38
477
478 // This is for the exterior name plate license plate font which as a render target doesn't vary DPI
479 // this is a built-in Windows font
480 AddFontResourceEx(L"Fonts\\LicensePlate.ttf", FR_PRIVATE, nullptr);
481 if (FAILED(hr = Rendering::CreateFontW(pd3dDevice, 24, 0, FW_MEDIUM, 1, false, DEFAULT_CHARSET,
482 OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
483 TEXT("License Plate"), &m_pFontLicense)))
484 {
485 logger->Log("Error creating font for exterior name plate license plate...", Logger::Level::Error);
486 return hr;
487 }
488 gameclass->AddTrackedResource("m_pFontLicense", Rendering::ResourcePool::Device); // really adds just 1, now 39
489
490 // This one is a render target only so no scaling based on desktop DPI, used for interior name plate and gear indication
491 // this is a built-in Windows font
492 AddFontResourceEx(L"Fonts\\pala.ttf", FR_PRIVATE, nullptr);
493 nHeight = -9 * 96 / 72;
494 if (FAILED(hr = Rendering::CreateFontW(pd3dDevice, nHeight, 0, FW_SEMIBOLD, 1, false, DEFAULT_CHARSET,
495 OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
496 TEXT("Palatino Linotype"), &m_pFontNamePlate)))
497 {
498 sprintf_s(msg, sizeof msg, "Error creating font for interior name plate: %S", Rendering::ErrorString(hr));
500 return E_FAIL;
501 }
502 // This one is a render target only so no scaling based on desktop DPI, used for interior name plate and gear indication
503 gameclass->AddTrackedResource("m_pFont3", Rendering::ResourcePool::Device); // really adds just 1, now 40
504
505
506
507 // This is for the exterior name plate Manx font which as a render target doesn't vary DPI
508 // this is a built-in Windows font
509 AddFontResourceEx(L"Fonts\\rcaf6-GIMP.ttf", FR_PRIVATE, nullptr);
510 if (FAILED(hr = Rendering::CreateFontW(pd3dDevice, 9, 6, FW_SEMIBOLD, 1, false, DEFAULT_CHARSET,
511 OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
512 TEXT("RCAF_60SQO_ATH_GIMP"), &m_pFontHull)))
513 {
514 sprintf_s(msg, sizeof msg, "Error creating font for exterior name plate: %S", Rendering::ErrorString(hr));
516 return E_FAIL;
517 }
518 gameclass->AddTrackedResource("m_pFontHull", Rendering::ResourcePool::Device); // really adds just 1, now 41
519
520
522 gameclass->AddTrackedResource("m_spriteVector", Rendering::ResourcePool::Device); // actually adds 2, now 43
523
524
525 logger->Log("InitDeviceObjects() font for HUD loaded!");
526
527
528 logger->Log("Viewscreen::OnCreateDevice() creating vertex buffers...");
529
530 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(starsC * sizeof(RiseStaticstarsVertex),
533 {
534 logger->Log("CreateVertexBuffer m_avStaticStars failed!", Logger::Level::Error);
535 return hr;
536 }
537 gameclass->AddTrackedResource("m_avStaticStars"); // managed
538
539 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(LandingLights::FogVertexCount * sizeof(RiseSkydomeVertex),
542 {
543 logger->Log("CreateVertexBuffer m_avCone failed!", Logger::Level::Error);
544 return hr;
545 }
546 gameclass->AddTrackedResource("m_avCone"); // managed
547
548 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(4 * sizeof(RiseNonormalVertex),
551 {
552 logger->Log("CreateVertexBuffer m_avBillboardVertices failed!", Logger::Level::Error);
553 return hr;
554 }
555 gameclass->AddTrackedResource("m_avBillboardVertices"); // managed
556
557 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(runninglightsC * sizeof(RiseNopsizeVertex),
560 {
561 logger->Log("CreateVertexBuffer m_avRunningLights failed!", Logger::Level::Error);
562 return hr;
563 }
564 gameclass->AddTrackedResource("m_avRunningLights"); // managed
565
566 if (FAILED(hr = pd3dDevice->CreateIndexBuffer(cloudindicesC * 2L, // 2 bytes per short
569 {
570 logger->Log("CreateVertexBuffer m_aiCloudGrid failed!", Logger::Level::Error);
571 return hr;
572 }
573 gameclass->AddTrackedResource("m_aiCloudGrid"); // managed
574
575 //if (FAILED(pd3dDevice->CreateIndexBuffer(35540L, // 2 bytes per short
576 // Rendering::BufferUsage::WRITEONLY, Rendering::ImageFormat::Index16,
577 // Rendering::ResourcePool::Managed, &game->m_aiLocalGrid, NULL)))
578 // return E_OUTOFMEMORY;
579
580 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(visiblevertC * sizeof(RiseLocalgrid2Vertex),
583 {
584 logger->Log("CreateVertexBuffer m_avLocalGrid failed!", Logger::Level::Error);
585 return hr;
586 }
587 gameclass->AddTrackedResource("m_avLocalGrid"); // managed
588
589 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(4096 * sizeof(RiseLocalgridVertex),
592 {
593 logger->Log("CreateVertexBuffer m_avCloudGrid failed!", Logger::Level::Error);
594 return hr;
595 }
596 gameclass->AddTrackedResource("m_avCloudGrid"); // managed
597
598 logger->Log("Viewscreen::OnCreateDevice() created all static vertex/index buffers!");
599
600 // ChangeCockpit polyobjects *************************************************************************
601
602 RiseNopsizeVertex* vtx2 = nullptr;
603 unsigned char offset = 0;
604 V(m_avRunningLights->Lock(0, 0, reinterpret_cast<void**>(&vtx2), 0));
605 int runningVerts = 0;
606
607 vtx2->x = 0.0f;
608 vtx2->z = 0.0f;
609 vtx2->y = 0.0f;
610 vtx2->diffuse = 0xFFFFFFFF;
611 offset++;
612 vtx2++;
613 runningVerts++;
614
615 int handle = -1, t = 0;
616 long s = 0;
617 RiseVertex2Vertex* vtx = nullptr;
618 for (t = 0; t < maxpolyC; t++)
619 {
620 if (t == 5 && polyobjects[t].VB)
621 {
622 // The selected interior is not one of the static DAW meshes below.
623 // Restore its authored bytes without reloading/resetting vehicle state.
624 V_RETURN(polyobjects[t].VB->Geometry().RestoreDevice(pd3dDevice->Native()));
625 gameclass->UpdateTrackedResource("polyobjects[5].VB", 2);
626 logger->Log("Restored selected cockpit geometry after device replacement");
627 continue;
628 }
629 bool skip = false;
630 handle = -1;
631 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
632 switch (t)
633 {
634 // Iomere
635 case 0: _sopen_s(&handle, "Meshes\\farspher.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
636 break;
637 // Docks
638 case 1:
639 skip = true;
640 break;
641 case 2: _sopen_s(&handle, "Meshes\\sphere.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
642 break;
643 case 3: _sopen_s(&handle, "Meshes\\E-10.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
644 break;
645 case 4: _sopen_s(&handle, "Meshes\\cargo-standard.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
646 polyobjects[t].overlay = true;
647 break;
648 // Cockpits and Interiors
649 case 5:
650 skip = true;
651 break;
652 case 6: _sopen_s(&handle, "Meshes\\T-8 Wanderer.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
653 break;
654 case 7: _sopen_s(&handle, "Meshes\\dihv.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
655 polyobjects[t].overlay = true;
656 break;
657 case 8: _sopen_s(&handle, "Meshes\\C-98 MuVER-construction.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
658 polyobjects[t].overlay = true;
659 break;
660 case 9: _sopen_s(&handle, "Meshes\\p-13.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
661 break;
662 case 10: _sopen_s(&handle, "Meshes\\C-2 Dasher.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
663 polyobjects[t].overlay = true;
664 break;
665 case 11: _sopen_s(&handle, "Meshes\\T-120 Steerhead-stock.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
666 polyobjects[t].overlay = true;
667 break;
668 case 12: _sopen_s(&handle, "Meshes\\E-11.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
669 polyobjects[t].overlay = true;
670 break;
671 case 13: _sopen_s(&handle, "Meshes\\WEP-WVM1-hornet.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
672 break;
673 case 14: _sopen_s(&handle, "Meshes\\C-2A Dasher.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
674 polyobjects[t].overlay = true;
675 break;
676 case 15: _sopen_s(&handle, "Meshes\\2007 T-120 EXT.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
677 polyobjects[t].overlay = true;
678 break;
679 case 16: _sopen_s(&handle, "Meshes\\manx-hex.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
680 polyobjects[t].overlay = true;
681 break;
682 case 17: _sopen_s(&handle, "Meshes\\BeishtKione.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
683 break;
684 case 18: _sopen_s(&handle, "Meshes\\fuel-standard-ext.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
685 polyobjects[t].overlay = true;
686 break;
687 case 19: _sopen_s(&handle, "Meshes\\T-19 Stratomaster.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
688 polyobjects[t].overlay = true;
689 break;
690 case 20: _sopen_s(&handle, "Meshes\\cargo-toploader.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
691 polyobjects[t].overlay = true;
692 break;
693 case 21: _sopen_s(&handle, "Meshes\\munitions-standard-ext.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
694 break;
695 case 22: _sopen_s(&handle, "Meshes\\Holidays\\Spacesuit-Morholt-posed.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
696 break;
697 case 23: _sopen_s(&handle, "Meshes\\pax-exterior-hex.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
698 polyobjects[t].overlay = true;
699 break;
700 case 24: _sopen_s(&handle, "Meshes\\T-27 Mammoth.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
701 polyobjects[t].overlay = true;
702 break;
703 }
704 if (handle == -1 && !skip) // disregard cockpit and docks
705 {
706 char strerr[99];
707 strerror_s(strerr, 99, errno);
708 sprintf_s(msg, sizeof(msg), "Could not load polygon object (DAW file) number %i: %s", t, strerr);
710 }
711
712
713 // Vertices -----------------------------------------------------------------------------
714 if (!skip) // disregard cockpit and docks
715 {
716 _lseek(handle, 0L, SEEK_SET);
717 _read(handle, &polyobjects[t].vertices, 2);
718 sprintf_s(msg, sizeof(msg), "Loading file (%i vertices) for polygon object number %i...", polyobjects[t].vertices, t);
719 logger->Log(msg);
720 }
721 else
722 {
723 if (t == 5)
725 else if (t == 1)
727 else
728 polyobjects[t].vertices = 0;
729 }
731
732
733 if (t == 2) // Vieneo sphere is dynamic
735 else if (polyobjects[t].vertices)
736 {
737 // Create the vertex buffer
738 sprintf_s(msg, sizeof(msg), "Creating memory (%i vertices) for polygon object number %i...", polyobjects[t].vertices, t);
739 logger->Log(msg);
740 if (skip) // cockpits and docks are still RiseVertexVertex ... we have to fix ship rendering to support it and weapon mesh and Iomere (even though they don't need it)
741 {
742 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(static_cast<long>(polyobjects[t].vertices) * sizeof RiseVertexVertex,
745 {
746 sprintf_s(msg, sizeof(msg), "Could not create memory (%i vertices) for polygon object number %i!", polyobjects[t].vertices, t);
747 logger->Log(msg);
748 return hr;
749 }
750 }
751 else
752 {
753 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(static_cast<long>(polyobjects[t].vertices) * sizeof RiseVertex2Vertex,
756 {
757 sprintf_s(msg, sizeof msg, "Could not create memory (%i vertices) for polygon object number %i!", polyobjects[t].vertices, t);
758 logger->Log(msg);
759 return hr;
760 }
761 }
762 sprintf_s(msg, sizeof msg, "polyobjects[%i].VB", t);
763 gameclass->AddTrackedResource(msg); // managed
764
765 // Lock the vertex buffer
766 if (!skip) // disregard cockpit and docks
767 {
768 V(polyobjects[t].VB->Lock(0, 0, reinterpret_cast<void**>(&vtx), 0));
769 }
770 }
771
772 if (!skip) // disregard cockpit and docks
773 {
774 for (s = 0; s < polyobjects[t].vertices; s++)
775 {
776 //if (polyobjects[t].overlay)
777 // _lseek(handle, 2L + s * 40L + 0L, SEEK_SET);
778 //else
779 // _lseek(handle, 2L + s * 32L + 0L, SEEK_SET);
780 _read(handle, &tempnormal, 12); // position
781 if (t == 2)
782 {
783 RiseMath::Vec3Normalize(&tempnormal, &tempnormal);
784 polyextras2.vertexbackup[s].x = tempnormal.x / 0.99879f; // so that lowest point
785 polyextras2.vertexbackup[s].y = tempnormal.y / 0.99879f; // is equal to
786 polyextras2.vertexbackup[s].z = tempnormal.z / 0.99879f; // cloudtopsC
787 }
788 else
789 {
790 vtx->x = tempnormal.x;
791 vtx->y = tempnormal.y;
792 vtx->z = tempnormal.z;
793 }
794
795 if (t == 2)
796 {
797 RiseMath::Vec3Normalize(&tempnormal, &tempnormal); // this sphere is shaded specially
798 polyextras2.vertexbackup[s].nx = tempnormal.x;
799 polyextras2.vertexbackup[s].ny = tempnormal.y;
800 polyextras2.vertexbackup[s].nz = tempnormal.z;
801 //_lseek(handle, 2L + s * 32L + 24L, SEEK_SET);
802 _lseek(handle, 12L, SEEK_CUR); // jump past normals
803 _read(handle, &polyextras2.vertexbackup[s].tu, 4);
804 _read(handle, &polyextras2.vertexbackup[s].tv, 4);
805 }
806 else
807 {
808 if (t == 0) // Iomere is spherically shaded
809 {
810 RiseMath::Vec3Normalize(&tempnormal, &tempnormal);
811 _lseek(handle, 12L, SEEK_CUR); // jump past normals
812 }
813 else
814 {
815 //_lseek(handle, 2L + s * 32L + 12L, SEEK_SET);
816 _read(handle, &tempnormal, 12);
817 }
818 vtx->nx = tempnormal.x;
819 vtx->ny = tempnormal.y;
820 vtx->nz = tempnormal.z;
821 //_lseek(handle, 2L + s * 32L + 24L, SEEK_SET);
822 _read(handle, &tempnormal.x, 4);
823 _read(handle, &tempnormal.y, 4);
824 vtx->tu = tempnormal.x;
825 vtx->tv = tempnormal.y;
826 if (polyobjects[t].overlay)
827 {
828 _read(handle, &tempnormal.x, 4);
829 _read(handle, &tempnormal.y, 4);
830 vtx->tu2 = tempnormal.x;
831 vtx->tv2 = tempnormal.y;
832 }
833 else
834 vtx->tu2 = vtx->tv2 = 0.0f;
835 vtx++;
836 }
837 }
838
839 if (t != 2)
840 {
841 if (polyobjects[t].VB)
842 {
843 V(polyobjects[t].VB->Unlock());
844 }
845 }
846 else
847 {
848 // For the upper cloud layer map
849 for (s = 0; s < polyobjects[t].polygons; s++)
850 {
851 polyextras2.center[s].x = polyextras2.vertexbackup[s * 3 + 0].x + polyextras2.vertexbackup[s * 3 + 1].x + polyextras2.vertexbackup[s * 3 + 2].x;
852 polyextras2.center[s].y = polyextras2.vertexbackup[s * 3 + 0].y + polyextras2.vertexbackup[s * 3 + 1].y + polyextras2.vertexbackup[s * 3 + 2].y;
853 polyextras2.center[s].z = polyextras2.vertexbackup[s * 3 + 0].z + polyextras2.vertexbackup[s * 3 + 1].z + polyextras2.vertexbackup[s * 3 + 2].z;
856 polyextras2.index[s] = static_cast<short>(s);
857 }
858 }
859
860
861
862 polyobjects[t].effects.clear();
865 // Lighting Effects ---------------------------------------------------------------------
866 switch (t)
867 {
868 case 3: // E-10 Saint
869 case 6: // A-4
870 case 7: // DIHV
871 case 8: // MuVER C-98
872 case 9: // P-13 Prowler
873 case 10: // C-2 Dasher
874 case 11: // T-120 Steerhead
875 case 12: // E-11
876 case 14: // C-2A Dasher
877 case 15: // T-1 Stratoranger
878 case 16: // W-6 Manx
879 case 18: // Aux. Fuel ARJ
880 case 19: // T-19 Stratomaster
881 case 24: // T-27 Mammoth
882 {
883 short numberOfEffects;
884 _read(handle, &numberOfEffects, 2);
885 sprintf_s(msg, sizeof(msg), "OnCreateDevice loading %i light(s) for polygon object number %i...", numberOfEffects, t);
886 logger->Log(msg);
887 for (s = 0; s < numberOfEffects; s++)
888 {
889 s_light_effect newEffect;
890 _read(handle, &vtx2->x, 4);
891 _read(handle, &vtx2->y, 4);
892 _read(handle, &vtx2->z, 4);
893 newEffect.position.x = vtx2->x;
894 newEffect.position.y = vtx2->y;
895 newEffect.position.z = vtx2->z;
896 _read(handle, &newEffect.normal, 12);
897 _read(handle, &vtx2->diffuse, 4);
898 newEffect.diffuse = vtx2->diffuse;
899 _read(handle, &newEffect.sequencing, 4);
900 _read(handle, &newEffect.speed, 4); // unused
901 _read(handle, &newEffect.power, 4);
902 _read(handle, &newEffect.attachto, 2);
903 newEffect.primitive = offset;
904 polyobjects[t].effects.emplace_back(newEffect);
905 offset++;
906 vtx2++;
907 runningVerts++;
908 }
909 }
910 break;
911 }
912
914 polyobjects[t].effects, polyobjects[t].landingLights);
915
916 if (handle != -1)
917 _close(handle); // close DAW file
918 }
919 }
920
921 if (runningVerts > runninglightsC)
922 {
923 logger->Log("runningVerts > runninglightsC", Logger::Level::Fatal);
924 }
925
927
928
929 float f_temp;
930 short i_temp;
931 // SHOULD BE ABLE TO DUMP COMPONENTARRAY UNTIL THE DAW IS LOADED ON THESE FOR EXTRA MEMORY
932 for (t = 0; t < maxstarC; t++)
933 {
934 if (t < maxdockC)
935 {
936 if (t == 0)
937 {
938 _sopen_s(&handle, "Meshes\\cutters.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
939 if (handle == -1)
940 {
941 logger->Log("Viewscreen::OnCreateDevice() failed to load \"Meshes\\cutters.dix\"!", Logger::Level::Error);
942 char strerr[99];
943 strerror_s(strerr, 99, errno);
945 }
946 }
947 else if (t == 1)
948 {
949 _sopen_s(&handle, "Meshes\\easydock.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
950 if (handle == -1)
951 {
952 logger->Log("Viewscreen::OnCreateDevice() failed to load \"Meshes\\easydock.dix\"!", Logger::Level::Error);
953 char strerr[99];
954 strerror_s(strerr, 99, errno);
956 }
957 }
958 else if (t == 2)
959 {
960 _sopen_s(&handle, "Meshes\\sentry station 12.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
961 if (handle == -1)
962 {
963 logger->Log("Viewscreen::OnCreateDevice() failed to load \"Meshes\\sentry station 12.dix\"!", Logger::Level::Error);
964 char strerr[99];
965 strerror_s(strerr, 99, errno);
967 }
968 }
969
970 _lseek(handle, 0, SEEK_SET);
971 _read(handle, &allobjects[t].components, 2);
972
973
974 sprintf_s(msg, sizeof msg, "allobjects[%i].componentarray", t);
975 if (allobjects[t].componentarray)
976 {
977 SAFE_DELETE_ARRAY(allobjects[t].componentarray);
979 }
981 if (allobjects[t].componentarray == nullptr)
982 {
983 sprintf_s(msg, sizeof(msg), "Failed to initialize %i components for dock mesh %i", allobjects[t].components, t);
984 logger->Log(msg);
985 return E_OUTOFMEMORY;
986 }
987 gameclass->AddTrackedResource(msg); // managed, memory only
988
989
990 sprintf_s(msg, sizeof(msg), "Initialized %i components for dock mesh %i", allobjects[t].components, t);
991 logger->Log(msg);
992
993 for (s = 0; s < allobjects[t].components; s++)
994 {
995 _lseek(handle, s * 100L + 99L, SEEK_SET); // To 0
996 _read(handle, &i_temp, 2); // 2
997 allobjects[t].componentarray[s].startvertex = (UINT)i_temp;
998 _read(handle, &i_temp, 2); // 4
999 allobjects[t].componentarray[s].primitives = (UINT)i_temp;
1000 _read(handle, &allobjects[t].componentarray[s].nominalxyz, 12); // 16
1001 _read(handle, &allobjects[t].componentarray[s].nominalypr, 12); // 28
1002 _read(handle, &allobjects[t].componentarray[s].boundsphere, 4); // 32
1003 _read(handle, &allobjects[t].componentarray[s].extendby, 12); // 44
1004 _read(handle, &allobjects[t].componentarray[s].texture, 2); // 46
1005
1006 // 12 unused bytes
1007
1008 _lseek(handle, 12, SEEK_CUR); // To 58
1009 _read(handle, &allobjects[t].componentarray[s].type, 1); // 59
1010
1011 allobjects[t].componentarray[s].extended = 0.0f; // Current extended %
1012 }
1013 _close(handle);
1014 }
1015 else
1016 {
1017 allobjects[t].components = 0;
1018 }
1019 }
1020
1021
1022
1023
1024 // STATIC STARS STUFF
1025 _sopen_s(&handle, "Meshes\\starlist.daw", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
1026 if (handle == -1)
1027 {
1028 logger->Log("Viewscreen::OnCreateDevice() failed to load \"Meshes\\STARLIST.DAW\"!", Logger::Level::Error);
1029 char strerr[99];
1030 strerror_s(strerr, 99, errno);
1032 }
1033
1035 RiseMath::Vector3 temp;
1036 RiseMath::Color tempcolor;
1037 unsigned char chtemp;
1038
1039 // Lock the vertex buffer
1040 V(m_avStaticStars->Lock(0, 0, reinterpret_cast<void**>(&vtxs), 0));
1041
1042 for (t = 0; t < starsC; t++)
1043 {
1044 _lseek(handle, static_cast<long>(t) * 19L, SEEK_SET); // To 28
1045 _read(handle, &temp, 12);
1046
1047 RiseMath::Vec3Normalize(&temp, &temp);
1048 vtxs->x = temp.x; vtxs->y = temp.y; vtxs->z = temp.z;
1049
1050 _read(handle, &f_temp, 4);
1051 vtxs->psize = powf(f_temp, 2.512f) * 4.0f; // 4 pixels across for smallest one
1052
1053 _read(handle, &chtemp, 1); tempcolor.r = static_cast<float>(chtemp) / 255.0f;
1054 _read(handle, &chtemp, 1); tempcolor.g = static_cast<float>(chtemp) / 255.0f;
1055 _read(handle, &chtemp, 1); tempcolor.b = static_cast<float>(chtemp) / 255.0f;
1056 vtxs->diffuse = tempcolor;
1057 vtxs++;
1058 }
1059
1061
1062
1063 const auto mode = *Rendering::ClientBackBufferDescription();
1064
1065 if (FAILED(hr = Rendering::CreateRenderToSurface(pd3dDevice, 907, 352, mode.Format, true, Rendering::ImageFormat::Depth24Stencil8, &m_pRenderToSurface)))
1066 {
1067 logger->Log("Could not CreateRenderToSurface for size 1", Logger::Level::Error);
1068 return hr;
1069 }
1071
1072 if (FAILED(hr = Rendering::CreateRenderToSurface(pd3dDevice, 1135, 388, mode.Format, true, Rendering::ImageFormat::Depth24Stencil8, &m_pRenderToSurfaceNextGen)))
1073 {
1074 logger->Log("Could not CreateRenderToSurface for size NextGen", Logger::Level::Error);
1075 return hr;
1076 }
1077 gameclass->AddTrackedResource("m_pRenderToSurfaceNextGen", Rendering::ResourcePool::Device);
1078
1079 if (FAILED(hr = Rendering::CreateRenderToSurface(pd3dDevice, 256, 128, mode.Format, false, Rendering::ImageFormat::Unknown, &m_pHullRender2Surface)))
1080 {
1081 logger->Log("Could not CreateRenderToSurface for size 2", Logger::Level::Error);
1082 return hr;
1083 }
1085
1086
1088
1089
1090 // Check to see if device supports visibility query
1091 m_bDeviceSupportsVizQuery = pd3dDevice->CreateQuery(0, nullptr) == S_OK;
1092
1093 ptrInstruments->OnCreateDevice(pd3dDevice);
1094
1095 logger->Log("Viewscreen::OnCreateDevice() exiting successfully!");
1096
1097 return S_OK;
1098}
1099
1101{
1102 logger->AddToCallStack("Viewscreen::SetProjectionMatrices");
1103
1104 f_compareFOV = sqrtf(powf(g_fFOV * 0.5f, 2.0f) + powf(g_fFOV * 0.5f * fAspect, 2.0f));
1105
1109
1110 RiseMath::Matrix matrixTemp;
1111 RiseMath::MatrixRotationZ(&matrixTemp, RiseMath::Pi); // ANSI standard is upside-down
1115}
1116
1118{
1120 // Post back to the UI message loop: never open a modal window from a
1121 // device-reset callback or in the middle of a D3D scene.
1124 logger->Log("Could not queue the reduced cloud effects warning", Logger::Level::Warn);
1125}
1126
1128{
1130 // A reset may have recovered the renderer before the message was handled.
1132 // Mark first: the dialog itself can trigger focus changes and device resets.
1134 MessageBoxW(owner,
1135 L"Rise is using simpler cloud rendering.\n\n"
1136 L"The following effects are unavailable:\n"
1137 L" - Volumetric cloud formations\n"
1138 L" - Cloud-top lightning flashes\n"
1139 L" - Headlight illumination inside clouds\n\n"
1140 L"You can continue playing. Details have been saved in the trace log. "
1141 L"Please include your trace log when reporting this issue.",
1142 L"Rise - Reduced cloud effects", MB_OK | MB_ICONWARNING);
1143}
1144
1146{
1147 logger->AddToCallStack("Viewscreen::OnResetDevice 1");
1148
1149 if (m_pFont == nullptr) // Create Device wasn't called yet
1150 {
1151 logger->Log("OnResetDevice before OnCreateDevice?", Logger::Level::Debug);
1152 return S_OK;
1153 }
1154
1155 logger->Log("Viewscreen::OnResetDevice() called!");
1156 const HRESULT cloudResult = cloudVolume.Initialize(pd3dDevice);
1157 logger->Log(cloudVolume.InitializationStatus().c_str(), FAILED(cloudResult) ? Logger::Level::Warn : Logger::Level::Info, cloudResult);
1158 if (FAILED(cloudResult))
1159 logger->Log("Volumetric clouds unavailable; using legacy clouds", Logger::Level::Warn, cloudResult);
1161 const HRESULT envelopeResult = reentryRenderer.Initialize(pd3dDevice->Native());
1162 if (FAILED(envelopeResult))
1163 logger->Log("Reentry envelope initialization failed", Logger::Level::Error, envelopeResult);
1164 const HRESULT boltResult = proceduralLightning.Initialize(pd3dDevice->Native());
1165 if (FAILED(boltResult))
1166 logger->Log("Procedural lightning initialization failed", Logger::Level::Error, boltResult);
1167 const HRESULT rainResult = exteriorRainRenderer.Initialize(pd3dDevice);
1168 if (FAILED(rainResult))
1169 logger->Log("Shader exterior rain unavailable; using legacy lines", Logger::Level::Warn, rainResult);
1170
1171 logger->AddToCallStack("Viewscreen::OnResetDevice 2");
1172
1173 HRESULT hr;
1174
1176 gameclass->UpdateTrackedResource("m_pFont", 2);
1177
1178 if (m_pFontLicense == nullptr)
1179 logger->Log("Viewscreen::OnResetDevice m_pFontLicense is nullptr!", Logger::Fatal);
1181 gameclass->UpdateTrackedResource("m_pFontLicense", 2);
1182 if (m_pFontNamePlate == nullptr)
1183 logger->Log("Viewscreen::OnResetDevice m_pFont3 is nullptr!", Logger::Fatal);
1185 gameclass->UpdateTrackedResource("m_pFont3", 2);
1186 if (m_pFontHull == nullptr)
1187 logger->Log("Viewscreen::OnResetDevice m_pFontHull is nullptr!", Logger::Fatal);
1189 gameclass->UpdateTrackedResource("m_pFontHull", 2);
1190 if (m_spriteVector == nullptr)
1191 logger->Log("Viewscreen::OnResetDevice m_spriteVector is nullptr!", Logger::Fatal);
1193 gameclass->UpdateTrackedResource("m_spriteVector", 2);
1194 if (m_pRenderToSurface == nullptr)
1195 logger->Log("Viewscreen::OnResetDevice m_pRenderToSurface is nullptr!", Logger::Fatal);
1197 gameclass->UpdateTrackedResource("m_pRenderToSurface", 2);
1198 if (m_pRenderToSurfaceNextGen == nullptr)
1199 logger->Log("Viewscreen::OnResetDevice m_pRenderToSurfaceNextGen is nullptr!", Logger::Fatal);
1201 gameclass->UpdateTrackedResource("m_pRenderToSurfaceNextGen", 2);
1202 if (m_pHullRender2Surface == nullptr)
1203 logger->Log("Viewscreen::OnResetDevice m_pHullRender2Surface is nullptr!", Logger::Fatal);
1205 gameclass->UpdateTrackedResource("m_pHullRender2Surface", 2);
1206
1207 logger->AddToCallStack("Viewscreen::OnResetDevice 3");
1208
1209 // Set any appropriate state
1210// pd3dDevice->SetRenderState( Rendering::RenderState::AMBIENT, 0L ); // 0L is default
1211 pd3dDevice->SetRenderState(Rendering::RenderState::ZENABLE, TRUE);//USEW ); // false is default with exceptions
1212 // pd3dDevice->SetRenderState( Rendering::RenderState::FILLMODE, Rendering::Fill::SOLID ); // SOLID is default
1213 // pd3dDevice->SetRenderState( Rendering::RenderState::SHADEMODE, 2 ); // GOURAUD is default
1214 // pd3dDevice->SetRenderState( Rendering::RenderState::DITHERENABLE, false ); // false is default
1215 // pd3dDevice->SetRenderState( Rendering::RenderState::SPECULARENABLE, false ); // false is default
1216 // pd3dDevice->SetRenderState( Rendering::RenderState::LOCALVIEWER, true ); // true is default
1217 // pd3dDevice->SetRenderState( Rendering::RenderState::ANTIALIASEDLINEENABLE, true ); // false is default
1218 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILENABLE, true); //g_bAboveClouds ); // false is default
1219 // pd3dDevice->SetRenderState( Rendering::RenderState::CLIPPING, true ); // true is default
1220 // pd3dDevice->SetRenderState( Rendering::RenderState::LIGHTING, true ); // true is default
1221 pd3dDevice->SetRenderState(Rendering::RenderState::NORMALIZENORMALS, true); // false is default
1223
1224 // @todo get rid of this block when we switch BCL cloud bases to use shaders
1225 // pd3dDevice->SetRenderState(Rendering::RenderState::FOGENABLE, false); // false is default, only used for BCL cloud bases
1227 // pd3dDevice->SetRenderState( Rendering::RenderState::FOGSTART, 0.0f ); // 0.0f is default
1228 pd3dDevice->SetRenderState(Rendering::RenderState::RANGEFOGENABLE, true); // false is default
1229
1230 pd3dDevice->SetRenderState(Rendering::RenderState::COLORWRITEENABLE, //Rendering::ColorWrite::ALPHA |
1234
1235 pd3dDevice->SetRenderState(Rendering::RenderState::POINTSPRITEENABLE, true); // false is default
1236 // pd3dDevice->SetRenderState( Rendering::RenderState::POINTSCALEENABLE, false ); // false is default
1237
1238 // pd3dDevice->SetSamplerState( 0, Rendering::SamplerState::BORDERCOLOR, 0L ); // 0L is default
1239
1240 logger->AddToCallStack("Viewscreen::OnResetDevice 4");
1241
1242 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::ALPHAARG1, Rendering::TextureArgument::TEXTURE ); // TEXTURE is default
1243 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE ); // MODULATE is default
1244 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE ); // TEXTURE is default
1246
1247 logger->AddToCallStack("Viewscreen::OnResetDevice 5");
1248
1249 // Get the aspect ratio
1250 fAspect = (float)pBackBufferSurfaceDesc->Height / (float)pBackBufferSurfaceDesc->Width;
1251
1253
1254 logger->AddToCallStack("Viewscreen::OnResetDevice 6");
1255
1256 // Set up the material
1257 restore.Diffuse.r = 1.0f; restore.Diffuse.g = 1.0f; restore.Diffuse.b = 1.0f; restore.Diffuse.a = 0.0f;
1259 restore.Emissive.r = 0.0f; restore.Emissive.g = 0.0f; restore.Emissive.b = 0.0f; restore.Emissive.a = 0.0f;
1261 restore.Power = 0.0f;
1262 pd3dDevice->SetMaterial(&restore);
1263
1264 logger->AddToCallStack("Viewscreen::OnResetDevice 7");
1265
1266 // Set up the sunlight ----------------------------------------------------------------------
1267 ZeroMemory(&sunlight, sizeof Rendering::Light);
1270 pd3dDevice->SetLight(0, &sunlight);
1271 pd3dDevice->LightEnable(0, true);
1272 // Set up the sunlight ----------------------------------------------------------------------
1273
1274 logger->AddToCallStack("Viewscreen::OnResetDevice 8");
1275
1276
1277
1278 logger->AddToCallStack("Viewscreen::OnResetDevice 9");
1279
1280 logger->Log("Viewscreen::OnResetDevice creating vertex buffers...");
1281
1282 if (!m_avSkyDome)
1283 {
1284 if (FAILED(hr = pd3dDevice->CreateVertexBuffer((skydomeC + 2) * sizeof(RiseSkydomeVertex),
1287 return hr;
1289 }
1290
1291 if (!m_avSkyRing)
1292 {
1293 if (FAILED(hr = pd3dDevice->CreateVertexBuffer((SkyRingRenderer::Segments * 2 + 2) * sizeof(RiseSkyringVertex),
1296 return hr;
1298 }
1299
1300 if (!m_avScreen)
1301 {
1302 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(4 * sizeof(RiseScreenVertex),
1305 return hr;
1307 }
1308
1309 if (!m_avInstrument)
1310 {
1311 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(12 * sizeof(RiseInstrumentVertex),
1314 return hr;
1316 }
1317
1318 if (!m_avRainDrops)
1319 {
1320 if (FAILED(hr = pd3dDevice->CreateVertexBuffer(MAX_RAINDROPS * sizeof(RiseRaindropVertex) * 2L, // every drop has a start and end position
1323 {
1324 sprintf_s(msg, sizeof msg, "CreateVertexBuffer (m_avRainDrops) returned %S", Rendering::ErrorString(hr));
1326 }
1327 else
1328 {
1330 }
1331 }
1332
1333 logger->Log("Viewscreen::OnResetDevice() created all dynamic vertex and index buffers!");
1334
1335 logger->AddToCallStack("Viewscreen::OnResetDevice 10");
1336
1338 {
1339 if (FAILED(hr = pd3dDevice->CreateQuery(0, &m_pLightSunVizQuery)))
1340 {
1341 logger->Log("Viewscreen::OnResetDevice() failed to CreateQuery even through device previously claimed to support it!", Logger::Fatal);
1342 return hr;
1343 }
1344 m_sunVizPending = false;
1346
1347 if (FAILED(hr = pd3dDevice->CreateQuery(0, &m_pNightVisionRangeQuery)))
1348 {
1349 logger->Log("Night-vision rangefinder disabled because its occlusion query could not be created.", Logger::Level::Warn);
1350 m_pNightVisionRangeQuery = nullptr;
1351 }
1352 else
1353 {
1354 gameclass->AddTrackedResource("m_pNightVisionRangeQuery", Rendering::ResourcePool::Device);
1355 }
1356 }
1359 m_nightVisionRangeKm = -1.0f;
1360
1361 logger->AddToCallStack("Viewscreen::OnResetDevice 11");
1362
1363 // Dynamic textures ------------------------------------------------------------------
1365 V_RETURN(ptrCockpit->OnResetDevice(pd3dDevice));
1366
1367 logger->AddToCallStack("Viewscreen::OnResetDevice 12");
1368
1369 if (FAILED(hr = Rendering::CreateTexture(pd3dDevice, 1135, 388, 1, Rendering::BufferUsage::RENDERTARGET,
1371 {
1372 logger->Log("Viewscreen::OnResetDevice() failed to create projection texture!", Logger::Fatal);
1373 return hr;
1374 }
1376
1378 {
1379 logger->Log("Viewscreen::OnResetDevice() failed to get projection surface!", Logger::Fatal);
1380 return hr;
1381 }
1383
1384 ptrInstruments->OnResetDevice(pd3dDevice, pBackBufferSurfaceDesc);
1385
1386 logger->Log("Viewscreen::OnResetDevice() exited successfully!");
1387
1388 logger->AddToCallStack("Viewscreen::OnResetDevice END");
1389
1390 return S_OK;
1391}
1392
1394{
1395 logger->AddToCallStack("Viewscreen::OnLostDevice");
1396 logger->Log("ViewScreen::OnLostDevice() called!");
1401 reentryState = {};
1402 reentryWindward = {};
1405
1406
1407 // pd3dDevice->SetTexture( 0, NULL );
1408 // pd3dDevice->SetTexture( 1, NULL );
1409 // pd3dDevice->SetTexture( 2, NULL );
1410 // pd3dDevice->SetTexture( 3, NULL );
1411 // pd3dDevice->SetTexture( 4, NULL );
1412 // pd3dDevice->SetStreamSource( 0, NULL, 0, 0 );
1413
1414 //Throws exeption here because the stuff below is no longer set
1415
1416
1417 if (m_pFont)
1418 {
1420 gameclass->UpdateTrackedResource("m_pFont", 1);
1421 }
1422 if (m_pFontLicense)
1423 {
1425 gameclass->UpdateTrackedResource("m_pFontLicense", 1);
1426 }
1427 if (m_pFontNamePlate)
1428 {
1430 gameclass->UpdateTrackedResource("m_pFont3", 1);
1431 }
1432 if (m_pFontHull)
1433 {
1435 gameclass->UpdateTrackedResource("m_pFontHull", 1);
1436 }
1437
1438 if (m_spriteVector)
1439 {
1441 gameclass->UpdateTrackedResource("m_spriteVector", 1);
1442 }
1444 {
1446 gameclass->UpdateTrackedResource("m_pRenderToSurface", 1);
1447 }
1449 {
1451 gameclass->UpdateTrackedResource("m_pRenderToSurfaceNextGen", 1);
1452 }
1454 {
1456 gameclass->UpdateTrackedResource("m_pHullRender2Surface", 1);
1457 }
1458
1459
1460 // Release dynamic vertex/index buffers
1461 if (m_avSkyDome)
1462 {
1464 gameclass->UpdateTrackedResource("m_avSkyDome", 1);
1465 }
1466 if (m_avSkyRing)
1467 {
1469 gameclass->UpdateTrackedResource("m_avSkyRing", 1);
1470 }
1471 if (m_avScreen)
1472 {
1474 gameclass->UpdateTrackedResource("m_avScreen", 1);
1475 }
1476 if (m_avInstrument)
1477 {
1479 gameclass->UpdateTrackedResource("m_avInstrument", 1);
1480 }
1481 if (m_avRainDrops)
1482 {
1484 gameclass->UpdateTrackedResource("m_avRainDrops", 1);
1485 }
1487 {
1489 gameclass->UpdateTrackedResource("m_pLightSunVizQuery", 1);
1490 }
1492 {
1494 gameclass->UpdateTrackedResource("m_pNightVisionRangeQuery", 1);
1495 }
1498
1499 if (ptrCockpit)
1501
1503 {
1505 gameclass->UpdateTrackedResource("m_pddsProjectionTexture", 1);
1506 }
1508 {
1510 gameclass->UpdateTrackedResource("m_pddsProjectionSurface", 1);
1511 }
1512
1513 for (short t = 0; t < MAX_SCAN; t++)
1514 {
1516 {
1517 sprintf_s(msg, sizeof(msg), "Viewscreen::OnLostDevice released m_pddsHullDynamicTexture slot %i!", t);
1518 logger->Log(msg);
1520 sprintf_s(msg, sizeof(msg), "m_pddsHullDynamicTexture[%i]", t);
1522 }
1523 }
1524
1525 if (ptrInstruments)
1527
1528 logger->Log("Viewscreen::OnLostDevice() exited successfully!");
1529}
1530
1531void Viewscreen::OnDestroyDevice(bool preserveModels)
1532{
1533 logger->AddToCallStack("Viewscreen::OnDestroyDevice");
1534 logger->Log("Viewscreen::OnDestroyDevice() called!");
1536 // Recovery at the same location still needs the normal terrain builders.
1537 oldRts.u = oldRts.v = -3;
1538 oldZone = 255;
1544 reentryState = {};
1545 reentryWindward = {};
1548
1550 gameclass->UpdateTrackedResource("m_pddsWorld2a1", 3);
1552 gameclass->UpdateTrackedResource("m_pddsCloudBaseMap", 3);
1554 gameclass->UpdateTrackedResource("m_pddsCloudDetailAbove", 3);
1556 gameclass->UpdateTrackedResource("m_pddsCloudDetailBelow", 3);
1558 gameclass->UpdateTrackedResource("m_pddsBinoculars", 3);
1560 gameclass->UpdateTrackedResource("m_pddsNightVision", 3);
1562 gameclass->UpdateTrackedResource("m_pddsBinocularsCompass", 3);
1564 gameclass->UpdateTrackedResource("m_pddsBinocularsArrow", 3);
1566 gameclass->UpdateTrackedResource("m_pddsNightVisionCompass", 3);
1568 gameclass->UpdateTrackedResource("m_pddsNightVisionArrow", 3);
1570 gameclass->UpdateTrackedResource("m_pddsSunglasses", 3);
1572 gameclass->UpdateTrackedResource("m_pddsSunTexture", 3);
1574 gameclass->UpdateTrackedResource("m_pddsStarTexture", 3);
1576 gameclass->UpdateTrackedResource("m_pddsHolidayTexture", 3);
1577
1578 // Interface
1580 gameclass->UpdateTrackedResource("m_pddsLetters", 3);
1581
1583 gameclass->UpdateTrackedResource("m_pddsMarston1", 3);
1585 gameclass->UpdateTrackedResource("m_pddsRunwayEdgeLight1", 3);
1587 gameclass->UpdateTrackedResource("m_pddsRoad", 3);
1589 gameclass->UpdateTrackedResource("m_pddsIntersection", 3);
1590
1591 for (size_t i = 0; i < m_pddsLogos.size(); i++)
1592 {
1594 sprintf_s(msg, sizeof msg, "m_pddsLogos[%zu]", i);
1596 }
1597
1598 logger->AddToCallStack("Viewscreen::OnDestroyDevice1");
1599
1600 short t;
1601 for (t = 1; t < shiptextureC; t++)
1602 {
1604 sprintf_s(msg, sizeof msg, "m_pddsShipTexture[%i]", t);
1606 if (m_pddsShipLights[t])
1607 {
1609 sprintf_s(msg, sizeof msg, "m_pddsShipLights[%i]", t);
1611 }
1612 }
1613 for (t = 1; t < citytextureC; t++)
1614 {
1616 sprintf_s(msg, sizeof msg, "m_pddsCityTexture[%i]", t);
1618 if (m_pddsCityLights[t])
1619 {
1621 sprintf_s(msg, sizeof msg, "m_pddsCityLights[%i]", t);
1623 }
1624 }
1625 for (t = 1; t < RTStextureC; t++)
1626 {
1627 if (m_pddsRTSTexture[t])
1628 {
1630 sprintf_s(msg, sizeof msg, "m_pddsRTSTexture[%i]", t);
1632 }
1633 if (m_pddsRTSLights[t])
1634 {
1636 sprintf_s(msg, sizeof msg, "m_pddsRTSLights[%i]", t);
1638 }
1639 }
1640
1641 for (t = 0; t < landformtextureC; t++)
1642 {
1644 sprintf_s(msg, sizeof msg, "m_pddsLandform[%i]", t);
1646 }
1647
1648 for (t = 0; t < transitiontextureC; t++)
1649 {
1651 sprintf_s(msg, sizeof msg, "m_pddsTransition[%i]", t);
1653 }
1654
1656 gameclass->UpdateTrackedResource("m_pddsWaterNormal", 3);
1657
1658#ifndef skipAnimations
1659 for (t = 0; t < weaponanimateC; t++)
1660 {
1662 sprintf_s(msg, sizeof msg, "m_pddsWeapon[%i]", t);
1665 sprintf_s(msg, sizeof msg, "m_pddsSinker[%i]", t);
1667 }
1668
1670 gameclass->UpdateTrackedResource("m_pddsFuzerX", 3);
1672 gameclass->UpdateTrackedResource("m_pddsSinkerX", 3);
1674 gameclass->UpdateTrackedResource("m_pddsBlastX", 3);
1675
1676#ifdef smoketestC
1677 for (t = 0; t < smoketrailC; t++)
1678 SAFE_RELEASE(m_pddsSmoke[t]);
1679#endif
1680
1681 for (t = 0; t < dihvanimateC; t++)
1682 {
1684 sprintf_s(msg, sizeof msg, "m_pddsDIHV[%i]", t);
1686 }
1687 for (t = 0; t < heartanimateC; t++)
1688 {
1690 sprintf_s(msg, sizeof msg, "m_pddsHeart[%i]", t);
1692 }
1693 for (t = 0; t < firework1C; t++)
1694 {
1696 sprintf_s(msg, sizeof msg, "m_pddsFirework1[%i]", t);
1698 }
1699 for (t = 0; t < firework2C; t++)
1700 {
1702 sprintf_s(msg, sizeof msg, "m_pddsFirework2[%i]", t);
1704 }
1705 for (t = 0; t < firework3C; t++)
1706 {
1708 sprintf_s(msg, sizeof msg, "m_pddsFirework3[%i]", t);
1710 }
1711
1713 gameclass->UpdateTrackedResource("m_pddsFlame", 3);
1714#endif
1715
1716 for (t = 0; t < elmoAnimateC; t++)
1717 {
1719 sprintf_s(msg, sizeof msg, "m_pddsElmo[%i]", t);
1721 }
1722
1723 //SAFE_RELEASE(m_pddsTempHuman);
1724 //gameclass->UpdateTrackedResource("m_pddsTempHuman");
1725 //SAFE_RELEASE(m_pddsTempHumanHead);
1726 //gameclass->UpdateTrackedResource("m_pddsTempHumanHead");
1727
1728
1730 gameclass->UpdateTrackedResource("m_pddsAtmosphere", 3);
1731
1732 // THESE ARE FROM COCKPIT.CPP
1733 if (m_pddsNamePlate)
1734 {
1736 gameclass->UpdateTrackedResource("m_pddsNamePlate", 3);
1737 }
1738
1740 {
1742 gameclass->UpdateTrackedResource("m_pddsGVBackground", 3);
1743 }
1745 {
1747 gameclass->UpdateTrackedResource("m_pddsGVDialSmall", 3);
1748 }
1749 if (m_pddsAOA[0])
1750 {
1752 gameclass->UpdateTrackedResource("m_pddsAOA[0]", 3);
1753 }
1754 if (m_pddsAOA[1])
1755 {
1757 gameclass->UpdateTrackedResource("m_pddsAOA[1]", 3);
1758 }
1759 if (m_pddsAOA[2])
1760 {
1762 gameclass->UpdateTrackedResource("m_pddsAOA[2]", 3);
1763 }
1765 {
1767 gameclass->UpdateTrackedResource("m_pddsLightsCruiseIcons", 3);
1768 }
1769 if (m_pddsFuelIcon)
1770 {
1772 gameclass->UpdateTrackedResource("m_pddsFuelIcon", 3);
1773 }
1774 if (m_pddsGVCompass)
1775 {
1777 gameclass->UpdateTrackedResource("m_pddsGVCompass", 3);
1778 }
1780 {
1782 gameclass->UpdateTrackedResource("m_pddsGVDirection", 3);
1783 }
1784
1785 for (t = 1; t < cockpittextureC; t++)
1786 {
1787 if (m_pddsCockpitTexture[t])
1788 {
1790 sprintf_s(msg, sizeof msg, "m_pddsCockpitTexture[%i]", t);
1792 }
1793 if (m_pddsCockpitLights[t])
1794 {
1796 sprintf_s(msg, sizeof msg, "m_pddsCockpitLights[%i]", t);
1798 }
1799 }
1800 // Not reloaded with different cockpits
1802 gameclass->UpdateTrackedResource("m_pddsInterlace[0]", 3);
1804 gameclass->UpdateTrackedResource("m_pddsInterlace[1]", 3);
1806 gameclass->UpdateTrackedResource("m_pddsCracked", 3);
1807 if (!preserveModels && ourcockpit.componentarray)
1808 {
1809 gameclass->UpdateTrackedResource("ourcockpit.componentarray", 3);
1812 }
1813 // THUS ENDS THE ONES FROM COCKPIT.CPP
1814
1815 // THESE ARE FROM RNDRDCKS.CPP
1816#ifndef skipDocks
1817 for (t = 1; t < docktextureC; t++)
1818 {
1820 sprintf_s(msg, sizeof msg, "m_pddsDockTexture[%i]", t);
1822 if (m_pddsDockLights[t])
1823 {
1825 sprintf_s(msg, sizeof msg, "m_pddsDockLights[%i]", t);
1827 }
1828 }
1829#endif
1830
1831 for (t = 0; t < maxdockC; t++)
1832 {
1833 if (allobjects[t].componentarray)
1834 {
1835 SAFE_DELETE_ARRAY(allobjects[t].componentarray);
1836 sprintf_s(msg, sizeof msg, "allobjects[%i].componentarray", t);
1838 }
1839 }
1840
1841 logger->AddToCallStack("Viewscreen::OnDestroyDevice2");
1842 // THESE ARE EITHER RENDER TARGETS, RENDER SURFACES, SPRITES, FONTS, ETC
1843
1844 for (t = 0; t < MAX_SCAN; t++)
1845 {
1847 {
1848 sprintf_s(msg, sizeof(msg), "Viewscreen::OnDestroyDevice released m_pddsHullDynamicTexture slot %i!", t);
1849 logger->Log(msg);
1851 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", t);
1853 }
1854
1855 if (!preserveModels && playerships[t].componentarray)
1856 {
1857 SAFE_DELETE_ARRAY(playerships[t].componentarray);
1858 playerships[t].components = 0;
1859 sprintf_s(msg, sizeof msg, "playerships[%i].componentarray", t);
1861 }
1862 }
1863
1864
1866 gameclass->UpdateTrackedResource("m_pFont", 3);
1868 gameclass->UpdateTrackedResource("m_pFontLicense", 3);
1870 gameclass->UpdateTrackedResource("m_pFont3", 3);
1872 gameclass->UpdateTrackedResource("m_pFontHull", 3);
1873
1875 gameclass->UpdateTrackedResource("m_pRenderToSurface", 3);
1877 gameclass->UpdateTrackedResource("m_pRenderToSurfaceNextGen", 3);
1879 gameclass->UpdateTrackedResource("m_pHullRender2Surface", 3);
1880
1882 gameclass->UpdateTrackedResource("m_spriteVector", 3);
1883
1885 gameclass->UpdateTrackedResource("m_pddsDynamicTexture", 3);
1887 gameclass->UpdateTrackedResource("m_pddsDynamicSurface", 3);
1888
1889
1890 // Release static vertex/index buffers
1892 gameclass->UpdateTrackedResource("m_avStaticStars", 3);
1894 gameclass->UpdateTrackedResource("m_avCone", 3);
1896 gameclass->UpdateTrackedResource("m_avBillboardVertices", 3);
1897
1899 gameclass->UpdateTrackedResource("m_avSkyDome", 3);
1901 gameclass->UpdateTrackedResource("m_avSkyRing", 3);
1903 gameclass->UpdateTrackedResource("m_avScreen", 3);
1905 gameclass->UpdateTrackedResource("m_avInstrument", 3);
1907 gameclass->UpdateTrackedResource("m_avRainDrops", 3);
1909 gameclass->UpdateTrackedResource("m_pLightSunVizQuery", 3);
1911 gameclass->UpdateTrackedResource("m_pNightVisionRangeQuery", 3);
1913 gameclass->UpdateTrackedResource("m_pddsProjectionTexture", 3);
1915 gameclass->UpdateTrackedResource("m_pddsProjectionSurface", 3);
1917 gameclass->UpdateTrackedResource("m_avRunningLights", 3);
1919 gameclass->UpdateTrackedResource("m_aiCloudGrid", 3);
1921 gameclass->UpdateTrackedResource("m_avCloudGrid", 3);
1922 //SAFE_RELEASE(m_aiLocalGrid);
1923 //gameclass->UpdateTrackedResource("m_aiLocalGrid");
1925 gameclass->UpdateTrackedResource("m_avLocalGrid", 3);
1926
1927 for (t = 0; t < maxpolyC; t++)
1928 {
1929 if (polyobjects[t].VB)
1930 {
1931 if (preserveModels && t == 5)
1932 {
1934 gameclass->UpdateTrackedResource("polyobjects[5].VB", 1);
1935 continue;
1936 }
1938 sprintf_s(msg, sizeof(msg), "polyobjects[%i].VB", t);
1940 }
1941 }
1942
1943 logger->AddToCallStack("Viewscreen::OnDestroyDevice3");
1944
1945 ptrGrid->geometryReady = false;
1946 ptrGrid->makeBuildings = true;
1947 ptrGrid->makeClouds = true;
1948 for (short l = 0; l < 64; l++)
1949 {
1950 for (short m = 0; m < 64; m++)
1951 {
1952 if (gridarray[l][m].buildzoneOrdinal != -1)
1953 {
1954 sprintf_s(msg, sizeof(msg), "OnDestroyDevice HG2 released VB slot %i!", gridarray[l][m].buildzoneOrdinal);
1955 logger->Log(msg);
1956
1957 ptrGrid->RemoveBuildZone(gridarray[l][m].buildzoneOrdinal);
1958
1959 gridarray[l][m].buildzoneOrdinal = -1;
1960 }
1961 }
1962 }
1963
1964 logger->AddToCallStack("Viewscreen::OnDestroyDevice4");
1965
1966 for (t = 0; t < maxstarC; t++)
1967 SAFE_DELETE_ARRAY(allobjects[t].componentarray);
1968
1969 logger->AddToCallStack("Viewscreen::OnDestroyDevice5");
1970
1972
1974
1976
1977 logger->AddToCallStack("Viewscreen::OnDestroyDevice DONE");
1978 logger->Log("Viewscreen::OnDestroyDevice() exited successfully!");
1979}
1980
1982{
1983 for (UINT i = 0; i < sofTracking.size(); i++)
1984 {
1985 std::string text = " --> " + sofTracking.at(i);
1986 logger->Log(text.c_str(), Logger::Debug);
1987 }
1988 sprintf_s(msg, sizeof(msg), " === X%7.3f Y%7.3f Z%7.3f total", sumofforces.x, sumofforces.y, sumofforces.z);
1990}
1991
1993{
1994 logger->AddToCallStack("Viewscreen::ApplyEnvironmentMap");
1995
1996 RiseMath::Matrix matrixTemp;
1997 HRESULT hr;
1998
1999 for (short t = 0; t < maxstarC; t++)
2000 {
2001 RiseMath::MatrixIdentity(&allobjects[t].matrixWorld);
2002
2003 if (allobjects[t].type == -5) // Static Stars
2004 {
2005 RiseMath::MatrixRotationX(&matrixTemp, RiseMath::HalfPi); // Tilt the star field 90�
2006 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
2007 }
2008 else // not static stars
2009 {
2010 if (allobjects[t].type != -1) // Not Vieneo
2011 {
2012 if (allobjects[t].type != 1) // Not docks
2013 {
2014 RiseMath::MatrixScaling(&matrixTemp, allobjects[t].scale, allobjects[t].scale, allobjects[t].scale);
2015 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
2016 }
2017 }
2018 else // Vieneo scale is left at 1, tilt is barycentric
2019 {
2020 // Surface map must be rotated west 90�
2022 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
2023 }
2024
2025
2026
2027 if (allobjects[t].type == -7) // yonmara
2028 RiseMath::MatrixTranslation(&matrixTemp, 0.0f, -allobjects[t].range, 0.0f);
2029 else
2030 RiseMath::MatrixTranslation(&matrixTemp, 0.0f, allobjects[t].range, 0.0f);
2031 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
2032
2033 // Need to find the initial meridian of Vieneo since docks are framemoved first
2034 if (allobjects[t].type == -1)
2035 {
2036 float f_temp = RiseMath::Tau / allobjects[t].rotation;
2038 allobjects[t].rotprog += f_Uphours * 3600.0f / f_temp;
2039 allobjects[t].rotprog -= floorf(allobjects[t].rotprog);
2040 allobjects[t].rotprog += g_UniverseTime / f_temp;
2041 allobjects[t].rotprog -= floorf(allobjects[t].rotprog);
2043 }
2044 } // End of not a static star part
2045
2047 }
2048
2049
2050 RiseNonormalVertex* vtxn;
2051
2052 // Lock the vertex buffer
2053 V(m_avBillboardVertices->Lock(0, 0, reinterpret_cast<void**>(&vtxn), 0));
2054
2055 // normal, -1, -2, 1, 2
2056 vtxn->x = 1.0f; vtxn->y = 0.0f; vtxn->z = 1.0f; // y's were -1
2057 vtxn->tu = 1.0f; vtxn->tv = 0.0f;
2058 vtxn++;
2059 vtxn->x = 1.0f; vtxn->y = 0.0f; vtxn->z = -1.0f;
2060 vtxn->tu = 0.0f; vtxn->tv = 0.0f;
2061 vtxn++;
2062 vtxn->x = -1.0f; vtxn->y = 0.0f; vtxn->z = 1.0f;
2063 vtxn->tu = 1.0f; vtxn->tv = 1.0f;
2064 vtxn++;
2065 vtxn->x = -1.0f; vtxn->y = 0.0f; vtxn->z = -1.0f;
2066 vtxn->tu = 0.0f; vtxn->tv = 1.0f;
2067 vtxn++;
2068
2070
2071
2072 RiseSkydomeVertex* vtx;
2073
2074 // Lock the vertex buffer
2075 V(m_avCone->Lock(0, 0, reinterpret_cast<void**>(&vtx), 0));
2077
2078 V(m_avCone->Unlock());
2079
2080 // Rain initialize random drop locations
2081 for (short t = 0; t < MAX_RAINDROPS; t++)
2082 {
2083 // box that is 50m above/below,
2084 const float width = RandomFloat() * 0.2f - 0.1f; // wide-half; // 200m wide
2085 const float zdist = RandomFloat() * 0.4f - 0.2f; // percentage of 200m distance
2086 rainarray[t].x = width;
2087 rainarray[t].y = RandomFloat() * 0.05f - 0.025f; // vertically 50m above/below
2088 rainarray[t].z = zdist;
2089 }
2090
2091
2092
2093 // Terrain visiblegrid, indexgrid, index buffers created
2094 ptrGrid->ClearGrid();
2095
2096
2097
2098 short l, m, n = 0, o = 0;
2099 for (l = 0; l < 63; l++)
2100 {
2101 for (m = 0; m < 63; m++)
2102 {
2103 // Clear this so we don't bomb the card!
2104 insidearray[l][m][0] = insidearray[l][m][1] = insidearray[l][m][2] = centerC;
2105 // Make visiblegrid array
2106 if (sqrtf(powf(31.0f - static_cast<float>(l), 2.0f) + powf(31.0f - static_cast<float>(m), 2.0f)) <= 32.0f)
2107 {
2108 visiblegrid[l][m] = true;
2109 n++;
2110 if (l > 15 && l < 48 && m > 15 && m < 48)
2111 o++;
2112 }
2113 else
2114 visiblegrid[l][m] = false;
2115 }
2116 }
2117
2118 ptrGrid->geometryReady = false; // VB not set, don't touch initialized which is for the data
2119
2120 sprintf_s(msg, sizeof(msg), "ApplyEnvironmentMap() visible grid has %i/%i squares (%i are patched)!", n, drawlistC, o);
2121 logger->Log(msg);
2122
2123
2124#if defined(_DEBUG) && defined(VISIBLEGRIDDUMP)
2125 int visiblegridfile;
2126 _sopen_s(&visiblegridfile, "visiblegrid.txt", _O_RDWR | _O_CREAT | _O_TRUNC | _O_TEXT | _O_SEQUENTIAL, SH_DENYWR, S_IWRITE);
2127 // draw grid in textfile
2128 for (l = 0; l < 63; l++)
2129 {
2130 for (m = 0; m < 63; m++)
2131 {
2132 sprintf_s(msg, sizeof msg, "%i ", visiblegrid[m][l] ? 1 : 0);
2133 _write(visiblegridfile, msg, strlen(msg));
2134 }
2135 sprintf_s(msg, sizeof msg, "\n");
2136 _write(visiblegridfile, msg, strlen(msg));
2137 }
2138 _close(visiblegridfile);
2139#endif
2140
2141 // indexgrid keeps track of linearly how far down each point is in the vertexbuffer
2142 short indexgrid[64][64]; // values 0 to visiblevertC (7168)
2143 n = 0;
2144 for (l = 0; l < 64; l++)
2145 {
2146 for (m = 0; m < 64; m++)
2147 {
2148 indexgrid[l][m] = n;
2149 n++;
2150 }
2151 }
2152 sprintf_s(msg, sizeof(msg), "ApplyEnvironmentMap() index grid for clouds has %i/%i indices!", n, 4096);
2153 logger->Log(msg);
2154
2155
2156 unsigned short* itxg;
2157 short s;
2158 n = 0;
2159 V(m_aiCloudGrid->Lock(0, 0, reinterpret_cast<void**>(&itxg), 0));
2160 for (short t = 0; t < 63; t++)
2161 {
2162 for (s = 0; s < 63; s++)
2163 {
2164 if (visiblegrid[t][s])
2165 {
2166 (*itxg++) = indexgrid[t][s];
2167 (*itxg++) = indexgrid[t + 1][s + 1];
2168 (*itxg++) = indexgrid[t][s + 1];
2169
2170 (*itxg++) = indexgrid[t][s];
2171 (*itxg++) = indexgrid[t + 1][s];
2172 (*itxg++) = indexgrid[t + 1][s + 1];
2173 n += 6;
2174 }
2175 }
2176 }
2178 sprintf_s(msg, sizeof msg, "ApplyEnvironmentMap() cloud index buffer has %i/%i indices!", n, cloudindicesC);
2179 logger->Log(msg);
2180 assert(n <= cloudindicesC);
2181
2182
2183
2184
2185
2186
2187 n = 0;
2188 short leftup, rightdown = 32;
2189
2190 // Immediate location
2191 unsigned short startindex = 0;
2192 drawlist[n].startindex = startindex;
2193 drawlist[n].primitives = 8;
2194 drawlist[n].u = 31;
2195 drawlist[n].v = 31;
2196 startindex += 24;
2197 n++;
2198
2199 // Work from inside and out, counterclockwise order
2200 for (leftup = 30; leftup >= 0; leftup--) //30 29 ... 1 0
2201 {
2202 // Top and bottom rows
2203 for (short t = leftup; t <= rightdown; t++)
2204 {
2205 if (visiblegrid[t][leftup])// && t!=63 && leftup!=63)
2206 {
2207 if (t > 15 && t < 47 && leftup > 15 && leftup < 47) // has to be <47 because [48][48][2] is NAN
2208 {
2209 drawlist[n].startindex = startindex;
2210 startindex += 24;
2211 drawlist[n].primitives = 8;
2212 }
2213 else
2214 {
2215 drawlist[n].startindex = startindex;
2216 startindex += 6;
2217 drawlist[n].primitives = 2;
2218 }
2219
2220 drawlist[n].u = (unsigned char)t;
2221 drawlist[n].v = (unsigned char)leftup;
2222 n++;
2223 }
2224
2225 if (visiblegrid[t][rightdown])// && t != 63 && rightdown != 63)
2226 {
2227 if (t > 15 && t < 47 && rightdown > 15 && rightdown < 47)
2228 {
2229 drawlist[n].startindex = startindex;
2230 startindex += 24;
2231 drawlist[n].primitives = 8;
2232 }
2233 else
2234 {
2235 drawlist[n].startindex = startindex;
2236 startindex += 6;
2237 drawlist[n].primitives = 2;
2238 }
2239
2240 drawlist[n].u = (unsigned char)t;
2241 drawlist[n].v = (unsigned char)rightdown;
2242 n++;
2243 }
2244 }
2245
2246 // Left and right sides
2247 for (s = leftup + 1; s < rightdown; s++)
2248 {
2249 if (visiblegrid[rightdown][s])// && rightdown != 63 && s != 63)
2250 {
2251 if (s > 15 && s < 47 && rightdown > 15 && rightdown < 47)
2252 {
2253 drawlist[n].startindex = startindex;
2254 startindex += 24;
2255 drawlist[n].primitives = 8;
2256 }
2257 else
2258 {
2259 drawlist[n].startindex = startindex;
2260 startindex += 6;
2261 drawlist[n].primitives = 2;
2262 }
2263
2264 drawlist[n].u = (unsigned char)rightdown;
2265 drawlist[n].v = (unsigned char)s;
2266 n++;
2267 }
2268
2269 if (visiblegrid[leftup][s])// && leftup != 63 && s != 63)
2270 {
2271 if (s > 15 && s < 47 && leftup > 15 && leftup < 47)
2272 {
2273 drawlist[n].startindex = startindex;
2274 startindex += 24;
2275 drawlist[n].primitives = 8;
2276 }
2277 else
2278 {
2279 drawlist[n].startindex = startindex;
2280 startindex += 6;
2281 drawlist[n].primitives = 2;
2282 }
2283
2284 drawlist[n].u = (unsigned char)leftup;
2285 drawlist[n].v = (unsigned char)s;
2286 n++;
2287 }
2288 }
2289 rightdown++;
2290 }
2291
2292 sprintf_s(msg, sizeof(msg), "ApplyEnvironmentMap() terrain draw list, vertices %i, list length %i/%i", startindex, n, drawlistC);
2293 logger->Log(msg);
2294 assert(n <= drawlistC);
2295}
2296
2297// Used in weapons and other vehicles (so we don't let them fall through the ground)
2298float Viewscreen::CalculateAGL(short u, short v, RiseMath::Vector3 position, bool makeleveler)
2299{
2300 logger->AddToCallStack("Viewscreen::CalculateAGL");
2301
2302 if (u < 1 || u > 62 || v < 1 || v > 62)
2303 return -1.0f;
2304
2305 position = -position;
2306
2308 RiseMath::Vector3 rayDir = position; // cast from center of planet to position
2309 RiseMath::Vec3Normalize(&rayDir, &rayDir);
2310 rayPos -= rayDir * 10.0f; // bring it inside the planet a bit, 4.1km minimum is lowest point
2311
2312 RiseMath::Vector3 temp0, temp1, temp2;
2313 float pu = -1.0f, pv = -1.0f, dist = -1.0f; // last if not overwritten
2314
2315 RiseMath::Vector3 a, b, c, d, e, f, g, h, i;
2316 a = centerC;
2317 b = insidearray[u][v][0] - gridarray[u][v].position;
2318 c = insidearray[u][v][1] - gridarray[u][v].position;
2319 d = insidearray[u][v][2] - gridarray[u][v].position;
2320 e = gridarray[u + 1][v].position - gridarray[u][v].position;
2321 f = insidearray[u + 1][v][1] - gridarray[u][v].position;
2322 g = gridarray[u][v + 1].position - gridarray[u][v].position;
2323 h = insidearray[u][v + 1][0] - gridarray[u][v].position;
2324 i = gridarray[u + 1][v + 1].position - gridarray[u][v].position;
2325
2326 if (u > 15 && u < 48 && v > 15 && v < 48)
2327 {
2328 // first quad (zone 1)
2329 if (RiseMath::IntersectTri(&a, &b, &c, &rayPos, &rayDir, &pu, &pv, &dist))
2330 {
2331 temp0 = gridarray[u][v].position; temp1 = insidearray[u][v][0]; temp2 = insidearray[u][v][1];
2332 }
2333 else if (RiseMath::IntersectTri(&b, &d, &c, &rayPos, &rayDir, &pu, &pv, &dist))
2334 {
2335 temp0 = insidearray[u][v][0]; temp1 = insidearray[u][v][2]; temp2 = insidearray[u][v][1];
2336 }
2337
2338 // second quad (zone 2)
2339 else if (RiseMath::IntersectTri(&b, &e, &d, &rayPos, &rayDir, &pu, &pv, &dist))
2340 {
2341 temp0 = insidearray[u][v][0]; temp1 = gridarray[u + 1][v].position; temp2 = insidearray[u][v][2];
2342 }
2343 else if (RiseMath::IntersectTri(&e, &f, &d, &rayPos, &rayDir, &pu, &pv, &dist))
2344 {
2345 temp0 = gridarray[u + 1][v].position; temp1 = insidearray[u + 1][v][1]; temp2 = insidearray[u][v][2];
2346 }
2347
2348 // third quad (zone 4)
2349 else if (RiseMath::IntersectTri(&c, &d, &g, &rayPos, &rayDir, &pu, &pv, &dist))
2350 {
2351 temp0 = insidearray[u][v][1]; temp1 = insidearray[u][v][2]; temp2 = gridarray[u][v + 1].position;
2352 }
2353 else if (RiseMath::IntersectTri(&d, &h, &g, &rayPos, &rayDir, &pu, &pv, &dist))
2354 {
2355 temp0 = insidearray[u][v][2]; temp1 = insidearray[u][v + 1][0]; temp2 = gridarray[u][v + 1].position;
2356 }
2357
2358 // fourth quad (zone 3)
2359 else if (RiseMath::IntersectTri(&d, &f, &h, &rayPos, &rayDir, &pu, &pv, &dist))
2360 {
2361 temp0 = insidearray[u][v][2]; temp1 = insidearray[u + 1][v][1]; temp2 = insidearray[u][v + 1][0];
2362 }
2363 else if (RiseMath::IntersectTri(&f, &i, &h, &rayPos, &rayDir, &pu, &pv, &dist))
2364 {
2365 temp0 = insidearray[u + 1][v][1]; temp1 = gridarray[u + 1][v + 1].position; temp2 = insidearray[u][v + 1][0];
2366 }
2367 else
2368 {
2369 sprintf_s(msg, sizeof msg, "*** CalculateAGL() u%i v%i x%.3f y%.3f z%.3f (%i) yielded no result, trying larger tesselation...", u, v, position.x, position.y, position.z, makeleveler);
2370 logger->Log(msg);
2371
2372 if (RiseMath::IntersectTri(&a, &e, &i, &rayPos, &rayDir, &pu, &pv, &dist))
2373 {
2374 temp0 = gridarray[u][v].position; temp1 = gridarray[u + 1][v].position; temp2 = gridarray[u + 1][v + 1].position;
2375 }
2376 if (RiseMath::IntersectTri(&a, &i, &g, &rayPos, &rayDir, &pu, &pv, &dist))
2377 {
2378 temp0 = gridarray[u][v].position; temp1 = gridarray[u + 1][v + 1].position; temp2 = gridarray[u][v + 1].position;
2379 }
2380 else
2381 {
2382 dist = -1.0f;
2383 sprintf_s(msg, sizeof msg, " CalculateAGL() u%i v%i is at x%.3f y%.3f z%.3f, still no result, returning %.3f (%.3f)", u, v, gridarray[u][v].position.x, gridarray[u][v].position.y, gridarray[u][v].position.z, dist, radiusC + playerships[0].mslKm - dist);
2384 logger->Log(msg);
2385 }
2386 }
2387 }
2388 else if (RiseMath::IntersectTri(&a, &e, &i, &rayPos, &rayDir, &pu, &pv, &dist))
2389 {
2390 temp0 = gridarray[u][v].position; temp1 = gridarray[u + 1][v].position; temp2 = gridarray[u + 1][v + 1].position;
2391 }
2392 else if (RiseMath::IntersectTri(&a, &i, &g, &rayPos, &rayDir, &pu, &pv, &dist))
2393 {
2394 temp0 = gridarray[u][v].position; temp1 = gridarray[u + 1][v + 1].position; temp2 = gridarray[u][v + 1].position;
2395 }
2396 else
2397 {
2398 dist = -1.0f;
2399 sprintf_s(msg, sizeof msg, "+++ CalculateAGL() u%i v%i x%.3f y%.3f z%.3f (%i) yielded no result, returning %.3f", u, v, position.x, position.y, position.z, makeleveler, dist);
2400 logger->Log(msg);
2401 }
2402
2403 if (makeleveler && dist != -1.0f)
2404 {
2405 RiseMath::Vector3 side1, side2;
2406 RiseMath::Vec3Subtract(&side1, &temp0, &temp1);
2407 RiseMath::Vec3Subtract(&side2, &temp0, &temp2);
2408 RiseMath::Vec3Cross(&temp0, &side1, &side2);
2410 }
2411
2412 if (dist != -1.0f)
2413 return -(dist - 10.0f);
2414
2415 return dist;
2416}
2417
2419{
2420 logger->AddToCallStack("Viewscreen::ProbeBoundSphere");
2421
2422 const float R = radiusC; // planet radius (km)
2423 const float H = aftersdC; // your atmosphere thickness
2424 const float RH = R + H; // outer atmosphere radius
2425
2426 // helper: solves (P + tD)·(P + tD) = r^2
2427 auto intersectSphere = [&](float r, float& tNear, float& tFar) {
2428 float B = RiseMath::Vec3Dot(Xsunlight, position); // D·P
2429 float C = RiseMath::Vec3Dot(position, position) - r * r; // P·P - r^2
2430 float disc = B * B - C;
2431 if (disc < 0.0f) return false;
2432 float sq = sqrtf(disc);
2433 tNear = -B - sq;
2434 tFar = -B + sq;
2435 return true;
2436 };
2437
2438 //float dP = RiseMath::Vec3Length(position);
2439 // 1) if camera is below surface, no sun
2440 //if (dP <= R) return 0.0f;
2441
2442 // 2) check if ray hits the planet proper first
2443 float tSurfaceNear, tSurfaceFar;
2444 if (intersectSphere(R, tSurfaceNear, tSurfaceFar)) {
2445 // any positive intersection means the surface blocks the sun
2446 if ((tSurfaceFar > 0.0f && tSurfaceNear <= 0.0f)
2447 || (tSurfaceNear > 0.0f))
2448 {
2449 return 0.0f;
2450 }
2451 }
2452
2453 // 3) find where the ray enters/exits the atmosphere shell
2454 float tAtmNear, tAtmFar;
2455 if (!intersectSphere(RH, tAtmNear, tAtmFar)) {
2456 // never intersects the shell ⇒ fully clear to sun
2457 return 1.0f;
2458 }
2459
2460 // we want the portion in front of the camera (t>0)
2461 float tEntry = (tAtmNear > 0.0f ? tAtmNear : 0.0f);
2462 float tExit = (tAtmFar > 0.0f ? tAtmFar : 0.0f);
2463
2464 // if tExit <= 0 then both intersections are behind us ⇒ clear sky
2465 if (tExit <= 0.0f) return 1.0f;
2466
2467 // 4) compute the path length through atmosphere
2468 float pathLength = tExit - tEntry; // km
2469
2470 // 5) normalize by the *maximum* chord through the shell at ground level:
2471 // 2 * sqrt((R+H)^2 - R^2)
2472 float maxChord = 2.0f * sqrtf(RH * RH - R * R);
2473
2474 float f = 1.0f - pathLength / maxChord;
2475 return Clamp(f, 0, 1);
2476}
2477
2478Sani Viewscreen::GetAni(float f_time, unsigned char ani) const
2479{
2480 Sani returnani = Sani();
2481 const int steps = 10;
2482 // find where we are at
2483 for (int t = 0; t < steps; t++)
2484 {
2485 // first frame is 0, 0
2486 if ((f_time >= aniarray[ani][t].start || fabsf(aniarray[ani][t].start - f_time) < 0.05f) &&
2487 f_time < aniarray[ani][t].end)
2488 {
2489 float frametime = aniarray[ani][t].end - aniarray[ani][t].start; // 8-4=4
2490 float frameprog = f_time - aniarray[ani][t].start; // 6-4=2
2491 RiseMath::Vec3Lerp(&returnani.xyz, &aniarray[ani][t].xyz, &aniarray[ani][t + 1].xyz, frameprog / frametime);
2492 for (short s = 0; s < 16; s++)
2493 RiseMath::Vec3Lerp(&returnani.ypr[s], &aniarray[ani][t].ypr[s], &aniarray[ani][t + 1].ypr[s], frameprog / frametime);
2494
2495 returnani.start = returnani.end = 0.0f;
2496
2497 return returnani;
2498 }
2499 // last frame is x==x
2500 if ((f_time >= aniarray[ani][t].start || fabsf(aniarray[ani][t].start - f_time) < 0.05f) &&
2501 fabsf(aniarray[ani][t].start - aniarray[ani][t].end) < 0.05f)
2502 {
2503 returnani = aniarray[ani][t]; // this is to cover a problem with returning uninit blink out stuff and making her legs split in mid-air
2504 returnani.end = -353.0f; // signifies end
2505 return returnani;
2506 }
2507 }
2508 char sliderstr[499];
2509 sprintf_s(sliderstr, 499, "Could not find key frame that covers the time interval of %.1f seconds", f_time);
2510 logger->Log(sliderstr, Logger::Level::Error);
2511 return returnani;
2512}
2513
2515{
2516 // Radius
2517 *radius = RiseMath::Vec3Length(position);
2518
2519 // Normalize a vector to ship
2521
2522 // Find barycentric velocity adjustment
2523 if (fabsf(gthrust->z) < 1.0f) // Can't be near poles or craps out on us
2524 {
2525 RiseMath::Vector3 cross;
2526 RiseMath::Vec3Cross(&cross, &northpoleK, gthrust); // Find perpendicular vector
2527 RiseMath::Vec3Normalize(&cross, &cross); // Shouldn't be necessary
2528 float lat = RiseMath::Vec3Dot(gthrust, &northpoleK);
2529 lat = acosf(lat) - RiseMath::HalfPi; // Find the angle and reduce by 90�
2530 // Update velocity to match planet rotation speed
2531 //*** changed this from -allobjects[ourmoonC].rotation
2532 const float f_temp = allobjects[ourmoonC].rotation * (*radius) * cosf(lat);
2533 return cross * f_temp;
2534 }
2535
2536 return centerC;
2537}
2538
2539bool Viewscreen::CheckPlotRoads(float f_tempu, float f_tempv)
2540{
2541 if (gridarray[31][31].roads >= 8) // segment 0
2542 {
2543 if (f_tempu >= 0.4981712f && f_tempu <= 0.5018288f && f_tempv <= 0.4963424f) // north
2544 return true;
2545 }
2546 if ((gridarray[31][31].roads >= 4 && gridarray[31][31].roads <= 7) || gridarray[31][31].roads >= 12) // segment 1
2547 {
2548 if (f_tempu >= 0.4963424 && f_tempu <= 0.5036576 && f_tempv >= 0.5036576) // south
2549 return true;
2550 }
2551 if (gridarray[31][31].roads == 2 || gridarray[31][31].roads == 3 || gridarray[31][31].roads == 6 || gridarray[31][31].roads == 7 ||
2552 gridarray[31][31].roads == 10 || gridarray[31][31].roads == 11 || gridarray[31][31].roads >= 14) // segment 2
2553 {
2554 if (f_tempu <= 0.4963424 && f_tempv >= 0.4963424 && f_tempv <= 0.5036576) // west
2555 return true;
2556 }
2557 if (gridarray[31][31].roads % 2 == 1) // segment 3
2558 {
2559 if (f_tempu >= 0.5036576 && f_tempv >= 0.4963424 && f_tempv <= 0.5036576) // east
2560 return true;
2561 }
2562 if (f_tempu > 0.4963424 && f_tempu < 0.5036576 && f_tempv > 0.4963424 && f_tempv < 0.5036576)
2563 return true;
2564 return false;
2565}
2566
2568{
2570 crashDamageEpisode = {};
2571 controlJoltEpisode = {};
2573 // Discard remote crash faults too; received faults are ignored in the simulator.
2574 for (auto& ship : playerships)
2575 {
2576 ship.crashHornFault = ship.hornPressed = ship.rainProtectionEnabled = false;
2577 ship.wipers = {};
2578 }
2580 playerships[0].hornPressed = false;
2581 playerships[0].wipers = {};
2582}
2583
2585{
2586 sumofforces += impulseKms;
2587 if (!playerships[0].isSimulator)
2588 structuralImpactImpulse += impulseKms;
2589}
2590
2592{
2593 RiseMath::Vector3 mount, rotation;
2595 const RiseMath::Vector3 omega(-playerships[0].pitch, -playerships[0].yawRadPerSec, -playerships[0].rollRadPerSec);
2596 RiseMath::Vec3Cross(&rotation, &omega, &mount);
2597 return velocityBody + rotation;
2598}
2599
2600void Viewscreen::DamageLandingLight(unsigned lamp, float clearanceKm, float closingMps, const char* cause)
2601{
2602 if (playerships[0].isSimulator || deathinhibit || lamp >= ourcockpit.landingLightCount ||
2604 gameclass->GUI->player[ourcockpit.ourplyrC].frame != 0) return;
2605 const int before = ourcockpit.vdat.landing[lamp];
2606 const int after = ourcockpit.landingLightImpact[lamp].Apply(before, clearanceKm, closingMps,
2608 if (after == before) return;
2609 ourcockpit.vdat.landing[lamp] = static_cast<char>(after);
2610 ourcockpit.vdatChanged = true;
2611 ourcockpit.vdatTime = 5.f;
2612 RiseMath::Vector3 mount;
2614 char message[256];
2615 sprintf_s(message, sizeof message,
2616 "Landing light impact: vehicle %u lamp %u (%s from driver) %d->%d, %s, closing %.2f m/s clearance %.3f m mountBody=(%.3f,%.3f,%.3f)m",
2617 unsigned(playerships[0].vehicleId), lamp, LandingLights::BodySide(mount.x), before, after, cause, closingMps, clearanceKm * 1000.f,
2618 mount.x * 1000.f, mount.y * 1000.f, mount.z * 1000.f);
2619 logger->Log(message);
2620}
2621
2622void Viewscreen::DamageLandingLights(const RiseMath::Vector3& surfaceNormalBody, float planeDistanceKm,
2623 const RiseMath::Vector3& impactVelocityBody, const char* cause)
2624{
2625 RiseMath::Vector3 normal;
2626 if (RiseMath::Vec3LengthSq(&surfaceNormalBody) < .5f) return;
2627 RiseMath::Vec3Normalize(&normal, &surfaceNormalBody);
2628 for (unsigned i = 0; i < ourcockpit.landingLightCount && i < LandingLights::MaxLights; ++i)
2629 {
2630 RiseMath::Vector3 mount;
2632 const auto velocity = LandingLightImpactVelocity(i, impactVelocityBody);
2633 DamageLandingLight(i, planeDistanceKm + RiseMath::Vec3Dot(&mount, &normal),
2634 -RiseMath::Vec3Dot(&velocity, &normal) * 1000.f, cause);
2635 }
2636}
2637
2639 const RiseMath::Vector3& velocityBody, float seconds)
2640{
2641 for (unsigned i = 0; i < ourcockpit.landingLightCount && i < LandingLights::MaxLights; ++i)
2642 {
2645 sweep.velocity = LandingLightImpactVelocity(i, velocityBody);
2646 sweep.seconds = seconds;
2647 const float closing = sweep.Sphere(centerBody, radiusKm);
2648 if (closing > 0) DamageLandingLight(i, 0, closing, "vehicle contact");
2649 }
2650}
2651
2652void Viewscreen::Movement(short t, float ElapsedTime)
2653{
2654 logger->AddToCallStack("Viewscreen::Movement");
2655
2656
2657 AssertTelemetry("Viewscreen::Movement1", t);
2658
2659
2660 RiseMath::Vector3 proposed, gthrust, cross;
2661 double proposedx, proposedy, proposedz;
2662 float radius;
2663
2664
2665 // New velocity adjustment section
2666 if (playerships[t].reference >= REF_DOCKENUMCPOC) // docks
2667 {
2668 //logger->AddToCallStack("Viewscreen::Movement Proposed Docks");
2669
2670 proposed = playerships[t].dockoffset + playerships[t].dockingvel * ElapsedTime;
2671 proposedx = proposed.x; proposedy = proposed.y; proposedz = proposed.z;
2672 // need to do collision then can set to proposed and return
2673 }
2674 else if (playerships[t].reference < REF_INANOTHER)
2675 {
2676 //logger->AddToCallStack("Viewscreen::Movement Proposed ACL/BCL");
2677
2679
2680
2681 if (t == 0)
2682 {
2683 float gravity = gravityKmssC / powf(radius / radiusC, 2.0f) * ElapsedTime;
2684 RiseMath::Vec3Scale(&gravityvec, &gthrust, gravity);
2685
2686 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
2687 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
2688 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
2690
2691 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f gravity1", -gravityacc.x * oneOvergForceKmssC / ElapsedTime, -gravityacc.y * oneOvergForceKmssC / ElapsedTime, -gravityacc.z * oneOvergForceKmssC / ElapsedTime);
2692 sofTracking.emplace_back(msg);
2693
2694 // verified gravityacc is in kmss (*ElapsedTime)
2696
2697#pragma region debug
2698 if (sumofforces.x > 100.0f || sumofforces.x < -100.0f || _isnan(sumofforces.x) || isinf(sumofforces.x) ||
2699 sumofforces.y > 100.0f || sumofforces.y < -100.0f || _isnan(sumofforces.y) || isinf(sumofforces.y) ||
2700 sumofforces.z > 100.0f || sumofforces.z < -100.0f || _isnan(sumofforces.z) || isinf(sumofforces.z))
2701 {
2702 sprintf_s(msg, sizeof(msg), "\tET: %f", ElapsedTime);
2704 sprintf_s(msg, sizeof(msg), "\treference: %i", playerships[0].reference);
2706 sprintf_s(msg, sizeof(msg), "\tsumofforces I: %f", sumofforces.x);
2708 sprintf_s(msg, sizeof(msg), "\tsumofforces J: %f", sumofforces.y);
2710 sprintf_s(msg, sizeof(msg), "\tsumofforces K: %f", sumofforces.z);
2712 sprintf_s(msg, sizeof(msg), "\tgravityvec X: %f", gravityvec.x);
2714 sprintf_s(msg, sizeof(msg), "\tgravityvec Y: %f", gravityvec.y);
2716 sprintf_s(msg, sizeof(msg), "\tgravityvec Z: %f", gravityvec.z);
2718 sprintf_s(msg, sizeof(msg), "\torientation X: %f", playerships[0].orientation.x);
2720 sprintf_s(msg, sizeof(msg), "\torientation Y: %f", playerships[0].orientation.y);
2722 sprintf_s(msg, sizeof(msg), "\torientation Z: %f", playerships[0].orientation.z);
2724 sprintf_s(msg, sizeof(msg), "\torientation W: %f", playerships[0].orientation.w);
2727 sprintf_s(msg, sizeof(msg), "Trapped a violation after gravity adjusted...");
2729 }
2730#pragma endregion
2731
2732 }
2733
2734 // this is amount our velocity would curve as we fly around planet
2735// if this doesn't work we have to take barycentric off of dock velocities
2736 if (playerships[t].reference != REF_ONGROUND)
2737 {
2738 RiseMath::Matrix matrixWorld;
2739 RiseMath::MatrixRotationZ(&matrixWorld, -allobjects[ourmoonC].rotation * ElapsedTime);
2740 RiseMath::Vec3TransformNormal(&playerships[t].velocity, &playerships[t].velocity, &matrixWorld);
2741 }
2742
2743
2744 // New proposed position section
2745 // Proposed position
2746 proposedx = playerships[t].precisionx + static_cast<double>((playerships[t].velocity.x - playerships[t].barycentric.x) * ElapsedTime);
2747 proposedy = playerships[t].precisiony + static_cast<double>((playerships[t].velocity.y - playerships[t].barycentric.y) * ElapsedTime);
2748 proposedz = playerships[t].precisionz + static_cast<double>((playerships[t].velocity.z - playerships[t].barycentric.z) * ElapsedTime);
2749
2750 // For visuals
2751 proposed.x = static_cast<float>(proposedx);
2752 proposed.y = static_cast<float>(proposedy);
2753 proposed.z = static_cast<float>(proposedz);
2754
2755 //if (t != 0 && playerships[t].reference == REF_APNMODE)
2756 //{
2757 // // limitations - seams between cube plates (assumed to be on the same plate)
2758 // // - won't work with buildings yet
2759 // VECTOR2SHORT tcp1 = CalculateCGC(proposed, ptrGrid->cube) - ptrGrid->tcp;
2760 // const float agl = CalculateAGL(tcp1.u + 31, tcp1.v + 31, proposed, false);
2761 // if (agl != -1.0f && agl < 0.004f)
2762 // {
2763 // sprintf_s(msg, sizeof msg, "Ship we were watching was going through the ground %f so we stopped them!", agl);
2764 // logger->Log(msg);
2765
2766 // float dist = RiseMath::Vec3Length(&proposed);
2767 // sprintf_s(msg, sizeof msg, "Distance from centerC: %f", dist);
2768 // logger->Log(msg);
2769
2770 // playerships[t].precisionx -= static_cast<double>(agl * gthrust.x);
2771 // playerships[t].precisiony -= static_cast<double>(agl * gthrust.y);
2772 // playerships[t].precisionz -= static_cast<double>(agl * gthrust.z);
2773
2774 // // For visuals
2775 // proposed.x = static_cast<float>(playerships[t].precisionx);
2776 // proposed.y = static_cast<float>(playerships[t].precisiony);
2777 // proposed.z = static_cast<float>(playerships[t].precisionz);
2778
2779 // playerships[t].velocity = playerships[t].barycentric;
2780 // playerships[t].velleft = playerships[t].veliter = centerC;
2781 // playerships[t].posleft = playerships[t].positer = centerC;
2782 // playerships[t].accleft = playerships[t].acciter = centerC;
2783 // playerships[t].reference = REF_ONGROUND;
2784
2785 // dist = RiseMath::Vec3Length(&proposed);
2786 // sprintf_s(msg, sizeof msg, "Distance from centerC: %f", dist);
2787 // logger->Log(msg);
2788
2789 // }
2790 //}
2791
2792 // WE TRIED THIS END OF 2019 AND IT CAUSED HOURS OF WASTED TIME TRYING TO FIGURE OUT WHY I WAS FALLING INTO THE GROUND
2793 //proposed = playerships[t].position + (playerships[t].velocity - playerships[t].barycentric) * ElapsedTime;
2794 }
2795 else if (playerships[t].reference == REF_INANOTHER)
2796 {
2797 //logger->AddToCallStack("Viewscreen::Movement Proposed Parent");
2798
2799 float yaw = 0.0f;
2800
2801 // Evaluated vehicle is in another vehicle
2805
2806 if (playerships[playerships[t].inarray].type == VehicleType::T120 ||
2807 playerships[playerships[t].inarray].type == VehicleType::T121) // parent is steerhead
2808 {
2809 if (playerships[t].type == VehicleType::C2 ||
2810 playerships[t].type == VehicleType::C2A)
2811 {
2812 playerships[t].dockoffset.y += 0.0009f;
2813 playerships[t].dockoffset.z -= 0.0019f; // fwd back
2814 }
2815 else if (playerships[t].type == VehicleType::C98)
2816 {
2817 playerships[t].dockoffset.y += 0.0008f;
2818 playerships[t].dockoffset.z -= 0.0015f; // fwd back
2819 }
2820 else
2821 {
2822 playerships[t].dockoffset.y += 0.000305f;
2823 playerships[t].dockoffset.z -= 0.0019f; // fwd back
2824 }
2825 if (playerships[playerships[t].inarray].type == VehicleType::T121)
2826 {
2827 playerships[t].dockoffset.y -= 0.0001f;
2828 playerships[t].dockoffset.z -= 0.00035f; // fwd back
2829 }
2830 }
2831 else if (playerships[playerships[t].inarray].type == VehicleType::T19) // parent is Stratomaster
2832 {
2833 if (playerships[t].type == VehicleType::C2 ||
2834 playerships[t].type == VehicleType::C2A)
2835 {
2836 playerships[t].dockoffset.y -= 0.0003f; // -down +up
2837 playerships[t].dockoffset.z -= 0.0018f; // +fwd -back
2838 }
2839 else if (playerships[t].type == VehicleType::C98)
2840 {
2841 playerships[t].dockoffset.y -= 0.0004f; // -down +up
2842 playerships[t].dockoffset.z -= 0.0014f; // +fwd -back
2843 }
2844 else
2845 {
2846 playerships[t].dockoffset.y -= 0.001f; // -down +up
2847 playerships[t].dockoffset.z -= 0.0018f; // +fwd -back
2848 }
2849 }
2850 else if (playerships[playerships[t].inarray].type == VehicleType::A4) // parent is A4
2851 {
2852 if (playerships[t].type != VehicleType::ARJ_PAX)
2853 yaw = -RiseMath::Pi; // turn everything around
2854 if (playerships[t].type == VehicleType::C2 ||
2855 playerships[t].type == VehicleType::C2A)
2856 {
2857 playerships[t].dockoffset.y += 0.0011f;
2858 playerships[t].dockoffset.z -= 0.0072f; // fwd back
2859 }
2860 else if (playerships[t].type == VehicleType::C98)
2861 {
2862 playerships[t].dockoffset.y += 0.0008f;
2863 playerships[t].dockoffset.z -= 0.0068f; // fwd back
2864 }
2865 else
2866 playerships[t].dockoffset.z -= 0.0072f; // fwd back
2867 }
2868 else if (playerships[playerships[t].inarray].type == VehicleType::E10 ||
2869 playerships[playerships[t].inarray].type == VehicleType::E11) // parent is a Saint class
2870 {
2871 if (playerships[t].bay % 2 == 0) // left side
2872 {
2873 yaw = -RiseMath::HalfPi;
2874 float aft = 0.0025f * (playerships[t].bay / 2);
2875
2876 if (playerships[t].type == VehicleType::C2 ||
2877 playerships[t].type == VehicleType::C2A)
2878 {
2879 float frontback = -0.003f - aft; // negative is back
2880 float updown = -0.0025f; // negative is down
2881 float leftright = -0.0030f; // positive is right
2882 playerships[t].dockoffset.x += leftright; // left right
2883 playerships[t].dockoffset.y += updown + 0.0007f; // up down
2884 playerships[t].dockoffset.z = frontback; // fwd back
2885 yaw += RiseMath::Pi;
2886 }
2887 else if (playerships[t].type == VehicleType::C98)
2888 {
2889 float frontback = -0.003f - aft; // negative is back
2890 float updown = -0.0025f; // negative is down
2891 float leftright = -0.0030f; // positive is right
2892 playerships[t].dockoffset.x += leftright; // left right
2893 playerships[t].dockoffset.y += updown + 0.0004f; // up down
2894 playerships[t].dockoffset.z = frontback; // fwd back
2895 yaw += RiseMath::Pi;
2896 }
2897 else // ARJ
2898 {
2899 float frontback = -0.003f - aft; // negative is back
2900 float updown = -0.0025f; // negative is down
2901 float leftright = -0.0030f; // positive is right
2902 playerships[t].dockoffset.x += leftright; // left right
2903 playerships[t].dockoffset.y += updown; // up down
2904 playerships[t].dockoffset.z += frontback; // fwd back
2905 }
2906 }
2907 else // right side
2908 {
2909 yaw = RiseMath::HalfPi;
2910 float aft = 0.0025f * ((playerships[t].bay - 1) / 2);
2911
2912 if (playerships[t].type == VehicleType::C2 ||
2913 playerships[t].type == VehicleType::C2A)
2914 {
2915 float frontback = -0.003f - aft; // negative is back
2916 float updown = -0.0025f; // negative is down
2917 float leftright = 0.003f; // positive is right
2918 playerships[t].dockoffset.x += leftright; // left right
2919 playerships[t].dockoffset.y += updown + 0.0007f; // up down
2920 playerships[t].dockoffset.z += frontback; // fwd back
2921 yaw += RiseMath::Pi;
2922 }
2923 else if (playerships[t].type == VehicleType::C98)
2924 {
2925 float frontback = -0.003f - aft; // negative is back
2926 float updown = -0.0025f; // negative is down
2927 float leftright = 0.003f; // positive is right
2928 playerships[t].dockoffset.x += leftright; // left right
2929 playerships[t].dockoffset.y += updown + 0.0004f; // up down
2930 playerships[t].dockoffset.z += frontback; // fwd back
2931 yaw += RiseMath::Pi;
2932 }
2933 else // ARJ
2934 {
2935 float frontback = -0.003f - aft; // negative is back
2936 float updown = -0.0025f; // negative is down
2937 float leftright = 0.003f; // positive is right
2938 playerships[t].dockoffset.x += leftright; // left right
2939 playerships[t].dockoffset.y += updown; // up down
2940 playerships[t].dockoffset.z += frontback; // fwd back
2941 }
2942 }
2943 }
2944 else if (playerships[playerships[t].inarray].type == VehicleType::W6Manx) // parent is Manx
2945 {
2946 if (playerships[t].type == VehicleType::C2 ||
2947 playerships[t].type == VehicleType::C2A)
2948 {
2949 playerships[t].dockoffset.y += 0.0006f;
2950 playerships[t].dockoffset.z -= 0.006f; // fwd+ back-
2951 }
2952 else if (playerships[t].type == VehicleType::C98)
2953 {
2954 playerships[t].dockoffset.y += 0.0005f;
2955 playerships[t].dockoffset.z -= 0.0056f; // fwd back
2956 }
2957 else
2958 playerships[t].dockoffset.z -= 0.006f; // fwd back
2959
2960 playerships[t].dockoffset.y -= 0.0024f;
2961 playerships[t].dockoffset.z += (playerships[t].bay - 1.0f) * 0.005f + 0.0017f;
2962 }
2963 else if (playerships[playerships[t].inarray].type == VehicleType::T27) // parent is a Mammoth
2964 {
2965 float updown = -0.0027f; // negative is down
2966 float aft = 0.005f * (playerships[t].bay / 3);
2967 if (playerships[t].bay >= 9)
2968 {
2969 updown += 0.0025f; // upper level
2970 aft -= 0.015f;
2971 }
2972 aft -= 0.007f;
2973
2974 yaw = 0;// RiseMath::Pi;
2975
2976 float leftright;
2977 if (playerships[t].bay % 3 == 0)
2978 leftright = -0.0025f;
2979 else if (playerships[t].bay % 3 == 1)
2980 leftright = 0.0f;
2981 else if (playerships[t].bay % 3 == 2)
2982 leftright = 0.0025f;
2983
2984 if (playerships[t].bay % 3 == 0) // left side
2985 {
2986 if (playerships[t].type == VehicleType::C2 ||
2987 playerships[t].type == VehicleType::C2A)
2988 {
2989 float frontback = -0.003f - aft; // negative is back
2990 playerships[t].dockoffset.x += leftright; // left right
2991 playerships[t].dockoffset.y += updown + 0.0007f; // up down
2992 playerships[t].dockoffset.z = frontback; // fwd back
2993 yaw += RiseMath::Pi;
2994 }
2995 else if (playerships[t].type == VehicleType::C98)
2996 {
2997 float frontback = -0.003f - aft; // negative is back
2998 playerships[t].dockoffset.x += leftright; // left right
2999 playerships[t].dockoffset.y += updown + 0.0004f; // up down
3000 playerships[t].dockoffset.z = frontback; // fwd back
3001 yaw += RiseMath::Pi;
3002 }
3003 else // ARJ
3004 {
3005 float frontback = -0.003f - aft; // negative is back
3006 playerships[t].dockoffset.x += leftright; // left right
3007 playerships[t].dockoffset.y += updown; // up down
3008 playerships[t].dockoffset.z += frontback; // fwd back
3009 }
3010 }
3011 else if (playerships[t].bay % 3 == 2) // right side
3012 {
3013 if (playerships[t].type == VehicleType::C2 ||
3014 playerships[t].type == VehicleType::C2A)
3015 {
3016 float frontback = -0.003f - aft; // negative is back
3017 playerships[t].dockoffset.x += leftright; // left right
3018 playerships[t].dockoffset.y += updown + 0.0007f; // up down
3019 playerships[t].dockoffset.z += frontback; // fwd back
3020 yaw += RiseMath::Pi;
3021 }
3022 else if (playerships[t].type == VehicleType::C98)
3023 {
3024 float frontback = -0.003f - aft; // negative is back
3025 playerships[t].dockoffset.x += leftright; // left right
3026 playerships[t].dockoffset.y += updown + 0.0004f; // up down
3027 playerships[t].dockoffset.z += frontback; // fwd back
3028 yaw += RiseMath::Pi;
3029 }
3030 else // ARJ
3031 {
3032 float frontback = -0.003f - aft; // negative is back
3033 playerships[t].dockoffset.x += leftright; // left right
3034 playerships[t].dockoffset.y += updown; // up down
3035 playerships[t].dockoffset.z += frontback; // fwd back
3036 }
3037 }
3038 else if (playerships[t].bay % 3 == 1) // middle
3039 {
3040 if (playerships[t].type == VehicleType::C2 ||
3041 playerships[t].type == VehicleType::C2A)
3042 {
3043 float frontback = -0.003f - aft; // negative is back
3044 playerships[t].dockoffset.x += leftright; // left right
3045 playerships[t].dockoffset.y += updown + 0.0007f; // up down
3046 playerships[t].dockoffset.z += frontback; // fwd back
3047 yaw += RiseMath::Pi;
3048 }
3049 else if (playerships[t].type == VehicleType::C98)
3050 {
3051 float frontback = -0.003f - aft; // negative is back
3052 playerships[t].dockoffset.x += leftright; // left right
3053 playerships[t].dockoffset.y += updown + 0.0004f; // up down
3054 playerships[t].dockoffset.z += frontback; // fwd back
3055 yaw += RiseMath::Pi;
3056 }
3057 else // ARJ
3058 {
3059 float frontback = -0.003f - aft; // negative is back
3060 playerships[t].dockoffset.x += leftright; // left right
3061 playerships[t].dockoffset.y += updown; // up down
3062 playerships[t].dockoffset.z += frontback; // fwd back
3063 }
3064 }
3065 }
3066
3067 if (t == 0) // if it is us in someone else's bay then offset our cockpit arm
3069
3070 RiseMath::QuaternionNormalize(&playerships[t].orientation, &playerships[playerships[t].inarray].orientation);
3071
3072 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3073 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[playerships[t].inarray].orientation);
3074 RiseMath::MatrixInverse(&matrixInverse, nullptr, &matrixInverse);
3075 RiseMath::Vec3TransformNormal(&cross, &playerships[t].dockoffset, &matrixInverse);
3076
3077 RiseMath::Quaternion quaternionTemp;
3078 RiseMath::QuaternionRotationYawPitchRoll(&quaternionTemp, yaw, 0, 0);
3079 RiseMath::QuaternionMultiply(&playerships[t].orientation, &playerships[t].orientation, &quaternionTemp);
3080
3081 playerships[t].precisionx = playerships[playerships[t].inarray].precisionx + static_cast<double>(cross.x);
3082 playerships[t].precisiony = playerships[playerships[t].inarray].precisiony + static_cast<double>(cross.y);
3083 playerships[t].precisionz = playerships[playerships[t].inarray].precisionz + static_cast<double>(cross.z);
3084
3086
3087 RiseMath::Vec3Add(&playerships[t].velocity, &playerships[t].dockingvel, &playerships[playerships[t].inarray].velocity);
3088
3089 // NEED TO KEEP CALCULATING THIS SO WE DON"T GO FLYING OFF
3091
3092 // Normalize a vector to ship
3094
3095 // Find barycentric velocity adjustment
3096 if (fabsf(gthrust.z) < 1.0f) // Can't be near poles or craps out on us
3097 {
3098 RiseMath::Vec3Cross(&cross, &northpoleK, &gthrust); // Find perpendicular vector
3099 RiseMath::Vec3Normalize(&cross, &cross); // Shouldn't be necessary
3100 float lat = RiseMath::Vec3Dot(&gthrust, &northpoleK);
3101 if (lat >= 1.0f)
3102 lat = -RiseMath::HalfPi; // 0-180
3103 else if (lat <= -1.0f)
3104 lat = 0.0f; // 180-180
3105 else
3106 lat = acosf(lat) - RiseMath::HalfPi; // Find the angle and reduce by 90�
3107 // Update velocity to match planet rotation speed
3108 //*** changed this from -allobjects[ourmoonC].rotation
3109 float f_temp = allobjects[ourmoonC].rotation * radius * cosf(lat);
3110 RiseMath::Vec3Scale(&playerships[t].barycentric, &cross, f_temp);
3111 }
3112 else
3114
3115 // No collisions, proposed unused
3116 return;
3117 }
3118 else if (playerships[t].reference == REF_PROXIMITY)
3119 {
3120 //logger->AddToCallStack("Viewscreen::Movement Proposed Proximity");
3121
3122 proposed = playerships[t].dockoffset + playerships[t].dockingvel * ElapsedTime;
3123 proposedx = proposed.x; proposedy = proposed.y; proposedz = proposed.z;
3124 // need to do collision then can set to proposed and return
3125 }
3126 else if (t == 0)
3127 {
3128 // No collisions or movement in a building, just return, no proposed
3129 return;
3130 }
3131 else
3132 {
3133 //logger->AddToCallStack("Viewscreen::Movement Proposed Undefined");
3134
3135 proposed = RiseMath::Vector3(0, 0, 0);
3136 proposedx = proposed.x; proposedy = proposed.y; proposedz = proposed.z;
3137 logger->Log("Using an uninitialized proposed and/or precision proposed!", Logger::Level::Fatal);
3138 }
3139
3140 // Collision detection vehicle to vehicle!
3141 if (t == 0)
3142 {
3145
3146 //logger->AddToCallStack("Viewscreen::Movement Collision Detection");
3147
3148 // Sweep each authored lamp through nearby building geometry before the
3149 // coarse hull/depth-map response stops the vehicle. Finite faces retain
3150 // the struck corner, including when the CG itself misses the obstacle.
3151 if (!g_bAboveClouds && !deathinhibit && !playerships[0].isSimulator &&
3152 playerships[0].reference < REF_INANOTHER)
3154
3155 bool collision = false;
3156 short s;
3157 RiseMath::Vector3 result, target, source;
3158
3159 // Disengaged because of docking procedures wreaks havoc
3160 // Check against docks
3161 if (playerships[0].reference >= REF_DOCKENUMCPOC && dockprogress == 0.0f && !playerships[0].docked && deathinhibit == 0.0f)
3162 {
3164 // proposed coord is 18 meters from centroid, 15 meter radius and our body is 5 meters ...
3165 // 18-15 < 5 ... that works
3166 if (RiseMath::Vec3Length(&proposed) < (playerships[0].bound + allobjects[s].bound))
3167 {
3168 for (unsigned short r = 0; r < allobjects[s].components; r++)
3169 {
3170 // types to skip: no bounding sphere, interior of cargo bay
3171 if (allobjects[s].componentarray[r].type == 53 || allobjects[s].componentarray[r].type == 54)
3172 continue;
3173
3174 // Extensions for each module of target (dock)
3175 RiseMath::Vec3Scale(&result, &allobjects[s].componentarray[r].extendby, allobjects[s].componentarray[r].extended);
3176 RiseMath::Vec3Add(&result, &allobjects[s].componentarray[r].nominalxyz, &result);
3177
3178 target = result;
3179
3180 for (unsigned short q = 0; q < playerships[0].components; q++)
3181 {
3182 // types to skip: no bounding sphere, interior of cargo bay
3183 if (playerships[0].componentarray[q].type == 53 || playerships[0].componentarray[q].type == 54)
3184 continue;
3185
3186 // Extensions for our ship
3187 RiseMath::Vec3Scale(&result, &playerships[0].componentarray[q].extendby, playerships[0].componentarray[q].extended);
3188 RiseMath::Vec3Add(&result, &playerships[0].componentarray[q].nominalxyz, &result);
3189 // This adjusts for orientation, could do scale but there is none ... does NOT do location
3190 RiseMath::Vec3TransformCoord(&source, &result, &playerships[0].matrixInvOrientation);
3191
3192 if (playerships[0].reference >= REF_DOCKENUMCPOC) // keep relative to our reference frame
3193 source -= playerships[0].dockoffset;
3194 else
3195 source -= playerships[0].position;
3196
3197 result = source - target;
3198
3200 float distCgtoCg = RiseMath::Vec3Length(&result);
3201 if (distCgtoCg <= separateBy)
3202 {
3203 // how many units of overlap to seperate them by
3204 float f_temp = RiseMath::Vec3Length(&result) - separateBy;
3205
3206 // use vector from object to us
3207 if (RiseMath::Vec3Length(&result) < FLT_EPSILON)
3208 {
3209 result.x = RandomFloat() - 0.5f;
3210 result.y = RandomFloat() - 0.5f;
3211 result.z = RandomFloat() - 0.5f;
3212 }
3213 RiseMath::Vec3Normalize(&result, &result);
3214 RiseMath::Vec3Scale(&result, &result, -f_temp);
3215
3216 proposed -= result;
3217 proposedx -= static_cast<double>(result.x);
3218 proposedy -= static_cast<double>(result.y);
3219 proposedz -= static_cast<double>(result.z);
3220
3221 if (-f_temp > 0.001f)
3222 collision = true;
3224
3225 q = playerships[0].components;
3226 r = allobjects[s].components;
3227 }
3228 }
3229 }
3230 } // not within main bounding sphere
3231 } // object loop
3232
3233
3234 // Collision detection check against ships
3235 if (deathinhibit == 0.0f)
3236 {
3237 for (s = 1; s < MAX_SCAN; s++) // cycle through all other ships
3238 {
3239 if (playerships[s].active && playerships[s].visible &&
3240 playerships[s].reference != REF_INANOTHER && // not in our bays, we should not have data on ones in interiors
3242 {
3243 // Solve for distance from our CG to their CG
3244 if (playerships[0].reference >= REF_DOCKENUMCPOC)
3245 {
3246 if (playerships[0].reference == playerships[s].reference)
3247 result = proposed - playerships[s].dockoffset; // apples to apples
3248 else
3249 result.x = result.y = result.z = 999.0f; // no chance
3250 }
3251 else
3252 result = proposed - playerships[s].position;
3253
3254 float dist = RiseMath::Vec3Length(&result);
3255
3256 // Check against biggest bounding sphere first to see if we need delve deeper
3257 if (dist >= (playerships[0].bound + playerships[s].bound))
3258 continue;
3259
3260 // Well, their big bounding spheres are interfering, check through components
3261 sprintf_s(msg, sizeof msg, "Major axis with IVR %s, separating %.3f %.3f %.3f dist %f", playerships[s].IVR, result.x, result.y, result.z, dist);
3262 logger->Log(msg);
3263 for (unsigned short r = 0; r < playerships[s].components; r++)
3264 {
3265 // types to skip: no bounding sphere, interior of cargo bay
3266 if (!playerships[s].componentarray[r].visible ||
3267 playerships[s].componentarray[r].type == 53 ||
3268 playerships[s].componentarray[r].type == 54)
3269 continue;
3270
3271 for (unsigned short q = 0; q < playerships[0].components; q++)
3272 {
3273 // types to skip: no bounding sphere, interior of cargo bay
3274 if (!playerships[0].componentarray[q].visible ||
3275 playerships[0].componentarray[q].type == 53 ||
3276 playerships[0].componentarray[q].type == 54)
3277 continue;
3278
3279 RiseMath::Vector3 ourComponentPosition = RiseMath::Vector3(0, 0, 0);
3280 RiseMath::Vec3TransformCoord(&ourComponentPosition, &ourComponentPosition, &playerships[0].componentarray[q].matWorld);
3281 RiseMath::Vector3 theirComponentPosition = RiseMath::Vector3(0, 0, 0);
3282 RiseMath::Vec3TransformCoord(&theirComponentPosition, &theirComponentPosition, &playerships[s].componentarray[r].matWorld);
3283 result = ourComponentPosition - theirComponentPosition;
3284 dist = RiseMath::Vec3Length(&result);
3285 if (dist < (playerships[0].componentarray[q].boundsphere + playerships[s].componentarray[r].boundsphere))
3286 {
3287 sprintf_s(msg, sizeof(msg), "Minor axis with IVR %s, separating %.3f %.3f %.3f dist %f", playerships[s].IVR, result.x, result.y, result.z, dist);
3288 logger->Log(msg);
3289
3290 // angle between the two CG's needs to be widened by the two spheres
3291 // how many units of overlap to separate them by (we are supposed to be 3 but are 2 then we have to sep by 1
3292 const float separation = (playerships[s].componentarray[r].boundsphere + playerships[0].componentarray[q].boundsphere) - dist;
3293 if (separation < 0.0001f) // 10th a meter
3294 continue;
3295
3296 // use vector from object to us
3297 if (dist < FLT_EPSILON)
3298 {
3299 result.x = RandomFloat() - 0.5f;
3300 result.y = RandomFloat() - 0.5f;
3301 result.z = RandomFloat() - 0.5f;
3302 }
3303 RiseMath::Vector3 resnorm;
3304 RiseMath::Vec3Normalize(&resnorm, &result);
3305 RiseMath::Vec3Scale(&result, &resnorm, separation);
3306 RiseMath::Vector3 displacement = result;
3307 collision = true;
3308 proposed -= displacement;
3309 proposedx -= static_cast<double>(displacement.x);
3310 proposedy -= static_cast<double>(displacement.y);
3311 proposedz -= static_cast<double>(displacement.z);
3312
3313
3314 // @todo we should explore getting weights for each vehicle from the server
3315 // difference in velocities adjusted for who is heaver
3316 float ourweight1 = ptrPropulsion->totalWeightLbs;
3317 float hisweight1 = static_cast<float>(playerships[s].totalWeightLbs);
3318 // so if they are equal it is 0.5 ... if we are 1 and they are 2 then it is 1/3 0.333
3319 const float theirPenalty = ourweight1 / (ourweight1 + hisweight1);
3320 const float ourPenalty = hisweight1 / (ourweight1 + hisweight1);
3321 if (playerships[0].reference < REF_INANOTHER)
3323 else
3324 cross = playerships[0].dockingvel;
3325 RiseMath::Vector3 velDiff = cross;
3326 if (playerships[0].reference < REF_INANOTHER)
3327 velDiff -= playerships[s].velocity - playerships[s].barycentric;
3328 else
3329 velDiff -= playerships[s].dockingvel;
3330 RiseMath::Vector3 theirPenaltyVel = velDiff * theirPenalty;
3331 RiseMath::Vector3 ourPenaltyVel = velDiff * ourPenalty;
3332 // Component spheres retain the actual obstacle location. Test
3333 // each lamp rather than infer a side from stopped velocity.
3334 RiseMath::Matrix impactToBody;
3335 RiseMath::MatrixRotationQuaternion(&impactToBody, &playerships[0].orientation);
3336 RiseMath::Vector3 centerBody, velocityBody;
3337 RiseMath::Vec3TransformNormal(&centerBody, &theirComponentPosition, &impactToBody);
3338 const auto exteriorVelocity = -velDiff;
3339 RiseMath::Vec3TransformNormal(&velocityBody, &exteriorVelocity, &impactToBody);
3340 DamageLandingLightsAgainstSphere(centerBody, playerships[s].componentarray[r].boundsphere,
3341 velocityBody, ElapsedTime);
3342
3343 if (RiseMath::Vec3Length(&theirPenaltyVel) >= 0.001f) // JIRA 1110 don't send if less than 1 meter
3344 {
3345 // send special packet for offline ships
3346 SClientPacket outpacket;
3347 outpacket.type = 5; // collision info
3348 outpacket.f_x = theirPenaltyVel.x;
3349 outpacket.f_y = theirPenaltyVel.y;
3350 outpacket.f_z = theirPenaltyVel.z;
3351 outpacket.f_w = static_cast<float>(playerships[s].vehicleId);
3352 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
3353 }
3354
3355 //playerships[s].velocity += theirPenaltyVel;
3356 playerships[0].velocity -= ourPenaltyVel;
3357
3358
3359 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3360 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3361 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3362 RiseMath::Vec3TransformNormal(&cross, &ourPenaltyVel, &matrixInverse);
3363 ApplyCollisionImpulse(-cross);
3364
3366 for (int i = 0; i < MAX_ENGINES; i++)
3367 {
3368 if (playerships[0].groundvehicle)
3369 gameclass->bus->EngineThrustLever[i] = 0.1f; // idle
3370 else
3371 gameclass->bus->EngineThrustLever[i] = 0.0f; // idle
3372 }
3373
3376
3377 sprintf_s(msg, sizeof msg, "Collided with IVR %s, separating %.3f %.3f %.3f dist %f", playerships[s].IVR, result.x, result.y, result.z, dist);
3378 logger->Log(msg);
3379 sprintf_s(msg, sizeof msg, "Sumofforces now %.3f %.3f %.3f", sumofforces.x, sumofforces.y, sumofforces.z);
3380 logger->Log(msg);
3381
3383 q = playerships[0].components;
3384 r = playerships[s].components;
3385 }
3386 }
3387 }
3388 }
3389 }
3390 }
3391
3392
3393 // CITY BUILDING COLLISION DETECTION AND AGL OFFSET CALCULATION
3394 if (!collision && !g_bAboveClouds)
3395 {
3396 static VECTOR2SHORT olddepthpos, oldbump;
3397 float f_tempu, f_tempv, f_tempd;
3398 result = -proposed;
3399 RiseMath::Vec3Normalize(&result, &result);
3400
3401 if (RiseMath::IntersectTri(&gridarray[32][31].position, &gridarray[31][31].position, &gridarray[32][32].position, &centerC, &result, &f_tempu, &f_tempv, &f_tempd))
3402 {
3403 f_tempu = 1.0f - f_tempu;
3404
3405 // BUMP
3406 f_tempd = roundf(f_tempu * 6656.0f); // V2-V1
3407 rts.u = static_cast<short>(floorf(f_tempd / 256.0f));
3408 bump.u = static_cast<short>(fmodf(f_tempd, 256.0f));
3409
3410 f_tempd = roundf(f_tempv * 6656.0f); // V3-V1
3411 rts.v = static_cast<short>(floorf(f_tempd / 256.0f));
3412 bump.v = static_cast<short>(fmodf(f_tempd, 256.0f));
3413
3414 rts.v = 25 - rts.v;
3415
3416 f_tempd = f_tempu * static_cast<float>(depthFloorResolutionC); // V2-V1
3417 newdepthpos.u = static_cast<short>(roundf(f_tempd));
3418 f_tempd = f_tempv * static_cast<float>(depthFloorResolutionC); // V3-V1
3419 newdepthpos.v = static_cast<short>(roundf(f_tempd));
3420 }
3421 else if (RiseMath::IntersectTri(&gridarray[31][32].position, &gridarray[32][32].position, &gridarray[31][31].position, &centerC, &result, &f_tempu, &f_tempv, &f_tempd))
3422 {
3423 f_tempv = 1.0f - f_tempv;
3424
3425 // BUMP
3426 f_tempd = roundf(f_tempu * 6656.0f); // V2-V1
3427 rts.u = static_cast<short>(floorf(f_tempd / 256.0f));
3428 bump.u = static_cast<short>(fmodf(f_tempd, 256.0f));
3429
3430 f_tempd = roundf(f_tempv * 6656.0f); // V3-V1
3431 rts.v = static_cast<short>(floorf(f_tempd / 256.0f));
3432 bump.v = static_cast<short>(fmodf(f_tempd, 256.0f));
3433
3434 rts.v = 25 - rts.v;
3435
3436 f_tempd = f_tempu * static_cast<float>(depthFloorResolutionC); // V2-V1
3437 newdepthpos.u = static_cast<short>(roundf(f_tempd));
3438 f_tempd = f_tempv * static_cast<float>(depthFloorResolutionC); // V3-V1
3439 newdepthpos.v = static_cast<short>(roundf(f_tempd));
3440 }
3441 else
3442 {
3443 rts.u = rts.v = bump.u = bump.v = -2;
3444 newdepthpos.u = newdepthpos.v = -2;
3445 }
3446
3447
3449 gameclass->bus->DebugType = gridarray[31][31].type;
3450
3451 if (ptrGrid->patchGeometry && (rts.u != oldRts.u || rts.v != oldRts.v))
3452 {
3453 // this is our hook for rebuilding the local curb map
3455 oldRts = rts;
3456 }
3457
3458 if (ptrGrid->patchGeometry && zone != oldZone)
3459 {
3461 oldZone = zone;
3462 }
3463
3464 float newcityelev, newflorelev;
3465 if (olddepthpos.u != newdepthpos.u || olddepthpos.v != newdepthpos.v)
3466 {
3467 olddepthpos = newdepthpos; // maybe use this to arrest the velocity correctly!!!
3468 newcityelev = CheckDepthMap(newdepthpos, 31, 31);
3471 newflorelev = CheckFloorMap(newdepthpos, 31, 31);
3472 }
3473 else
3474 {
3475 newcityelev = citystuff.elevation;
3476 newflorelev = citystuff.floorelev;
3477 }
3478
3479
3480 float newcurbelev;
3481 if (oldbump.u != bump.u || oldbump.v != bump.v || (gridarray[31][31].roads && oldbump.u == bump.u && oldbump.v == bump.v))
3482 {
3483 ptrBuildings->g_bRoad = false;
3484 if (gridarray[31][31].type == PlotType::UserAirfield &&
3485 buildings::CheckLayout(98, gridarray[31][31]) && // runway is completed
3486 f_tempu > 0.73857f && f_tempu < 0.76143189f && f_tempv > 0.25f) // has to match the shader
3487 {
3488 ptrBuildings->g_bRoad = true;
3489 newcurbelev = 0.0f;
3490 }
3491 else if (gridarray[31][31].roads && CheckPlotRoads(f_tempu, f_tempv))
3492 {
3493 ptrBuildings->g_bRoad = true;
3494 newcurbelev = 0.0f;
3495 }
3496 else
3497 {
3498 newcurbelev = ptrBuildings->CheckRtsBumpMap(rts, bump, 31, 31);
3499 }
3500 }
3501 else
3502 {
3503 newcurbelev = citystuff.curbelev;
3504 }
3505
3506 gameclass->bus->DebugDepth.z = newcurbelev;
3507
3508
3513 RiseMath::Vector3 plumb;
3514 RiseMath::Vec3Normalize(&plumb, &gridarray[31][31].position); // @todo @rana is testing i think this is just the building depth map collision? &buildzone[gridarray[31][31].buildzoneOrdinal].terpos);
3515
3516
3517 RiseMath::Vector3 leftvec, rightvec, northNormal, eastNormal;
3518 RiseMath::Vec3Subtract(&leftvec, &ll, &ul);
3519 RiseMath::Vec3Subtract(&rightvec, &lr, &ur);
3520 RiseMath::Vec3Add(&northNormal, &leftvec, &rightvec);
3521 RiseMath::Vec3Scale(&northNormal, &northNormal, 0.5f);
3522 RiseMath::Vec3Normalize(&northNormal, &northNormal);
3523
3524 RiseMath::Vec3Cross(&eastNormal, &northNormal, &plumb);
3525 RiseMath::Vec3Normalize(&eastNormal, &eastNormal);
3526
3527
3528 if (f_AGL < newflorelev && newflorelev != 255.0f) // so we can go under overhangs without movement.cpp repositioning us
3529 newcityelev = 0.0f;
3530
3531 // hit the side
3533 {
3534 cross = UniverseRelativeVelocityKms; // speed in which they hit the side
3535 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3536 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3537 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3538 RiseMath::Vec3TransformNormal(&cross, &cross, &matrixInverse);
3539 ApplyCollisionImpulse(-cross);
3540 // Lamp damage was resolved against finite city faces before this coarse stop.
3541
3542 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f collision side", -cross.x * oneOvergForceKmssC / ElapsedTime, 0.0f, -cross.z * oneOvergForceKmssC / ElapsedTime);
3543 sofTracking.emplace_back(msg);
3544
3545 proposed = playerships[0].position;
3546 proposedx = playerships[0].precisionx;
3547 proposedy = playerships[0].precisiony;
3548 proposedz = playerships[0].precisionz;
3549
3550 sprintf_s(msg, sizeof msg, "*** Hit side... floor %.3f us %.3f height %f (u%i v%i)", newflorelev, f_AGL, newcityelev, newdepthpos.u, newdepthpos.v);
3551 logger->Log(msg);
3552
3553 for (int i = 0; i < MAX_ENGINES; i++)
3554 {
3555 if (playerships[0].groundvehicle)
3556 gameclass->bus->EngineThrustLever[i] = 0.1f; // idle
3557 else
3558 gameclass->bus->EngineThrustLever[i] = 0.0f; // idle
3559 }
3560
3561 collision = true;
3563 }
3564 else
3565 {
3566 citystuff.elevation = newcityelev;
3567 citystuff.floorelev = newflorelev;
3568 }
3569
3570
3571 // Curbs on bumpmap from RTS
3572 if (playerships[0].reference == REF_ONGROUND && newcityelev == 0.0f && (bump.u != oldbump.u || bump.v != oldbump.v))
3573 {
3574 // sin of 0 is 0, 90 is 1 ... cos of 0 is 1, 90 is 0
3575 const float elevationDiff = newcurbelev - citystuff.curbelev; // Clamp(newcurbelev - citystuff.curbelev, -0.0002032f, 0.0002032f); // I don't think we do anything over 8"
3576 float theta = RiseMath::HalfPi; // impassible
3577 if (ourcockpit.tireRadiusKm > elevationDiff && elevationDiff > FLT_EPSILON)
3578 theta = acosf((ourcockpit.tireRadiusKm - elevationDiff) / ourcockpit.tireRadiusKm); // radians
3579 // Curb height (h) = 0.000203 km = 20.3 cm = 8 inches
3580 // Tire radius(r) = 0.000348 km = 34.8 cm = ~13.7 inches
3581 // θ ≈ 65.3°
3582 // Vertical redirection ≈ 90.97 %
3583 // Vertical displacement = 4.22 meters
3584 // Only ~1.2 % of vertical motion can be absorbed by a 5 cm strut
3585 // Approximately 58.3% of the horizontal velocity is lost (redirected upward) when the tire climbs the curb in this case.
3586
3587
3588 float longitudinalMod = 1.0f - cosf(theta);
3589 float verticalMod = sinf(theta);
3590
3591 auto applyCurbImpact = [&](const char* direction)
3592 {
3593 const float verticalVelocityKms = cross.z * verticalMod;
3594 const float verticalDisplacementKm =
3595 (verticalVelocityKms * verticalVelocityKms) / (2.0f * gravityKmssC);
3596
3597 const float weightRatio = Clamp(
3599 const float normalLoadG = Clamp(suspensionNormalLoadG, 0.0f, 3.0f);
3600 const float bumpTravelKm = GetAverageSuspensionBumpTravelKm();
3601 const float loadedSagKm = RiseMath::Max(0.0f, ourcockpit.suspensionTravelKm - bumpTravelKm);
3602 const float droopTravelKm = loadedSagKm;
3603 const float compliantTravelKm = playerships[0].groundvehicle
3604 ? bumpTravelKm + ourcockpit.tireComplianceKm
3606 const float unabsorbedRatio = verticalDisplacementKm > FLT_EPSILON
3607 ? 1.0f - RiseMath::Min(1.0f, compliantTravelKm / verticalDisplacementKm)
3608 : 0.0f;
3609 const float suspensionShare = compliantTravelKm > FLT_EPSILON
3610 ? bumpTravelKm / compliantTravelKm
3611 : 0.0f;
3612 ApplySuspensionImpact(fabsf(verticalVelocityKms) * (1.0f - unabsorbedRatio) * suspensionShare);
3613
3614 const float lateralVelocityKms = -cross.x;
3615 playerships[0].rollRadPerSec += cross.x * 2000000.0f /
3617 ApplyCollisionImpulse(RiseMath::Vector3(lateralVelocityKms,
3618 -verticalVelocityKms * unabsorbedRatio, -cross.z * longitudinalMod) * ElapsedTime);
3619
3620 char diagnostic[1024];
3621 sprintf_s(diagnostic, sizeof(diagnostic),
3622 "CURB #%u dir=%s dt=%.5f speed=%.2fkph height=%.1fmm tireRadius=%.1fmm theta=%.2fdeg "
3623 "weight=%.0flb weightRatio=%.3f normalLoad=%.3fG travel=%.1fmm sag=%.1fmm bump=%.1fmm droop=%.1fmm "
3624 "tireCompliance=%.1fmm verticalDisp=%.1fmm unabsorbed=%.3f longMod=%.3f "
3625 "wheelCompression=(%.1f,%.1f,%.1f,%.1f)mm wheelVelocity=(%.3f,%.3f,%.3f,%.3f)mps "
3626 "deltaV=(%+.6f,%+.6f,%+.6f)",
3627 curbDiagnosticSequence, direction, ElapsedTime, RiseMath::Vec3Length(&cross) * 3600.0f,
3628 elevationDiff * 1000000.0f, ourcockpit.tireRadiusKm * 1000000.0f, RiseMath::ToDegree(theta),
3629 ptrPropulsion->totalWeightLbs, weightRatio, normalLoadG,
3630 ourcockpit.suspensionTravelKm * 1000000.0f, loadedSagKm * 1000000.0f,
3631 bumpTravelKm * 1000000.0f, droopTravelKm * 1000000.0f,
3632 ourcockpit.tireComplianceKm * 1000000.0f, verticalDisplacementKm * 1000000.0f,
3633 unabsorbedRatio, longitudinalMod,
3634 suspensionWheels[FrontLeft].compressionKm * 1000000.0f,
3635 suspensionWheels[FrontRight].compressionKm * 1000000.0f,
3636 suspensionWheels[RearLeft].compressionKm * 1000000.0f,
3637 suspensionWheels[RearRight].compressionKm * 1000000.0f,
3638 suspensionWheels[FrontLeft].velocityKms * 1000.0f,
3639 suspensionWheels[FrontRight].velocityKms * 1000.0f,
3640 suspensionWheels[RearLeft].velocityKms * 1000.0f,
3641 suspensionWheels[RearRight].velocityKms * 1000.0f,
3642 lateralVelocityKms * ElapsedTime,
3643 -verticalVelocityKms * unabsorbedRatio * ElapsedTime,
3644 -cross.z * longitudinalMod * ElapsedTime);
3645 LogCurbDiagnostic(diagnostic);
3646
3647 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f curb %s",
3648 lateralVelocityKms * oneOvergForceKmssC,
3649 -verticalVelocityKms * unabsorbedRatio * oneOvergForceKmssC,
3650 -cross.z * longitudinalMod * oneOvergForceKmssC, direction);
3651 sofTracking.emplace_back(msg);
3652 };
3653
3654 if ((newcurbelev != 0 || citystuff.curbelev != 0) && fabsf(elevationDiff) > FLT_EPSILON)
3655 {
3656 sprintf_s(msg, sizeof msg, "Bary U%i V%i RTS U%i V%i Bump U%i V%i newcurb %f oldcurb %f", newdepthpos.u, newdepthpos.v, rts.u, rts.v, bump.u, bump.v, newcurbelev, citystuff.curbelev);
3657 logger->Log(msg);
3658 sprintf_s(msg, sizeof msg, "-> elevation change %f theta %f longitudinalMod %f verticalMod %f", elevationDiff, theta, longitudinalMod, verticalMod);
3659 logger->Log(msg);
3660 }
3661
3662 if (UniverseRelativeSpeedKms > 0 && deathinhibit == 0.0f) // added deathinhibit 8/27/2021 for hipp0cat coming out of the sim and sent flying
3663 {
3665
3666 if (elevationDiff > FLT_EPSILON) // riding UP on curb
3667 {
3668 sprintf_s(msg, sizeof(msg), "-> Riding up a curb %.6f", elevationDiff);
3669 logger->Log(msg);
3672 curbDiagnosticFramesRemaining = 60; // capture roughly two seconds of spring compression/rebound
3673
3674 if (bump.u > oldbump.u && abs(bump.u - oldbump.u) < 128) // traveling east on map into curb
3675 {
3676 float f_temp = RiseMath::Vec3Dot(&overallNormal, &eastNormal); // east component
3677 RiseMath::Vector3 eastVector;
3678 RiseMath::Vec3Scale(&eastVector, &eastNormal, f_temp * UniverseRelativeSpeedKms);
3679
3680 sprintf_s(msg, sizeof(msg), "-> Was traveling east %.3f at %.3f", f_temp, f_temp * UniverseRelativeSpeedKms);
3681 logger->Log(msg);
3682
3683 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3684 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3685 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3686 RiseMath::Vec3TransformNormal(&cross, &eastVector, &matrixInverse);
3687
3688 applyCurbImpact("east");
3689
3690 sprintf_s(msg, sizeof msg, "-> W2E cross.x %f cross.z %f cross.z*rolldiff %f ewmag %f", cross.x, cross.z, cross.z * longitudinalMod, fabsf(f_temp * UniverseRelativeSpeedKms));
3691 logger->Log(msg);
3692 }
3693 else if (bump.u < oldbump.u && abs(bump.u - oldbump.u) < 128) // traveling west on map into curb
3694 {
3695 float f_temp = RiseMath::Vec3Dot(&overallNormal, &eastNormal);
3696 RiseMath::Vector3 eastVector;
3697 RiseMath::Vec3Scale(&eastVector, &eastNormal, f_temp * UniverseRelativeSpeedKms);
3698
3699 sprintf_s(msg, sizeof(msg), "-> Was traveling west %.3f at %.3f", f_temp, f_temp * UniverseRelativeSpeedKms);
3700 logger->Log(msg);
3701
3702 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3703 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3704 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3705 RiseMath::Vec3TransformNormal(&cross, &eastVector, &matrixInverse);
3706
3707 applyCurbImpact("west");
3708
3709 sprintf_s(msg, sizeof msg, "-> E2W cross.x %f cross.z %f cross.z*skiddiff*rolldiff %f ewmag %f", cross.x, cross.z, cross.z * elevationDiff * longitudinalMod, fabsf(f_temp * UniverseRelativeSpeedKms));
3710 logger->Log(msg);
3711 }
3712
3713 if (bump.v < oldbump.v && abs(bump.v - oldbump.v) < 128) // traveling north on map into curb
3714 {
3715 float f_temp = RiseMath::Vec3Dot(&overallNormal, &northNormal);
3716 RiseMath::Vector3 northVector;
3717 RiseMath::Vec3Scale(&northVector, &northNormal, f_temp * UniverseRelativeSpeedKms);
3718
3719 sprintf_s(msg, sizeof(msg), "-> Was traveling north %.3f at %.3f", f_temp, f_temp * UniverseRelativeSpeedKms);
3720 logger->Log(msg);
3721
3722 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3723 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3724 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3725 RiseMath::Vec3TransformNormal(&cross, &northVector, &matrixInverse);
3726
3727 applyCurbImpact("north");
3728
3729 sprintf_s(msg, sizeof msg, "-> S2N cross.x %f cross.z %f cross.z*skiddiff*rolldiff %f nsmag %f", cross.x, cross.z, cross.z * elevationDiff * longitudinalMod, fabsf(f_temp * UniverseRelativeSpeedKms));
3730 logger->Log(msg);
3731 }
3732 else if (bump.v > oldbump.v && abs(bump.v - oldbump.v) < 128) // traveling south on map into curb
3733 {
3734 float f_temp = RiseMath::Vec3Dot(&overallNormal, &northNormal);
3735 RiseMath::Vector3 northVector;
3736 RiseMath::Vec3Scale(&northVector, &northNormal, f_temp * UniverseRelativeSpeedKms);
3737
3738 sprintf_s(msg, sizeof(msg), "-> Was traveling south %.3f at %.3f", f_temp, f_temp * UniverseRelativeSpeedKms);
3739 logger->Log(msg);
3740
3741 RiseMath::Matrix matrixInverse; // need to make new one because we have moved since
3742 RiseMath::QuaternionNormalize(&playerships[0].orientation, &playerships[0].orientation);
3743 RiseMath::MatrixRotationQuaternion(&matrixInverse, &playerships[0].orientation);
3744 RiseMath::Vec3TransformNormal(&cross, &northVector, &matrixInverse);
3745
3746 applyCurbImpact("south");
3747
3748 sprintf_s(msg, sizeof msg, "-> N2S cross.x %f cross.z %f cross.z*skiddiff*rolldiff %f nsmag %f", cross.x, cross.z, cross.z * elevationDiff * longitudinalMod, fabsf(f_temp * UniverseRelativeSpeedKms));
3749 logger->Log(msg);
3750 }
3751 }
3752 else if (elevationDiff < -FLT_EPSILON)
3753 {
3754 // airborne, do this way or gravityacc can be applied to sumofforces (global)
3756
3757 sprintf_s(msg, sizeof(msg), "-> Riding down a curb %.6f", elevationDiff);
3758 logger->Log(msg);
3759 }
3760 }
3761
3762 oldbump = bump;
3763 citystuff.curbelev = newcurbelev;
3764 }
3765 }
3766 else
3767 {
3768 citystuff.elevation = 0.0f;
3769 citystuff.floorelev = 255.0f * cityscaleC;
3770 }
3771
3773 if (!collision && !g_bAboveClouds)
3774 {
3775 if (gridarray[31][31].IsUserColony())
3776 {
3777 short buildZoneOrdinal = gridarray[31][31].buildzoneOrdinal;
3778 if (buildZoneOrdinal != -1)
3779 {
3780 if (ptrBuildings->CheckCollision(buildZoneOrdinal, playerships[0].position, UniverseRelativeVelocityKms, playerships[0].bound, ElapsedTime, &cross))
3781 {
3782 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f collision colony", cross.x * oneOvergForceKmssC / ElapsedTime, cross.y * oneOvergForceKmssC / ElapsedTime, cross.z * oneOvergForceKmssC / ElapsedTime);
3783 sofTracking.emplace_back(msg);
3784
3785 ApplyCollisionImpulse(cross);
3786
3788
3789 for (int i = 0; i < MAX_ENGINES; i++)
3790 {
3791 if (playerships[0].groundvehicle)
3792 gameclass->bus->EngineThrustLever[i] = 0.1f; // idle
3793 else
3794 gameclass->bus->EngineThrustLever[i] = 0.0f; // idle
3795 }
3796 }
3797 }
3798 }
3799 }
3800
3801
3802
3803 // It hit one of these objects! should depend on how HARD we hit it
3804 if (collision)
3805 {
3806 if (rand() < 4096 || dockprogress < 1.0f) // 12% chance
3807 {
3808 sprintf_s(msg, sizeof msg, "Collision calling Undock...");
3809 logger->Log(msg);
3810 Undock();
3811 rcsThrustOutputY -= 0.02f;
3812 }
3813 if (rand() < 4096) // 12% chance
3814 {
3815 if (ourcockpit.vdat.thrustaug > 0)
3816 ourcockpit.vdat.thrustaug -= (char)(RandomFloat() * (float)(ourcockpit.vdat.thrustaug + 1.0f));
3817 ourcockpit.vdatChanged = true;
3818 }
3819 if (rand() < 4096) // 12% chance
3820 {
3821 if (ourcockpit.vdat.yawdamper > 0)
3822 ourcockpit.vdat.yawdamper -= (char)(RandomFloat() * (float)(ourcockpit.vdat.yawdamper + 1.0f));
3823 ourcockpit.vdatChanged = true;
3824 }
3825 if (rand() < 2048) // 6% chance on right engine
3826 {
3827 if (ourcockpit.vdat.rightengine > 0)
3828 ourcockpit.vdat.rightengine -= (char)(RandomFloat() * (float)(ourcockpit.vdat.rightengine + 1.0f));
3829 ourcockpit.vdatChanged = true;
3830 }
3831 if (rand() < 2048) // 6% chance on left engine
3832 {
3833 if (ourcockpit.vdat.leftengine > 0)
3834 ourcockpit.vdat.leftengine -= (char)(RandomFloat() * (float)(ourcockpit.vdat.leftengine + 1.0f));
3835 ourcockpit.vdatChanged = true;
3836 }
3837 if (rand() < 2048) // 6% chance on tail engine
3838 {
3839 if (ourcockpit.vdat.clengine > 0)
3840 ourcockpit.vdat.clengine -= (char)(RandomFloat() * (float)(ourcockpit.vdat.clengine + 1.0f));
3841 ourcockpit.vdatChanged = true;
3842 }
3843 if (rand() < 1024) // 3% chance on vtail
3844 {
3845 if (ourcockpit.vdat.vtail > 0)
3846 ourcockpit.vdat.vtail -= (char)(RandomFloat() * (float)(ourcockpit.vdat.vtail + 1.0f));
3847 ourcockpit.vdatChanged = true;
3848 }
3849 if (rand() < 1024) // 3% chance on htail
3850 {
3851 if (ourcockpit.vdat.htail > 0)
3852 ourcockpit.vdat.htail -= (char)(RandomFloat() * (float)(ourcockpit.vdat.htail + 1.0f));
3853 ourcockpit.vdatChanged = true;
3854 }
3855 if (rand() < 1024) // 3% chance on right wing
3856 {
3857 if (ourcockpit.vdat.rightwing > 0)
3858 ourcockpit.vdat.rightwing -= (char)(RandomFloat() * (float)(ourcockpit.vdat.rightwing + 1.0f));
3859 ourcockpit.vdatChanged = true;
3860 }
3861 if (rand() < 1024) // 3% chance on left wing
3862 {
3863 if (ourcockpit.vdat.leftwing > 0)
3864 ourcockpit.vdat.leftwing -= (char)(RandomFloat() * (float)(ourcockpit.vdat.leftwing + 1.0f));
3865 ourcockpit.vdatChanged = true;
3866 }
3867
3868 if (rand() % 2 == 0)
3870 else
3872 }
3873 }
3874
3875 // At a dock
3876 if (playerships[t].reference >= REF_DOCKENUMCPOC)
3877 {
3878 //logger->AddToCallStack("Viewscreen::Movement Dock Reference");
3879
3880 playerships[t].dockoffset = proposed; // double proposedxyz not used
3881 playerships[t].precisionx = static_cast<double>(allobjects[playerships[t].reference - REF_DOCKENUMCPOC].position.x) + static_cast<double>(playerships[t].dockoffset.x);
3882 playerships[t].precisiony = static_cast<double>(allobjects[playerships[t].reference - REF_DOCKENUMCPOC].position.y) + static_cast<double>(playerships[t].dockoffset.y);
3883 playerships[t].precisionz = static_cast<double>(allobjects[playerships[t].reference - REF_DOCKENUMCPOC].position.z) + static_cast<double>(playerships[t].dockoffset.z);
3884
3886 RiseMath::Vec3Add(&playerships[t].velocity, &playerships[t].dockingvel, &allobjects[playerships[t].reference - REF_DOCKENUMCPOC].velocity);
3887
3888 return;
3889 }
3890
3891 // floating man?
3892 if (playerships[t].reference == REF_PROXIMITY)
3893 {
3894 //logger->AddToCallStack("Viewscreen::Movement Proximity Reference");
3895
3896 playerships[t].dockoffset = proposed; // double proposedxyz not used
3900
3902 RiseMath::Vec3Add(&playerships[t].velocity, &playerships[t].dockingvel, &playerships[playerships[t].inarray].velocity);
3903
3904 return;
3905 }
3906
3907
3908 //logger->AddToCallStack("Viewscreen::Movement Copy Proposed");
3909
3910 playerships[t].position = proposed;
3911 playerships[t].precisionx = proposedx;
3912 playerships[t].precisiony = proposedy;
3913 playerships[t].precisionz = proposedz;
3914
3915
3916 if (t == 0)
3917 {
3918 AssertTelemetry("Viewscreen::Movement2", t);
3919 }
3920
3921 if (playerships[t].tireCircumferenceKm)
3922 {
3923 RiseMath::Vector3 tempGroundSpeedKms = playerships[t].velocity - playerships[t].barycentric;
3924 RiseMath::Vec3TransformNormal(&tempGroundSpeedKms, &tempGroundSpeedKms, &playerships[t].matrixInvOrientation);
3925 if (t == 0 && !playerships[t].groundvehicle)
3926 gameclass->bus->GroundSpeedKms = tempGroundSpeedKms.z;
3927 if (playerships[t].reference == REF_ONGROUND)
3929 else if (!playerships[t].geardown)
3930 playerships[t].tireRotationRadPerS = 0.0f; // snub it
3931 else if (playerships[t].tireRotationRadPerS)
3932 {
3933 // 85.2 rad/s when Bill took off in T-19 ... spin down 15-20 seconds
3934 playerships[t].tireRotationRadPerS -= playerships[t].tireRotationRadPerS * 0.2f * ElapsedTime;
3935 if (fabsf(playerships[t].tireRotationRadPerS) < 0.852f)
3937 }
3938
3940 playerships[t].tirePositionRad = fmodf(playerships[t].tirePositionRad, RiseMath::Tau);
3941 }
3942}
3943
3945{
3946 logger->AddToCallStack("Viewscreen::CalculateCube");
3947
3950 posnorml = -posnorml;
3951
3952 RiseMath::Vector3 cubeface[6];
3953 cubeface[0] = -meridianJ; //pm
3954 cubeface[1] = eastpoleI; //ep
3955 cubeface[2] = -eastpoleI; //wp
3956 cubeface[3] = meridianJ; //dl
3957 cubeface[4] = northpoleK; //np
3958 cubeface[5] = -northpoleK; // sp
3959
3960 float f_temp = FLT_MAX;
3961 char cube = -1; // oldcube is the playerships[t].cube
3962 for (short s = 0; s < 6; s++)
3963 {
3964 RiseMath::Vec3Subtract(&cubeface[s], &cubeface[s], &posnorml);
3965 float f_temp2 = RiseMath::Vec3Length(&cubeface[s]);
3966 if (f_temp2 < f_temp)
3967 {
3968 f_temp = f_temp2;
3969 cube = static_cast<char>(s);
3970 }
3971 }
3972 return cube;
3973}
3974
3976{
3977 logger->AddToCallStack("Viewscreen::CalculateCGC");
3978
3979 VECTOR2SHORT tcp = VECTOR2SHORT();
3980 // Determine the cubic grid coordinate for [31][31] (tcp)
3981 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
3982 switch (cube)
3983 {
3984 case 0: // pm
3985 {
3986 RiseMath::Vector3 ul, lr, ll;
3987 ul.x = -1.0f; ul.y = -1.0f; ul.z = 1.0f; //ul
3988 lr.x = 1.0f; lr.y = -1.0f; lr.z = -1.0f; //lr
3989 ll.x = -1.0f; ll.y = -1.0f; ll.z = -1.0f; //ll
3990 RiseMath::Plane pm;
3991 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
3992
3994 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
3995 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
3996 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
3997
3998 // 0-2038 by 0-2038, but 0-2037 available on this bitmap
3999 tcp.u = (short)((ul.x + 1.0f) * 1019.0f); tcp.v = (short)((ul.z + 1.0f) * 1019.0f);
4000 }
4001 break;
4002 case 1: // ep
4003 {
4004 RiseMath::Vector3 ul, lr, ll;
4005 ul.x = 1.0f; ul.y = -1.0f; ul.z = 1.0f;
4006 lr.x = 1.0f; lr.y = 1.0f; lr.z = -1.0f;
4007 ll.x = 1.0f; ll.y = -1.0f; ll.z = -1.0f;
4008 RiseMath::Plane pm;
4009 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
4010 // RiseMath::PlaneNormalize( &pm, &pm );
4011
4013 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
4014 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
4015 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
4016
4017 // 2038-4076 by 0-2038
4018 tcp.u = (short)((ul.y + 1.0f) * 1019.0f) + 2038; tcp.v = (short)((ul.z + 1.0f) * 1019.0f);
4019 }
4020 break;
4021 case 2: // wp
4022 {
4023 RiseMath::Vector3 ul, lr, ll;
4024 ul.x = -1.0f; ul.y = 1.0f; ul.z = 1.0f;
4025 lr.x = -1.0f; lr.y = -1.0f; lr.z = -1.0f;
4026 ll.x = -1.0f; ll.y = 1.0f; ll.z = -1.0f;
4027 RiseMath::Plane pm;
4028 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
4029 // RiseMath::PlaneNormalize( &pm, &pm );
4030
4032 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
4033 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
4034 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
4035
4036 // -2038-0 by 0-2038
4037 tcp.u = (short)((-ul.y + 1.0f) * 1019.0f) - 2038; tcp.v = (short)((ul.z + 1.0f) * 1019.0f); // backwards
4038 }
4039 break;
4040 case 3: // dl
4041 {
4042 RiseMath::Vector3 ul, lr, ll;
4043 ul.x = 1.0f; ul.y = 1.0f; ul.z = 1.0f;
4044 lr.x = -1.0f; lr.y = 1.0f; lr.z = -1.0f;
4045 ll.x = 1.0f; ll.y = 1.0f; ll.z = -1.0f;
4046 RiseMath::Plane pm;
4047 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
4048 // RiseMath::PlaneNormalize( &pm, &pm );
4049
4051 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
4052 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
4053 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
4054
4055 // 4076-6114 by 0-2038
4056 tcp.u = (short)((-ul.x + 1.0f) * 1019.0f) + 4076; tcp.v = (short)((ul.z + 1.0f) * 1019.0f); // backwards
4057 }
4058 break;
4059 case 4: // np
4060 {
4061 RiseMath::Vector3 ul, lr, ll;
4062 ul.x = -1.0f; ul.y = 1.0f; ul.z = -1.0f;
4063 lr.x = 1.0f; lr.y = -1.0f; lr.z = -1.0f;
4064 ll.x = -1.0f; ll.y = -1.0f; ll.z = -1.0f;
4065 RiseMath::Plane pm;
4066 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
4067 // RiseMath::PlaneNormalize( &pm, &pm );
4068
4070 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
4071 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
4072 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
4073
4074 // 0-2038 by -2038-0
4075 tcp.u = (short)((ul.x + 1.0f) * 1019.0f);
4076 tcp.v = (short)((-ul.y + 1.0f) * 1019.0f) - 2038; // backwards
4077 }
4078 break;
4079 case 5: // sp
4080 {
4081 RiseMath::Vector3 ul, lr, ll;
4082 ul.x = -1.0f; ul.y = -1.0f; ul.z = 1.0f;
4083 lr.x = 1.0f; lr.y = 1.0f; lr.z = 1.0f;
4084 ll.x = -1.0f; ll.y = 1.0f; ll.z = 1.0f;
4085 RiseMath::Plane pm;
4086 RiseMath::PlaneFromPoints(&pm, &ul, &lr, &ll);
4087 // RiseMath::PlaneNormalize( &pm, &pm );
4088
4090 RiseMath::Vec3Scale(&ll, &ul, 0.5f);
4091 RiseMath::Vec3Scale(&lr, &ul, 1.5f);
4092 RiseMath::PlaneIntersectLine(&ul, &pm, &ll, &lr);
4093
4094 // 0-2038 by 2038-4076
4095 tcp.u = (short)((ul.x + 1.0f) * 1019.0f); tcp.v = (short)((ul.y + 1.0f) * 1019.0f) + 2038;
4096 }
4097 break;
4098 } // switch (cube)
4099 return tcp;
4100}
4101
4102VECTOR2SHORT Viewscreen::CalculateWrap(short u, short v, char cube, char* rotate) const
4103{
4104 logger->AddToCallStack("Viewscreen::CalculateWrap");
4105 // Checking for corners, wrapping, alignment issues, et al.
4106 // That is the correct information for the vertex color, elevation, position
4107 // However, the UL grid system and texel coordinates are botched
4108 *rotate = 0;
4109 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
4110 switch (cube)
4111 {
4112 case 0: // pm (no rotations required) (no wrapping required)
4113 {
4114 if (u == 2038 && v < 0) // need the adjacency data to RIGHT for VP to render it!
4115 {
4116 // come in top of EP so as 2038,-1 becomes 2039,0 and 2038,-2 is 2040,0
4117 u -= v;
4118 v = 0;
4119 // rotation doesn't matter because we won't really render it
4120 }
4121 else if ((u < 0 || u > 2037) && (v < 0 || v > 2037)) // in the ul or ur, ll or lr void
4122 {
4123 u = 30000;
4124 v = 30000; // set some sort of type to keep these from being drawn
4125 }
4126 break;
4127 }
4128 case 1: // ep
4129 {
4130 if (v < 0 && u == 2038) // this is the missing adjacency data bottom of NP
4131 {
4132 // should be top of PM
4133 // so 2038,-1 should be 2037,0
4134 // so 2038,-2 should be 2036,0
4135 u = (short)(2038 + v);
4136 v = 0;
4137 *rotate = 1; // right 90 don't think it matters though because it will never get rendered!
4138 }
4139 else if ((u < 2038 || u>4076) && (v < 0 || v>2038)) // in the ul, ll corner void, (ur and lr corner void added 10/30/05)
4140 {
4141 u = 30000;
4142 v = 30000; // set some sort of type to keep these from being drawn
4143 }
4144 else if (u == 2038 && v < 0) // np doesn't have a right seam
4145 {
4146 u = 30000;
4147 v = 30000; // set some sort of type to keep these from being drawn
4148 }
4149 else if (u > 2038 && u < 4076 && v < 0) // off top of ep come in right of np, flip axes
4150 {
4151 short vtemp = v;
4152 v = -u + 2038;
4153 u = 2038 + vtemp;
4154 *rotate = 1; // right 90
4155 }
4156 else if (u >= 2038 && u <= 4076 && v > 2037) // off bottom of ep come in right of sp, flip axes
4157 {
4158 // 2039 2039 - 2037 2039
4159 short vtemp = v;
4160 v = u;
4161 u = 2038 - (vtemp - 2038);
4162 *rotate = -1; // left 90
4163 }
4164 else if (u > 4076 && u < 6114 && v>2037) // off bottom of dl come in bottom of sp, flip u
4165 {
4166 u = 6114 - u;
4167 v = 4076 - (v - 2038);
4168 }
4169 break;
4170 }
4171 case 2: // wp
4172 {
4173 if (u >= 0 && (v < 0 || v > 2037)) // in the ur, lr corner void
4174 {
4175 u = 30000;
4176 v = 30000; // set some sort of type to keep these from being drawn
4177 }
4178 else if (v < 0 && u >= -2038 && u < 0) // off top of wp come in left of np but flip axes
4179 {
4180 // -1, 0 should be 0, -1
4181 // -1, -1 should be 1, -1
4182 short vtemp = v; // 0
4183 v = u; // from U -2038 through -1 to V -2038 through -1 ... -1
4184 u = (short)-vtemp; // from V -1 through -32 to U 1 to 32
4185 *rotate = -1; // left 90
4186 }
4187 else if (v >= 2038 && u >= -2038 && u <= 0) // off bottom of wp come in left of sp but flip axes
4188 {
4189 short vtemp = v;
4190 v = (short)(2038 - u);
4191 u = (short)(vtemp - 2038);
4192 *rotate = 1; // right 90
4193 }
4194 else if (u < -2038) // Easy to map from wp to dl
4195 {
4196 u += 8152;
4197 }
4198 break;
4199 }
4200 case 3: // dl
4201 {
4202 if ((u < 4076 || u>6114) && (v < 0 || v>2038)) // in the corner voids
4203 {
4204 u = 30000; v = 30000; // set some sort of type to keep these from being drawn
4205 }
4206 else if (u == 4076 && v < 0) // np doesn't have a right seam, replicate ep top seam
4207 {
4208 u = 4076 + v; v = 0;
4209 }
4210 else if (u == 6114 && v < 0) // np doesn't have a left seam, replicate wp top seam
4211 {
4212 u = 6114 - v - 8152; v = 0;
4213 }
4214 else if (u > 4076 && u < 6114 && v < 0) // off top of dl come in top of np, flip u
4215 {
4216 u = (short)abs(u - 6114);
4217 v = -2038 - v;
4218 }
4219 else if (u < 4076 && v == 2038) // ep doesn't have a bottom seam, replicate sp right seam
4220 {
4221 v = u; u = 2038;
4222 }
4223 else if (u > 6113 && v == 2038) // wp doesn't have a bottom seam, replicate sp left seam
4224 {
4225 v = 10190 - u; u = 0;
4226 }
4227 else if (u >= 4076 && u < 6114 && v >= 2038) // off bottom of dl come in bottom of sp, flip u
4228 {
4229 // 4076,2038 = 2038,4076
4230 // 4077,2039 =
4231 u = (short)abs(u - 6114);
4232 v = 4076 - (v - 2038);
4233 }
4234 else if (u >= 6114) // Easy to map from dl to wp
4235 {
4236 u -= 8152;
4237 }
4238 break;
4239 }
4240 case 4: // np
4241 {
4242 if ((u < 0 || u>2038) && (v < -2038 || v>0)) // in the corner voids
4243 {
4244 u = 30000; v = 30000; // set some sort of type to keep these from being drawn
4245 }
4246 else if (u < 0 && v == 0) // wp doesn't have a right seam, replicate pm left seam
4247 {
4248 v = -u; u = 0; // This is done seperately because it is correctly oriented
4249 }
4250 else if (u < 1 && v >= -2038 && v < 0) // off left of np come in top of wp but flip axes
4251 {
4252 short vtemp = v;
4253 v = -u; // from U 0 through -31 to V 0 through 31
4254 u = vtemp; // from V -2317 through -1 to U -2318 to -2
4255 }
4256 else if (u > 2038 && v == -2038) // ep doesn't have a right seam, replicate dl left seam
4257 {
4258 v = u - 2038; u = 4076;
4259 }
4260 else if (u >= 2038 && v >= -2038 && v <= 0) // Include the closing v=0 edge on EP; flip axes
4261 {
4262 short vtemp = v;
4263 v = u - 2038;
4264 u = 2038 - vtemp;
4265 }
4266 else if (u > 0 && u <= 2038 && v <= -2038) // off top of np, come in top of dl
4267 {
4268 u = 6114 - u;
4269 v = -v - 2038;
4270 }
4271 break;
4272 }
4273 case 5: // sp
4274 if ((u < 0 || u > 2038) && (v < 2038 || v >= 4076)) // in the ul, ur corner voids
4275 {
4276 u = 30000;
4277 v = 30000; // set some sort of type to keep these from being drawn
4278 }
4279 else if (u < 0 && v > 2038 && v < 4076) // off left of sp come in bottom of wp but flip axes
4280 {
4281 short vtemp = v;
4282 v = (short)(u + 2038);
4283 u = (short)(2038 - vtemp);
4284 }
4285 // This one doesn't need a "ep doesn't have a seam" because it will go to the dl automatically
4286 else if (u > 2038 && v >= 2038 && v < 4076) // off right of sp come in bottom of ep but flip axes
4287 {
4288 // corrected 6/1/2019 to be u > 2038 instead of u >= 2038
4289 short vtemp = v;
4290 v = (short)(2038 - (u - 2038));
4291 u = vtemp;
4292 }
4293 // Can't let this one go automatic because there is nothing to check the wrap from wp to dl
4294 else if (u == 0 && v >= 4076) // dl doesn't have a right seam, replicate wp left seam
4295 {
4296 u = -2038;
4297 v = (short)(6114 - v);
4298 }
4299 else if (u > 0 && u <= 2038 && v >= 4076) // off bottom of sp, come in bottom of dl, flip u & v
4300 {
4301 u = (short)(2038 - u + 4076);
4302 v = (short)(6114 - v);
4303 }
4304 break;
4305 } // switch (cube)
4306
4307 VECTOR2SHORT tcp;
4308 tcp.u = u; tcp.v = v;
4309 return tcp;
4310}
4311
4312LOCALGRID2 Viewscreen::CalculateSRV(short t, short s, VECTOR2SHORT tcp, char cube, SRenderVertex sourcedata)
4313{
4314 logger->AddToCallStack("Viewscreen::CalculateSRV");
4315 // gridtemp.align=0; // No special orientation
4316
4317 LOCALGRID2 gridtemp;
4318
4319 char rotate;
4320 const VECTOR2SHORT temp = CalculateWrap(tcp.u + t - 31, tcp.v + s - 31, cube, &rotate);
4321 gridtemp.tcp = temp;
4322
4323 if (temp.u == 30000 || temp.v == 30000 || sourcedata.pri_landform == 255)
4324 {
4325 gridtemp.pri_landform = 255; // set some sort of flag to keep these from being drawn
4326 gridtemp.pri_transition = 0;
4327 gridtemp.sec_landform = 0;
4328 gridtemp.sec_transition = 0;
4329 gridtemp.ter_landform = 0;
4330 gridtemp.type = PlotType::DoNotRender;
4331 gridtemp.position.x = static_cast<float>(tcp.u + t - 31);
4332 gridtemp.position.y = static_cast<float>(tcp.v + s - 31);
4333 gridtemp.position.z = 0.0f;
4334 gridtemp.cloudpos = -playerships[0].position * 2.0f;
4335 // The continuous cloud patch also covers terrain cube-net voids.
4336 // These cells contribute no ground light, but need normal cloud diffuse.
4337 gridtemp.emissive = 0UL;
4338 gridtemp.clouddif = Rendering::ColorRGB(254, 254, 254);
4339 gridtemp.zone = 0;
4340 gridtemp.elevation = 0;
4341 gridtemp.raster = 0UL;
4342 gridtemp.powered = false;
4343 gridtemp.roads = 0;
4344 gridtemp.layout1 = gridtemp.layout2 = gridtemp.layout3 = gridtemp.layout4 = 0L;
4345 return gridtemp;
4346 }
4347
4348
4349 // these get zeroed out when released, overwritten with buildings
4351 gridtemp.zone = gridarray[t][s].zone;
4352 gridtemp.layout1 = gridarray[t][s].layout1;
4353 gridtemp.layout2 = gridarray[t][s].layout2;
4354 gridtemp.layout3 = gridarray[t][s].layout3;
4355 gridtemp.layout4 = gridarray[t][s].layout4;
4356 gridtemp.powered = gridarray[t][s].powered;
4357 gridtemp.type = gridarray[t][s].type;
4358 gridtemp.emissive = gridarray[t][s].emissive;
4359
4360
4361 gridtemp.raster = sourcedata.color;
4362
4363 if (sourcedata.pri_landform >= landformtextureC)
4364 {
4365 sprintf_s(msg, sizeof msg, "Got a pri_landform type %i that we don't recognize at %i %i!", sourcedata.pri_landform, gridtemp.tcp.u, gridtemp.tcp.v);
4367 }
4368 gridtemp.pri_landform = sourcedata.pri_landform;
4369
4370 // transition can be 255 to signify that we don't know actually how to transition it
4371 if (sourcedata.pri_transition > transitiontextureC) // > because 15 is valid
4372 gridtemp.pri_transition = 0;
4373 gridtemp.pri_transition = sourcedata.pri_transition;
4374
4375 if (sourcedata.sec_landform >= landformtextureC && sourcedata.pri_transition)
4376 logger->Log("Got a sec_landform type that we don't recognize!", Logger::Fatal);
4377 gridtemp.sec_landform = sourcedata.sec_landform;
4378
4379 if (sourcedata.sec_transition > transitiontextureC) // > because 15 is valid
4380 gridtemp.sec_transition = 0;
4381 gridtemp.sec_transition = sourcedata.sec_transition;
4382
4383 if (sourcedata.ter_landform >= landformtextureC && sourcedata.sec_transition)
4384 logger->Log("Got a ter_landform type that we don't recognize!", Logger::Fatal);
4385 gridtemp.ter_landform = sourcedata.ter_landform;
4386
4387 //gridtemp.type = 0;
4388
4389
4390 //gridtemp.specular = 0UL;
4391
4392 gridtemp.elevation = sourcedata.elevation;
4393
4394 // 255*( 0.4 to 0.6 ) multiplied by 2X is .8 to 1.2 which means the highest color on the
4395 // texture map can be 212
4396 const unsigned char uc_temp = static_cast<unsigned char>(255.0f - RandomFloat() * 0.2f);
4397 gridtemp.clouddif = Rendering::ColorRGB(uc_temp, uc_temp, uc_temp);
4398
4399 RiseMath::Vector3 planar = CalculatePlanar(temp.u, temp.v);
4400 if (planar.x == 0.0f && planar.y == 0.0f && planar.z == 0.0f)
4401 {
4402 gridtemp.position = gridtemp.cloudpos = planar;
4403 sprintf_s(msg, sizeof msg, "CalculateSRV found a renderable plot at u%i v%i but couldn't determine CalculatePlanar!", temp.u, temp.v);
4405 }
4406 else
4407 {
4408 gridtemp.elevationAvailable = true;
4409 const float elevation = static_cast<float>(gridtemp.elevation) * 0.001f;
4410 const float height = -(radiusC + elevation);
4411 RiseMath::Vec3Scale(&gridtemp.position, &planar, height);
4412
4413 // For clouds, fixed at ground and then elevated
4414 RiseMath::Vec3Scale(&gridtemp.cloudpos, &planar, -radiusC);
4415 }
4416
4417 gridtemp.roads = sourcedata.roads;
4418
4419 return gridtemp;
4420}
4421
4423{
4424 logger->AddToCallStack("Viewscreen::QuadraticVectorInterpolation");
4425
4426 const float t0 = 0.0f;
4427 const float t1 = 1.0f;
4428 const float t2 = 2.0f;
4429
4430 const float scale0 = ((t - t1) / (t0 - t1)) * ((t - t2) / (t0 - t2));
4431 const float scale1 = ((t - t0) / (t1 - t0)) * ((t - t2) / (t1 - t2));
4432 const float scale2 = ((t - t0) / (t2 - t0)) * ((t - t1) / (t2 - t1));
4433
4434 RiseMath::Vector3 newvel0, newvel1, newvel2;
4435 RiseMath::Vec3Scale(&newvel0, vel0, scale0);
4436 RiseMath::Vec3Scale(&newvel1, vel1, scale1);
4437 RiseMath::Vec3Scale(&newvel2, vel2, scale2);
4438
4439 return newvel0 + newvel1 + newvel2;
4440}
4441
4442long Viewscreen::FontOffset(char letter) const
4443{
4444 logger->AddToCallStack("Viewscreen::FontOffset");
4445 // skip space = 32
4446 // % = 33 $ = 34 # = 35 " = 36 ! = 37
4447 // & = 38 ' = 39 ( = 40 ) = 41 * = 42 + = 43 , = 44
4448 // - = 45 . = 46 / = 47
4449 // 0123456789 = 48 to 57
4450 // : = 58 ; = 59 < = 60 = = 61 > = 62 ? = 63 @ = 64
4451 // A-Z = 65 to 90
4452 // [ = 91 \ = 92 ] = 93 ^ = 94 _ = 95 ` = 96
4453 // { = 123 | = 124 } = 125 ~ = 126 � = 127
4454 if (letter >= 65 && letter <= 90)
4455 return (long)(letter - 65) * 23;
4456 if (letter == 38)
4457 return 26 * 23;
4458 if (letter == 45)
4459 return 27 * 23;
4460 if (letter >= 48 && letter <= 57)
4461 return (long)(letter - 20) * 23;
4462
4463 return 38 * 23; // blank space
4464}
4465
4467{
4468 logger->AddToCallStack("Viewscreen::CheckDepthMap");
4469
4470 int depthFile = -2;
4472 {
4473 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
4474 switch (gridarray[u][v].type)
4475 {
4476 case PlotType::DeoisFinancial: _sopen_s(&depthFile, "Textures\\Cities\\deoisdepth.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4477 break;
4478 case PlotType::DeoisIndustrial: _sopen_s(&depthFile, "Textures\\Cities\\deoisdepth1.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4479 break;
4480 case PlotType::DeoisCityCenter: _sopen_s(&depthFile, "Textures\\Cities\\deoisdepth2.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4481 break;
4482 case PlotType::DeoisTransit: _sopen_s(&depthFile, "Textures\\Cities\\deoisdepth3.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4483 break;
4484 case PlotType::DeoisPort: _sopen_s(&depthFile, "Textures\\Cities\\deoisdepth4.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4485 break;
4486 case PlotType::Arcridge: _sopen_s(&depthFile, "Textures\\Cities\\arcridgedepth.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4487 break;
4488 case PlotType::O4Ruin1: _sopen_s(&depthFile, "Textures\\Cities\\o4ruindepth1.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4489 break;
4490 case PlotType::O4Ruin2: _sopen_s(&depthFile, "Textures\\Cities\\o4ruindepth2.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4491 break;
4492 case PlotType::O4Ruin3: _sopen_s(&depthFile, "Textures\\Cities\\o4ruindepth3.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4493 break;
4494 case PlotType::O4Ruin4: _sopen_s(&depthFile, "Textures\\Cities\\o4ruindepth4.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4495 break;
4496 case PlotType::NorthPole: _sopen_s(&depthFile, "Textures\\Cities\\northpoledepth.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4497 break;
4498 case PlotType::Chojeir: _sopen_s(&depthFile, "Textures\\Cities\\chojeirdepth.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4499 break;
4500 }
4501
4502 if (depthFile != -2)
4503 {
4504 if (depthFile == -1)
4505 {
4506 sprintf_s(msg, sizeof(msg), "DEPTH Could not find depth file for type %i!", gridarray[u][v].type);
4508 }
4509 unsigned char uch_temp;
4510 unsigned long bpr = depthFloorResolutionC; // VERIFIED WITH SPE greyscale 2039, 2039 has 1024 additional header
4511 unsigned long k = 54L + 1024L + newdepthpos.u + (bpr - newdepthpos.v - 1L) * bpr;
4512 _lseek(depthFile, k, SEEK_SET);
4513 _read(depthFile, &uch_temp, 1);
4514 _close(depthFile);
4515
4516 return static_cast<float>(uch_temp) * cityscaleC;
4517 }
4518 }
4519
4520 return citystuff.elevation;
4521}
4522
4524{
4525 logger->AddToCallStack("Viewscreen::CheckFloorMap");
4526 int floorFile = -2;
4528 {
4529 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
4530 switch (gridarray[u][v].type)
4531 {
4532 case PlotType::DeoisFinancial: _sopen_s(&floorFile, "Textures\\Cities\\deoisfloor.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4533 break;
4534 case PlotType::DeoisIndustrial: _sopen_s(&floorFile, "Textures\\Cities\\deoisfloor1.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4535 break;
4536 case PlotType::DeoisCityCenter: _sopen_s(&floorFile, "Textures\\Cities\\deoisfloor2.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4537 break;
4538 case PlotType::DeoisTransit: _sopen_s(&floorFile, "Textures\\Cities\\deoisfloor3.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4539 break;
4540 case PlotType::DeoisPort: _sopen_s(&floorFile, "Textures\\Cities\\deoisfloor4.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4541 break;
4542 case PlotType::Arcridge: _sopen_s(&floorFile, "Textures\\Cities\\arcridgefloor.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4543 break;
4544 case PlotType::O4Ruin1: _sopen_s(&floorFile, "Textures\\Cities\\o4ruinfloor1.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4545 break;
4546 case PlotType::O4Ruin2: _sopen_s(&floorFile, "Textures\\Cities\\o4ruinfloor2.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4547 break;
4548 case PlotType::O4Ruin3: _sopen_s(&floorFile, "Textures\\Cities\\o4ruinfloor3.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4549 break;
4550 case PlotType::O4Ruin4: _sopen_s(&floorFile, "Textures\\Cities\\o4ruinfloor4.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4551 break;
4552 case PlotType::NorthPole: _sopen_s(&floorFile, "Textures\\Cities\\northpolefloor.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4553 break;
4554 case PlotType::Chojeir: _sopen_s(&floorFile, "Textures\\Cities\\chojeirfloor.bmp", _O_RDONLY | O_BINARY, _SH_DENYWR, _S_IWRITE);
4555 break;
4556 }
4557
4558 if (floorFile != -2)
4559 {
4560 if (floorFile == -1)
4561 {
4562 sprintf_s(msg, sizeof msg, "Could not find floor file %i!", gridarray[u][v].type);
4564 }
4565 unsigned char uch_temp;
4566 unsigned long bpr = depthFloorResolutionC; // VERIFIED WITH SPE greyscale 2039, 2039 has 1024 additional header
4567 unsigned long k = 54L + 1024L + newdepthpos.u + (bpr - newdepthpos.v - 1L) * bpr;
4568 _lseek(floorFile, k, SEEK_SET);
4569 _read(floorFile, &uch_temp, 1);
4570 _close(floorFile);
4571 return static_cast<float>(uch_temp) * cityscaleC;
4572 }
4573 }
4574
4575 return citystuff.floorelev;
4576}
4577
4579{
4580 logger->AddToCallStack("Viewscreen::Undock");
4581 if (dockprogress < 1.0f)
4582 {
4583 if (playerships[0].docked)
4584 {
4585 playerships[0].docked = false;
4586 logger->Log("Tried to undock but was not finished docking...");
4587 }
4588 }
4589 else
4590 {
4591 // Undocking
4592 if (playerships[0].docked)
4593 {
4594 playerships[0].docked = false;
4595
4596 if (!playerships[0].isSimulator)
4597 {
4598 SClientPacket outpacket;
4599 outpacket.type = 2; // Docking change
4600 outpacket.f_x = playerships[0].portassigned;
4601 outpacket.f_y = 0.0f; // undocked
4602 outpacket.f_z = 0.0f; // NULL
4603 outpacket.f_w = 0.0f; // NULL
4604 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
4605 }
4606
4607 logger->Log("Undocked...");
4608
4609 SOUNDS DOCKRAND = static_cast<SOUNDS>(SOUND_DOCKEVAC - SOUND_DOCKANNOUNCE1);
4610 for (short t = 0; t < DOCKRAND; t++)
4611 gameclass->sound->Stop(static_cast<SOUNDS>(SOUND_DOCKANNOUNCE1 + t));
4614
4615 Command command;
4616 command.name = "AuralAllMooringsCleared";
4617 command.delay = 3.0f;
4618 gameclass->bus->commandStream.emplace_back(command);
4619
4621 }
4622 else
4623 {
4624 logger->Log("Tried to undock but was not not docked...");
4625 }
4626 }
4627}
4628
4632RiseMath::Color Viewscreen::HSVtoRGB(float hue, float s, float v)
4633{
4634 if (s <= 0)
4635 return RiseMath::Color(v, v, v, 0);
4636
4637 float hf = (hue - floorf(hue)) * 6.0f;
4638 int i = static_cast<int>(floorf(hf));
4639 float f = hf - i;
4640 float p = v * (1.0f - s);
4641 float q = v * (1.0f - s * f);
4642 float t = v * (1.0f - s * (1.0f - f));
4643
4644 switch (i)
4645 {
4646 case 0: // red→yellow
4647 return RiseMath::Color(v, t, p, 0); // R=v, G=t, B=p
4648 case 1: // yellow→green
4649 return RiseMath::Color(q, v, p, 0); // R=q, G=v, B=p
4650 case 2: // green→cyan
4651 return RiseMath::Color(p, v, t, 0); // R=p, G=v, B=t
4652 case 3: // cyan→blue
4653 return RiseMath::Color(p, q, v, 0); // R=p, G=q, B=v
4654 case 4: // blue→magenta
4655 return RiseMath::Color(t, p, v, 0); // R=t, G=p, B=v
4656 default: // magenta→red
4657 return RiseMath::Color(v, p, q, 0); // R=v, G=p, B=q
4658 }
4659}
4660
4661// This one is only used by us
4662float Viewscreen::CalculateAGLd(RiseMath::Vector3 terpos, double terprecisionx, double terprecisiony, double terprecisionz, double proposedx, double proposedy, double proposedz, RiseMath::Vector3 proposed, bool makeleveler)
4663{
4664 logger->AddToCallStack("Viewscreen::CalculateAGLd");
4665 RiseMath::Vector3 negposition, tempcenter;
4666 tempcenter.x = -static_cast<float>(proposedx + terprecisionx);
4667 tempcenter.y = -static_cast<float>(proposedy + terprecisiony);
4668 tempcenter.z = -static_cast<float>(proposedz + terprecisionz);
4669
4670 negposition = proposed; // temppos makes the new origin...
4671 RiseMath::Vec3Normalize(&negposition, &negposition);
4672
4673 tempcenter -= negposition * 10.0f; // unit vector of 1
4674
4675 RiseMath::Vector3 temp0, temp1, temp2;
4676 float pu = -1.0f, pv = -1.0f, dist = -1.0f; // last if not overwritten
4677
4678 RiseMath::Vector3 grid3131 = gridarray[31][31].position - terpos;
4679 RiseMath::Vector3 ins03131 = insidearray[31][31][0] - terpos;
4680 RiseMath::Vector3 ins13131 = insidearray[31][31][1] - terpos;
4681 RiseMath::Vector3 ins23131 = insidearray[31][31][2] - terpos;
4682 RiseMath::Vector3 grid3231 = gridarray[32][31].position - terpos;
4683 RiseMath::Vector3 ins13231 = insidearray[32][31][1] - terpos;
4684 RiseMath::Vector3 grid3132 = gridarray[31][32].position - terpos;
4685 RiseMath::Vector3 ins03132 = insidearray[31][32][0] - terpos;
4686 RiseMath::Vector3 grid3232 = gridarray[32][32].position - terpos;
4687
4688 // Upper left zone
4689 if (RiseMath::IntersectTri(&grid3131, &ins03131, &ins13131, &tempcenter, &negposition, &pu, &pv, &dist))
4690 {
4691 temp0 = gridarray[31][31].position; temp1 = insidearray[31][31][0]; temp2 = insidearray[31][31][1];
4692 pu *= 0.5f;
4693 pv *= 0.5f;
4694 strcpy_s(area, 3, "1a");
4695 zone = 1;
4696 }
4697 else if (RiseMath::IntersectTri(&ins23131, &ins13131, &ins03131, &tempcenter, &negposition, &pu, &pv, &dist))
4698 {
4699 temp0 = insidearray[31][31][0]; temp1 = insidearray[31][31][2]; temp2 = insidearray[31][31][1];
4700 pu *= 0.5f;
4701 pv *= 0.5f;
4702 strcpy_s(area, 3, "1b");
4703 pu = 0.5f - pu;
4704 pv = 0.5f - pv;
4705 zone = 1;
4706 }
4707
4708 // Upper right zone
4709 else if (RiseMath::IntersectTri(&ins03131, &grid3231, &ins23131, &tempcenter, &negposition, &pu, &pv, &dist))
4710 {
4711 temp0 = insidearray[31][31][0]; temp1 = gridarray[32][31].position; temp2 = insidearray[31][31][2];
4712 pu *= 0.5f;
4713 pv *= 0.5f;
4714 strcpy_s(area, 3, "2a");
4715 pu += 0.5f;
4716 zone = 2;
4717 }
4718 else if (RiseMath::IntersectTri(&ins13231, &ins23131, &grid3231, &tempcenter, &negposition, &pu, &pv, &dist))
4719 {
4720 temp0 = gridarray[32][31].position; temp1 = insidearray[32][31][1]; temp2 = insidearray[31][31][2];
4721 pu *= 0.5f;
4722 pv *= 0.5f;
4723 strcpy_s(area, 3, "2b");
4724 pu = 0.5f - pu;
4725 pv = 0.5f - pv;
4726 pu += 0.5f;
4727 zone = 2;
4728 }
4729
4730 // Lower left zone
4731 else if (RiseMath::IntersectTri(&ins13131, &ins23131, &grid3132, &tempcenter, &negposition, &pu, &pv, &dist))
4732 {
4733 temp0 = insidearray[31][31][1]; temp1 = insidearray[31][31][2]; temp2 = gridarray[31][32].position;
4734 pu *= 0.5f;
4735 pv *= 0.5f;
4736 strcpy_s(area, 3, "4a");
4737 pv += 0.5f;
4738 zone = 4;
4739 }
4740 else if (RiseMath::IntersectTri(&ins03132, &grid3132, &ins23131, &tempcenter, &negposition, &pu, &pv, &dist))
4741 {
4742 temp0 = insidearray[31][31][2]; temp1 = insidearray[31][32][0]; temp2 = gridarray[31][32].position;
4743 pu *= 0.5f;
4744 pv *= 0.5f;
4745 strcpy_s(area, 3, "4b");
4746 pu = 0.5f - pu;
4747 pv = 0.5f - pv;
4748 pv += 0.5f;
4749 zone = 4;
4750 }
4751
4752 // Lower right zone
4753 else if (RiseMath::IntersectTri(&ins23131, &ins13231, &ins03132, &tempcenter, &negposition, &pu, &pv, &dist))
4754 {
4755 temp0 = insidearray[31][31][2]; temp1 = insidearray[32][31][1]; temp2 = insidearray[31][32][0];
4756 pu *= 0.5f;
4757 pv *= 0.5f;
4758 strcpy_s(area, 3, "3a");
4759 pu += 0.5f;
4760 pv += 0.5f;
4761 zone = 3;
4762 }
4763 else if (RiseMath::IntersectTri(&grid3232, &ins03132, &ins13231, &tempcenter, &negposition, &pu, &pv, &dist))
4764 {
4765 temp0 = insidearray[32][31][1]; temp1 = gridarray[32][32].position; temp2 = insidearray[31][32][0];
4766 pu *= 0.5f;
4767 pv *= 0.5f;
4768 strcpy_s(area, 3, "3b");
4769 pu = 0.5f - pu;
4770 pv = 0.5f - pv;
4771 pu += 0.5f;
4772 pv += 0.5f;
4773 zone = 3;
4774 }
4775 else
4776 {
4778 sprintf_s(msg, sizeof msg, "*** CalculateAGLd() yielded no result, returning %.3f", dist - 1.0f);
4780 zone = 0;
4781 dist = -1.0f;
4782 }
4783
4784 if (makeleveler && dist != -1.0f)
4785 {
4786 if (gameclass->timeLapse)
4787 leveler = negposition;
4788 else
4789 {
4790 RiseMath::Vector3 side1, side2;
4791 RiseMath::Vec3Subtract(&side1, &temp0, &temp1);
4792 RiseMath::Vec3Subtract(&side2, &temp0, &temp2);
4793 RiseMath::Vec3Cross(&temp0, &side1, &side2);
4795 }
4796 }
4797
4798 if (pu != -1.0f && pv != -1.0f)
4799 {
4800 // Publish the cell used by these triangles together with its fractions.
4801 // A failed AGL sample during a grid shift must retain the whole previous
4802 // position; mixing a new cell with old fractions fabricates a 2 km jump
4803 // and can permanently advance turn-by-turn guidance past a junction.
4804 gameclass->bus->tcp = gridarray[31][31].tcp;
4807 }
4808
4809 if (dist != -1.0f)
4810 return dist - 10.0f;
4811 return dist;
4812}
4813
4815{
4816 logger->AddToCallStack("Viewscreen::CalculatePlanar");
4817 RiseMath::Vector3 planar;
4818 if (u >= -2038 && u < 0 && v >= 0 && v < 2038) // point is over wp grid
4819 {
4820 planar.x = -2038.0f;
4821 planar.y = -2.0f * (float)(u + 1019); // Backwards
4822 planar.z = 2.0f * (float)(v - 1019);
4823 }
4824 else if (u >= 0 && u < 2038 && v >= 0 && v < 2038) // point is over pm grid
4825 {
4826 planar.x = 2.0f * (float)(u - 1019);
4827 planar.y = -2038.0f;
4828 planar.z = 2.0f * (float)(v - 1019);
4829 }
4830 else if (u >= 2038 && u < 4076 && v >= 0 && v < 2038) // point is over ep grid
4831 {
4832 planar.x = 2038.0f;
4833 planar.y = 2.0f * (float)(u - 3057);
4834 planar.z = 2.0f * (float)(v - 1019);
4835 }
4836 else if (u >= 4076 && u < 6114 && v >= 0 && v < 2038) // point is over dl grid
4837 {
4838 planar.x = -2.0f * (float)(u - 5095); // Backwards
4839 planar.y = 2038.0f;
4840 planar.z = 2.0f * (float)(v - 1019);
4841 }
4842 else if (u > 0 && u < 2038 && v >= -2038 && v <= 0) // point is over np grid (no left or top row)
4843 {
4844 planar.x = 2.0f * (float)(u - 1019);
4845 planar.y = -2.0f * (float)(v + 1019); // Backwards
4846 planar.z = -2038.0f;
4847 }
4848 else if (u >= 0 && u <= 2038 && v >= 2038 && v <= 4076) // point is over sp grid
4849 {
4850 planar.x = 2.0f * (float)(u - 1019);
4851 planar.y = 2.0f * (float)(v - 3057);
4852 planar.z = 2038.0f;
4853 }
4854 else
4855 {
4856 sprintf_s(msg, sizeof msg, "u%i v%i was not on any face...", u, v);
4858 planar.x = planar.y = planar.z = 0.0f;
4859 return planar;
4860 }
4861
4862 RiseMath::Vec3Normalize(&planar, &planar);
4863
4864 // Ian has this formula, secant case intersection
4865// RiseMath::Vec3Scale(&planar, &planar, 1.1949187320431308145240431795878f);
4866
4867 return planar;
4868}
4869
4870void Viewscreen::RunBindingFunction(BindingEnum function, bool repeating)
4871{
4872 switch (function)
4873 {
4874 case BindingEnum::ENGINE1_CYCLE: // left engine
4875 if (!repeating && ourcockpit.power > 0.5f)
4876 {
4877 if (ourcockpit.vdat.leftengine > -1)
4878 {
4879 if (ourcockpit.vdat.leftengine >= 64)
4881 else
4883 ourcockpit.vdatChanged = true;
4884 }
4885 }
4886 break;
4887 case BindingEnum::ENGINE2_CYCLE: // center or right engine
4888 if (!repeating && ourcockpit.power > 0.5f)
4889 {
4890 if (ourcockpit.engines == 2)
4891 {
4892 if (ourcockpit.vdat.rightengine > -1)
4893 {
4894 if (ourcockpit.vdat.rightengine >= 64)
4896 else
4898 ourcockpit.vdatChanged = true;
4899 }
4900 }
4901 else if (ourcockpit.engines == 3)
4902 {
4903 if (ourcockpit.vdat.clengine > -1)
4904 {
4905 if (ourcockpit.vdat.clengine >= 64)
4907 else
4908 ourcockpit.vdat.clengine = 127;
4909 ourcockpit.vdatChanged = true;
4910 }
4911 }
4912 }
4913 break;
4914 case BindingEnum::ENGINE3_CYCLE: // right engine
4915 if (!repeating && ourcockpit.power > 0.5f && ourcockpit.engines == 3)
4916 {
4917 if (ourcockpit.vdat.rightengine > -1)
4918 {
4919 if (ourcockpit.vdat.rightengine >= 64)
4921 else
4923 ourcockpit.vdatChanged = true;
4924 }
4925 }
4926 break;
4929 break; // Fixed gear: ignore every keyboard/controller binding and its side effects.
4930 if (!repeating && playerships[0].reference != REF_WINDOWLESS)
4931 {
4932 if (ourcockpit.power > 0.0f && ourcockpit.vdat.leftStrut != -1)
4933 {
4934 ourcockpit.sentgearvoice = false;
4935 if (playerships[0].geardown && gameclass->bus->LandingGearExtended == 1.0f)
4936 {
4937 playerships[0].geardown = false;
4938 Command command;
4939 command.name = "AuralInTransit";
4940 gameclass->bus->commandStream.emplace_back(command);
4941 }
4942 else if (!playerships[0].geardown && gameclass->bus->LandingGearExtended == 0.0f)
4943 playerships[0].geardown = true;
4944
4945 gameclass->sound->PlayEx(playerships[0].geardown ? SOUND_GEAREXTEND : SOUND_GEARRETRACT, false, 1, 1, 0, true, false, true);
4946
4948 }
4949 }
4950 break;
4952 if (!repeating)
4953 {
4955
4957
4958 if (playerships[0].isSimulator)
4960 }
4961 break;
4963 if (!repeating && gameclass->GUI->IsAdmin)
4964 {
4966 // @todo we may want it to reload the cockpit?
4967 }
4968 break;
4970 if (!repeating && ourcockpit.power > 0.5f)
4971 {
4972 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
4973 switch (static_cast<int>(gameclass->bus->MapScaleInnerRingKm))
4974 {
4975 case 10: gameclass->bus->MapScaleInnerRingKm = 5; break;
4976 case 20: gameclass->bus->MapScaleInnerRingKm = 10; break;
4977 case 40: gameclass->bus->MapScaleInnerRingKm = 20; break;
4978 case 80: gameclass->bus->MapScaleInnerRingKm = 40; break;
4979 case 160: gameclass->bus->MapScaleInnerRingKm = 80; break;
4980 }
4981 //gameclass->bus->turnByTurnDirty = true;
4984 }
4985 break;
4987 if (!repeating && ourcockpit.power > 0.5f)
4988 {
4989 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
4990 switch (static_cast<int>(gameclass->bus->MapScaleInnerRingKm))
4991 {
4992 case 5: gameclass->bus->MapScaleInnerRingKm = 10; break;
4993 case 10: gameclass->bus->MapScaleInnerRingKm = 20; break;
4994 case 20: gameclass->bus->MapScaleInnerRingKm = 40; break;
4995 case 40: gameclass->bus->MapScaleInnerRingKm = 80; break;
4996 case 80: gameclass->bus->MapScaleInnerRingKm = 160; break;
4997 }
4998 //gameclass->bus->turnByTurnDirty = true;
5001 }
5002 break;
5004 if (!repeating && !playerships[0].groundvehicle)
5005 {
5006 const bool newStatus = !gameclass->bus->ThrustReverserCommand[0];
5007 for (int i = 0; i < MAX_ENGINES; i++)
5008 gameclass->bus->ThrustReverserCommand[i] = newStatus;
5009
5010 Command command;
5011 command.name = newStatus ? "AuralReverseThrust" : "AuralForwardThrust";
5012 gameclass->bus->commandStream.emplace_back(command);
5013 }
5014 break;
5015 case BindingEnum::HORN: // hold a vehicle horn; police lights retain their toggle/chirp
5017 || GetForegroundWindow() != Rendering::ClientWindow()) break;
5018 if (!playerships[0].police)
5019 {
5021 break;
5022 }
5023 if (!repeating)
5024 {
5025 bool honk = false;
5026 if (playerships[0].police)
5027 {
5028 if (playerships[0].specialight)
5029 {
5030 playerships[0].specialight = false;
5032 }
5033 else
5034 {
5035 playerships[0].specialight = honk = true;
5037 }
5038 }
5039 else if (playerships[0].groundvehicle)
5040 honk = true;
5041 if (!honk || playerships[0].isSimulator)
5042 break;
5043
5044 // honk horn
5045 SClientPacket outpacket{};
5046 outpacket.type = 23; // Sound Effect in universe
5047 outpacket.f_x = 0.0f; // car noise
5048 outpacket.f_y = 0.0f; // horn honk
5049 outpacket.f_z = 0.0f; // NULL
5050 outpacket.f_w = 0.0f; // NULL
5051 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
5052
5053 if (playerships[0].police)
5054 gameclass->sound->PlayEx(SOUND_POLICECHIRP, false, 1, 1, 0, true, true);
5055
5056 }
5057 break;
5059 if (!repeating && gameclass->GUI->IsAdmin)
5060 playerships[0].precisiony -= 0.001f;
5061 break;
5063 if (!repeating && playerships[0].groundvehicle && ourcockpit.power > 0.5f)
5064 {
5065 const char newGear = ourcockpit.gearshift - 1;
5066 if (newGear >= -2)
5067 gameclass->ChangeGear(newGear);
5068 }
5069 break;
5071 if (!repeating && !playerships[0].groundvehicle)
5072 {
5073 if (!gameclass->bus->AFCS.TvmOn)
5074 {
5075 gameclass->TurnOffDOR(); // Manual thrust overrides orbital execution.
5076 for (int i = 0; i < MAX_ENGINES; i++)
5077 {
5078 gameclass->bus->EngineThrustLever[i] = 0.0f;
5079 }
5080 }
5081 else
5082 {
5085 else
5087 }
5088 }
5089 break;
5091 if (!repeating && playerships[0].groundvehicle && ourcockpit.power > 0.5f)
5092 {
5093 const char newGear = ourcockpit.gearshift + 1;
5094 if (newGear <= ourcockpit.fwdgears)
5095 gameclass->ChangeGear(newGear);
5096 }
5097 break;
5099 if (!repeating && !playerships[0].groundvehicle)
5100 {
5101 if (!gameclass->bus->AFCS.TvmOn)
5102 {
5103 gameclass->TurnOffDOR(); // Manual thrust overrides orbital execution.
5104 for (int i = 0; i < MAX_ENGINES; i++)
5105 {
5106 gameclass->bus->EngineThrustLever[i] = 1.0f;
5107 }
5108 }
5109 else
5110 {
5113 else
5115 }
5116 }
5117 break;
5120 break;
5123 break;
5126 break;
5129 break;
5131 if (!repeating && !ourcockpit.flapSettings.empty() && ourcockpit.power > 0.5f && (ourcockpit.vdat.flapsTE > 0 || ourcockpit.vdat.flapsLE > 0) && gameclass->bus->flapSettingTE < ourcockpit.flapSettings.size() - 1)
5132 {
5134 const float extent = ourcockpit.flapSettings.at(gameclass->bus->flapSettingTE).degrees / ourcockpit.flapMaxDegrees;
5135 playerships[0].flapdown = extent;
5138 }
5139 break;
5141 if (!repeating && !ourcockpit.flapSettings.empty() && ourcockpit.power > 0.5f && (ourcockpit.vdat.flapsTE > 0 || ourcockpit.vdat.flapsLE > 0) && gameclass->bus->flapSettingTE > 0)
5142 {
5144 const float extent = ourcockpit.flapSettings.at(gameclass->bus->flapSettingTE).degrees / ourcockpit.flapMaxDegrees;
5145 playerships[0].flapdown = extent;
5148 }
5149 break;
5151 if (!repeating)
5152 {
5153 if (gameclass->GUI->IsAdmin)
5154 ourcockpit.hitpoints = 255;
5155
5157
5159 break;
5160
5161 if (playerships[0].groundvehicle && ourcockpit.gearshift != -2)
5162 {
5164 }
5165 else if (!playerships[0].groundvehicle && ptrPropulsion->GetTotalThrust() > 0.0005f) // 0.05G (.49 m/s2) is perceptible
5166 {
5168 }
5169 else
5170 {
5173 }
5174 }
5175 break;
5176 case BindingEnum::FLIP:
5177 if (!repeating && fabsf(ptrPropulsion->levelerroll) >= 1.5f && playerships[0].reference == REF_ONGROUND)
5178 {
5179 RiseMath::Quaternion quaternionTemp;
5181 RiseMath::QuaternionMultiply(&playerships[0].orientation, &playerships[0].orientation, &quaternionTemp);
5183 deathinhibit = 2.0f;
5184 }
5185 break;
5188 {
5189 // camera views have RiseMath::Vector3 location, pitch, yaw, maybe roll? bit fixed or pannable?
5190 WCHAR str[199];
5191 swprintf_s(str, 199, L"Camera mount %i %.4ff,%.4ff,%.4ff,%.3ff,%.3ff", ourcockpit.texturelib,
5193
5194 const HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, wcslen(str) * 2 + 2);
5195 memcpy(GlobalLock(hMem), str, wcslen(str) * 2 + 2);
5196 GlobalUnlock(hMem);
5197
5198 OpenClipboard(nullptr);
5199 EmptyClipboard();
5200 SetClipboardData(CF_UNICODETEXT, hMem);
5201 CloseClipboard();
5202
5203 }
5204 break;
5207 {
5208 cameraOrdinal++;
5209 if (cameraOrdinal >= cameras.size())
5210 cameraOrdinal = 0;
5211 ChangeCamera();
5212 }
5213 break;
5215 if (!repeating && ourcockpit.power > 0.5f)
5216 {
5218 {
5219 // ReSharper disable once CppExpressionWithoutSideEffects
5221 // ReSharper disable once CppExpressionWithoutSideEffects
5224 }
5225 else if (!playerships[0].groundvehicle)
5226 {
5229 if (ourcockpit.vdat.autoflyte > 0)
5230 {
5233 }
5234 }
5235 }
5236 break;
5237 case BindingEnum::TOGA:
5238 if (!repeating && ourcockpit.power > 0.5f && !playerships[0].groundvehicle)
5239 {
5244 }
5245 break;
5247 if (!repeating)
5248 {
5249 gameclass->bus->targetC++; // was -1 now 0
5250
5251 bool flag = true;
5252 while (flag)
5253 {
5255 {
5260 {
5261 flag = false;
5262 }
5263 else
5264 {
5265 gameclass->bus->targetC++;
5266 }
5267 }
5268 else
5269 flag = false;
5270 }
5271
5273 gameclass->bus->targetC = -4;
5275 gameclass->bus->targetC = static_cast<short>(gameclass->bus->scanscroll);
5276
5278 {
5281 }
5282
5283 if (ourcockpit.power > 0.5f)
5284 {
5288 }
5289
5290 // need to find which ship that is
5291 if (gameclass->bus->targetC >= 0)
5292 {
5295 }
5296 else
5297 {
5300 }
5301 }
5302 break;
5304 if (!repeating)
5305 {
5306 gameclass->bus->targetC--; // was 0 now -1
5307
5308 bool flag = true;
5309 while (flag)
5310 {
5312 {
5317 {
5318 flag = false;
5319 }
5320 else
5321 {
5322 gameclass->bus->targetC--;
5323 }
5324 }
5325 else
5326 flag = false;
5327 }
5328
5329 if (gameclass->bus->targetC < -4)
5330 gameclass->bus->targetC = static_cast<short>(gameclass->bus->scanscroll) + ourcockpit.scanDisplayVesselLimit - 1; // this sets to the last one in the 64 list but not necessarily visible on-screen
5331
5333 {
5336 }
5337
5338 if (ourcockpit.power > 0.5f)
5339 {
5343 }
5344
5345 // need to find which ship that is
5346 if (gameclass->bus->targetC >= 0)
5347 {
5350 }
5351 else
5352 {
5355 }
5356 }
5357 break;
5359 if (!repeating)
5360 {
5365 }
5366 break;
5368 // commented out 11/12/2025 for beta-assist extended mode tests
5369 //if (!repeating && gameclass->GUI->IsAdmin)
5370 //{
5371 // playerships[0].precisiony += 0.001f;
5372 //}
5373 break;
5375 if (!repeating)
5376 {
5377 const std::string newPage = gameclass->displays->TogglePageReverse("MFD");
5378 if (!camera->outside && camera->currentPan > 0.55f &&
5379 camera->currentTilt < -0.045f && camera->currentTilt > -0.74f &&
5382 if (newPage == "Cargo Manifest" && gameclass->GUI->informationDialog->DismissHelp(ActiveHelp::TaxiService55))
5383 {
5386 }
5387 }
5388 break;
5389
5391 if (!repeating)
5392 {
5393 const std::string newPage = gameclass->displays->TogglePage("MFD");
5394 if (!camera->outside && camera->currentPan > 0.55f &&
5395 camera->currentTilt < -0.045f && camera->currentTilt > -0.74f &&
5398 if (newPage == "Cargo Manifest" && gameclass->GUI->informationDialog->DismissHelp(ActiveHelp::TaxiService55))
5399 {
5402 }
5403 }
5404 break;
5406 // @todo spoiler VDAT && (ourcockpit.vdat.flapsTE > 0 || ourcockpit.vdat.flapsLE > 0))
5407 if (!repeating && ourcockpit.power > 0.5f && ourcockpit.spoilerAreaMod > 0)
5408 {
5410 {
5414 }
5415 }
5416 break;
5417
5419 // @todo spoiler VDAT && (ourcockpit.vdat.flapsTE > 0 || ourcockpit.vdat.flapsLE > 0))
5420 if (!repeating && ourcockpit.power > 0.5f && ourcockpit.spoilerAreaMod > 0)
5421 {
5423 {
5427 }
5428 }
5429 break;
5431 if (!repeating && ourcockpit.vdat.antiIce != -1)
5432 {
5435 }
5436 break;
5438 if (!repeating && !dead && !playerships[0].isSimulator)
5439 SetRainProtection(!playerships[0].rainProtectionEnabled);
5440 break;
5442 if (!repeating && fuel > 0.0f && playerships[0].reference != REF_BUILDING && playerships[0].reference != REF_WINDOWLESS)
5443 {
5444 if (ourcockpit.startcycle == 0) // shut down
5445 {
5446 ourcockpit.startcycle = 1; // starting
5447
5448 playerships[0].logolight = true;
5450
5452 gameclass->viewscreen->lampTest = 5.0f;
5454
5455 gameclass->displays->ChangePage("MFD", 0);
5460 }
5461 if (ourcockpit.startcycle == 2) // running
5462 {
5463 if (playerships[0].groundvehicle && ourcockpit.gearshift != -2)
5464 {
5466 break;
5467 }
5468
5469 ourcockpit.startcycle = 3; // shutting down
5470 playerships[0].logolight = false;
5471
5473 }
5474 }
5475 break;
5476
5478 // Switching off is always allowed; switching on requires a working lamp.
5479 if (!repeating && (playerships[0].domelight || ourcockpit.vdat.overhead > 0))
5480 {
5484 }
5485 break;
5487 if (!repeating)
5488 {
5489 if ((gameclass->bus->AFCS.CurrentLateralMode || gameclass->bus->AFCS.CurrentVerticalMode) && ourcockpit.power > 0.5f) // FD engaged and has power
5490 {
5494 }
5495 else
5496 {
5498 }
5499 }
5500 break;
5502 if (!repeating && !gameclass->TurnOffDOR()) // DOR is not on
5503 {
5505 {
5506 const auto entryBlock=Orbital::EntryEngagementBlock(gameclass->bus->orbit.snapshot);
5508 !entryBlock.empty())
5509 {
5510 gameclass->bus->orbit.guidance = {};
5512 gameclass->bus->orbit.guidance.status = L"DOR: "+entryBlock;
5515 gameclass->sound->Play(SOUND_APCAVALRY); // Refused engagement: announce the immediate disconnect.
5516 break;
5517 }
5518 gameclass->bus->AFCS.DorOn = true;
5519 gameclass->bus->AFCS.DesiredClosingSpeed = 0.0f; // reset
5520 gameclass->bus->AFCS.TvmOn = false; // switching modes, no cavalry
5521
5523 // Preserve the pilot's ATC departure guidance. DOR owns attitude
5524 // and thrust while following this heading, until STEER ORBIT.
5529 }
5532
5534 }
5536 {
5538 }
5539 }
5540 break;
5541
5543 if (!repeating && !gameclass->TurnOffTVM()) // TVM is not on
5544 {
5545 if (!playerships[0].groundvehicle)
5546 {
5547 gameclass->bus->AFCS.TvmOn = true;
5548 gameclass->bus->AFCS.DesiredClosingSpeed = 0.0f; // reset
5549 gameclass->TurnOffDOR(); // DOR always announces its hand-off.
5550
5553
5555 }
5556 if (playerships[0].reference == REF_ONGROUND)
5557 {
5559 }
5560 }
5561 break;
5563 if (!repeating && ourcockpit.power > 0.5f)
5564 {
5566
5569
5571
5573 }
5574 break;
5576 if (!repeating && !playerships[0].isSimulator)
5577 {
5578 if (!ourcockpit.bays)
5579 {
5581 break;
5582 }
5583
5584 if (!playerships[0].baydoor)
5585 {
5587 break;
5588 }
5589
5590 if (gameclass->bus->targetC < 0)
5591 {
5593 break;
5594 }
5595
5597 if (playership.reference == REF_INANOTHER && playership.inarray == 0)
5598 {
5600 break;
5601 }
5602
5603 if (playership.type != VehicleType::DIHV)
5604 {
5605 SClientPacket outpacket; // NOLINT
5606 outpacket.type = 18; // cargo ops
5607 outpacket.f_x = 1.0f; // load request
5608 outpacket.f_y = 0.0f; // NULL
5609 outpacket.f_z = 0.0f; // NULL
5610 // @todo this may not even be needed now since we send the targetVehicleId when we change targets
5611 outpacket.f_w = static_cast<float>(playership.vehicleId);
5612 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
5613
5614 // switch to Scan page on MFD
5615 gameclass->displays->ChangePage("MFD", "Cargo Manifest");
5616 }
5617 else
5618 {
5620 }
5621 }
5622 break;
5624 if (!repeating && gameclass->GUI->player[gameclass->GUI->ourplayerC].frame == 0)
5625 {
5626 if (gameclass->bus->targetC >= 0)
5627 {
5628 if (!playerships[0].isSimulator)
5629 {
5630 SClientPacket outpacket{};
5631 outpacket.type = 17; // change ships
5632 outpacket.f_x = 0.0f; // move us to target
5633 outpacket.f_y = 0.0f; // NULL
5634 outpacket.f_z = 0.0f; // NULL
5635 // @todo this may not even be needed now since we send the targetVehicleId when we change targets
5636 outpacket.f_w = static_cast<float>(playerships[gameclass->bus->scanslot[gameclass->bus->targetC]].vehicleId);
5637 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
5638 }
5639 }
5640 else
5641 {
5643 }
5644 }
5645 break;
5647 if (!repeating && gameclass->GUI->IsAdmin)
5648 {
5649 playerships[0].precisionx -= 0.001f;
5650 }
5651 break;
5652
5654 if (!repeating && gameclass->GUI->player[gameclass->GUI->ourplayerC].frame == 0)
5655 {
5656 if (gameclass->bus->targetC >= 0)
5657 {
5658 if (!playerships[0].isSimulator)
5659 {
5660 SClientPacket outpacket{};
5661 outpacket.type = 17; // change ships (displace?)
5662 outpacket.f_x = 1.0f; // move target to lineinput dest
5663 outpacket.f_y = 0.0f; // NULL
5664 outpacket.f_z = 0.0f; // NULL
5665 // @todo this may not even be needed now since we send the targetVehicleId when we change targets
5666 outpacket.f_w = static_cast<float>(playerships[gameclass->bus->scanslot[gameclass->bus->targetC]].vehicleId);
5667 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
5668 }
5669 }
5670 else
5671 {
5673 }
5674 }
5675 break;
5677 if (!repeating && gameclass->GUI->IsAdmin)
5678 {
5679 playerships[0].precisionz += 0.001f;
5680 }
5681 break;
5683 if (!repeating)
5684 {
5686 const auto lateral=gameclass->bus->AFCS.CurrentLateralMode;
5687 const auto vertical=gameclass->bus->AFCS.CurrentVerticalMode;
5691 }
5693 {
5695 {
5697 }
5708 {
5709 if (playerships[0].mslKm <= cloudTopsMslC) // @ref https://jira.risetvp.com/view.php?id=1645 skip AGL when ground data is not available
5711 else
5713 }
5714
5715 if (gameclass->bus->AFCS.CurrentVerticalMode >= Bus::Afcs::VerticalModes::Glideslope) // G/S is armed separately; wrap to PIT, preserving lateral guidance
5716 {
5718 }
5719 else
5720 verticaltime = 4.0f;
5724 }
5728 {
5730 if (fabsf(gameclass->bus->RollAttitudeRadians) < 0.087266462599716478846184538424431f) // 5�
5732 else
5734 }
5735 }
5736 else
5737 {
5739 }
5740 }
5741 break;
5743 if (!repeating)
5744 {
5746 {
5748 }
5749 else
5750 {
5752 }
5753 }
5754 break;
5756 if (!repeating)
5757 {
5759 const auto lateral=gameclass->bus->AFCS.CurrentLateralMode;
5760 const auto vertical=gameclass->bus->AFCS.CurrentVerticalMode;
5764 }
5766 {
5768 {
5770 }
5773 {
5774 if (fabsf(gameclass->bus->RollAttitudeRadians) < 0.087266462599716478846184538424431f) // 5�
5776 else
5778 }
5782 {
5786 else if (gameclass->bus->AFCS.DesiredCourseRadians <= 0.0f)
5788 //char msg[99];
5789 //sprintf_s(msg, sizeof(msg), "LOOK HERE, we were %.1f he was bear %.1f so course is %.1f", insthdgDegrees, bear, desiredcrs);
5790 //logger->Log(msg);
5791 }
5795 {
5797 }
5798 else
5799 lateraltime = 4.0f;
5801 {
5804 }
5805 }
5806 else
5807 {
5809 }
5810 }
5811 //else if (viewscreen->gameclass->GUI->IsAdmin)
5812 //{
5813 // playerships[0].precisionx += 0.001f;
5814 //}
5815 break;
5817 if (!repeating)
5818 {
5820 {
5822 }
5823 else
5824 {
5826 }
5827 }
5828 break;
5830 if (!repeating && ourcockpit.power > 0.5f && ourcockpit.vdat.baydoor > 0 && playerships[0].reference != REF_WINDOWLESS)
5831 {
5835 if (playerships[0].reference == REF_ONGROUND)
5837 }
5838 break;
5840 if (!repeating && gameclass->GUI->IsAdmin)
5841 camera->position.y -= 0.0001f;
5842 break;
5844 if (!repeating)
5845 {
5849 }
5850 break;
5852 if (!repeating && gameclass->GUI->IsAdmin)
5853 camera->position.y += 0.0001f;
5854 break;
5856 if (!repeating)
5857 {
5859 if (gameclass->bus->scanscroll < 0)
5860 gameclass->bus->scanscroll = 0;
5861 }
5862 break;
5865 rcsThrustRequestZ = -0.002f;
5866 break;
5869 rcsThrustRequestZ = 0.002f;
5870 break;
5874 break;
5878 break;
5880 if (!repeating)
5881 {
5883 pitchInput = rollInput = 0.0f;
5884 yawInput = steerInput = 0.0f;
5885 }
5886 break;
5888 if (!repeating && ourcockpit.power > 0.5f)
5889 {
5892 }
5893 break;
5895 if (!repeating && !playerships[0].groundvehicle)
5896 {
5897 if (!gameclass->bus->AFCS.TvmOn)
5898 {
5899 gameclass->TurnOffDOR(); // Manual thrust overrides orbital execution.
5900 for (int i = 0; i < MAX_ENGINES; i++)
5901 {
5902 gameclass->bus->EngineThrustLever[i] -= 0.1f;
5903 if (gameclass->bus->EngineThrustLever[i] < 0.0f)
5904 gameclass->bus->EngineThrustLever[i] = 0.0f;
5905 }
5906 }
5907 else
5908 {
5911 else
5913 }
5914 }
5915 break;
5917 if (!repeating && !playerships[0].groundvehicle)
5918 {
5919 if (!gameclass->bus->AFCS.TvmOn)
5920 {
5921 gameclass->TurnOffDOR(); // Manual thrust overrides orbital execution.
5922 for (int i = 0; i < MAX_ENGINES; i++)
5923 {
5924 gameclass->bus->EngineThrustLever[i] += 0.1f;
5925 if (gameclass->bus->EngineThrustLever[i] > 1.0f)
5926 gameclass->bus->EngineThrustLever[i] = 1.0f;
5927 }
5928 }
5929 else
5930 {
5933 else
5935 }
5936 }
5937 break;
5939 {
5942 }
5943 break;
5945 if (!repeating)
5946 {
5947 Command command;
5948 command.name = "AcknowledgeAllMessages";
5949 gameclass->bus->commandStream.emplace_back(command);
5950 }
5951 break;
5954 if (!repeating)
5955 {
5956 Command c;
5957 if (function == BindingEnum::GPWS_TEST) { c.name = "GPWSTestGsCancel"; c.ivalues[0] = 1; }
5958 else if (function == BindingEnum::GPWS_INHIBIT) c.name = "GPWSInhibitToggle";
5959 gameclass->bus->commandStream.push_back(c);
5960 }
5961 break;
5963 if (!repeating)
5964 {
5965 Command command;
5966 command.name = ptrKeyboard->g_bControl ? "TcasSystemTest" : "VMUTest";
5967 logger->Log(ptrKeyboard->g_bControl ? "KEYBOARD: Requesting TCAS test!" : "KEYBOARD: Requesting VMUTest!");
5968 gameclass->bus->commandStream.emplace_back(command);
5969 }
5970 break;
5972 if (!repeating && playerships[0].isSimulator)
5973 {
5976 }
5977 break;
5979 if (gameclass->GUI->player[ourcockpit.ourplyrC].frame) // interior
5980 {
5981 ourcockpit.turnin = -1.0f; // turn left
5984 }
5985 break;
5988 if (playerships[0].reference == REF_ONGROUND && (playerships[0].groundvehicle || ourcockpit.vdat.steering > 0))
5989 {
5990 // speed sensitive steering
5991 const float mod = powf(1.0f - gameclass->bus->GroundSpeedKms / 0.3f, 2.0f) * 2.5f;
5994 else
5996 steerInput = Clamp(steerInput, -1.0f, 1.0f);
5997
6000 }
6001 else
6002 {
6005 else
6007 rollInput = Clamp(rollInput, -1.0f, 1.0f);
6008 }
6009 break;
6011 if (gameclass->GUI->player[ourcockpit.ourplyrC].frame) // interior
6012 {
6013 ourcockpit.turnin = 1.0f; // turn right
6016 }
6017 break;
6020 if (playerships[0].reference == REF_ONGROUND && (playerships[0].groundvehicle || ourcockpit.vdat.steering > 0))
6021 {
6022 // speed sensitive steering
6023 const float mod = powf(1.0f - gameclass->bus->GroundSpeedKms / 0.3f, 2.0f) * 2.5f;
6026 else
6028 steerInput = Clamp(steerInput, -1.0f, 1.0f);
6029
6032 }
6033 else
6034 {
6037 else
6039 rollInput = Clamp(rollInput, -1.0f, 1.0f);
6040 }
6041 break;
6044 {
6047 else
6049 yawInput = Clamp(yawInput, -1.0f, 1.0f);
6050 }
6051 break;
6052
6055 {
6058 else
6060 yawInput = Clamp(yawInput, -1.0f, 1.0f);
6061 }
6062 break;
6064 if (!repeating)
6065 {
6066 if (!playerships[0].docked && playerships[0].portassigned != -1)
6067 {
6068 if (RiseMath::Vec3Length(&playerships[0].dockingvel) > 0.010f)
6069 {
6071 }
6072 else
6073 {
6075 if (RiseMath::Vec3Length(&result) < 0.1f) // within 100m
6076 {
6077 playerships[0].docked = true;
6078 dockprogress = 0.0f;
6079 gameclass->bus->AFCS.DesiredClosingSpeed = 0.0f; // reset
6080 }
6081 else
6082 {
6084 }
6085 }
6086 }
6087 else if (playerships[0].docked)
6088 {
6089 Undock();
6090 }
6091 }
6092 break;
6094 if (!repeating)
6095 {
6097 }
6098 break;
6099 case BindingEnum::WALK:
6100 if (gameclass->GUI->player[ourcockpit.ourplyrC].frame) // interior
6101 {
6102 ourcockpit.moving = 1.0f; // walk forward (1-5 reserved)
6105 }
6106 break;
6109 if (!playerships[0].groundvehicle)
6110 {
6112 pitchInput = Clamp(pitchInput, -1.0f, 1.0f);
6113 }
6114 break;
6115 case BindingEnum::GAS:
6116 if (playerships[0].groundvehicle)
6117 {
6118 for (int i = 0; i < MAX_ENGINES; i++)
6119 {
6121 if (gameclass->bus->EngineThrustLever[i] > 1.0f)
6122 gameclass->bus->EngineThrustLever[i] = 1.0f;
6123 if (i == 0 && gameclass->bus->EngineThrustLever[i] > 0.4f)
6124 {
6127 }
6128 }
6129 }
6130 break;
6132 {
6134 if (playerships[0].groundvehicle)
6135 {
6138 for (int i = 0; i < MAX_ENGINES; i++)
6139 {
6141 if (gameclass->bus->EngineThrustLever[i] < 0.1f) // engine can't reverse on gv
6142 gameclass->bus->EngineThrustLever[i] = 0.1f;
6143 }
6144 }
6145 }
6146 break;
6148 if (!repeating && ourcockpit.wheeled && !playerships[0].groundvehicle && ourcockpit.vdat.parkingBrake > 0)
6149 {
6153 }
6154 break;
6156 if (!repeating)
6157 {
6159 {
6160 if (gameclass->bus->targetC >= 0)
6161 {
6163
6164 if (network_objects.type != VehicleType::DIHV)
6165 {
6166 SClientPacket outpacket = SClientPacket();
6167 outpacket.type = 36; // scan
6168 outpacket.f_x = 0.0f; // shallow VPT mode S
6169 outpacket.f_y = 0.0f; // NULL
6170 outpacket.f_z = 0.0f; // NULL
6171 // @todo this may not even be needed now since we send the targetVehicleId when we change targets
6172 outpacket.f_w = static_cast<float>(network_objects.vehicleId);
6173 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
6175
6176 // store what we know in the scan database - we don't need to send it to the server because they already know!
6177 SmodeAC modeAC;
6178 strcpy_s(modeAC.hullname, 23, network_objects.hullname);
6179 strcpy_s(modeAC.IVR, 6, network_objects.IVR);
6180 //strcpy_s(modeAC.owner, 13, network_objects.owner);
6181 //modeAC.ownerId = network_objects.ownerId;
6182 //modeAC.allegiance = network_objects.allegiance;
6183 modeAC.location = network_objects.position;
6184 modeAC.reference = network_objects.reference;
6185 //modeAC.reposess = network_objects.reposess;
6186 //modeAC.stolen = network_objects.stolen;
6187 //modeAC.tow = network_objects.tow;
6188 modeAC.type = network_objects.type;
6189 modeAC.vehicleId = network_objects.vehicleId;
6191
6192 // clear out vehicles that we know used to point to this parent vehicle
6193 gameclass->bus->Scanner.ClearChildren(network_objects.vehicleId);
6194
6195 // switch to Scan page on MFD
6196 gameclass->displays->ChangePage("MFD", "Scanner");
6197
6198 // update bus with target vehicle ID
6199 gameclass->bus->Scanner.CurrentScanTarget = network_objects.vehicleId;
6200
6201 // update alignment colorize based on owner
6202 network_objects.align = gameclass->GUI->GetAlignment(modeAC.ownerId);
6203 }
6204 else
6205 {
6207 }
6208 }
6209 else
6210 {
6212 }
6213 }
6214 }
6215 break;
6217 {
6218 ourcockpit.chairfwd -= ptrKeyboard->frameTime; // 5 seconds
6219 if (ourcockpit.chairfwd < 0.0f)
6220 ourcockpit.chairfwd = 0.0f;
6221 }
6222 break;
6224 {
6225 ourcockpit.chairfwd += ptrKeyboard->frameTime; // 5 seconds
6226 if (ourcockpit.chairfwd > 1.0f)
6227 ourcockpit.chairfwd = 1.0f;
6228 }
6229 break;
6232 // if (!g_bOutside && game->gameclass->GUI->player[ourcockpit.ourplyrC].frame) // interior
6233 // {
6234 // ourcockpit.moving = 2; // walk backward (1-5 reserved)
6235 // static float footstep = 0.0f;
6236 // footstep += frameTime * 1.2f;
6237 // if (footstep >= 1.0f)
6238 // {
6239 // footstep = 0.0f;
6240 // game->gameclass->sound->Play(SOUND_COCKPITLAND);
6241 // }
6242 // }
6243 // else
6244 if (!playerships[0].groundvehicle)
6245 {
6247 pitchInput = Clamp(pitchInput, -1.0f, 1.0f);
6248 }
6249 break;
6250 case BindingEnum::COAST:
6251 if (playerships[0].groundvehicle)
6252 {
6253 for (int i = 0; i < MAX_ENGINES; i++)
6254 {
6256 if (gameclass->bus->EngineThrustLever[i] < 0.1f) // engine can't reverse on gv
6257 gameclass->bus->EngineThrustLever[i] = 0.1f;
6258 }
6259 }
6260 break;
6262 if (ourcockpit.power > 0.5f)
6263 {
6264 float adj = ptrKeyboard->frameTime * 5.0f * lateralincr;
6266 adj *= 10.0f;
6268 {
6269 lateralmod = true;
6271 if (gameclass->bus->AFCS.DesiredCourseRadians < RiseMath::ToRadian(0.5f)) // run from 0.5 (1) to 360.4999 (360)
6273 lateraltime = 4.0f;
6274 }
6276 {
6277 lateralmod = true;
6280 gameclass->bus->AFCS.DesiredHeadingRadians += RiseMath::Tau; // run from 0.5 (1) to 360.4999 (360)
6281 lateraltime = 4.0f;
6282 }
6284 {
6285 lateralmod = true;
6286 gameclass->bus->AFCS.DesiredRollRadians -= 0.1f * adj;
6289 }
6290 }
6291 break;
6293 if (ourcockpit.power > 0.5f)
6294 {
6295 float adj = ptrKeyboard->frameTime * 5.0f * lateralincr;
6297 adj *= 10.0f;
6299 {
6300 lateralmod = true;
6302 if (gameclass->bus->AFCS.DesiredCourseRadians >= RiseMath::ToRadian(360.5f)) // run from 0.5 (1) to 360.4999 (360)
6304 lateraltime = 4.0f;
6305 }
6307 {
6308 lateralmod = true;
6310 if (gameclass->bus->AFCS.DesiredHeadingRadians >= RiseMath::ToRadian(360.5f)) // run from 0.5 (1) to 360.4999 (360)
6312 lateraltime = 4.0f;
6313 }
6315 {
6316 lateralmod = true;
6317 gameclass->bus->AFCS.DesiredRollRadians += 0.1f * adj;
6320 }
6321 }
6322 break;
6324 if (ourcockpit.power > 0.5f && !playerships[0].groundvehicle)
6325 {
6326 float adj = ptrKeyboard->frameTime * 0.3f * trimlimiterC;
6327 if (playerships[0].reference == REF_ONGROUND || ptrKeyboard->g_bControl)
6328 adj *= 10;
6331 gameclass->bus->PitchTrimScalar += adj;
6332 else
6333 gameclass->bus->PitchTrimScalar -= adj;
6335 pitchTrimMod = true;
6336 }
6337 break;
6339 if (ourcockpit.power > 0.5f)
6340 {
6341 float adj = ptrKeyboard->frameTime * 5.0f * verticalincr;
6343 adj *= 10.0f;
6345 {
6346 verticalmod = true;
6347 gameclass->bus->AFCS.DesiredPitchRadians += 0.026f * adj;
6348 if (gameclass->bus->AFCS.DesiredPitchRadians > RiseMath::ToRadian(20)) // nose up 20
6350 }
6352 verticalmod = true;
6354 }
6356 {
6357 verticalmod = true;
6358 gameclass->bus->AFCS.DesiredVsiKms += 0.05f * adj;
6359 }
6361 {
6362 verticalmod = true;
6363 gameclass->bus->AFCS.DesiredIasKms += 0.01f * adj;
6364 }
6367 {
6368 verticalmod = true;
6369 gameclass->bus->AFCS.DesiredAltitudeKm += 0.25f * adj;
6370 }
6371 verticaltime = 4.0f;
6372 }
6373 break;
6375 if (ourcockpit.power > 0.5f && !playerships[0].groundvehicle)
6376 {
6377 float adj = ptrKeyboard->frameTime * 0.3f * trimlimiterC;
6378 if (playerships[0].reference == REF_ONGROUND || ptrKeyboard->g_bControl)
6379 adj *= 10;
6382 gameclass->bus->PitchTrimScalar -= adj;
6383 else
6384 gameclass->bus->PitchTrimScalar += adj;
6386 pitchTrimMod = true;
6387 }
6388 break;
6390 if (ourcockpit.power > 0.5f)
6391 {
6392 float adj = ptrKeyboard->frameTime * 5.0f * verticalincr;
6394 adj *= 10.0f;
6396 {
6397 verticalmod = true;
6398 gameclass->bus->AFCS.DesiredPitchRadians -= 0.026f * adj; // 0.5 deg
6399 if (gameclass->bus->AFCS.DesiredPitchRadians < RiseMath::ToRadian(-15)) // nose down 15
6401 }
6403 verticalmod = true;
6405 }
6407 {
6408 verticalmod = true;
6409 gameclass->bus->AFCS.DesiredVsiKms -= 0.05f * adj;
6410 }
6412 {
6413 verticalmod = true;
6414 gameclass->bus->AFCS.DesiredIasKms -= 0.01f * adj;
6415 if (gameclass->bus->AFCS.DesiredIasKms < 0.0f)
6417 }
6420 {
6421 verticalmod = true;
6422 gameclass->bus->AFCS.DesiredAltitudeKm -= 0.25f * adj;
6425 }
6426 verticaltime = 4.0f;
6427 }
6428 break;
6429 }
6430}
6431
6432void Viewscreen::TriggerBCLLightning(int u, int v, float distanceKm, int seed, int chainedBolts) const
6433{
6434 if (playerships[0].isSimulator) return;
6435 const auto ground=-gridarray[u][v].position;
6436 RiseMath::Vector3 normal;
6438 const auto cloud=-(normal*RiseMath::Min(ptrWeather->GetCloudCeilingMslKm(),cloudTopsMslC)+gridarray[u][v].cloudpos);
6439 TriggerBCLLightningAt(ground,cloud,distanceKm,seed,chainedBolts);
6440}
6441
6442void Viewscreen::TriggerBCLLightningAt(const RiseMath::Vector3& ground, const RiseMath::Vector3& cloud, float distanceKm, int seed, int chainedBolts, bool testStrike) const
6443{
6444 logger->AddToCallStack("Viewscreen::TriggerBCLLightning");
6445
6446 // Keep every entry point out of the simulator, including legacy packets:
6447 // no visual state, thunder, gameplay RNG, or impact side effects.
6448 if (playerships[0].isSimulator) return;
6449 if (!std::isfinite(distanceKm) || distanceKm<0 || distanceKm>=64) return;
6450 const auto path=LightningChain::Build(ground,cloud,uint32_t(seed),chainedBolts,radiusC+cloudTopsMslC);
6451 if(!path.count)return;
6452 srand(seed);
6453
6454 // Each connected section gets a complete bolt interval in sequence.
6455 // Geometry stays fixed; sound onset follows the same deterministic schedule.
6456 lightningbelow.Start(uint32_t(seed),path);
6457 lightningbelow.distanceScalar = distanceKm / 64.0f; // now 0 is very close
6458 // Slight bias toward bright flashes
6459 lightningbelow.intensity = testStrike ? 1.f : powf(RandomFloat(), 0.5f);
6460
6461#pragma region Color
6462
6463 // map brightness to saturation & value
6464 float saturation = Lerp(0.05f, 0.25f, lightningbelow.intensity);
6465
6466 // random hue between 220° and 260°
6467 float boltHue = ((220.0f + RandomFloat() * 40.0f) / 360.0f);
6468
6469 lightningbelow.color = HSVtoRGB(boltHue, saturation, 1.0f);
6470
6471#pragma endregion
6472
6473
6474 for (int i = 0; i < path.count; i++)
6475 {
6476 const auto& segment=path.segments[i];
6477 const float intensity=lightningbelow.intensity;
6478 const auto source=segment.SoundSource(playerships[0].position);
6479 distanceKm=GridLightning::Distance(source,playerships[0].position);
6480 if(!std::isfinite(distanceKm) || distanceKm>=64)continue;
6481 const float delaySeconds=float(lightningbelow.SegmentStart(i))
6482 +distanceKm/ptrPropulsion->speedOfSoundKms;
6483 float volume = sqrtf(1.0f - distanceKm/64.f) * intensity; // volume
6484 volume *= 1.0f - 0.65f * powf(ptrWeather->snowBlend, 1.2f); // snow attenuation
6485 if (volume > 0.5f && rand() % 2 && intensity > 0.5f && gameclass->GUI->player[gameclass->GUI->ourplayerC].frame == 0)
6486 {
6487 ourcockpit.adrenolinBPM += 20.0f * volume; // volume reflects intensity and distance
6489 if (!testStrike && segment.groundContact && distanceKm < 2.0f) // Diagnostic bolts must not damage the test vehicle.
6491 }
6492
6493 if (distanceKm < 2.0f)
6494 {
6495 SOUNDS newThunderNear = static_cast<SOUNDS>(SOUND_THUNDER_NEAR + rand() % 5);
6496 while (newThunderNear == gameclass->sound->oldThunderNear)
6497 newThunderNear = static_cast<SOUNDS>(SOUND_THUNDER_NEAR + rand() % 5);
6498 gameclass->sound->oldThunderNear = newThunderNear;
6499 gameclass->sound->AddDelayedSound(newThunderNear, delaySeconds, 1, 1, true);
6500 }
6501 else if (distanceKm < 20.0f)
6502 {
6503 SOUNDS newThunderMid = static_cast<SOUNDS>(SOUND_THUNDER_MID + rand() % 5);
6504 while (newThunderMid == gameclass->sound->oldThunderMid)
6505 newThunderMid = static_cast<SOUNDS>(SOUND_THUNDER_MID + rand() % 5);
6506 gameclass->sound->oldThunderMid = newThunderMid;
6507 gameclass->sound->AddDelayedSound(newThunderMid, delaySeconds, 1, 1, true);
6508 }
6509 else if (distanceKm < 50.0f) // distance 20 is 0.6875 ... distance 64 is 0
6510 {
6511 SOUNDS newThunderFar = static_cast<SOUNDS>(SOUND_THUNDER_FAR + rand() % 5);
6512 while (newThunderFar == gameclass->sound->oldThunderFar)
6513 newThunderFar = static_cast<SOUNDS>(SOUND_THUNDER_FAR + rand() % 5);
6514 gameclass->sound->oldThunderFar = newThunderFar;
6515 gameclass->sound->AddDelayedSound(newThunderFar, delaySeconds, (1.0f - distanceKm / 50.0f), 1, true);
6516 }
6517
6518 char msg[99];
6519 sprintf_s(msg, sizeof(msg), "Lightning channel %i/%i: distance %.3f km intensity %.3f delay %.3f s", i+1, path.count, distanceKm, intensity, delaySeconds);
6520 logger->Log(msg);
6521
6522 }
6523}
6524
6526{
6527 logger->AddToCallStack("Viewscreen::LoadVehicleProfile");
6528
6530 if (playerships[t].componentarray)
6531 {
6532 SAFE_DELETE_ARRAY(playerships[t].componentarray);
6533 playerships[t].components = 0;
6534 sprintf_s(msg, sizeof(msg), "playerships[%i].componentarray", t);
6536 }
6537
6538 // rotating nose to the right 90� from what we see in the makeship? and pointing the nose away?
6539 RiseMath::Matrix matrixTemp;
6540 RiseMath::MatrixIdentity(&playerships[t].matrixBase);
6541 RiseMath::MatrixRotationX(&matrixTemp, RiseMath::HalfPi); // pitch
6542 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6543
6544 int handle = -1;
6545
6546 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
6547 switch (playerships[t].type)
6548 {
6549 case VehicleType::C98:
6550 _sopen_s(&handle, "meshes\\C-98 MuVER-construction.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6551 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6552 playerships[t].bound = 0.004647f;
6553 playerships[t].steerLimitRadian = RiseMath::ToRadian(45.0f); // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6554 playerships[t].tireCircumferenceKm = 0.0004065f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6555 playerships[t].VB = 8;
6556 // haha we were actually rotating it to the right! So we don't have to do that anymore
6557 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6558 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6559 break;
6560 case VehicleType::DIHV:
6561 _sopen_s(&handle, "meshes\\dihv.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6562 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6563 playerships[t].bound = 0.337061f;
6564 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6565 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6566 playerships[t].VB = 7;
6567 // haha we were actually rotating it to the right! So we don't have to do that anymore
6568 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6569 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6570 break;
6571 case VehicleType::E10:
6572 _sopen_s(&handle, "meshes\\e-10.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6573 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6574 playerships[t].bound = 0.034726f;
6575 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6576 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6577 playerships[t].VB = 3;
6578 // haha we were actually rotating it to the right! So we don't have to do that anymore
6579 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6580 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6581 break;
6582 case VehicleType::P13:
6583 _sopen_s(&handle, "meshes\\p-13.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6584 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6585 playerships[t].bound = 0.018931f;
6586 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6587 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6588 playerships[t].VB = 9;
6589 // haha we were actually rotating it to the right! So we don't have to do that anymore
6590 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6591 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6592 break;
6593 case VehicleType::A4:
6594 _sopen_s(&handle, "meshes\\T-8 Wanderer.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6595 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6596 playerships[t].bound = 0.032570f;
6597 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6598 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6599 playerships[t].VB = 6;
6600 // haha we were actually rotating it to the right! So we don't have to do that anymore
6601 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6602 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6603 break;
6604 case VehicleType::C2:
6605 _sopen_s(&handle, "meshes\\C-2 Dasher.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6606 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6607 playerships[t].bound = 0.003726f;
6608 playerships[t].steerLimitRadian = RiseMath::ToRadian(45.0f); // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6609 playerships[t].tireCircumferenceKm = 0.0002155f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6610 playerships[t].VB = 10;
6611 // haha we were actually rotating it to the right! So we don't have to do that anymore
6612 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6613 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6614 break;
6615 case VehicleType::T120:
6616 _sopen_s(&handle, "meshes\\T-120 Steerhead-stock.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6617 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6618 playerships[t].bound = 0.005191f;
6619 playerships[t].steerLimitRadian = RiseMath::ToRadian(45.0f); // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6620 playerships[t].tireCircumferenceKm = 0.0004065f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6621 playerships[t].VB = 11;
6622 // haha we were actually rotating it to the right! So we don't have to do that anymore
6623 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6624 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6625 break;
6626 case VehicleType::E11:
6627 _sopen_s(&handle, "meshes\\E-11.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6628 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6629 playerships[t].bound = 0.036348f;
6630 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6631 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6632 playerships[t].VB = 12;
6633 // so north oriented on the screen needs this rotation
6634 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6635 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6636 break;
6638 _sopen_s(&handle, "meshes\\pax-exterior-hex.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6639 playerships[t].speed = 0.0f;
6640 playerships[t].bound = 0.003656f;
6641 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6642 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6643 playerships[t].VB = 23;
6644 // 180 degrees backwards
6645 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // now yaw, was roll
6646 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6647 break;
6649 _sopen_s(&handle, "meshes\\cargo-standard.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6650 playerships[t].speed = 0.0f;
6651 playerships[t].bound = 0.003656f;
6652 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6653 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6654 playerships[t].VB = 4;
6655 // 180 degrees backwards
6656 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // now yaw, was roll
6657 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6658 break;
6660 _sopen_s(&handle, "meshes\\fuel-standard-ext.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6661 playerships[t].speed = 0.0f;
6662 playerships[t].bound = 0.003656f;
6663 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6664 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6665 playerships[t].VB = 18;
6666 // 180 degrees backwards
6667 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // now yaw, was roll
6668 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6669 break;
6671 _sopen_s(&handle, "meshes\\cargo-toploader.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6672 playerships[t].speed = 0.0f;
6673 playerships[t].bound = 0.003656f;
6674 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6675 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6676 playerships[t].VB = 20;
6677 // 180 degrees backwards
6678 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // now yaw, was roll
6679 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6680 break;
6682 _sopen_s(&handle, "meshes\\munitions-standard-ext.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6683 playerships[t].speed = 0.0f;
6684 playerships[t].bound = 0.003656f;
6685 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6686 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6687 playerships[t].VB = 21;
6688 // 180 degrees backwards
6689 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // now yaw, was roll
6690 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6691 break;
6692 case VehicleType::C2A:
6694 _sopen_s(&handle, "meshes\\C-2A Dasher.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6695 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6696 playerships[t].bound = 0.002675f;
6697 playerships[t].steerLimitRadian = RiseMath::ToRadian(45.0f); // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6698 playerships[t].tireCircumferenceKm = 0.001012f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6699 playerships[t].VB = 14;
6700 // so north oriented on the screen needs this rotation
6701 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6702 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6703 break;
6704 case VehicleType::T27: // Mammoth
6705 _sopen_s(&handle, "meshes\\T-27 Mammoth.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6706 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6707 playerships[t].bound = 0.030989f;
6708 playerships[t].steerLimitRadian = 0.0f; // skid-steer wheels do not deflect
6709 playerships[t].tireCircumferenceKm = 0.001619f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6710 playerships[t].VB = 24;
6711 // so north oriented on the screen needs this rotation
6712 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6713 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6714 break;
6716 _sopen_s(&handle, "meshes\\BeishtKione.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6717 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6718 playerships[t].bound = 0.014789f;
6719 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6720 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6721 playerships[t].VB = 17;
6722 // so north oriented on the screen needs this rotation
6723 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6724 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6725 break;
6727 _sopen_s(&handle, "meshes\\manx-hex.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6728 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6729 playerships[t].bound = 0.036829f;
6730 playerships[t].steerLimitRadian = 1.22173f; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6731 playerships[t].tireCircumferenceKm = 0.00069f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6732 playerships[t].VB = 16;
6733 // so north oriented on the screen needs this rotation
6734 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6735 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6736 break;
6737 case VehicleType::T19:
6738 _sopen_s(&handle, "meshes\\T-19 Stratomaster.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6739 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6740 playerships[t].bound = 0.023887f;
6741 playerships[t].steerLimitRadian = 1.22173f; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6742 playerships[t].tireCircumferenceKm = 0.000406f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6743 playerships[t].VB = 19;
6744 // so north oriented on the screen needs this rotation
6745 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6746 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6747 break;
6749 _sopen_s(&handle, "meshes\\Holidays\\Spacesuit-Morholt-posed.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6750 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6751 playerships[t].bound = 0.001f;
6752 playerships[t].steerLimitRadian = 0; // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6753 playerships[t].tireCircumferenceKm = 0; // this is based on the radius in ourcockpit.tireRadiusKm
6754 playerships[t].VB = 22;
6755 // so north oriented on the screen needs this rotation
6756 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::Pi); // now yaw, was roll
6757 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6758 break;
6759 case VehicleType::T121:
6760 _sopen_s(&handle, "meshes\\2007 T-120 EXT.dix", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
6761 playerships[t].speed = 0.045f + RandomFloat() * 0.01f; // 4.5-5.5
6762 playerships[t].bound = 0.005864f;
6763 playerships[t].steerLimitRadian = RiseMath::ToRadian(45.0f); // if we change this here we have to change it in ourcockpit.steerLimitRadian too
6764 playerships[t].tireCircumferenceKm = 0.0003555f * RiseMath::Tau; // this is based on the radius in ourcockpit.tireRadiusKm
6765 playerships[t].VB = 15;
6766 // haha we were actually rotating it to the right! So we don't have to do that anymore
6767 RiseMath::MatrixRotationY(&matrixTemp, -RiseMath::HalfPi); // now yaw, was roll
6768 RiseMath::MatrixMultiply(&playerships[t].matrixBase, &playerships[t].matrixBase, &matrixTemp);
6769 break;
6770 }
6771
6772 if (t == 0)
6773 {
6776 if (playerships[0].VB >= 0 && playerships[0].VB < maxpolyC)
6777 {
6778 const auto& model = polyobjects[playerships[0].VB];
6779 ourcockpit.landingLights = model.landingLights;
6780 ourcockpit.landingLightCount = model.landingLightCount;
6781 }
6782 // The EVA suit borrows a vehicle mesh/profile, but has one helmet lamp.
6783 if (playerships[0].type == VehicleType::EVA_SUIT)
6784 {
6787 }
6790 for (unsigned i = 0; i < ourcockpit.landingLightCount; ++i)
6792 }
6793
6794 if (handle == -1)
6795 {
6796 sprintf_s(msg, sizeof(msg), "InitApp() failed to load DIX for type %i!", playerships[t].type);
6798 }
6799 else
6800 {
6801 _lseek(handle, 0, SEEK_SET);
6802 _read(handle, &playerships[t].components, 2);
6803
6804 float version;
6805 _read(handle, &version, 4);
6806
6807 sprintf_s(msg, sizeof msg, "playerships[%i].componentarray", t);
6808 if (playerships[t].componentarray)
6809 {
6810 SAFE_DELETE_ARRAY(playerships[t].componentarray);
6812 }
6814 if (playerships[t].componentarray == nullptr)
6815 {
6816 sprintf_s(msg, sizeof(msg), "LoadVehicleProfile() Failed to initialize %i component(s) for slot %i, type %i", playerships[t].components, t, playerships[t].type);
6818 }
6819 else
6820 {
6821 gameclass->AddTrackedResource(msg); // managed, memory only
6822
6823 sprintf_s(msg, sizeof(msg), "LoadVehicleProfile() Initialized %i component(s) for slot %i, type %i", playerships[t].components, t, playerships[t].type);
6824 logger->Log(msg);
6825 }
6826
6827
6828 short i_temp;
6829 for (short s = 0; s < playerships[t].components; s++)
6830 {
6831 _lseek(handle, (long)s * 100L + 99L, SEEK_SET); // To 0
6832 _read(handle, &i_temp, 2); // 0
6833 playerships[t].componentarray[s].startvertex = (UINT)i_temp;
6834 _read(handle, &i_temp, 2); // 2
6835 playerships[t].componentarray[s].primitives = (UINT)i_temp;
6836 _read(handle, &playerships[t].componentarray[s].nominalxyz, 12); // 4
6837 _read(handle, &playerships[t].componentarray[s].nominalypr, 12); // 16
6838 _read(handle, &playerships[t].componentarray[s].boundsphere, 4); // 28
6839 _read(handle, &playerships[t].componentarray[s].extendby, 12); // 32
6840 _read(handle, &playerships[t].componentarray[s].texture, 2); // 44
6841 if (playerships[t].componentarray[s].texture >= shiptextureC)
6842 {
6843 sprintf_s(msg, sizeof(msg), "Type %i Component %i Texture %i out-of-bounds", t, s, playerships[t].componentarray[s].texture);
6845 }
6846 _read(handle, &playerships[t].componentarray[s].nominalCG, 12); // 46
6847 _read(handle, &playerships[t].componentarray[s].type, 1); // 58
6848 _read(handle, &playerships[t].componentarray[s].speedExtend, 4); // 59
6849 _read(handle, &playerships[t].componentarray[s].hingeaxis, 12); // 63
6850 _read(handle, &playerships[t].componentarray[s].hingeCG, 12); // 75
6851 _read(handle, &playerships[t].componentarray[s].hingeextent, 4); // 87
6852 _read(handle, &playerships[t].componentarray[s].attachto, 2); // 91
6853
6854 if (version >= 2.44f)
6855 {
6856 _read(handle, &playerships[t].componentarray[s].useLightMap, 1); // 93
6857 _read(handle, &playerships[t].componentarray[s].speedRetract, 4); // 59
6858 }
6859 else
6860 {
6863 }
6864
6865 // Dynamic
6866 playerships[t].componentarray[s].extended = 0.0f; // these are initialized down below like ~6857
6867 }
6868 _close(handle);
6869 }
6870
6871 sprintf_s(msg, sizeof(msg), "LoadVehicleProfile() finished component list");
6872 logger->Log(msg);
6873
6874 for (unsigned short s = 0; s < playerships[t].components; s++)
6875 {
6876 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
6877 switch (playerships[t].componentarray[s].type)
6878 {
6879 case 1: // Main gear
6880 case 2: // Nose gear
6881 case 6: // Main wheel
6882 case 9: // Nose wheel
6883 {
6884 playerships[t].componentarray[s].extended = playerships[t].geardown ? 1.0f : 0.0f;
6885 if (t == 0)
6886 {
6887 ourcockpit.gearextent = playerships[t].geardown ? 1.0f : 0.0f;
6889 }
6890 }
6891 break;
6892 case 16: // flaps (TE)
6893 case 68: // flaps (LE)
6894 {
6896 if (t == 0)
6897 {
6901 }
6902 }
6903 break;
6904 case 30: // Bay doors
6905 {
6906 playerships[t].componentarray[s].extended = playerships[t].baydoor ? 1.0f : 0.0f;
6908 }
6909 break;
6910 case 69: // spoilers
6911 {
6913 if (t == 0)
6914 {
6915 //ourcockpit.flapExtent = playerships[t].componentarray[s].extended;
6916 // @todo I warned Bill about this on 3/23/2023 ... if he switches vehicles the server doesn't track these separate
6917 // if he hops in a vehicles and spoilers are extended AND flaps are extended AND WOW then it is probably GLD ...
6918 // otherwise the dipshit left the flight spoilers extended!
6919 if (playerships[t].spoilersUp > 0 && playerships[t].flapdown > 0 && playerships[t].reference == REF_ONGROUND)
6920 {
6923 }
6924 else
6925 {
6928 }
6929 }
6930 }
6931 break;
6932 }
6933 }
6934
6935 if (t == 0)
6937
6938 logger->Log("LoadVehicleProfile() done!");
6939}
@ ScanFailedInterference
Definition ActiveHelp.h:15
@ RepairedVehicle
Definition ActiveHelp.h:16
@ KeyboardBindings
Definition ActiveHelp.h:412
@ GroundVehicleKeysSteer
Definition ActiveHelp.h:369
@ WelcomeWheeled
Definition ActiveHelp.h:411
@ MoveAroundKeys
Definition ActiveHelp.h:386
@ Scanning
Definition ActiveHelp.h:14
@ TaxiService54
Definition ActiveHelp.h:407
@ DockingGetCloser
Definition ActiveHelp.h:18
@ GroundVehicleJoySteer
Definition ActiveHelp.h:373
@ FirstOpenDoors
Definition ActiveHelp.h:5
@ ToPowerOffPutInPark
Definition ActiveHelp.h:322
@ WelcomeSimulator1
Definition ActiveHelp.h:381
@ RepairPutInPark
Definition ActiveHelp.h:314
@ NoCargoBedOrCargoBay
Definition ActiveHelp.h:9
@ DockingFullAndCompleteStop
Definition ActiveHelp.h:17
@ NightOutDomeLight
Definition ActiveHelp.h:390
@ VehicleTooLargeForVehicle
Definition ActiveHelp.h:13
@ GroundVehicleJoyGas
Definition ActiveHelp.h:393
@ WhereIsTheBrakeKeys
Definition ActiveHelp.h:391
@ TaxiService47
Definition ActiveHelp.h:400
@ FirstSelectVehicleOrContainer
Definition ActiveHelp.h:10
@ TaxiService55
Definition ActiveHelp.h:408
@ TaxiService61
Definition ActiveHelp.h:414
@ UpsideDown
Definition ActiveHelp.h:357
@ GroundVehicleKeysGas
Definition ActiveHelp.h:392
@ TaxiService56
Definition ActiveHelp.h:409
@ TaxiService48
Definition ActiveHelp.h:401
@ RepairStopThrusting
Definition ActiveHelp.h:315
@ MoveAroundJoy
Definition ActiveHelp.h:426
@ Repair
Definition ActiveHelp.h:417
@ VehicleOrContainerOnBoard
Definition ActiveHelp.h:11
@ WelcomeDasher
Definition ActiveHelp.h:361
@ WhereIsTheBrakeJoy
Definition ActiveHelp.h:377
@ NightOutHeadlight
Definition ActiveHelp.h:389
#define SAFE_DELETE_ARRAY(value)
#define V_RETURN(expression)
#define SAFE_RELEASE(value)
#define V(expression)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
float Lerp(float val1, float val2, float lerp)
float RandomFloat()
constexpr auto Clamp(T1 val, T2 min, T3 max)
@ EVENT_SELECT_PAGE
Definition Networking.h:60
@ EVENT_HEADLIGHT_ON
Definition Networking.h:40
@ EVENT_LANDINGGEAR_UP
Definition Networking.h:45
@ EVENT_HEADLIGHT_OFF
Definition Networking.h:41
@ EVENT_SPOILERSETTING
Definition Networking.h:65
@ EVENT_LANDINGGEAR_DOWN
Definition Networking.h:44
@ EVENT_SELECT_TARGET
Definition Networking.h:59
@ EVENT_ANTIICE
Definition Networking.h:55
@ EVENT_MAP_ZOOM
Definition Networking.h:62
@ EVENT_DOMELIGHT_ON
Definition Networking.h:46
@ EVENT_FLAPSETTING
Definition Networking.h:52
@ EVENT_BAYDOOR_CLOSED
Definition Networking.h:43
@ EVENT_PARKINGBRAKE
Definition Networking.h:53
@ EVENT_YAWDAMPER
Definition Networking.h:54
@ EVENT_LOGOLIGHT_ON
Definition Networking.h:50
@ EVENT_LOGOLIGHT_OFF
Definition Networking.h:51
@ EVENT_DOMELIGHT_OFF
Definition Networking.h:47
@ EVENT_POLICELIGHT_OFF
Definition Networking.h:49
@ EVENT_BAYDOOR_OPEN
Definition Networking.h:42
@ EVENT_POLICELIGHT_ON
Definition Networking.h:48
const RiseMath::Vector3 eastpoleI
@ W6Manx
Definition ServerTypes.h:84
@ ARJ_CARGOAFT
Definition ServerTypes.h:72
@ EVA_SUIT
Definition ServerTypes.h:69
@ ARJ_FUEL
Definition ServerTypes.h:73
@ C98
Definition ServerTypes.h:61
@ C2
Definition ServerTypes.h:66
@ BeishtKione
Definition ServerTypes.h:83
@ C2A
Definition ServerTypes.h:81
@ ARJ_MUNITIONS
Definition ServerTypes.h:75
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ ARJ_PAX
Definition ServerTypes.h:70
@ E10
Definition ServerTypes.h:63
@ T120
Definition ServerTypes.h:67
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ FloatingMan
Definition ServerTypes.h:88
@ DIHV
Definition ServerTypes.h:62
@ A4
Definition ServerTypes.h:65
@ T121
Definition ServerTypes.h:89
@ ARJ_CARGOTOP
Definition ServerTypes.h:74
#define MAX_ENGINES
#define MAX_SCAN
@ DeoisIndustrial
@ PlotTypeEnum
@ NorthPole
@ O4Ruin4
@ DeoisPort
@ Arcridge
@ DeoisFinancial
@ O4Ruin3
@ UserAirfield
@ DeoisTransit
@ Chojeir
@ DoNotRender
@ DeoisCityCenter
@ O4Ruin2
@ O4Ruin1
const RiseMath::Vector3 northpoleK
const RiseMath::Vector3 meridianJ
#define maxdockC
const RiseMath::Vector3 centerC
@ REF_BUILDING
Definition ServerTypes.h:46
@ REF_PROXIMITY
Definition ServerTypes.h:48
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_INANOTHER
Definition ServerTypes.h:45
@ REF_APNMODE
Definition ServerTypes.h:42
@ REF_ONGROUND
Definition ServerTypes.h:43
@ REF_WINDOWLESS
Definition ServerTypes.h:50
#define limiterC
SOUNDS
Definition Sound.h:23
@ SOUND_CYCLETARGET
Definition Sound.h:173
@ SOUND_THUNDER_MID
Definition Sound.h:126
@ SOUND_GEARRETRACT
Definition Sound.h:213
@ SOUND_POLICECHIRP
Definition Sound.h:267
@ SOUND_COLLISION1
Definition Sound.h:248
@ SOUND_THUNDER_FAR
Definition Sound.h:131
@ SOUND_COCKPITSTART
Definition Sound.h:26
@ SOUND_UNDOCK
Definition Sound.h:208
@ SOUND_APCAVALRY
Definition Sound.h:171
@ SOUND_THUNDER_NEAR
Definition Sound.h:121
@ SOUND_DEPLANING
Definition Sound.h:189
@ SOUND_COLLISION2
Definition Sound.h:249
@ SOUND_DOORCLOSE
Definition Sound.h:212
@ SOUND_FLAPMOTOR
Definition Sound.h:210
@ SOUND_SPEAKERPOP
Definition Sound.h:144
@ SOUND_DOOROPEN
Definition Sound.h:211
@ SOUND_DOCKANNOUNCE1
Definition Sound.h:192
@ SOUND_DOCKEVAC
Definition Sound.h:204
@ SOUND_GEAREXTEND
Definition Sound.h:214
@ SOUND_BEFORETAKEOFF
Definition Sound.h:183
#define depthFloorResolutionC
Definition Viewscreen.h:43
BindingEnum
Definition binding.h:6
@ LATERALMODE_LEFT
Definition binding.h:93
@ VERTICALMODE_CYCLE
Definition binding.h:56
@ RCS_BACKWARD
Definition binding.h:64
@ FIREWEAPON_2
Definition binding.h:24
@ LATERALMODE_CYCLE
Definition binding.h:54
@ YAWDAMPER_CYCLE
Definition binding.h:36
@ ADMIN_STORECAMERA_CLIPBOARD
Definition binding.h:32
@ THRUST0TVMMINUS1KM
Definition binding.h:21
@ CHAIR_FORWARD
Definition binding.h:92
@ SCAN_SHALLOW
Definition binding.h:90
@ BAYDOOR_CYCLE
Definition binding.h:58
@ LOCALIZERARMED_CYCLE
Definition binding.h:55
@ RCS_UP
Definition binding.h:26
@ DOWNSHIFT
Definition binding.h:19
@ REVERSERS_CYCLE
Definition binding.h:16
@ NULL_RATES
Definition binding.h:67
@ THRUST_MINUS10_TVMMINUS
Definition binding.h:69
@ LANDINGLIGHT_CYCLE
Definition binding.h:48
@ BRAKES
Definition binding.h:88
@ MAPZOOMIN
Definition binding.h:14
@ FLAPS_DOWN
Definition binding.h:27
@ MFD_PAGE_NEXT
Definition binding.h:38
@ SPOILER_DOWN
Definition binding.h:40
@ FIREWEAPON_1
Definition binding.h:23
@ DISPLACEPLAYER
Definition binding.h:50
@ TURN_RIGHT
Definition binding.h:77
@ ADMIN_RELOADVEHICLEPROFILE
Definition binding.h:13
@ FLIGHTDIRECTOR_CYCLE
Definition binding.h:45
@ ADMIN_PRECISIONY_UP
Definition binding.h:18
@ REPAIR
Definition binding.h:29
@ ENGINE1_CYCLE
Definition binding.h:7
@ PITCH_DOWN
Definition binding.h:84
@ THRUST_PLUS10_TVMPLUS
Definition binding.h:70
@ ADMIN_PRECISIONX_LEFT
Definition binding.h:51
@ GPWS_INHIBIT
Definition binding.h:103
@ SPOILER_UP
Definition binding.h:41
@ YAW_LEFT
Definition binding.h:79
@ HORN
Definition binding.h:17
@ TARGET_NEXT
Definition binding.h:34
@ ADMIN_PRECISIONY_DOWN
Definition binding.h:37
@ DOR_CYCLE
Definition binding.h:46
@ CAMERA_CYCLE
Definition binding.h:31
@ BINDINGSMAP
Definition binding.h:71
@ ADMIN_PRECISIONX_RIGHT
Definition binding.h:53
@ ENGINE2_CYCLE
Definition binding.h:8
@ PARKINGBRAKE_CYCLE
Definition binding.h:89
@ ADMIN_CAMERAY_UP
Definition binding.h:61
@ DOCKING_CYCLE
Definition binding.h:81
@ ADMIN_CAMERAY_DOWN
Definition binding.h:62
@ TVM_CYCLE
Definition binding.h:47
@ MAPZOOMOUT
Definition binding.h:15
@ GAS
Definition binding.h:85
@ RAIN_PROTECTION_CYCLE
Definition binding.h:101
@ NULL_PITCH_TRIM
Definition binding.h:68
@ FLIP
Definition binding.h:30
@ SCANNER_PAGE_NEXT
Definition binding.h:59
@ PITCHTRIM_UP
Definition binding.h:97
@ LOADVEHICLE
Definition binding.h:49
@ UPSHIFT
Definition binding.h:20
@ FLAPS_UP
Definition binding.h:28
@ TURN_LEFT
Definition binding.h:75
@ GEAR_CYCLE
Definition binding.h:10
@ RCS_DOWN
Definition binding.h:25
@ ANTIICE_CYCLE
Definition binding.h:42
@ BOARDVEHICLE
Definition binding.h:52
@ GPWS_TEST
Definition binding.h:102
@ MFD_PAGE_PREV
Definition binding.h:39
@ LATERALMODE_RIGHT
Definition binding.h:94
@ YAW_RIGHT
Definition binding.h:80
@ STEERROLL_RIGHT
Definition binding.h:78
@ AUTOFLYTE_CYCLE
Definition binding.h:33
@ RCS_LEFT
Definition binding.h:65
@ STEERROLL_LEFT
Definition binding.h:76
@ TOGA
Definition binding.h:100
@ RELOADXML
Definition binding.h:12
@ CHAIR_BACK
Definition binding.h:91
@ RCS_FORWARD
Definition binding.h:63
@ TARGET_PREV
Definition binding.h:35
@ THRUST100TVMPLUS1KM
Definition binding.h:22
@ GLIDESLOPEARMED_CYCLE
Definition binding.h:57
@ FLIGHTFREEZE_CYCLE
Definition binding.h:74
@ POWER_CYCLE
Definition binding.h:43
@ DOMELIGHT_CYCLE
Definition binding.h:44
@ RCS_RIGHT
Definition binding.h:66
@ AURALWARNINGTEST
Definition binding.h:72
@ COAST
Definition binding.h:87
@ CAS_CLEAR
Definition binding.h:73
@ VERTICALMODE_DOWN
Definition binding.h:96
@ SCANNER_PAGE_PREV
Definition binding.h:60
@ ENGINE3_CYCLE
Definition binding.h:9
@ PITCHTRIM_DOWN
Definition binding.h:98
@ VERTICALMODE_UP
Definition binding.h:95
@ THRUSTAUGMENTATION_CYCLE
Definition binding.h:82
@ PITCH_UP
Definition binding.h:86
@ WALK
Definition binding.h:83
scanDb Scanner
Definition Bus.h:484
float RightBrake
Definition Bus.h:383
RiseMath::Vector3 DebugDepth
Definition Bus.h:549
VECTOR2SHORT tcp
Definition Bus.h:314
float RollAttitudeRadians
Definition Bus.h:48
float MapScaleInnerRingKm
Definition Bus.h:490
float GroundSpeedKms
Definition Bus.h:179
float PitchAttitudeRadians
Definition Bus.h:47
VECTOR2SHORT DebugRts
Definition Bus.h:561
float TrailingEdgeFlapsPosition
Definition Bus.h:424
float LeftBrake
Definition Bus.h:383
float ComputedTrimTargetDegrees
Definition Bus.h:416
short targetC
Definition Bus.h:480
long topscroll
Definition Bus.h:483
float LandingGearExtended
Definition Bus.h:301
bool OnGround
Definition Bus.h:173
UINT flapSettingTE
Definition Bus.h:67
float EngineThrustLever[MAX_ENGINES]
Definition Bus.h:357
float IndicatedAirspeedKms
Definition Bus.h:34
double SimulatorTimeOffset
Definition Bus.h:475
struct Bus::Afcs AFCS
float HeadingTrueDegrees
Definition Bus.h:41
float LeadingEdgeFlapsPosition
Definition Bus.h:426
float FlightSpoilerPositionScalar
Definition Bus.h:76
bool AntiIce
Definition Bus.h:392
float PitchTrimScalar
Definition Bus.h:415
void AddCommand(const Command &command, bool onlyOne)
Definition Bus.cpp:5
float assayProgressV
Definition Bus.h:496
bool YawDamperStatus
Definition Bus.h:433
short scanslot[MAX_SCAN]
Definition Bus.h:485
short DebugType
Definition Bus.h:564
long scanscroll
Definition Bus.h:483
bool FlightFreeze
Definition Bus.h:474
double ProgramTime
Definition Bus.h:473
float GroundSpoilerPositionScalar
Definition Bus.h:75
float VerticalSpeedKms
Definition Bus.h:451
float TargetBearingDeg
Definition Bus.h:503
Orbital::BusState orbit
Definition Bus.h:481
bool ThrustReverserCommand[MAX_ENGINES]
Definition Bus.h:72
std::vector< Command > commandStream
Definition Bus.h:442
float assayProgressU
Definition Bus.h:496
HRESULT Initialize(Rendering::RenderDevice *device)
const std::string & InitializationStatus() const
InputConfig inputConfigSteer
Definition config.h:38
InputConfig inputConfigRoll
Definition config.h:33
InputConfig inputConfigYaw
Definition config.h:34
InputConfig inputConfigPitchTrim
Definition config.h:45
std::string TogglePageReverse(std::string screenName)
Definition Displays.cpp:814
std::string TogglePage(std::string screenName)
Definition Displays.cpp:791
void ChangeCockpit()
Definition Displays.cpp:562
void ChangePage(std::string screenName, std::string pageName)
Definition Displays.cpp:750
HRESULT Initialize(Rendering::RenderDevice *device)
GameState displaystage
Definition GameClass.h:118
std::unique_ptr< Bus > bus
Definition GameClass.h:108
Config config
Definition GameClass.h:100
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
std::unique_ptr< Sound > sound
Definition GameClass.h:104
bool TurnOffTVM() const
std::unique_ptr< Networking > networking
Definition GameClass.h:103
void AddTrackedResource(const char *name, Rendering::ResourcePool pool=Rendering::ResourcePool::Managed)
void UpdateTrackedResource(const char *name, int status)
void FlightDirectorOn() const
std::unique_ptr< Displays > displays
Definition GameClass.h:110
bool showKeymapOverlay
Definition GameClass.h:133
bool timeLapse
Definition GameClass.h:134
void RepairVehicle() const
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
bool TurnOffDOR(bool preserveGuidance=false) const
void ChangeGear(char newGear, bool isInit=false) const
std::unique_ptr< Logger > logger
Definition GameClass.h:109
void AutopilotDisconnect() const
SPlayerData player[MAX_ONLINEPLAYERS]
Definition gui.h:1093
int build
Definition gui.h:1118
int major
Definition gui.h:1116
InformationDialog * informationDialog
Definition gui.h:1120
bool Editing
Definition gui.h:1109
char GetAlignment(int ownerId) const
Definition gui.h:1155
unsigned char ourplayerC
Definition gui.h:1094
int minor
Definition gui.h:1117
int revision
Definition gui.h:1119
bool Edited
Definition gui.h:1109
bool IsAdmin
Definition gui.h:1108
bool DismissHelp(int helpId, int nControlID=GUI_UNDERSTOOD)
bool PopUpHelp(short helpId, bool allowDismiss=true, bool isLearnMore=false)
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
@ Debug
Definition Logger.h:27
@ Info
Definition Logger.h:25
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
void RequestVerbiage(int helpId) const
void SendEvent(EventType eventType, float extent=0.0f) const
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &directory={})
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &directory={})
HRESULT Lock(UINT offset, UINT bytes, void **output, DWORD flags)
HRESULT SetMaterial(const Material *value)
HRESULT LightEnable(DWORD index, BOOL enabled)
HRESULT SetLight(DWORD index, const Light *value)
HRESULT CreateIndexBuffer(UINT bytes, DWORD usage, ImageFormat format, ResourcePool pool, RenderBuffer **result, void *shared)
HRESULT SetRenderState(DWORD state, DWORD value)
HRESULT CreateQuery(UINT type, RenderQuery **result)
HRESULT CreateVertexBuffer(UINT bytes, DWORD usage, DWORD format, ResourcePool pool, RenderBuffer **result, void *shared)
HRESULT SetTextureStageState(DWORD stage, DWORD state, DWORD value)
HRESULT GetSurfaceLevel(UINT level, RenderSurface **result)
float currentPan
Definition Camera.h:12
RiseMath::Vector3 position
Definition Camera.h:11
float currentTilt
Definition Camera.h:13
bool outside
Definition Camera.h:17
void AddDelayedSound(SOUNDS soundEnum, float delay, float volume=1.0f, float freq=1.0f, bool fromOutside=false)
Definition Sound.cpp:3376
void Stop(SOUNDS soundEnum) const
Definition Sound.cpp:3397
void PlayCabinAnnouncement(SOUNDS sound_enum)
Definition Sound.cpp:3456
float Play(SOUNDS soundEnum, float volume=1.0f)
Definition Sound.cpp:802
void PlayEx(SOUNDS soundEnum, bool loop, float volume=1.0f, float frequencyMod=1.0f, float pan=0.0f, bool restart=true, bool fromOutside=false, bool partOfHull=false)
Definition Sound.cpp:1006
SOUNDS oldThunderNear
Definition Sound.h:704
SOUNDS oldThunderFar
Definition Sound.h:704
SOUNDS oldThunderMid
Definition Sound.h:704
float lateraltime
Definition Viewscreen.h:378
void ChangeCamera()
Rendering::RenderFont * m_pFontLicense
Definition Viewscreen.h:130
Rendering::RenderTexture * m_pddsShipTexture[shiptextureC]
Definition Viewscreen.h:289
Rendering::RenderQuery * m_pNightVisionRangeQuery
Definition Viewscreen.h:352
Rendering::ProceduralLightning11 proceduralLightning
Definition Viewscreen.h:397
RiseMath::Vector3 position
Definition Viewscreen.h:382
float rcsThrustRequestY
Definition Viewscreen.h:374
float suspensionNormalLoadG
Definition Viewscreen.h:113
Rendering::RenderTexture * m_pddsHullDynamicTexture[MAX_SCAN]
Definition Viewscreen.h:320
Rendering::RenderBuffer * m_avInstrument
Definition Viewscreen.h:229
Rendering::RenderTexture * m_pddsHeart[heartanimateC]
Definition Viewscreen.h:262
void ShowCloudFallbackWarning(HWND owner) const
Rendering::RenderTexture * m_pddsFlame
Definition Viewscreen.h:263
Rendering::RenderTexture * m_pddsFirework2[firework2C]
Definition Viewscreen.h:255
bool pitchTrimMod
Definition Viewscreen.h:101
void Movement(short t, float ElapsedTime)
std::unique_ptr< renderer > ptrRenderer
Definition Viewscreen.h:433
RiseMath::Matrix matrixProjSim
Definition Viewscreen.h:345
std::unique_ptr< keyboard > ptrKeyboard
Definition Viewscreen.h:429
Rendering::RenderTexture * m_pddsSinker[weaponanimateC]
Definition Viewscreen.h:250
float steerInput
Definition Viewscreen.h:372
float CheckFloorMap(VECTOR2SHORT newdepthpos, short u, short v)
Rendering::RenderBuffer * m_avStaticStars
Definition Viewscreen.h:215
Rendering::RenderBuffer * m_avCone
Definition Viewscreen.h:216
Rendering::RenderBuffer * m_avSkyDome
Definition Viewscreen.h:226
char msg[199]
Definition Viewscreen.h:50
float yawInput
Definition Viewscreen.h:372
static constexpr UINT CloudFallbackWarningMessage
Definition Viewscreen.h:405
CloudVolumeRenderer cloudVolume
Definition Viewscreen.h:396
Rendering::RenderToTexture * m_pHullRender2Surface
Definition Viewscreen.h:318
Rendering::Material restore
Definition Viewscreen.h:327
void DamageLandingLight(unsigned lamp, float clearanceKm, float closingMps, const char *cause)
Rendering::RenderTexture * m_pddsNamePlate
Definition Viewscreen.h:269
Rendering::RenderTexture * m_pddsFuelIcon
Definition Viewscreen.h:273
Rendering::RenderTexture * m_pddsBinoculars
Definition Viewscreen.h:238
Rendering::RenderTexture * m_pddsShipLights[shiptextureC]
Definition Viewscreen.h:290
RiseMath::Matrix matrixProjCock
Definition Viewscreen.h:345
bool m_nightVisionRangefinderActive
Definition Viewscreen.h:354
Rendering::RenderBuffer * m_avLocalGrid
Definition Viewscreen.h:222
VECTOR2SHORT oldRts
Definition Viewscreen.h:77
Rendering::RenderBuffer * m_aiCloudGrid
Definition Viewscreen.h:219
Rendering::RenderTexture * m_pddsWeapon[weaponanimateC]
Definition Viewscreen.h:249
RiseMath::Vector3 UniverseRelativeVelocityKms
Definition Viewscreen.h:125
float pitchInput
Definition Viewscreen.h:372
Rendering::RenderTexture * m_pddsDIHV[dihvanimateC]
Definition Viewscreen.h:261
void RunBindingFunction(BindingEnum function, bool repeating)
bool cloudFallbackWarningShown
Definition Viewscreen.h:409
void ApplyCollisionImpulse(const RiseMath::Vector3 &impulseKms)
Rendering::RenderQuery * m_pLightSunVizQuery
Definition Viewscreen.h:350
RiseMath::Vector3 LandingLightImpactVelocity(unsigned lamp, const RiseMath::Vector3 &velocityBody) const
Rendering::RenderTexture * m_pddsDockTexture[docktextureC]
Definition Viewscreen.h:291
RiseMath::Vector3 QuadraticVectorInterpolation(RiseMath::Vector3 *vel0, RiseMath::Vector3 *vel1, RiseMath::Vector3 *vel2, float t) const
void OnDestroyDevice(bool preserveModels=false)
Rendering::RenderToTexture * m_pRenderToSurface
Definition Viewscreen.h:316
float GetAverageSuspensionBumpTravelKm() const
Viewscreen(GameClass *)
void Initialize()
DeathType causechain
Definition Viewscreen.h:376
Rendering::RenderBuffer * m_avRainDrops
Definition Viewscreen.h:225
std::array< LandingLights::Light, LandingLights::MaxLights > landingLights
Definition Viewscreen.h:329
Rendering::RenderTexture * m_pddsMarston1
Definition Viewscreen.h:302
RiseMath::Vector3 rainarray[MAX_RAINDROPS]
Definition Viewscreen.h:393
Rendering::RenderTexture * m_pddsSinkerX
Definition Viewscreen.h:252
RiseMath::Vector3 gravityacc
Definition Viewscreen.h:112
Rendering::RenderTexture * m_pddsInterlace[2]
Definition Viewscreen.h:278
Sani GetAni(float f_time, unsigned char ani) const
std::unique_ptr< waypoints > ptrWaypoints
Definition Viewscreen.h:437
float fAspect
Definition Viewscreen.h:344
void DamageLandingLightsAgainstSphere(const RiseMath::Vector3 &centerBody, float radiusKm, const RiseMath::Vector3 &velocityBody, float seconds)
RiseMath::Vector3 leveler
Definition Viewscreen.h:143
GameClass * gameclass
Definition Viewscreen.h:439
static bool CheckPlotRoads(float f_tempu, float f_tempv)
Rendering::RenderTexture * m_pddsCloudDetailBelow
Definition Viewscreen.h:237
Rendering::RenderTexture * m_pddsAtmosphere
Definition Viewscreen.h:288
Rendering::RenderTexture * m_pddsNightVisionArrow
Definition Viewscreen.h:243
ReentryEnvelope::State reentryState
Definition Viewscreen.h:399
void SetRainProtection(bool enabled)
std::unique_ptr< propulsion > ptrPropulsion
Definition Viewscreen.h:432
bool m_sunVizPending
Definition Viewscreen.h:351
Rendering::RenderTexture * m_pddsWaterNormal
Definition Viewscreen.h:300
Rendering::RenderTexture * m_pddsWorld2a1
Definition Viewscreen.h:234
Rendering::RenderTexture * m_pddsCloudDetailAbove
Definition Viewscreen.h:236
bool m_bDeviceSupportsVizQuery
Definition Viewscreen.h:349
HRESULT OnCreateDevice(Rendering::RenderDevice *pd3dDevice)
int curbDiagnosticFramesRemaining
Definition Viewscreen.h:119
RiseMath::Vector3 reentryWindward
Definition Viewscreen.h:400
Rendering::RenderTexture * m_pddsCityTexture[citytextureC]
Definition Viewscreen.h:295
std::unique_ptr< weather > ptrWeather
Definition Viewscreen.h:434
float lampTest
Definition Viewscreen.h:424
Rendering::RenderBuffer * m_avRunningLights
Definition Viewscreen.h:218
size_t cameraOrdinal
Definition Viewscreen.h:139
std::vector< SCamera > cameras
Definition Viewscreen.h:136
unsigned int curbDiagnosticSequence
Definition Viewscreen.h:117
RiseMath::Vector3 posnorml
Definition Viewscreen.h:383
bool lateralmod
Definition Viewscreen.h:379
std::unique_ptr< grid > ptrGrid
Definition Viewscreen.h:426
Rendering::RenderTexture * m_pddsGVCompass
Definition Viewscreen.h:270
unsigned short causearray
Definition Viewscreen.h:377
void SetProjectionMatrices()
Rendering::RenderTexture * m_pddsNightVision
Definition Viewscreen.h:239
Rendering::RenderTexture * m_pddsStarTexture
Definition Viewscreen.h:246
Rendering::RenderTexture * m_pddsElmo[elmoAnimateC]
Definition Viewscreen.h:257
std::array< SuspensionWheelState, 4 > suspensionWheels
Definition Viewscreen.h:116
Rendering::RenderTexture * m_pddsBinocularsCompass
Definition Viewscreen.h:240
void ApplyEnvironmentMap()
std::vector< std::string > sofTracking
Definition Viewscreen.h:134
void LoadVehicleProfile(short t)
Rendering::Light sunlight
Definition Viewscreen.h:328
static RiseMath::Color HSVtoRGB(float hue, float s, float v)
Converts HSV in [0…1] to RGB in [0…1].
Rendering::RenderTexture * m_pddsLetters
Definition Viewscreen.h:286
bool AssertTelemetry(const char *location, short id)
void LogCurbDiagnostic(const char *text)
Rendering::RenderFont * m_pFontHull
Definition Viewscreen.h:132
unsigned char zone
Definition Viewscreen.h:141
Rendering::RenderTexture * m_pddsNightVisionCompass
Definition Viewscreen.h:242
float CalculateAGLd(RiseMath::Vector3 terpos, double terprecisionx, double terprecisiony, double terprecisionz, double proposedx, double proposedy, double proposedz, RiseMath::Vector3 proposed, bool makeleveler)
float verticalincr
Definition Viewscreen.h:387
std::unique_ptr< instruments > ptrInstruments
Definition Viewscreen.h:436
VECTOR2SHORT newdepthpos
Definition Viewscreen.h:76
Rendering::RenderBuffer * m_avSkyRing
Definition Viewscreen.h:227
Rendering::RenderTexture * m_pddsRunwayEdgeLight1
Definition Viewscreen.h:303
Rendering::AdDiagnostics11 adDiagnostics
Definition Viewscreen.h:401
double terprecisionz
Definition Viewscreen.h:370
Rendering::RenderTexture * m_pddsRoad
Definition Viewscreen.h:304
float rollInput
Definition Viewscreen.h:372
CityCampaignLogos cityCampaignLogos
Definition Viewscreen.h:309
float UniverseRelativeSpeedKms
Definition Viewscreen.h:126
Rendering::RenderTexture * m_pddsGVBackground
Definition Viewscreen.h:268
float verticaltime
Definition Viewscreen.h:378
Rendering::RenderTexture * m_pddsRTSLights[RTStextureC]
Definition Viewscreen.h:294
VECTOR2SHORT CalculateCGC(RiseMath::Vector3 position, char cube) const
Rendering::RenderSprite * m_spriteVector
Definition Viewscreen.h:325
Rendering::RenderTexture * m_pddsCockpitTexture[cockpittextureC]
Definition Viewscreen.h:275
Rendering::RenderTexture * m_pddsCityLights[citytextureC]
Definition Viewscreen.h:296
unsigned char oldZone
Definition Viewscreen.h:78
LPDIRECTINPUT8 g_pDI
Definition Viewscreen.h:210
void DumpSofTracking()
float CalculateAGL(short u, short v, RiseMath::Vector3 position, bool makeleveler)
Rendering::RenderTexture * m_pddsLandform[landformtextureC]
Definition Viewscreen.h:298
void DamageLandingLights(const RiseMath::Vector3 &surfaceNormalBody, float planeDistanceKm, const RiseMath::Vector3 &impactVelocityBody, const char *cause)
unsigned int curbDiagnosticFrame
Definition Viewscreen.h:118
static RiseMath::Vector3 CalculateBarycentric(RiseMath::Vector3 *position, RiseMath::Vector3 *gthrust, float *radius)
Rendering::RenderBuffer * m_avBillboardVertices
Definition Viewscreen.h:217
VECTOR2SHORT CalculateWrap(short u, short v, char cube, char *rotate) const
void QueueCloudFallbackWarning() const
Rendering::RenderTexture * m_pddsGVDialSmall
Definition Viewscreen.h:267
std::unique_ptr< buildings > ptrBuildings
Definition Viewscreen.h:428
long FontOffset(char letter) const
Rendering::RenderTexture * m_pddsRTSTexture[RTStextureC]
Definition Viewscreen.h:293
float insthdgDegrees
Definition Viewscreen.h:369
Rendering::RenderTexture * m_pddsCockpitLights[cockpittextureC]
Definition Viewscreen.h:276
float rcsThrustOutputY
Definition Viewscreen.h:373
void ApplySuspensionImpact(float absorbedVelocityKms)
Rendering::RenderBuffer * m_avScreen
Definition Viewscreen.h:228
RiseMath::Vector3 cloudpos
Definition Viewscreen.h:392
RiseMath::Vector3 sumofforces
Definition Viewscreen.h:108
std::vector< Rendering::RenderTexture * > m_pddsLogos
Definition Viewscreen.h:307
Rendering::RenderTexture * m_pddsGVDirection
Definition Viewscreen.h:271
Rendering::RenderTexture * m_pddsSunglasses
Definition Viewscreen.h:244
LOCALGRID2 CalculateSRV(short t, short s, VECTOR2SHORT tcp, char cube, SRenderVertex sourcedata)
double terprecisionx
Definition Viewscreen.h:370
CollisionDamage::StructuralEpisode crashDamageEpisode
Definition Viewscreen.h:338
RiseMath::Vector3 CalculatePlanar(short u, short v)
Rendering::RenderBuffer * m_avCloudGrid
Definition Viewscreen.h:220
void Undock() const
std::unique_ptr< cockpit > ptrCockpit
Definition Viewscreen.h:435
bool m_nightVisionRangeQueryPending
Definition Viewscreen.h:353
bool cloudFallbackWarningPending
Definition Viewscreen.h:408
float CheckDepthMap(VECTOR2SHORT newdepthpos, short u, short v)
Rendering::RenderSurface * m_pddsDynamicSurface
Definition Viewscreen.h:313
s_polygon_extras2 polyextras2
Definition Viewscreen.h:390
RiseMath::Vector3 gravityvec
Definition Viewscreen.h:72
void TriggerBCLLightningAt(const RiseMath::Vector3 &ground, const RiseMath::Vector3 &cloud, float distanceKm, int seed, int chainedBolts, bool testStrike=false) const
float rcsThrustRequestX
Definition Viewscreen.h:374
bool hornBindingDown
Definition Viewscreen.h:413
void UpdateLandingLights(double seconds)
Definition framemove.cpp:23
RiseMath::Vector3 terpos
Definition Viewscreen.h:368
std::unique_ptr< joystick > ptrJoystick
Definition Viewscreen.h:430
bool verticalmod
Definition Viewscreen.h:379
float rcsThrustRequestZ
Definition Viewscreen.h:374
Rendering::RenderTexture * m_pddsBlastX
Definition Viewscreen.h:253
WindshieldRainRenderer windshieldRain
Definition Viewscreen.h:395
SCamera * cockpitCamera
Definition Viewscreen.h:138
Rendering::RenderSurface * m_pddsProjectionSurface
Definition Viewscreen.h:315
char CalculateCube(RiseMath::Vector3 position) const
VECTOR2SHORT rts
Definition Viewscreen.h:77
Rendering::RenderTexture * m_pddsFirework1[firework1C]
Definition Viewscreen.h:254
std::unique_ptr< FreeTrack > ptrFreeTrack
Definition Viewscreen.h:431
HRESULT OnResetDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc)
std::unique_ptr< weapon > ptrWeapon
Definition Viewscreen.h:427
double terprecisiony
Definition Viewscreen.h:370
Rendering::RenderTexture * m_pddsIntersection
Definition Viewscreen.h:305
Rendering::RenderTexture * m_pddsCracked
Definition Viewscreen.h:279
Rendering::RenderTexture * m_pddsCloudBaseMap
Definition Viewscreen.h:235
void OnLostDevice()
Rendering::RenderTexture * m_pddsHolidayTexture
Definition Viewscreen.h:247
float m_nightVisionRangeKm
Definition Viewscreen.h:358
float lateralincr
Definition Viewscreen.h:386
ExteriorRainRenderer exteriorRainRenderer
Definition Viewscreen.h:403
Rendering::RenderTexture * m_pddsProjectionTexture
Definition Viewscreen.h:314
Logger * logger
Definition Viewscreen.h:440
CollisionDamage::Episode controlJoltEpisode
Definition Viewscreen.h:339
Rendering::RenderTexture * m_pddsBinocularsArrow
Definition Viewscreen.h:241
Rendering::RenderTexture * m_pddsTransition[transitiontextureC]
Definition Viewscreen.h:299
void ClearCollisionEffects()
Rendering::RenderTexture * m_pddsSunTexture
Definition Viewscreen.h:245
Rendering::RenderToTexture * m_pRenderToSurfaceNextGen
Definition Viewscreen.h:317
RiseMath::Matrix matrixProj
Definition Viewscreen.h:345
VECTOR2SHORT bump
Definition Viewscreen.h:77
Rendering::RenderTexture * m_pddsLightsCruiseIcons
Definition Viewscreen.h:272
SCamera * camera
Definition Viewscreen.h:137
float ProbeBoundSphere(RiseMath::Vector3 *position, const RiseMath::Vector3 *Xsunlight) const
Rendering::RenderTexture * m_pddsAOA[3]
Definition Viewscreen.h:274
Rendering::RenderTexture * m_pddsFirework3[firework3C]
Definition Viewscreen.h:256
Rendering::RenderFont * m_pFontNamePlate
Definition Viewscreen.h:131
RiseMath::Vector3 structuralImpactImpulse
Definition Viewscreen.h:111
Rendering::RenderTexture * m_pddsFuzerX
Definition Viewscreen.h:251
Rendering::ReentryEnvelope11 reentryRenderer
Definition Viewscreen.h:398
Rendering::RenderFont * m_pFont
Definition Viewscreen.h:129
Rendering::RenderTexture * m_pddsDynamicTexture
Definition Viewscreen.h:312
Rendering::RenderTexture * m_pddsDockLights[docktextureC]
Definition Viewscreen.h:292
void TriggerBCLLightning(int u, int v, float distanceKm, int seed, int chainedBolts) const
static bool CheckLayout(unsigned i, LOCALGRID2 localgrid2)
void BuildCurbs(VECTOR2SHORT rts)
void DamageLandingLightContacts(const RiseMath::Vector3 &velocity, float seconds) const
bool g_bRoad
Definition buildings.h:62
float CheckRtsBumpMap(VECTOR2SHORT rts, VECTOR2SHORT bump, short u, short v)
void BuildRocks()
void OnDestroyDevice()
bool CheckCollision(short buildZoneOrdinal, RiseMath::Vector3 position, RiseMath::Vector3 velocity, float bound, float ElapsedTime, RiseMath::Vector3 *cross) const
HRESULT OnResetDevice(Rendering::RenderDevice *pd3dDevice) const
Definition cockpit.cpp:3545
void CacheEngineSounds(bool useExteriorModel) const
Definition cockpit.cpp:189
void OnLostDevice() const
Definition cockpit.cpp:3457
bool geometryReady
Definition grid.h:37
void ClearGrid()
Definition grid.cpp:78
void RemoveBuildZone(short ordinal) const
Definition grid.cpp:13
bool makeClouds
Definition grid.h:43
bool patchGeometry
Definition grid.h:38
bool makeBuildings
Definition grid.h:42
void OnLostDevice()
void OnResetDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc)
void OnDestroyDevice()
void OnCreateDevice(Rendering::RenderDevice *pd3dDevice)
float frameTime
Definition keyboard.h:29
bool g_bControl
Definition keyboard.h:32
float speedOfSoundKms
Definition propulsion.h:82
void ResetControlLoops()
float totalWeightLbs
Definition propulsion.h:81
float GetTotalThrust() const
float levelerroll
Definition propulsion.h:98
int CurrentScanTarget
Definition scanDb.h:66
void InsertUpdateModeAC(USHORT vehicleId, SmodeAC modeAC)
Definition scanDb.cpp:26
void ClearChildren(unsigned short parentId)
Definition scanDb.cpp:17
void EnergyWeaponImpact()
Definition weapon.cpp:26
void FireWeapon(unsigned char bay) const
Definition weapon.cpp:598
float snowBlend
Definition weather.h:202
float GetCloudCeilingMslKm() const
Definition weather.cpp:1483
float weapontimer[2]
Definition globals.cpp:89
float fuel
Definition globals.cpp:90
s_city_stuff citystuff
Definition globals.cpp:110
unsigned char ourplanetC
Definition globals.cpp:25
DeathType dead
Definition globals.cpp:37
unsigned char UCLobjC
Definition globals.cpp:23
char area[3]
Definition globals.cpp:87
float g_UniverseTime
Definition globals.cpp:18
float f_AGL
Definition globals.cpp:9
FIREWORKS fireworks[fireworksC]
Definition globals.cpp:118
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
bool visiblegrid[63][63]
Definition globals.cpp:101
RiseMath::Vector3 dockMarker
Definition globals.cpp:34
unsigned char ourmoonC
Definition globals.cpp:21
float f_compareFOV
Definition globals.cpp:81
RiseMath::Vector3 insidearray[63][63][3]
Definition globals.cpp:102
float deathinhibit
Definition globals.cpp:39
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
BATCHINDEX2 drawlist[drawlistC]
Definition globals.cpp:104
float dockprogress
Definition globals.cpp:32
unsigned char cloudBaseObjC
Definition globals.cpp:22
bool g_bAboveClouds
Definition globals.cpp:16
Sani aniarray[MAX_ANI][MAX_STEPS]
Definition globals.cpp:122
LIGHTNINGBELOW lightningbelow
Definition globals.cpp:116
s_polygon_object polyobjects[maxpolyC]
Definition globals.cpp:106
LOCALGRID2 gridarray[64][64]
Definition globals.cpp:100
float g_fFOV
Definition globals.cpp:80
char g_bTextInput
Definition globals.cpp:61
float f_Uphours
Definition globals.cpp:19
bool g_bAugment
Definition globals.cpp:47
unsigned char ourstarC
Definition globals.cpp:24
#define RTStextureC
Definition globals.h:54
#define MAX_RAINDROPS
Definition globals.h:80
#define maxpolyC
Definition globals.h:32
#define oneOvergForceKmssC
Definition globals.h:109
#define RISE_FVF_NOPSIZE
Definition globals.h:124
#define drawlistC
Definition globals.h:65
#define citytextureC
Definition globals.h:53
#define cockplanefarC
Definition globals.h:31
#define cockplanenearC
Definition globals.h:30
#define firework1C
Definition globals.h:60
#define firework3C
Definition globals.h:62
#define landformtextureC
Definition globals.h:47
#define radiusC
Definition globals.h:87
@ MidairCollision
Definition globals.h:156
@ TwinTowers
Definition globals.h:154
#define RISE_FVF_SKYDOME
Definition globals.h:120
#define cockpitvertC
Definition globals.h:67
#define dihvanimateC
Definition globals.h:63
#define RISE_FVF_INSTRUMENT
Definition globals.h:127
#define farplaneC
Definition globals.h:27
#define cloudTopsRadiusC
Definition globals.h:112
#define trimlimiterC
Definition globals.h:44
#define maxcompareC
Definition globals.h:71
#define visiblevertC
Definition globals.h:66
#define cloudTopsMslC
Definition globals.h:110
#define cityscaleC
Definition globals.h:35
#define dockvertC
Definition globals.h:68
#define RISE_FVF_VERTEX
Definition globals.h:118
#define RISE_FVF_NONORMAL
Definition globals.h:125
#define RISE_FVF_LOCALGRID
Definition globals.h:129
#define fireworksC
Definition globals.h:769
#define weaponanimateC
Definition globals.h:55
#define runninglightsC
Definition globals.h:52
#define RISE_FVF_RAINDROP
Definition globals.h:121
#define skydomeC
Definition globals.h:90
#define firework2C
Definition globals.h:61
#define RISE_FVF_VERTEX2
Definition globals.h:119
#define docktextureC
Definition globals.h:51
#define cloudindicesC
Definition globals.h:69
#define RISE_FVF_STATICSTARS
Definition globals.h:123
#define nearplaneC
Definition globals.h:29
#define RISE_FVF_SCREEN
Definition globals.h:126
#define cockpittextureC
Definition globals.h:50
#define maxstarC
Definition globals.h:33
#define sunColorC
Definition globals.h:116
#define gravityKmssC
Definition globals.h:88
#define transitiontextureC
Definition globals.h:48
#define RISE_FVF_SKYRING
Definition globals.h:122
#define shiptextureC
Definition globals.h:49
#define elmoAnimateC
Definition globals.h:56
#define starsC
Definition globals.h:76
#define heartanimateC
Definition globals.h:64
#define aftersdC
Definition globals.h:113
#define maxcomparebitC
Definition globals.h:72
constexpr double Degrees
Definition FlightPath.h:9
auto NextVertical(typename Afcs::VerticalModes current, bool onGround, double horizontal, double vertical)
Definition FlightPath.h:18
constexpr double Maximum
Definition FlightPath.h:10
double Capture(double horizontal, double vertical)
Definition FlightPath.h:13
constexpr double Minimum
Definition FlightPath.h:10
float Distance(const Vector3 &a, const Vector3 &b)
Light Configure(Light light, unsigned char type, const RiseMath::Matrix &modelBase)
unsigned FromModel(const Effects &effects, std::array< Light, MaxLights > &lights)
constexpr unsigned MaxLights
constexpr unsigned FogVertexCount
void FogMesh(const Light &light, Vertex *output, bool spill)
const char * BodySide(float x)
Path Build(Vector3 ground, Vector3 cloud, uint32_t seed, int chains, float cloudTopRadius)
std::wstring EntryEngagementBlock(const Snapshot &s)
Definition OrbitState.h:278
Mode Objective(const Request &r, TargetKind target)
Definition OrbitState.h:368
bool EntryGearRefusal(const BusState &data)
bool AscentSelected(const BusState &data)
Definition OrbitState.h:353
Command EntryGearCallout(const BusState &data, int vehicle)
bool ManualAttitudeDisconnect(const Guidance &g)
Definition OrbitState.h:355
constexpr uint32_t DYNAMIC
constexpr uint32_t POINTS
constexpr uint32_t RENDERTARGET
constexpr uint32_t WRITEONLY
constexpr uint32_t RED
constexpr uint32_t GREEN
constexpr uint32_t BLUE
constexpr uint32_t LINEAR
constexpr uint32_t DIRECTIONAL
constexpr uint32_t COLORWRITEENABLE
constexpr uint32_t MULTISAMPLEANTIALIAS
constexpr uint32_t POINTSPRITEENABLE
constexpr uint32_t STENCILENABLE
constexpr uint32_t RANGEFOGENABLE
constexpr uint32_t NORMALIZENORMALS
constexpr uint32_t FOGVERTEXMODE
constexpr uint32_t ZENABLE
constexpr uint32_t DIFFUSE
constexpr uint32_t COLORARG2
HWND ClientWindow()
HRESULT CreateRenderToSurface(RenderDevice *owner, UINT width, UINT height, ImageFormat format, BOOL depth, ImageFormat depthFormat, RenderToTexture **result)
constexpr PackedColor ColorRGB(unsigned r, unsigned g, unsigned b)
HRESULT CreateFontW(RenderDevice *owner, INT height, UINT width, UINT weight, UINT mipLevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitch, const wchar_t *face, RenderFont **result)
double ClientTime()
HRESULT CreateSprite(RenderDevice *owner, RenderSprite **result)
HRESULT SaveTextureToFile(const wchar_t *path, ImageFile format, RenderTexture *texture, const void *)
const wchar_t * ErrorString(HRESULT code)
const SurfaceDescription * ClientBackBufferDescription()
const wchar_t * ClientDeviceStats()
HRESULT CreateTexture(RenderDevice *owner, UINT width, UINT height, UINT levels, DWORD usage, ImageFormat format, ResourcePool pool, RenderTexture **result)
auto ToRadian(T value)
Definition ClientMath.h:13
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
constexpr float Pi
Definition ClientMath.h:12
Vector3 * Vec3Cross(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:105
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
bool IntersectTri(const Vector3 *a, const Vector3 *b, const Vector3 *c, const Vector3 *origin, const Vector3 *direction, float *u, float *v, float *distance)
Definition ClientMath.h:197
Vector3 * Vec3TransformCoord(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:109
Vector3 * Vec3Add(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:96
Plane * PlaneFromPoints(Plane *out, const Vector3 *a, const Vector3 *b, const Vector3 *c)
Definition ClientMath.h:175
Matrix * MatrixRotationX(Matrix *out, float value)
Definition ClientMath.h:126
Quaternion * QuaternionMultiply(Quaternion *out, const Quaternion *a, const Quaternion *b)
Definition ClientMath.h:168
Matrix * MatrixMultiply(Matrix *out, const Matrix *a, const Matrix *b)
Definition ClientMath.h:116
Matrix * MatrixRotationQuaternion(Matrix *out, const Quaternion *q)
Definition ClientMath.h:135
Quaternion * QuaternionNormalize(Quaternion *out, const Quaternion *q)
Definition ClientMath.h:165
Vector3 * Vec3Lerp(Vector3 *out, const Vector3 *a, const Vector3 *b, float t)
Definition ClientMath.h:99
float Vec3LengthSq(const Vector3 *a)
Definition ClientMath.h:94
Vector3 * Vec3Subtract(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:97
Quaternion * QuaternionRotationYawPitchRoll(Quaternion *out, float yaw, float pitch, float roll)
Definition ClientMath.h:169
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:107
Matrix * MatrixRotationY(Matrix *out, float value)
Definition ClientMath.h:127
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Definition ClientMath.h:118
constexpr float Tau
Definition ClientMath.h:12
Matrix * MatrixPerspectiveRH(Matrix *out, float width, float height, float nearZ, float farZ)
Definition ClientMath.h:143
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
Quaternion * QuaternionIdentity(Quaternion *out)
Definition ClientMath.h:164
float Vec3Dot(const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:93
Matrix * MatrixScaling(Matrix *out, float x, float y, float z)
Definition ClientMath.h:124
Vector3 * Vec3Normalize(Vector3 *out, const Vector3 *a)
Definition ClientMath.h:103
Vector3 * Vec3Scale(Vector3 *out, const Vector3 *a, float scale)
Definition ClientMath.h:98
Matrix * MatrixRotationZ(Matrix *out, float value)
Definition ClientMath.h:128
auto ToDegree(T value)
Definition ClientMath.h:14
constexpr auto Max(A first, B second)
Definition ClientMath.h:16
Matrix * MatrixTranslation(Matrix *out, float x, float y, float z)
Definition ClientMath.h:125
Vector3 * PlaneIntersectLine(Vector3 *out, const Plane *plane, const Vector3 *first, const Vector3 *second)
Definition ClientMath.h:191
constexpr float HalfPi
Definition ClientMath.h:12
constexpr unsigned Segments
unsigned char u
Definition globals.h:330
unsigned char v
Definition globals.h:330
unsigned char primitives
Definition globals.h:333
unsigned short startindex
Definition globals.h:329
float DesiredPitchRadians
Definition Bus.h:141
float DesiredRollRadians
Definition Bus.h:140
float DesiredAltitudeKm
Definition Bus.h:122
LateralModes
Definition Bus.h:110
@ Navigation
Definition Bus.h:115
@ LateralMode_Off
Definition Bus.h:112
@ Localizer
Definition Bus.h:116
@ Heading
Definition Bus.h:114
@ LateralMode_TakeOff
Definition Bus.h:111
@ Roll
Definition Bus.h:113
@ LateralMode_Enum
Definition Bus.h:117
float DesiredHeadingRadians
Definition Bus.h:133
@ Glideslope
Definition Bus.h:104
@ FlightPathAngle
Definition Bus.h:99
@ SpeedPitch
Definition Bus.h:101
@ Pitch
Definition Bus.h:98
@ VerticalMode_Off
Definition Bus.h:97
@ VerticalMode_TakeOff
Definition Bus.h:96
@ VerticalSpeed
Definition Bus.h:100
@ AltitudeAgl
Definition Bus.h:103
@ AltitudeMsl
Definition Bus.h:102
@ VerticalMode_Enum
Definition Bus.h:105
bool DorOn
Definition Bus.h:148
bool TvmOn
Definition Bus.h:151
enum Bus::Afcs::LateralModes CurrentLateralMode
float DesiredVsiKms
Definition Bus.h:129
float DesiredCourseRadians
Definition Bus.h:136
bool AutopilotEngaged
Definition Bus.h:87
bool DorAircraft
Definition Bus.h:149
float DesiredFpaRadians
Definition Bus.h:130
float DesiredClosingSpeed
Definition Bus.h:152
enum Bus::Afcs::VerticalModes StandbyVerticalMode
enum Bus::Afcs::LateralModes StandbyLateralMode
float DesiredIasKms
Definition Bus.h:126
enum Bus::Afcs::VerticalModes CurrentVerticalMode
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
float delay
Definition Command.h:8
RiseMath::Color color
Definition globals.h:764
float intensity
Definition globals.h:763
float distanceScalar
Definition globals.h:763
PlotType type
Definition globals.h:276
unsigned char sec_landform
Definition globals.h:280
RiseMath::Color raster
Definition globals.h:283
long layout3
Definition globals.h:287
RiseMath::Color clouddif
Definition globals.h:275
RiseMath::Vector3 cloudpos
Definition globals.h:273
unsigned char pri_landform
Definition globals.h:278
long layout4
Definition globals.h:287
long layout2
Definition globals.h:287
unsigned char zone
Definition globals.h:285
unsigned char sec_transition
Definition globals.h:281
short buildzoneOrdinal
Definition globals.h:286
long layout1
Definition globals.h:287
bool powered
Definition globals.h:292
RiseMath::Vector3 position
Definition globals.h:273
short elevation
Definition globals.h:288
unsigned char pri_transition
Definition globals.h:279
unsigned char ter_landform
Definition globals.h:282
RiseMath::Color emissive
Definition globals.h:274
VECTOR2SHORT tcp
Definition globals.h:290
bool elevationAvailable
Definition globals.h:291
unsigned char roads
Definition globals.h:285
float Sphere(const RiseMath::Vector3 &center, float radiusKm) const
Definition LampContact.h:45
RiseMath::Vector3 start
Definition LampContact.h:12
RiseMath::Vector3 velocity
Definition LampContact.h:12
double SegmentStart(int index) const
void Start(uint32_t packetSeed, const Path &geometry)
std::wstring status
Definition OrbitState.h:315
TargetKind targetKind
Definition OrbitState.h:255
RiseMath::Color Diffuse
RiseMath::Color Diffuse
RiseMath::Color Specular
RiseMath::Color Emissive
RiseMath::Color Ambient
unsigned char type
unsigned char pri_transition
unsigned char ter_landform
unsigned char pri_landform
unsigned char sec_landform
unsigned char sec_transition
unsigned char roads
char leftengine
char autoflyte
char parkingBrake
char overhead
char leftwing
char landing[2]
char rightwing
char rightengine
char yawdamper
char steering
char thrustaug
char leftStrut
char clengine
float end
Definition globals.h:809
float start
Definition globals.h:808
RiseMath::Vector3 ypr[16]
Definition globals.h:810
RiseMath::Vector3 xyz
Definition globals.h:811
short scanDisplayVesselLimit
Definition globals.h:725
float dntranslimit
Definition globals.h:601
float tireComplianceKm
Definition globals.h:620
float maxGrossLbs
Definition globals.h:634
short texturelib
Definition globals.h:602
float lrtranslimit
Definition globals.h:601
float momentr
Definition globals.h:636
char fwdgears
Definition globals.h:677
float impatientime
Definition globals.h:685
short ourplyrC
Definition globals.h:682
float moving
Definition globals.h:683
float uptranslimit
Definition globals.h:601
float power
Definition globals.h:599
float tireRadiusKm
Definition globals.h:733
float flapExtent
Definition globals.h:660
unsigned short components
Definition globals.h:626
std::vector< FlapSetting > flapSettings
Definition globals.h:661
int landingDamageVehicleId
Definition globals.h:606
std::array< LandingLights::ImpactCondition, LandingLights::MaxLights > landingLightImpact
Definition globals.h:608
SVesselDC vdat
Definition globals.h:664
char gearshift
Definition globals.h:677
float gearextent
Definition globals.h:617
float flapMaxDegrees
Definition globals.h:714
std::array< LandingLights::Light, LandingLights::MaxLights > landingLights
Definition globals.h:604
float suspensionTravelKm
Definition globals.h:618
float adrenolinBPM
Definition globals.h:741
bool parkingBrake
Definition globals.h:709
float spoilerAreaMod
Definition globals.h:717
bool vdatChanged
Definition globals.h:665
char startcycle
Definition globals.h:599
bool sentgearvoice
Definition globals.h:625
float chairfwd
Definition globals.h:613
unsigned char hitpoints
Definition globals.h:686
bool wheeled
Definition globals.h:596
char bays
Definition globals.h:630
float landingGearAbsorbKms
Definition globals.h:617
float turnin
Definition globals.h:684
bool spaceCapable
Definition globals.h:596
char engines
Definition globals.h:630
float vdatTime
Definition globals.h:666
s_mesh_component * componentarray
Definition globals.h:704
unsigned landingLightCount
Definition globals.h:605
RiseMath::Vector3 location
Definition scanDb.h:20
char reference
Definition scanDb.h:19
unsigned char type
Definition scanDb.h:17
char hullname[23]
Definition scanDb.h:18
int ownerId
Definition scanDb.h:22
char IVR[6]
Definition scanDb.h:16
unsigned short vehicleId
Definition scanDb.h:15
float curbelev
Definition globals.h:477
float timer[PlotType::PlotTypeEnum]
Definition globals.h:480
float elevation
Definition globals.h:476
unsigned long compare[PlotType::PlotTypeEnum]
Definition globals.h:479
float floorelev
Definition globals.h:477
float speed[PlotType::PlotTypeEnum]
Definition globals.h:480
RiseMath::Vector3 normal
Definition globals.h:350
RiseMath::Vector3 position
Definition globals.h:350
unsigned long sequencing
Definition globals.h:352
short attachto
Definition globals.h:354
RiseMath::Color diffuse
Definition globals.h:351
unsigned char primitive
Definition globals.h:349
float speedExtend
Definition globals.h:409
float boundsphere
Definition globals.h:410
float speedRetract
Definition globals.h:409
RiseMath::Vector3 barycentric
Definition globals.h:500
RiseMath::Vector3 dockingvel
Definition globals.h:500
RiseMath::Vector3 position
Definition globals.h:511
RiseMath::Vector3 positer
Definition globals.h:501
unsigned short components
Definition globals.h:551
float tireRotationRadPerS
Definition globals.h:545
double precisionz
Definition globals.h:512
unsigned long compare
Definition globals.h:514
bool inhibitvisibility
Definition globals.h:528
unsigned char bay
Definition globals.h:510
unsigned char type
Definition globals.h:488
float tireCircumferenceKm
Definition globals.h:526
float steerLimitRadian
Definition globals.h:526
bool rainProtectionEnabled
Definition globals.h:532
RiseMath::Vector3 dockoffset
Definition globals.h:511
RiseMath::Vector3 velleft
Definition globals.h:501
unsigned short vehicleId
Definition globals.h:537
s_mesh_component * componentarray
Definition globals.h:552
double precisiony
Definition globals.h:512
RiseMath::Vector3 posleft
Definition globals.h:501
float tirePositionRad
Definition globals.h:544
RiseMath::Vector3 velocity
Definition globals.h:500
float rollRadPerSec
Definition globals.h:523
WindshieldWipers::Motion wipers
Definition globals.h:535
double precisionx
Definition globals.h:512
unsigned char inarray
Definition globals.h:509
float baydoorextent
Definition globals.h:539
RiseMath::Vector3 veliter
Definition globals.h:501
RiseMath::Matrix matrixBase
Definition globals.h:519
char hullname[23]
Definition globals.h:495
RiseMath::Vector3 center[4500]
Definition globals.h:342
RiseVertexVertex * vertexbackup
Definition globals.h:341
short index[4500]
Definition globals.h:343
unsigned landingLightCount
Definition globals.h:363
Rendering::RenderBuffer * VB
Definition globals.h:360
std::vector< s_light_effect > effects
Definition globals.h:361
std::array< LandingLights::Light, LandingLights::MaxLights > landingLights
Definition globals.h:362
RiseMath::Matrix matrixBase
Definition globals.h:452
s_mesh_component * componentarray
Definition globals.h:458
RiseMath::Matrix matrixWorld
Definition globals.h:452
RiseMath::Vector3 position
Definition globals.h:454
unsigned short components
Definition globals.h:457
unsigned long compare
Definition globals.h:467