Rise
The Vieneo Province
Loading...
Searching...
No Matches
render.cpp
Go to the documentation of this file.
1#include "Viewscreen.h"
3#include "CockpitLighting.h"
4#include "NightVisionStars.h"
5#include "LocalLightning.h"
6#include "VehicleVisibility.h"
7#include "SkyRingRenderer.h"
10#include "../MathUtilities.h"
11
12//--------------------------------------------------------------------------------------------
13// Name: Render()
14// Desc: Renders the scene.
15//--------------------------------------------------------------------------------------------
16void Viewscreen::OnFrameRender(Rendering::RenderDevice* pd3dDevice, double fTime) const
17{
18 Rendering::ProfileScope11 sceneTiming("Viewscreen total");
22 playerships[0].active && playerships[0].mslKm != -1.0f);
25 logger->AddToCallStack("Viewscreen::OnFrameRender");
26
27 HRESULT hr;
28
30 const bool opticalView = InventoryItemEffectsEnabled() && ourcockpit.inventoryItemInUseType == 1 &&
34 // Human visual memory uses real elapsed time and the pre-flash ambient.
35 // Optics keep their own masks/exposure; view switches discard old imprints.
37 !dead && !playerships[0].isSimulator && playerships[0].reference != REF_WINDOWLESS && !opticalView,
38 ptrWeather->lightningAfterimageAmbient,(uint64_t(uint32_t(playerships[0].vehicleId))<<32)|uint64_t(cameraOrdinal));
40 {
41 Rendering::ProfileScope11 identityTiming("Ad diagnostics identities", false);
42 static const std::string noCreative;
43 for (unsigned slot = 0; slot < MAX_SCAN; ++slot)
44 {
45 const auto& vehicle = playerships[slot];
46 const int ordinal = vehicle.logoOrdinal;
47 const std::string& creative = vehicle.active && ordinal >= 0 && size_t(ordinal) < logofiles.size() ? logofiles[ordinal] : noCreative;
48 adDiagnostics.SyncPlacement(slot, vehicle.active ? vehicle.vehicleId : 0, creative);
49 }
50 identityTiming.Stop();
51 // Glass is measured per pixel; the rain draw excludes refracting samples.
52 const bool itemEffect = InventoryItemEffectsEnabled() && ourcockpit.inventoryItemInUseType == 1 &&
56 const char* blocker = IsIconic(Rendering::ClientWindow()) ? "minimized window" :
57 GetForegroundWindow() != Rendering::ClientWindow() ? "game not in foreground" :
58 dead ? "dead-player view" : playerships[0].isSimulator ? "simulator view" :
59 gameclass->timeLapse ? "replay/time-lapse" : gameclass->bus->FlightFreeze ? "flight freeze" :
60 raindrops != 0 ? "rain post-effect unsupported" :
61 ptrWeather->betascreen.a > 0 ? "glare post-effect unsupported" :
62 itemEffect ? "inventory visual effect unsupported" :
63 (proceduralLightning.AfterimageActive() || lightningbelow.inuse) ? "lightning visual effect unsupported" : nullptr;
64 // UI exclusions are determined after this frame's GUI has actually drawn.
66 adDiagnostics.BeginFrame(*pd3dDevice, Rendering::ClientAbsoluteTime(), blocker == nullptr, blocker);
67 }
68 adWeatherMeasured = false;
69
70 short r, s, t; // For debug
71
72 RiseMath::Matrix matrixTemp, matrixWorld, matrixLookAtHorizon, matrixLookAtSkydome, matrixLookAtLocal;
73 RiseMath::Vector3 result, vieneohit;
74
75 float f_temp;
76
77 // Determine g_bAboveClouds flag before clearing backbuffer
78 // Everything after this would/could be in the atmosphere...
79 const RiseMath::Vector3 Xsunlight = sunlight.Direction; // Start of the ray
80
81
83 !(playerships[0].reference == REF_INANOTHER && !playerships[playerships[0].inarray].baydoor && !camera->outside));
84
85 // Resolve one shared strike state before any exterior draws. World matrices
86 // use physical planet axes relative to the player's craft, not camera axes.
87 LocalLightning::Frame strike{};
89 {
90 RiseMath::Matrix strikeInverseView;
91 RiseMath::MatrixInverse(&strikeInverseView,nullptr,&matrixLook);
93 -playerships[0].position,{strikeInverseView._41,strikeInverseView._42,strikeInverseView._43},
96 }
97 V(gameclass->graphics->g_pEffect->SetVector("StrikeGround",&strike.ground));
98 V(gameclass->graphics->g_pEffect->SetVector("StrikeTop",&strike.top));
99 V(gameclass->graphics->g_pEffect->SetVector("StrikeColor",&strike.color));
100 V(gameclass->graphics->g_pEffect->SetVector("StrikeEye",&strike.eye));
101 V(gameclass->graphics->g_pEffect->SetVector("StrikeUp",&strike.up));
102
104
105 // Clear the back-buffer
106 if (dead)
107 {
108 logger->AddToCallStack("Viewscreen::OnFrameRender DEAD");
109
110 WCHAR str2[99];
111
112 // Begin the scene either simulator or RL
113 if (playerships[0].isSimulator)
114 {
116 gameclass->beginScene = 2; // proj is 2
117 }
118 else
119 {
120 V(pd3dDevice->BeginScene());
121 gameclass->beginScene = 1; // prim is 1
122 }
123
124 // Alternate shades of red
125 if ((static_cast<int>(fTime) % 2) == 1)
126 {
127 V(pd3dDevice->Clear(0, NULL, Rendering::ClearFlags::ZBUFFER | Rendering::ClearFlags::TARGET, 0x00800000, 1.0f, 0));
128 }
129 else
130 {
131 V(pd3dDevice->Clear(0, NULL, Rendering::ClearFlags::ZBUFFER | Rendering::ClearFlags::TARGET, 0x00A00000, 1.0f, 0));
132 }
133
134 // Text and GUI button
135 if (!playerships[0].isSimulator)
136 {
137 const double now = Rendering::ClientTime();
138 const auto& countdown = gameclass->GUI->rejoinCountdown;
139 const bool ready = countdown.Ready(now);
140 if (ready)
141 swprintf_s(str2, 99, gameclass->GUI->strings[L_DEAD_REJOIN].c_str());
142 else
143 swprintf_s(str2, 99, gameclass->GUI->strings[L_DEAD_COUNTDOWN].c_str(), countdown.SecondsRemaining(now));
145
146 WCHAR strcom[199];
147 swprintf_s(strcom, 199, L"%s\n%s", gameclass->GUI->strings[L_DEAD_BUTTON + dead].c_str(), str2);
149
152 }
153 }
154 else // not dead
155 {
156 logger->AddToCallStack("Viewscreen::OnFrameRender ALIVE");
157
160 else
161 {
162 logger->Log("IDC_REJOINBTN is nullptr!", Logger::Level::Error);
164 const HRESULT hudResult = gameclass->InitializeGameHud();
165 if (FAILED(hudResult))
166 logger->Log("Could not recover the in-game HUD", Logger::Level::Fatal, hudResult);
168 logger->Log("IDC_REJOINBTN is nullptr!", Logger::Level::Fatal);
169 }
172 else
173 logger->Log("IDC_REJOINTEXT is nullptr!", Logger::Level::Fatal);
174
175 // Begin the scene
176 if (playerships[0].isSimulator)
177 {
178 // using a texture instead of the video card
180 {
182 gameclass->beginScene = 2; // proj is 2
183 }
184 else
185 logger->Log("m_pRenderToSurfaceNextGen is nullptr!", Logger::Level::Fatal);
186
187 // note: no viewport, full canvas
188
189 // straight ahead
190 if (pd3dDevice)
191 {
193 }
194 else
195 logger->Log("pd3dDevice is nullptr!", Logger::Level::Fatal);
196 }
197 else
198 {
199 if (pd3dDevice)
200 {
201 V(pd3dDevice->BeginScene());
202 gameclass->beginScene = 1; // prim is 1
203 }
204 else
205 logger->Log("pd3dDevice is nullptr!", Logger::Level::Fatal);
206 }
207
209 {
210 // Terrain fog and distant cloud bases converge on alphascreen's RGB.
211 // A zenith-blue clear below the deck leaves a bright horizon seam
212 // wherever neither finite terrain nor the curved volume covers it.
213 RiseMath::Color background;
215 RiseMath::ColorLerp(&background, &alphascreen, &zenith,
217 background.a = 1;
219 }
220 else if (g_bAboveClouds)
221 {
223 }
224 else
225 {
226 // keeps seams from showing on horizon
229 }
230 }
231
232
233 // All Skydome
234 float bury, inner;
235
236
237 if (!dead) // only draw outside stuff if we are not dead, simulator or otherwise
238 {
239#pragma region Outside
240 logger->AddToCallStack("Viewscreen::OnFrameRender OUTSIDE");
241
243 result.x = 0.0f; result.y = 0.0f; result.z = -1.0f;
244 RiseMath::Vector3 result1 = RiseMath::Vector3(0.0f, 1.0f, 0.0f); // We want this oriented sideways to the ship
245 RiseMath::Vec3TransformNormal(&result, &result, &playerships[0].matrixWorld);
246 RiseMath::Vec3TransformNormal(&result1, &result1, &playerships[0].matrixWorld);
247 // This one is oriented to be level with the horizon (good for smoke, weapons, skydome)
248 RiseMath::MatrixLookAtRH(&matrixLookAtSkydome, &centerC, &posnorml, &result); // eye at up
249 RiseMath::MatrixInverse(&matrixLookAtSkydome, nullptr, &matrixLookAtSkydome);
250 // This one is oriented with our ship (good for light flares, some weapons with flare effect)
251 RiseMath::MatrixLookAtRH(&matrixLookAtLocal, &centerC, &result1, &result); // eye at up
252 RiseMath::MatrixInverse(&matrixLookAtLocal, nullptr, &matrixLookAtLocal);
253 if (!playerships[0].isSimulator)
254 RiseMath::MatrixMultiply(&matrixLookAtLocal, &matrixLookAtLocal, &matrixLookAdj); // for weapons?
255 // the horizon should always face the viewer, not be dependant on the viewer's direction
256 result.x = 0.0f; result.y = 0.0f; result.z = -1.0f;
257 if (!playerships[0].isSimulator)
258 RiseMath::MatrixInverse(&matrixTemp, nullptr, &matrixLookAdj);
259 else
260 RiseMath::MatrixIdentity(&matrixTemp);
261 matrixTemp = matrixTemp * playerships[0].matrixWorld;
262 RiseMath::Vec3TransformNormal(&result, &result, &matrixTemp);
263 RiseMath::MatrixLookAtRH(&matrixLookAtHorizon, &centerC, &posnorml, &result); // eye at up
264 RiseMath::MatrixInverse(&matrixLookAtHorizon, nullptr, &matrixLookAtHorizon);
265
266
267
268 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX));
269
270 if (playerships[0].reference == REF_WINDOWLESS)
271 {
272 { Rendering::ProfileScope11 timing("Ships"); ptrRenderer->RenderShips(pd3dDevice, &Xsunlight); }
273 }
274
275
276
277 // replaces areas where the cockpit is rendered (sans the windshield and hud) with stencil 3
278 // Since we are rendering to a projection surface we don't want to render the cockpit right now
279 if (!playerships[0].isSimulator)
280 {
281 Rendering::ProfileScope11 timing("Cockpit geometry");
282 ptrCockpit->Render(pd3dDevice, strike);
283 }
284 else
285 {
286 // here is where we can override the ACL lighting?
287 Rendering::Light templight = sunlight;
288 templight.Ambient.r = templight.Ambient.g = templight.Ambient.b = 1.0f;
289 templight.Diffuse = RiseMath::Color();
290 pd3dDevice->SetLight(0, &templight);
291 }
292
293 // sprintf_s(msg, sizeof(msg), "Narrow down 2" );
294 // _write(logfile, msg, strlen(msg));
295
296
297
298#pragma region Upper Cloud Layer Stencil
299 if (g_bAboveClouds) // replaces stencil with 1
300 {
301 Rendering::ProfileScope11 timing("Planet stencil");
302 logger->AddToCallStack("Viewscreen::OnFrameRender STENCIL");
303
305 RiseSkydomeVertex* vtx2;
306 inner = sinf(ptrWeather->cloudHorizonAngle) * ptrWeather->cloudHorizonDistance; // radius of stencil (2a)
307 bury = (playerships[0].mslKm + radiusC) - ptrWeather->cloudHorizonDistance * cosf(ptrWeather->cloudHorizonAngle); // difference between 1c and 2b
308 V(m_avSkyDome->Lock(0, 0, reinterpret_cast<void**>(&vtx2), Rendering::LockFlags::DISCARD));
309 vtx2->x = 0.0f; vtx2->y = 0.0f; vtx2->z = -bury;
311 vtx2++;
312 for (s = 0; s < skydomeC; s++)
313 {
314 vtx2->x = cosf(radperseg * static_cast<float>(s)) * inner;
315 vtx2->y = sinf(radperseg * static_cast<float>(s)) * inner;
316 vtx2->z = -bury;
318 vtx2++;
319 }
320 vtx2->x = inner; vtx2->y = 0.0f; vtx2->z = -bury;
322 V(m_avSkyDome->Unlock());
323 matrixWorld = matrixLookAtSkydome;
325 matrixWorld._41 = -position.x; matrixWorld._42 = -position.y; matrixWorld._43 = -position.z;
326 // Fix those who are beyond clipping plane
328 if (f_temp > cutplaneC)
329 {
330 f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
331
332 // Scale apparent scale in matrix
333 RiseMath::MatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
334 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
335
336 // Scale location in matrix
337 RiseMath::Vec3Scale(&result, &position, 1.0f - f_temp);
338 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
339 RiseMath::MatrixMultiply(&matrixWorld, &matrixWorld, &matrixTemp);
340 }
341
342 pd3dDevice->SetFVF(RISE_FVF_SKYDOME);
343
345 // If succeeds, replaces stencil bit
346 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILREF, 1); // was 4 from cockpit (not sim) or else 0
353 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::DISABLE );
354
355 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixWorld);
356 pd3dDevice->SetStreamSource(0, m_avSkyDome, 0, sizeof(RiseSkydomeVertex));
357 // total primitives minus the first two on the fan
359
369 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // was 1
372 }
373#pragma endregion
374
375 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX));
376
377
378 if (!g_bAboveClouds) // Start setting up in the middle of the cloud layer
379 {
380 Rendering::ProfileScope11 timing("Terrain and city");
381
382#pragma region Buildings and Terrain
383 // when they ARE close, it is important to draw them first!
384 // Ahhh but we can't if we are doing the domes!
385 if (playerships[0].reference != REF_WINDOWLESS)
386 ptrBuildings->Render(pd3dDevice, &fTime, false);
387
388
389 logger->AddToCallStack("Viewscreen::OnFrameRender TERRAIN setup");
390 Rendering::ProfileScope11 terrainTiming("Terrain tiles");
391
392 RiseMath::MatrixTranslation(&matrixTemp,
393 static_cast<float>(playerships[0].precisionx + terprecisionx),
394 static_cast<float>(playerships[0].precisiony + terprecisiony),
395 static_cast<float>(playerships[0].precisionz + terprecisionz));
396 const RiseMath::Vector3 terrainEye(-matrixTemp._41, -matrixTemp._42, -matrixTemp._43);
397
398 RiseMath::Matrix mWorldViewProj;
399 if (playerships[0].isSimulator)
400 mWorldViewProj = matrixTemp * matrixView * matrixProjSim;
401 else
402 mWorldViewProj = matrixTemp * matrixLook * matrixProj;
403 V(gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
404 V(gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixTemp));
405
406
407
408 // NEW FOR WATER SHADER ... we already have look vector and cloud normal (inverse of normalvector) and cloudUV
409 // need to calculate normal from center, north vector and east vector? it is essentially constant for all visible plates!
410 RiseMath::Vector3 northvector = gridarray[31][31].position - gridarray[31][30].position; // then
411 RiseMath::Vec3Normalize(&northvector, &northvector);
412 RiseMath::Vector4 temp4 = RiseMath::Vector4(northvector.x, northvector.y, northvector.z, 0.0f); // w unused
413 V(gameclass->graphics->g_pEffect->SetVector("Tangent", &temp4));
414 RiseMath::Vector3 eastvector = gridarray[30][31].position - gridarray[31][31].position;
415 RiseMath::Vec3Normalize(&eastvector, &eastvector);
416 temp4 = RiseMath::Vector4(eastvector.x, eastvector.y, eastvector.z, 0.0f); // w unused
417 V(gameclass->graphics->g_pEffect->SetVector("Sunlight", &temp4));
418 RiseMath::Vector3 normalvector;
419 RiseMath::Vec3Normalize(&normalvector, &gridarray[31][31].position);
420 temp4 = RiseMath::Vector4(normalvector.x, normalvector.y, normalvector.z, 0.0f); // w unused
421 V(gameclass->graphics->g_pEffect->SetVector("Radiosity", &temp4));
422
423 const RiseMath::Vector4 terrainDetail(!playerships[0].isSimulator && TerrainSurfaceDetail::Enabled() ? 1.0f : 0.0f, 0, 0, 0);
426 V(gameclass->graphics->g_pEffect->SetVector("TerrainDetail", &terrainDetail));
427 V(gameclass->graphics->g_pEffect->SetVector("TerrainDetailSun", &terrainSun));
428
429
430 RiseMath::Vector4 ambient;
431 ambient.x = alphascreen.r; ambient.y = alphascreen.g; ambient.z = alphascreen.b; ambient.w = ptrWeather->GetRenderVisibilityKm();
432 V(gameclass->graphics->g_pEffect->SetVector("ambient", &ambient));
433
434
435 temp4.x = -static_cast<float>(BCLoffsetu); // clouds
436 temp4.y = -static_cast<float>(BCLoffsetv); // clouds
437 temp4.z = H2Ooffsetu; // water
438 temp4.w = 0.0f; // unused, water?
439 if (!playerships[0].isSimulator) // this is for the cloud shadow on the ground ... we should skip altogether?
440 temp4.x += allobjects[cloudBaseObjC].rotprog;
441 V(gameclass->graphics->g_pEffect->SetVector("clouduv", &temp4));
442
443
444
445 V(pd3dDevice->SetFVF(RISE_FVF_LOCALGRID));
446
448
451
452 //pd3dDevice->SetIndices(m_aiLocalGrid);
453 V(pd3dDevice->SetStreamSource(0, m_avLocalGrid, 0, sizeof(RiseLocalgrid2Vertex)));
454
455 // shadows on ground from clouds
456 if (!playerships[0].isSimulator)
457 {
459 }
460
461 // V(g_pEffect->SetTexture("HFreqMap", m_pddsDetail1));
462
463
464
465
466
467
468
469 unsigned char old_pri_landform = 255, old_pri_transition = 255;
470 unsigned char old_sec_landform = 255, old_sec_transition = 255;
471 unsigned char old_ter_landform = 255;
472
473 if (playerships[0].reference != REF_WINDOWLESS)
474 {
475 logger->AddToCallStack("Viewscreen::OnFrameRender TERRAIN begin");
476
477 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
478
479 for (r = 0; r < drawlistC; r++)
480 {
481 // the 255 is a server flag, not in DB that way
482 if (drawlist[r].pri_landform == 255)
483 continue;
484
485 if (!drawlist[r].bounds.IntersectsFrustum(mWorldViewProj))
486 continue;
487
488 if (old_pri_landform != drawlist[r].pri_landform)
489 {
490 if (drawlist[r].pri_landform == 1)
491 {
493 }
494 else
495 {
497 }
498 old_pri_landform = drawlist[r].pri_landform;
499 }
500
501 if (drawlist[r].sec_landform == 255) // flag for RTS grid overlay (stencil) which means pri_transition is 0?
502 {
504 }
505
506 if (drawlist[r].pri_transition)
507 {
508 if (old_pri_transition != drawlist[r].pri_transition)
509 {
510 // NOTE: 0 indexed
512 old_pri_transition = drawlist[r].pri_transition;
513 }
514
515 if (old_sec_landform != drawlist[r].sec_landform)
516 {
517 if (drawlist[r].sec_landform == 1)
518 {
520 }
521 else
522 {
524 }
525 old_sec_landform = drawlist[r].sec_landform;
526 }
527
528 if (drawlist[r].sec_transition)
529 {
530 if (old_sec_transition != drawlist[r].sec_transition)
531 {
532 // NOTE: 0 indexed
534 old_sec_transition = drawlist[r].sec_transition;
535 }
536
537 if (old_ter_landform != drawlist[r].ter_landform)
538 {
539 if (drawlist[r].ter_landform == 1)
540 {
542 }
543 else
544 {
546 }
547 old_ter_landform = drawlist[r].ter_landform;
548 }
549 }
550 else
551 {
552 old_sec_transition = old_ter_landform = 255;
553 }
554 }
555 else
556 {
557 old_pri_transition = old_sec_landform = 255;
558 }
559
560 RiseMath::Vector4 features;
561 if (drawlist[r].runways == 1) // airfield
562 {
563 if (drawlist[r].runwayLights == 1)
564 {
565 features.x = 2.0f; // runway and edge lights
567 }
568 else
569 features.x = 1.0f; // runway only
570 features.w = powf(1.0f - sunlight.Diffuse.a, 2.0f);
573 }
574 else if (drawlist[r].roads) // roads
575 {
576 features.x = 3.0f; // roads
577 features.w = drawlist[r].roads;
578 // east west 2 discreet segments, north south 2 discreet segments
581 }
582 else
583 features.x = features.w = 0.0f;
584 features.y = features.z = 0.0f; // unused
585 V(gameclass->graphics->g_pEffect->SetVector("Features", &features));
586
587 /*BOOL boolArray[5];
588 boolArray[0] = drawlist[r].pri_landform == 1;
589 boolArray[1] = drawlist[r].pri_transition;
590 boolArray[2] = drawlist[r].sec_landform == 1;
591 boolArray[3] = drawlist[r].sec_transition;
592 boolArray[4] = drawlist[r].ter_landform == 1;
593 V(gameclass->graphics->g_pEffect->SetBoolArray("flags", boolArray, 5));*/
594
595 INT boolArray[5];
596 boolArray[0] = drawlist[r].pri_landform;
597 boolArray[1] = drawlist[r].pri_transition;
598 boolArray[2] = drawlist[r].sec_landform;
599 boolArray[3] = drawlist[r].sec_transition;
600 boolArray[4] = drawlist[r].ter_landform;
601 V(gameclass->graphics->g_pEffect->SetIntArray("flags", boolArray, 5));
602
603
604
605 // Snow is joined by canonical plot coordinates, independent of grid centers.
606 const int snowU=drawlist[r].u, snowV=drawlist[r].v;
607 const auto snow00=ptrWeather->TerrainSnowTint(snowU,snowV);
608 const auto snow10=ptrWeather->TerrainSnowTint(snowU+1,snowV);
609 const auto snow01=ptrWeather->TerrainSnowTint(snowU,snowV+1);
610 const auto snow11=ptrWeather->TerrainSnowTint(snowU+1,snowV+1);
611 V(gameclass->graphics->g_pEffect->SetVector("TerrainSnow00",&snow00));
612 V(gameclass->graphics->g_pEffect->SetVector("TerrainSnow10",&snow10));
613 V(gameclass->graphics->g_pEffect->SetVector("TerrainSnow01",&snow01));
614 V(gameclass->graphics->g_pEffect->SetVector("TerrainSnow11",&snow11));
615
616 ptrRenderer->SetSceneShipLights(drawlist[r].bounds,matrixTemp);
617
618 // Keep headlights and pixel fog on every tile reaching within 4 km.
619 if (!playerships[0].isSimulator && drawlist[r].bounds.IsWithinDistance(terrainEye, 4.0f))
620 {
622 }
623 else
624 {
626 }
627
629
631
632 if (drawlist[r].sec_landform == 255) // flag for RTS grid overlay (stencil)
633 {
635 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILFUNC, Rendering::Compare::GREATEREQUAL ); // 1 or 0
636 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
637 }
638 }
639
641
643 logger->AddToCallStack("Viewscreen::OnFrameRender TERRAIN end");
644 }
645
646 V(pd3dDevice->SetRenderState(Rendering::RenderState::CULLMODE, Rendering::Cull::CW)); // Far or underside
647
648 // pd3dDevice->SetSamplerState( 0, Rendering::SamplerState::MINFILTER, Rendering::Filter::POINT );
649 // pd3dDevice->SetSamplerState( 0, Rendering::SamplerState::MAGFILTER, Rendering::Filter::POINT );
650 // pd3dDevice->SetSamplerState( 0, Rendering::SamplerState::MIPFILTER, Rendering::Filter::NONE );
651
652
653 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::TEXTURETRANSFORMFLAGS, Rendering::TextureTransform::DISABLE );
654
655 //change
656 // pd3dDevice->SetVertexShader( NULL );
657 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE );
661
662
663 // transparency at the end!
664 terrainTiming.Stop();
665 if (playerships[0].reference != REF_WINDOWLESS)
666 {
667 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX));
668 ptrBuildings->Render(pd3dDevice, &fTime, true);
669 }
670
671
672
673 // } //!g_bAboveClouds
674 // Vieneo -----------------------------------------------------------------------------------
675#pragma endregion
676
677 Rendering::ProfileScope11 bclTiming("BCL base setup and legacy clouds");
678 logger->AddToCallStack("Viewscreen::OnFrameRender BCL");
679
680
681 // @todo he uses fixed-function pipeline still... needs to be converted to a shader so we can get rid of the FFP fog
682#pragma region BCL Cloud Bases
683 // Lower Cloud Layer ------------------------------------------------------------------------
684// if (!g_bAboveClouds) // Start setting up in the middle of the cloud layer
685// {
686
689 const float renderVisibility = ptrWeather->GetRenderVisibilityKm();
690 DWORD fogEnd = *reinterpret_cast<const DWORD*>(&renderVisibility);
691 V(pd3dDevice->SetRenderState(Rendering::RenderState::FOGEND, fogEnd));
692
693 logger->AddToCallStack("Viewscreen::OnFrameRender FogEnd");
694
695 Rendering::Light templight = sunlight;
696 templight.Ambient = sunlight.Diffuse;
697 pd3dDevice->SetLight(0, &templight);
698
699 logger->AddToCallStack("Viewscreen::OnFrameRender LightEnd");
700
702 RiseMath::MatrixTranslation(&matrixWorld,
703 static_cast<float>(playerships[0].precisionx + cloudprecisionx) + offsetClouds.x,
704 static_cast<float>(playerships[0].precisiony + cloudprecisiony) + offsetClouds.y,
705 static_cast<float>(playerships[0].precisionz + cloudprecisionz) + offsetClouds.z);
706
707 V(pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixWorld));
708
709 RiseMath::MatrixIdentity(&matrixTemp);
710 matrixTemp._31 = allobjects[cloudBaseObjC].rotprog;
711 V(pd3dDevice->SetTransform(Rendering::TransformSlot::TEXTURE1, &matrixTemp));
713
715
717
720 V(pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::SPECULAR)); // reflection of buildings and the airglow?
724
728
729 V(pd3dDevice->SetFVF(RISE_FVF_LOCALGRID));
730
731 if (!VolumeCloudsEnabled() && playerships[0].reference != REF_WINDOWLESS && !playerships[0].isSimulator)
732 {
733 V(pd3dDevice->SetTexture(1, m_pddsCloudDetailBelow));
734
735 V(pd3dDevice->SetIndices(m_aiCloudGrid));
736 V(pd3dDevice->SetStreamSource(0, m_avCloudGrid, 0, sizeof(RiseLocalgridVertex)));
737
738 V(pd3dDevice->DrawIndexedPrimitive(Rendering::Primitive::TriangleList, 0, 0, 4096, 0, 6002));
739 }
742
743 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX));
744
746
751
753
754 V(pd3dDevice->LightEnable(0, true));
755 EnableLandingLights(); // not interior
756
758
759#pragma endregion
760
761 bclTiming.Stop();
762 logger->AddToCallStack("Viewscreen::OnFrameRender RTS");
763
764#pragma region RTS Grid
765 // RTS grid time! -------------------------------------------------------------------------------
766 //pd3dDevice->SetTextureStageState(0, Rendering::TextureState::ALPHAOP, Rendering::TextureOperation::SELECTARG1); // from RTSday
767 //pd3dDevice->SetTextureStageState(0, Rendering::TextureState::ALPHAARG1, Rendering::TextureArgument::TEXTURE);
768 //pd3dDevice->SetTextureStageState(1, Rendering::TextureState::ALPHAOP, Rendering::TextureOperation::SELECTARG1); // carry through
769 //pd3dDevice->SetTextureStageState(1, Rendering::TextureState::ALPHAARG1, Rendering::TextureArgument::CURRENT);
770
771 RiseMath::Vector4 clouduv;
772 clouduv.x = -static_cast<float>(BCLoffsetu); // clouds
773 if (!playerships[0].isSimulator) // this is for the cloud shadow on the ground ... we should skip altogether?
774 clouduv.x += allobjects[cloudBaseObjC].rotprog;
775 clouduv.y = -static_cast<float>(BCLoffsetv); // clouds
776 clouduv.z = 0.0f; // UNUSED
777 clouduv.w = powf(1.0f - sunlight.Diffuse.a, 2.0f); // light blend
778 V(gameclass->graphics->g_pEffect->SetVector("clouduv", &clouduv));
779
780
783 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
784
787 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX2));
788
792
793 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
794
795 ptrBuildings->RenderRts(pd3dDevice, clouduv.w);
796
797 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP );
799
802
803 if (playerships[0].reference != REF_WINDOWLESS && !playerships[0].isSimulator && f_AGL <= 0.78f)
804 {
805 ptrBuildings->RenderCurbs(pd3dDevice, clouduv.w);
806 ptrBuildings->RenderRocks(pd3dDevice);
807 }
808
810
812
813
814#pragma endregion
815
816
817 if (playerships[0].isSimulator)
818 {
819 // here is where we can override the ACL lighting?
820 Rendering::Light templight = sunlight;
821 templight.Ambient.r = templight.Ambient.g = templight.Ambient.b = 1.0f;
822 templight.Diffuse = RiseMath::Color();
823 pd3dDevice->SetLight(0, &templight);
824 }
825 else
826 pd3dDevice->SetLight(0, &sunlight);
827
828
829 }
830
831
832
833
834 logger->AddToCallStack("Viewscreen::OnFrameRender CELEST");
835
836 bool cloudVolumeDrawn = false;
837 bool deferredSkyRing = false;
838 RiseMath::Matrix skyRingWorld;
839 float deferredSkyRingScale = 1;
840 const auto drawCloudVolume = [&]() {
841 if (cloudVolumeDrawn || !VolumeCloudsEnabled() || playerships[0].reference == REF_WINDOWLESS ||
842 (playerships[0].reference == REF_INANOTHER && !playerships[playerships[0].inarray].baydoor && !camera->outside)) return;
843 Rendering::ProfileScope11 timing("Volumetric clouds total");
844 // Supply incident light at the deck, independent of the observer's
845 // altitude/elevation. The shader applies each cloud point's sun angle.
846 const float cloudSunAttenuation = expf(-.5f * expf(-ptrWeather->cloudParameters.top / ScaleHeightC));
847 const RiseMath::Color direct = sunColorC * cloudSunAttenuation;
852 const bool localFlash = lightningbelow.inuse && !playerships[0].isSimulator;
853 const RiseMath::Color flashColor = localFlash
855 : RiseMath::Color(0, 0, 0, 0);
857 std::vector<CloudVolumeRenderer::Headlight> cloudLights;
858 cloudLights.reserve(CloudVolumeRenderer::MaxHeadlights);
859 const RiseMath::Vector3 planetOrigin = -playerships[0].position;
860 RiseMath::Matrix inverseCamera;
861 RiseMath::MatrixInverse(&inverseCamera, nullptr, &matrixLook);
862 const RiseMath::Vector3 planetCamera = planetOrigin + RiseMath::Vector3(inverseCamera._41, inverseCamera._42, inverseCamera._43);
863 for (unsigned i = 0; i < activeLandingLightCount; ++i)
864 {
865 const auto& light = landingLights[i];
866 cloudLights.push_back({ planetOrigin + light.origin, light.direction, light.color, light.profile.rangeKm, light.up, light.profile, light.extinctionPerKm });
867 }
868 const size_t ownLights = cloudLights.size();
869 for (int ship = 1; ship < MAX_SCAN; ++ship)
870 {
871 const auto& vehicle = playerships[ship];
872 if (VehicleVisibility::AcrossCloudDeck(playerships[0].mslKm, vehicle.mslKm, cloudTopsMslC)) continue;
873 if (!vehicle.active || !vehicle.visible || vehicle.isSimulator ||
874 !vehicle.headlight || !vehicle.logolight || vehicle.cloaking <= 0 ||
875 vehicle.VB < 0 || vehicle.VB >= maxpolyC) continue;
876 // A light can enter the view even when its source is offscreen;
877 // do not use the ship's geometry-frustum drawflag to reject it.
878 const auto offset = -vehicle.position - planetCamera;
879 if (RiseMath::Vec3LengthSq(&offset) > 16) continue;
880 if (vehicle.reference == REF_INANOTHER && vehicle.inarray >= 0 && vehicle.inarray < MAX_SCAN &&
881 !playerships[vehicle.inarray].baydoor) continue;
882 const auto& model = polyobjects[vehicle.VB];
883 for (unsigned i = 0; i < model.landingLightCount; ++i)
884 {
885 auto light = LandingLights::Transform(LandingLights::Configure(model.landingLights[i], vehicle.type, vehicle.matrixBase), vehicle.matrixExterior);
886 light.extinctionPerKm = 3.912f / RiseMath::Max(.05f, ptrWeather->GetVisibilityKm());
887 cloudLights.push_back({ planetOrigin + light.origin, light.direction,
888 light.color * vehicle.cloaking, light.profile.rangeKm, light.up, light.profile, light.extinctionPerKm });
889 }
890 }
891 std::stable_sort(cloudLights.begin() + ownLights, cloudLights.end(), [&](const auto& a, const auto& b) {
892 const auto da = a.position - planetCamera, db = b.position - planetCamera;
893 return RiseMath::Vec3LengthSq(&da) < RiseMath::Vec3LengthSq(&db);
894 });
895 // Own light first, then the closest remote sources, with a fixed GPU budget.
896 cloudVolume.SetHeadlights(cloudLights);
898 const HRESULT cloudResult = cloudVolume.Render(pd3dDevice, matrixLook, matrixProj,
900 RiseMath::Color(.125f, .375f, .25f, 1), haze, atmosphereHaze, ptrWeather->nightVisionCloudGain);
901 cloudVolumeDrawn = true;
902 if (FAILED(cloudResult))
903 {
905 logger->Log("Volumetric cloud rendering failed; reverting to legacy clouds", Logger::Level::Warn, cloudResult);
908 }
909 };
910 // Do all the celestial objects -----------------------------------------------------------
911 if (playerships[0].reference != REF_WINDOWLESS)
912 {
913 for (t = 0; t < maxstarC; t++)
914 {
915 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
916 switch (allobjects[t].type)
917 {
918#pragma region Upper cloud layer
919 case -2: // Upper cloud layer (only drawn where stencil equals 1, smooths the edges ---
920 if (VolumeCloudsEnabled()) break;
921 if (g_bAboveClouds && (playerships[0].reference != REF_INANOTHER || playerships[playerships[0].inarray].baydoor || camera->outside)) // Draw only when we are above upper cloud layer, sorted in framemove
922 {
923 // Fix those who are beyond clipping plane
924 result.x = -allobjects[t].matrixWorld._41; // Relative to our position
925 result.y = -allobjects[t].matrixWorld._42; // Relative to our position
926 result.z = -allobjects[t].matrixWorld._43; // Relative to our position
927 f_temp = RiseMath::Vec3Length(&result);
928 if (f_temp > cutplaneC)
929 {
930 f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
931
932 // Scale apparent scale in matrix
933 RiseMath::MatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
934 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
935
936 // Scale location in matrix
937 RiseMath::Vec3Scale(&result, &result, 1.0f - f_temp);
938 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
939 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
940 }
941
942
943
944 UINT renderpolygons = static_cast<unsigned long>(fabsf(atanf(playerships[0].mslKm / 1591.0f) / RiseMath::HalfPi * 2250.0f)) + 9; // 9 at ground level, 68% at 45°
945 if (renderpolygons > 2250)
946 renderpolygons = 2250;
947
948
949 //pd3dDevice->LightEnable(1, false); // on my laptop you could see headlight and weapon
950
951 RiseMath::Vector4 temp4;
952 temp4.x = alphascreen.r;
953 temp4.y = alphascreen.g;
954 temp4.z = alphascreen.b;
955 temp4.w = alphascreen.a;
956 V(gameclass->graphics->g_pEffect->SetVector("ambient", &temp4));
957
958 RiseMath::Vector4 Sunlight;
959 Sunlight.x = -sunlight.Direction.x; Sunlight.y = -sunlight.Direction.y; Sunlight.z = -sunlight.Direction.z;
960 Sunlight.w = ptrWeather->solarVisibility; // Legacy deck: include Iomere, not Vieneo self-shadow.
961 V(gameclass->graphics->g_pEffect->SetVector("Sunlight", &Sunlight));
962
963#pragma region Radiosity
964 RiseMath::Vector4 radiosity = RiseMath::Vector4(0, 0, 0, 0);
965 if (!playerships[0].isSimulator)
966 {
967 /*Rendering::Light templight;
968 ZeroMemory(&templight, sizeof Rendering::Light);
969 templight.Type = Rendering::LightKind::DIRECTIONAL;*/
970
972 //templight.Direction = result; // sunlight comes from the moon
973 float radio = RiseMath::Vec3Dot(&Xsunlight, &result); // angular difference
974 if (radio >= 1.0f)
975 f_temp = 0.0f;
976 else if (radio <= -1.0f)
977 f_temp = RiseMath::HalfPi;
978 else
979 f_temp = acosf(radio);
980 radio = (RiseMath::Tau - f_temp) / RiseMath::Tau; // percent of 180° that is visible
981 radio /= 5.0f;
982
983 radiosity.x = result.x; radiosity.y = result.y; radiosity.z = -result.z;
984 radiosity.w = radio;
985 //templight.Diffuse.r = 0.3525f*radio; templight.Diffuse.g = 0.41f*radio; templight.Diffuse.b = 0.57f*radio;
986 //pd3dDevice->SetLight(2, &templight); // Radiosity
987 //pd3dDevice->LightEnable(2, true);
988 }
989 V(gameclass->graphics->g_pEffect->SetVector("Radiosity", &radiosity));
990#pragma endregion
991
992 //pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &allobjects[t].matrixWorld);
994 RiseMath::Matrix mWorldViewProj;
995 if (playerships[0].isSimulator)
996 mWorldViewProj = allobjects[t].matrixWorld * matrixView * matrixProjSim;
997 else
998 mWorldViewProj = allobjects[t].matrixWorld * matrixLook * matrixProj;
999 V(gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
1000
1001 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1002
1003 RiseMath::Color tempcolor;
1004 if (f_ACL > 500.0f)
1005 {
1006 if (f_ACL < 1000.0f)
1007 tempcolor.a = 1.0f - (f_ACL - 500.0f) / 500.0f;
1008 else
1009 tempcolor.a = 0.0f;
1010 }
1011 else
1012 tempcolor.a = 1.0f;
1013 //tempcolor.r = tempcolor.g = tempcolor.b = 0.5f; // must be 0.5 for the MODULATE2X
1014 //pd3dDevice->SetRenderState(Rendering::RenderState::TEXTUREFACTOR, tempcolor);
1015 temp4.x = 0; // UNUSED
1016 temp4.y = 0; // UNUSED
1017 temp4.z = 0; // UNUSED
1018 temp4.w = tempcolor.a;
1019 V(gameclass->graphics->g_pEffect->SetVector("clouduv", &temp4));
1020
1021
1022 /*pd3dDevice->SetSamplerState(0, Rendering::SamplerState::MINFILTER, Rendering::Filter::LINEAR);
1023 pd3dDevice->SetSamplerState(0, Rendering::SamplerState::MAGFILTER, Rendering::Filter::LINEAR);
1024 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::BLENDFACTORALPHA);*/
1025
1026
1027 //pd3dDevice->SetTexture(0, m_pddsCloudDetailAbove);
1029
1030
1031
1032
1033 /*pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE);
1034 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::TFACTOR);
1035 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::TEXCOORDINDEX, 1);
1036
1037 pd3dDevice->SetSamplerState(1, Rendering::SamplerState::MINFILTER, Rendering::Filter::LINEAR);
1038 pd3dDevice->SetSamplerState(1, Rendering::SamplerState::MAGFILTER, Rendering::Filter::LINEAR);
1039 pd3dDevice->SetTextureStageState(1, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE2X);*/
1040
1041 //pd3dDevice->SetTexture(1, m_pddsCloudBaseMap);
1043
1044 //pd3dDevice->SetTextureStageState(1, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::CURRENT);
1045 //pd3dDevice->SetTextureStageState(1, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE);
1046 //pd3dDevice->SetTextureStageState(1, Rendering::TextureState::TEXCOORDINDEX, 0);
1047
1048
1050 //pd3dDevice->SetTexture(2, nullptr);
1051 //pd3dDevice->SetTextureStageState(2, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE);
1052 //pd3dDevice->SetTextureStageState(2, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::CURRENT);
1053 //pd3dDevice->SetTextureStageState(2, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::DIFFUSE);
1054
1055
1056 // lessequal seemed to get rid of some artifacts when extremely distant
1058
1060 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP );
1061 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
1062
1063 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
1064 V(gameclass->graphics->g_pEffect->BeginPass(14)); // cloud tops
1065
1067
1068 V(gameclass->graphics->g_pEffect->EndPass()); // cloud tops
1070
1072 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP );
1073 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
1074
1076
1077 }
1078 break; // Upper cloud layer
1079#pragma endregion
1080
1081#pragma region Iomere
1082 case -3: // Iomere
1083 if (g_bAboveClouds && !playerships[0].isSimulator)
1084 {
1085 Rendering::ProfileScope11 timing("Iomere");
1086 // Fix those who are beyond clipping plane
1087 result.x = -allobjects[t].matrixWorld._41;
1088 result.y = -allobjects[t].matrixWorld._42;
1089 result.z = -allobjects[t].matrixWorld._43;
1090 f_temp = RiseMath::Vec3Length(&result);
1091 if (f_temp > cutplaneC)
1092 {
1093 f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
1094 //f_temp=0.5f;
1095
1096 // Scale apparent scale in matrix
1097 RiseMath::MatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
1098 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
1099
1100 // Scale location in matrix
1101 RiseMath::Vec3Scale(&result, &result, 1.0f - f_temp);
1102 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
1103 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1104 }
1105
1106 pd3dDevice->SetFVF(RISE_FVF_VERTEX2);
1109
1112 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
1113
1114 pd3dDevice->SetTexture(0, m_pddsWorld2a1);
1115 // pd3dDevice->SetTexture( 1, m_pddsWorld2a1Bump );
1116 // pd3dDevice->SetTexture( 2, NULL );
1117 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::TEXCOORDINDEX, 0 );
1118 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLOROP, D3DTOP_BUMPENVMAPLUMINANCE);
1119 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE );
1120 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::CURRENT );
1121 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::BUMPENVMAT00, F2DW(1.0f) );
1122 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::BUMPENVMAT01, F2DW(0.0f) );
1123 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::BUMPENVMAT10, F2DW(0.0f) );
1124 //pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::BUMPENVMAT11, F2DW(1.0f) );
1125
1130
1131 // Iomere receives sunlight in space, not the observer's local
1132 // weather/horizon illumination. Surface normals retain its phase;
1133 // the texture-factor blend above still represents foreground air.
1134 Rendering::Light iomereSunlight{};
1135 iomereSunlight.Type = Rendering::LightKind::DIRECTIONAL;
1136 iomereSunlight.Direction = Xsunlight;
1137 iomereSunlight.Diffuse = sunColorC;
1138 pd3dDevice->SetLight(0, &iomereSunlight);
1139
1140 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &allobjects[t].matrixWorld);
1141 pd3dDevice->SetStreamSource(0, polyobjects[0].VB, 0, sizeof(RiseVertex2Vertex));
1143 pd3dDevice->SetLight(0, &sunlight); // restore observer lighting for subsequent draws
1144
1145 // pd3dDevice->SetTextureStageState( 2, Rendering::TextureState::COLOROP, Rendering::TextureOperation::DISABLE ); // leave on for static stars
1146 // pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLOROP, Rendering::TextureOperation::BLENDFACTORALPHA );
1147 // pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TFACTOR );
1148 // pd3dDevice->SetTextureStageState( 1, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::CURRENT );
1150 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1151
1152 // We are assuming that the SetRenderState Lighting FALSE overrides these later
1154 }
1155 break;
1156#pragma endregion
1157
1158#pragma region Static Stars
1159 case -5: // Render the static stars -----------------------------------------------------
1160 if (g_bAboveClouds && !playerships[0].isSimulator)
1161 {
1162 Rendering::ProfileScope11 timing("Static stars");
1163 V(pd3dDevice->SetFVF(RISE_FVF_STATICSTARS));
1164 pd3dDevice->SetTexture(0, m_pddsStarTexture);
1165 pd3dDevice->SetStreamSource(0, m_avStaticStars, 0, sizeof(RiseStaticstarsVertex));
1166
1168 pd3dDevice->SetRenderState(Rendering::RenderState::ZWRITEENABLE, false); // Don't modify
1169
1170 RiseMath::MatrixRotationZ(&matrixTemp, -allobjects[ourmoonC].rotprog); // barycentric
1171 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixBase, &matrixTemp);
1172
1173 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &allobjects[t].matrixWorld);
1174
1175 // If it passes, don't change the value from 0 to 1
1176 // still pass only if less than 1
1177 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILFUNC, Rendering::Compare::GREATEREQUAL ); // only if 0
1178 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP );
1179 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 1 ); // 0 is default
1180
1199
1200 if (!m_bPsize) // https://jira.risetvp.com/view.php?id=211
1201 {
1202 float psize = 4.0f;
1203 V(pd3dDevice->SetRenderState(Rendering::RenderState::POINTSIZE, *reinterpret_cast<DWORD*>(&psize)));
1204 }
1205 // Enhance the catalog signal before the existing sky/fog blend.
1206 // Keep this local to stars: no gain on the following sun/moon draws.
1207 const float starGain = NightVisionStars::Gain(ptrWeather->cockpitVision);
1208 auto& starVision = pd3dDevice->Draws().Fixed().nightVisionSurface;
1209 starVision = {starGain, starGain, starGain, starGain > 1.f ? 1.f : 0.f};
1211 starVision = {};
1212
1215 // pd3dDevice->SetSamplerState( 0, Rendering::SamplerState::MAGFILTER, Rendering::Filter::POINT );
1217 // pd3dDevice->SetSamplerState( 1, Rendering::SamplerState::MINFILTER, Rendering::Filter::POINT );
1218 // pd3dDevice->SetSamplerState( 1, Rendering::SamplerState::MAGFILTER, Rendering::Filter::POINT );
1219 // pd3dDevice->SetSamplerState( 1, Rendering::SamplerState::MIPFILTER, Rendering::Filter::NONE );
1220 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE );
1221 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE );
1222 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::DIFFUSE );
1224
1225 // Leave off through Yonmara
1226 // pd3dDevice->SetRenderState( Rendering::RenderState::LIGHTING, true );
1227 }
1228 break; // Done with static stars --------------------------------------------------------
1229#pragma endregion
1230
1231#pragma region Yonmara
1232 case -7: // Yonmara
1233 if (g_bAboveClouds && !playerships[0].isSimulator)
1234 {
1235 Rendering::ProfileScope11 timing("Sun billboard");
1236 // Fix those who are beyond clipping plane
1237 result.x = -allobjects[t].matrixWorld._41;
1238 result.y = -allobjects[t].matrixWorld._42;
1239 result.z = -allobjects[t].matrixWorld._43;
1240 f_temp = RiseMath::Vec3Length(&result);
1241 if (f_temp > cutplaneC)
1242 {
1243 f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
1244
1245 // Scale apparent scale in matrix
1246 RiseMath::MatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
1247 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
1248
1249 // Scale location in matrix
1250 RiseMath::Vec3Scale(&result, &result, 1.0f - f_temp);
1251 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
1252 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1253 }
1254
1255 // Off since static stars
1256 // pd3dDevice->SetRenderState( Rendering::RenderState::LIGHTING, false );
1257
1258
1259 //const short rgb = 255 - static_cast<short>(255.0f * alphascreen.a); // fades it out as we go into clouds
1260 //const Rendering::PackedColor sunblend = Rendering::ColorRGB(rgb, rgb, rgb);
1263 // but we have to fix based on alphascreen
1266 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &allobjects[t].matrixWorld);
1267
1268
1271
1275
1276 pd3dDevice->SetFVF(RISE_FVF_NONORMAL);
1278
1279 pd3dDevice->SetStreamSource(0, m_avBillboardVertices, 0, sizeof(RiseNonormalVertex));
1280 pd3dDevice->SetTexture(0, m_pddsSunTexture);
1282
1283 // will be fixed in skyring
1284 // pd3dDevice->SetRenderState( Rendering::RenderState::CULLMODE, Rendering::Cull::CW );
1285 // pd3dDevice->SetRenderState( Rendering::RenderState::ALPHABLENDENABLE, false );
1286
1287 // pd3dDevice->SetFVF( RISE_FVF_VERTEX );
1288
1291
1294
1296 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP );
1297 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILREF, 2); // 0 is default
1298
1300
1301 // Leave off through skyring
1302 // pd3dDevice->SetRenderState( Rendering::RenderState::LIGHTING, true );
1303 // pd3dDevice->SetRenderState( Rendering::RenderState::ZWRITEENABLE, true );
1304 }
1305 break;
1306#pragma endregion
1307
1308#pragma region Skyring
1309 case -9: // Skyring ---------------------------------------------------------------------
1310 if (g_bAboveClouds && !playerships[0].isSimulator)
1311 {
1312 Rendering::ProfileScope11 timing("Sky ring preparation");
1314 RiseSkyringVertex* vtx3;
1315 V(m_avSkyRing->Lock(0, 0, reinterpret_cast<void**>(&vtx3), Rendering::LockFlags::DISCARD));
1316 float bright;
1317
1318 inner = sinf(ptrWeather->cloudHorizonAngle) * ptrWeather->cloudHorizonDistance - aftersdC; // radius of stencil (2a)
1319 bury = ((playerships[0].mslKm + radiusC) - ptrWeather->cloudHorizonDistance * cosf(ptrWeather->cloudHorizonAngle)); // difference between 1c and 2b
1320
1321 const float outer = sinf(ptrWeather->cloudHorizonAngle) * ptrWeather->cloudHorizonDistance + aftersdC; // radius of stencil (2a)
1322 const float upper = -aftersdC * sinf(ptrWeather->cloudHorizonAngle); // upper radius
1323 const float lower = -upper;// aftersdC * sinf(ptrWeather->cloudHorizonAngle);
1324
1325 RiseMath::Color tempcolor;
1326 for (s = 0; s < SkyRingRenderer::Segments; s++)
1327 {
1328 result.x = cosf((RiseMath::Tau / SkyRingRenderer::Segments) * static_cast<float>(s)) * inner;
1329 result.y = sinf((RiseMath::Tau / SkyRingRenderer::Segments) * static_cast<float>(s)) * inner;
1330 result.z = lower - bury;
1331 vtx3->x = result.x; vtx3->y = result.y; vtx3->z = result.z;
1332
1333 RiseMath::Vec3TransformNormal(&result, &result, &matrixLookAtSkydome);
1334 RiseMath::Vec3Normalize(&result, &result);
1335
1336 f_temp = -RiseMath::Vec3Dot(&result, &Xsunlight) - playerships[0].mslKm / 70000.0f;
1337 if (f_temp < -0.3f)
1338 bright = 0.0f;
1339 else if (f_temp >= -0.3f && f_temp < 0.0f)
1340 bright = (f_temp + 0.3f) / 0.3f;
1341 else
1342 bright = 1.0f;
1343
1344 tempcolor.r = ptrWeather->colorhorizon.r * bright;
1345 tempcolor.g = ptrWeather->colorhorizon.g * bright;
1346 tempcolor.b = ptrWeather->colorhorizon.b * bright;
1347 RiseMath::ColorLerp(&tempcolor, &tempcolor, &alphascreen,
1349
1350
1351 // This is handled by the &sunlight (light 0) ambient color now!
1352 tempcolor.a = 1.0f;//f_temp; // doesn't matter, it gets it from the texture
1353
1354 vtx3->diffuse = tempcolor;
1355 vtx3->tu = static_cast<float>(s); vtx3->tv = 1.0f;
1356 vtx3++;
1357
1358 result.x = cosf((RiseMath::Tau / SkyRingRenderer::Segments) * static_cast<float>(s)) * outer;
1359 result.y = sinf((RiseMath::Tau / SkyRingRenderer::Segments) * static_cast<float>(s)) * outer;
1360 result.z = upper - bury;
1361 vtx3->x = result.x; vtx3->y = result.y; vtx3->z = result.z;
1362 vtx3->diffuse = tempcolor;
1363 vtx3->tu = static_cast<float>(s); vtx3->tv = 0.0f;
1364 vtx3++;
1365 }
1366 result.x = inner; result.y = 0.0f; result.z = lower - bury;
1367 vtx3->x = result.x; vtx3->y = result.y; vtx3->z = result.z;
1368 vtx3->diffuse = (vtx3 - 2 * SkyRingRenderer::Segments)->diffuse;
1369 vtx3->tu = static_cast<float>(s); vtx3->tv = 1.0f;
1370 vtx3++;
1371
1372 result.x = outer; result.y = 0.0f; result.z = upper - bury;
1373 vtx3->x = result.x; vtx3->y = result.y; vtx3->z = result.z;
1374 vtx3->diffuse = (vtx3 - 2 * SkyRingRenderer::Segments)->diffuse;
1375 vtx3->tu = static_cast<float>(s); vtx3->tv = 0.0f;
1376
1377 V(m_avSkyRing->Unlock());
1378
1379
1380 matrixWorld = matrixLookAtSkydome;
1381 matrixWorld._41 = -position.x; matrixWorld._42 = -position.y; matrixWorld._43 = -position.z;
1382
1383 // Fix those who are beyond clipping plane
1384 float skyRingScale = 1.f;
1385 f_temp = RiseMath::Vec3Length(&position);
1386 if (f_temp > cutplaneC)
1387 {
1388 f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
1389 skyRingScale = f_temp;
1390
1391 // Scale apparent scale in matrix
1392 RiseMath::MatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
1393 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
1394
1395 // Scale location in matrix closer
1396 RiseMath::Vec3Scale(&result, &position, 1.0f - f_temp);
1397 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
1398 RiseMath::MatrixMultiply(&matrixWorld, &matrixWorld, &matrixTemp);
1399 }
1400
1401 if (VolumeCloudsEnabled())
1402 {
1403 // Ships and docks must contribute scene depth before the
1404 // volume. Keep the ring behind that same cloud composite.
1405 deferredSkyRing = true;
1406 skyRingWorld = matrixWorld;
1407 deferredSkyRingScale = skyRingScale;
1408 }
1409 else
1410 {
1412 }
1413
1415 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::ALPHAOP, Rendering::TextureOperation::DISABLE ); benjey2
1416 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE );
1418
1419 // This also fixes for Yonmara
1424
1425 }
1426 break; // Skyring -----------------------------------------------------------------------
1427#pragma endregion
1428 } // End of switch
1429 } // End of loop
1430 }
1431 // Do all the cellestial objects and docks --------------------------------------------------
1432
1433
1434
1435
1436 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1440
1441 // Opaque objects supply depth to the volume. Celestial sprites leave
1442 // depth writes disabled, so do not inherit their state here.
1443 if (VolumeCloudsEnabled())
1444 {
1448 }
1449 // Legacy ordering keeps docks in front of its atmosphere ring.
1451 {
1452 Rendering::ProfileScope11 timing("Docks"); ptrRenderer->RenderDocks(pd3dDevice, &Xsunlight);
1453 }
1454
1455
1456
1457 // The opaque hull must precede cloud composition; translucent exhaust
1458 // must blend over the completed cloud/atmosphere background.
1459 const bool deferThrust=ThrustConeRender::Defer(VolumeCloudsEnabled(),playerships[0].isSimulator);
1460 // has to be here because otherwise the skyring overwrites them
1461 // this will change when we want to show simulators inside the sim bay
1462 if (playerships[0].reference != REF_WINDOWLESS)
1463 {
1464 Rendering::ProfileScope11 timing("Ships"); ptrRenderer->RenderShips(pd3dDevice, &Xsunlight,
1466 }
1467
1468 // Opaque depth must be captured before the cloud composite changes it.
1469 adDiagnostics.CaptureScene(*pd3dDevice);
1471 drawCloudVolume();
1472 adWeatherMeasured = VolumeCloudsEnabled() && (!cloudVolumeDrawn || cloudVolume.Effect()->Pass().AdOpacityWritten());
1474 if (deferredSkyRing)
1475 {
1476 Rendering::ProfileScope11 timing("Sky ring composite");
1477 if (cloudVolumeDrawn && VolumeCloudsEnabled())
1478 {
1479 V(cloudVolume.RenderSkyRing(pd3dDevice, m_pddsAtmosphere, m_avSkyRing, skyRingWorld, SkyRingRenderer::Segments, deferredSkyRingScale));
1480 }
1481 else
1482 {
1484 }
1485 }
1486
1487
1488
1489
1490 if (deferThrust && playerships[0].reference != REF_WINDOWLESS)
1491 {
1492 Rendering::ProfileScope11 timing("Thrust cones");
1493 ptrRenderer->RenderShips(pd3dDevice,&Xsunlight,ThrustConeRender::Pass::AfterClouds,cloudVolumeDrawn);
1494 }
1495
1496 // One exterior object is visible from both the windshield and exterior
1497 // mounts. Draw after the atmosphere, using hull depth and cockpit stencil.
1502 {
1503 Rendering::ProfileScope11 timing("Reentry envelope");
1504 auto* hullBuffer=polyobjects[playerships[0].VB].VB;
1505 auto spheres=hullBuffer ? ReentryEnvelope::ExteriorHull(playerships[0].componentarray,
1506 playerships[0].components,hullBuffer->Geometry().Bytes(),sizeof(RiseVertex2Vertex))
1507 : std::vector<ReentryEnvelope::Sphere>{};
1508 // Some detailed cockpits sit ahead of their exterior model (E-11).
1509 // Include the actual glass in its fixed vehicle mount, even while an
1510 // external camera is selected. Never fit the envelope to the active eye.
1511 if (cockpitCamera && polyobjects[5].VB)
1512 {
1513 RiseMath::Matrix cockpitView,orientation,mount,inverseCockpitView;
1514 RiseMath::MatrixRotationQuaternion(&orientation,&playerships[0].orientation);
1517 cockpitView=orientation*mount;
1518 RiseMath::MatrixInverse(&inverseCockpitView,nullptr,&cockpitView);
1519 for (int c=0;c<ourcockpit.components;++c)
1520 {
1521 const auto& part=ourcockpit.componentarray[c];
1522 if (part.visible && part.type==5)
1523 ReentryEnvelope::AppendPart(spheres,part,polyobjects[5].VB->Geometry().Bytes(),sizeof(RiseVertexVertex),
1524 part.matWorld*matrixView*inverseCockpitView);
1525 }
1526 }
1527 RiseMath::Matrix worldToBody;
1528 RiseMath::MatrixRotationQuaternion(&worldToBody,&playerships[0].orientation);
1529 const auto& exterior=playerships[0].matrixExterior;
1530 const auto mesh=ReentryEnvelope::Attached(std::move(spheres),reentryWindward,worldToBody,
1531 {exterior._41,exterior._42,exterior._43});
1532 float transmission=1.f;
1533 if (cloudVolumeDrawn && VolumeCloudsEnabled())
1534 {
1535 RiseMath::Matrix inverseLook;
1536 RiseMath::MatrixInverse(&inverseLook,nullptr,&matrixLook);
1537 const auto eye=-playerships[0].position+RiseMath::Vector3(inverseLook._41,inverseLook._42,inverseLook._43);
1538 const auto origin=-playerships[0].position;
1539 // Compact-emitter cloud approximation, also used by exterior exhaust.
1540 transmission=CloudVolume::Transmittance({eye.x,eye.y,eye.z},{origin.x,origin.y,origin.z},
1542 }
1543 V(reentryRenderer.Render(pd3dDevice->Context(),pd3dDevice->Owner().SceneTarget(),
1544 pd3dDevice->Owner().Depth(),pd3dDevice->Draws().Viewport(),matrixLook,matrixProj,
1546 }
1547
1548 // Rain
1549 if (playerships[0].reference != REF_WINDOWLESS && raindrops > 0)
1550 {
1551 Rendering::ProfileScope11 timing("Exterior rain");
1552 logger->AddToCallStack("Viewscreen::OnFrameRender RAIN");
1553
1555 {
1556 V(exteriorRainRenderer.Render(pd3dDevice,
1557 cloudVolumeDrawn && VolumeCloudsEnabled() ? cloudVolume.Effect() : nullptr));
1558 }
1559 else
1560 {
1565
1566 RiseMath::MatrixLookAtRH(&matrixTemp, &centerC, &forwardVector, &posnorml); // eye at up
1567 // always oriented to our space
1568
1569 RiseMath::MatrixInverse(&matrixWorld, nullptr, &matrixTemp);
1570
1571 pd3dDevice->SetFVF(RISE_FVF_RAINDROP);
1572 pd3dDevice->SetStreamSource(0, m_avRainDrops, 0, sizeof(RiseRaindropVertex));
1573 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixWorld);
1574
1576
1577 if (cloudVolumeDrawn && VolumeCloudsEnabled())
1578 {
1579 V(cloudVolume.RenderRain(pd3dDevice, matrixWorld, static_cast<unsigned int>(raindrops)));
1580 }
1581 else
1582 {
1583 V(pd3dDevice->DrawPrimitive(Rendering::Primitive::LineList, 0, static_cast<unsigned int>(raindrops)));
1584 }
1585
1586 }
1587
1590 }
1591
1592
1593
1594
1595
1596 if (playerships[0].reference != REF_WINDOWLESS)
1597 {
1598 Rendering::ProfileScope11 timing("Light sprites"); ptrRenderer->RenderLights(pd3dDevice, &fTime);
1599 }
1600
1601
1602
1603
1605
1606
1607
1608 // Technically somehow we should have the sun drawn at this point ideally
1610 {
1611 Rendering::ProfileScope11 timing("Sun visibility poll", false);
1612 // Retain the last completed result while the GPU finishes a prior
1613 // frame. Never flush, spin, or reuse a query that is still pending.
1614 const HRESULT queryResult = m_pLightSunVizQuery->GetData(&ptrWeather->m_dwSunViz, sizeof(DWORD), 0);
1615 if (queryResult != S_FALSE) m_sunVizPending = false;
1616 }
1617 if (g_bAboveClouds && m_bDeviceSupportsVizQuery && !m_sunVizPending) // test for sun visibility
1618 {
1619 Rendering::ProfileScope11 timing("Sun visibility draw");
1622
1625 RiseMath::MatrixMultiply(&matrixTemp, &matrixTemp, &allobjects[ourstarC].matrixWorld);
1626 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixTemp);
1627
1628 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1629 pd3dDevice->SetStreamSource(0, polyobjects[0].VB, 0, sizeof(RiseVertex2Vertex));
1631
1635
1637 m_sunVizPending = true;
1638 }
1639
1640
1641
1642
1643 // Weapons and BCL lightning and fireworks? Oh my! --------------------------------------------------------------
1644
1645
1646 pd3dDevice->SetFVF(RISE_FVF_NONORMAL);
1650 pd3dDevice->SetStreamSource(0, m_avBillboardVertices, 0, sizeof(RiseNonormalVertex));
1651
1652
1653
1654 // these are used by the explosion not the weapon, weapon is color based blending
1658
1659 pd3dDevice->SetRenderState(Rendering::RenderState::ZWRITEENABLE, false); // was always before cockpit
1660
1661 if (playerships[0].reference != REF_WINDOWLESS && !playerships[0].isSimulator)
1662 {
1663 Rendering::ProfileScope11 timing("Weapons"); ptrWeapon->Render(pd3dDevice, &matrixLookAtLocal);
1664 }
1665
1666 pd3dDevice->SetRenderState(Rendering::RenderState::ZWRITEENABLE, true); // was always before cockpit
1667
1668
1669 RiseMath::MatrixRotationX(&matrixTemp, -RiseMath::Pi); // 1.5
1670 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixLookAtHorizon);
1671
1672 RiseMath::MatrixScaling(&matrixTemp, 0.25f, 0.25f, 0.25f);
1673 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
1675 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld); // matrixWorld is scaled lookat matrix
1676
1679
1680 if (playerships[0].reference != REF_WINDOWLESS && !playerships[0].isSimulator)
1681 {
1682 // fireworks
1683 for (t = 0; t < fireworksC; t++)
1684 {
1685 if (fireworks[t].inuse)
1686 {
1687 matrixTemp = matrixWorld;
1688
1689 result = fireworks[t].position - playerships[0].position;
1690 matrixTemp._41 = -result.x;
1691 matrixTemp._42 = -result.y;
1692 matrixTemp._43 = -result.z;
1693
1694 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixTemp);
1695 float limit;
1696 if (fireworks[t].type == 0)
1697 {
1698 pd3dDevice->SetTexture(0, m_pddsFirework1[fireworks[t].texture]);
1699 limit = (float)fireworks[t].texture / 16.0f;
1700 }
1701 else if (fireworks[t].type == 1)
1702 {
1703 pd3dDevice->SetTexture(0, m_pddsFirework2[fireworks[t].texture]);
1704 limit = (float)fireworks[t].texture / 16.0f;
1705 }
1706 else
1707 {
1708 pd3dDevice->SetTexture(0, m_pddsFirework3[fireworks[t].texture]);
1709 limit = (float)fireworks[t].texture / 16.0f;
1710 }
1711
1712 RiseMath::Color tempcolor = 0xFFFFFFFF;
1713 if (limit > 1.0f)
1714 limit = 1.0f;
1715 RiseMath::ColorLerp(&tempcolor, &tempcolor, &fireworks[t].color, limit);
1717 pd3dDevice->SetStreamSource(0, m_avBillboardVertices, 0, sizeof(RiseNonormalVertex));
1720 }
1721 }
1722 }
1723
1724#ifdef smoketestC
1725 RiseMath::MatrixScaling(&matrixTemp, 0.03f, 0.03f, 0.03f);
1726 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixLookAtHorizon);
1727 // pd3dDevice->SetRenderState(Rendering::RenderState::SRCBLEND, Rendering::Blend::SRCCOLOR); // works good for reentry and explosions
1728 // pd3dDevice->SetRenderState(Rendering::RenderState::DESTBLEND, Rendering::Blend::ONE); // works good for reentry and explosions
1735
1736
1737 // smoke trails
1738 for (t = 0; t < MAX_WEAPONS; t++)
1739 {
1740 if (weaponarray[t].active)
1741 {
1742 for (s = 0; s < smoketrailC; s++)
1743 // for (s=(smoketrailC-1); s>-1; s--)
1744 {
1745 if (weaponarray[t].smoketrail[s].animate < smoketrailC)
1746 {
1747 matrixTemp = matrixWorld; // reset to scaled lookat matrix
1748 result.x = (float)(weaponarray[t].precisionx - playerships[0].precisionx) - weaponarray[t].smoketrail[s].offset.x;
1749 result.y = (float)(weaponarray[t].precisiony - playerships[0].precisiony) - weaponarray[t].smoketrail[s].offset.y;
1750 result.z = (float)(weaponarray[t].precisionz - playerships[0].precisionz) - weaponarray[t].smoketrail[s].offset.z;
1751 matrixTemp._41 = -result.x;
1752 matrixTemp._42 = -result.y;
1753 matrixTemp._43 = -result.z;
1754
1755 if (playerships[0].mslKm < 63.0f)
1756 {
1757 r = (int)(192.0f * (fFogEndHorizon - RiseMath::Vec3Length(&result)) / (fFogEndHorizon - fFogStartHorizon));
1758 if (r < 0)
1759 r = 0;
1760 else if (r > 192)
1761 r = 192;
1762 }
1763 else
1764 r = 192;
1766
1767 pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &matrixTemp);
1768 pd3dDevice->SetTexture(0, m_pddsSmoke[weaponarray[t].smoketrail[s].animate]);
1769
1771 }
1772 }
1773 }
1774 }
1775
1776
1777#endif
1778 if (playerships[0].reference != REF_WINDOWLESS && !playerships[0].isSimulator && lightningbelow.inuse && !g_bAboveClouds)
1779 {
1780 Rendering::ProfileScope11 timing("Procedural lightning");
1782 V(proceduralLightning.Render(pd3dDevice->Context(),pd3dDevice->Owner().SceneTarget(),
1783 pd3dDevice->Owner().Depth(),pd3dDevice->Draws().Viewport(),matrixLook,matrixProj,
1784 -playerships[0].position,-segment.end,-segment.start,segment.seed,
1786 cloudVolumeDrawn && VolumeCloudsEnabled() ? cloudVolume.Effect() : nullptr,lightningbelow.growth));
1787 }
1788
1789
1798
1799
1800
1801
1804
1805 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLORARG2, Rendering::TextureArgument::DIFFUSE );
1806 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE );
1810
1811 // pd3dDevice->SetRenderState( Rendering::RenderState::ALPHABLENDENABLE, false );
1812 // pd3dDevice->SetFVF( RISE_FVF_VERTEX );
1813 // Weapons ----------------------------------------------------------------------------------
1814
1815
1816 // pd3dDevice->SetRenderState( Rendering::RenderState::LIGHTING, false ); // should still be false from lights.coo
1817
1818
1819
1820
1821
1822
1823 // sprintf_s(msg, sizeof(msg), "Narrow down 5" );
1824 // _write(logfile, msg, strlen(msg));
1825
1826
1827 // this takes care of the case when we are in the clouds
1828 // normally we use the windshield glass for this but in the simulator that won't work
1829 /*
1830 if (outside || playerships[0].isSimulator)
1831 {
1832 // need to impede visibility like we do with the windshield
1834 if (alphascreen.a > 0.0f)
1835 {
1836 pd3dDevice->SetFVF(RISE_FVF_SCREEN);
1837
1838 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::ALPHAOP, Rendering::TextureOperation::SELECTARG1);
1839 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::ALPHAARG1, Rendering::TextureArgument::TFACTOR);
1840 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::SELECTARG1);
1841 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TFACTOR);
1842
1843 pd3dDevice->SetRenderState(Rendering::RenderState::TEXTUREFACTOR, alphascreen);
1844
1845 pd3dDevice->SetRenderState(Rendering::RenderState::SRCBLEND, Rendering::Blend::SRCALPHA);
1846 pd3dDevice->SetRenderState(Rendering::RenderState::DESTBLEND, Rendering::Blend::INVSRCALPHA);
1847 pd3dDevice->SetRenderState(Rendering::RenderState::ALPHABLENDENABLE, true);
1848
1849 pd3dDevice->SetRenderState(Rendering::RenderState::ZFUNC, Rendering::Compare::ALWAYS);
1850 //pd3dDevice->SetRenderState( Rendering::RenderState::STENCILREF, 4); // 0 is default
1851 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILFUNC, Rendering::Compare::ALWAYS); // was always before cockpit
1852 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILPASS, Rendering::StencilOperation::KEEP); // with 2
1853
1855 RiseScreenVertex* vtxs;
1856 // tempcolor=Rendering::ColorARGB( (int)(betascreen.a*255.0f), (int)(betascreen.r*255.0f), (int)(betascreen.g*255.0f), (int)(betascreen.b*255.0f) );
1857 // Lock the vertex buffer
1858 V(m_avScreen->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
1859
1860 vtxs->x = static_cast<float>(pp->Width); vtxs->y = 0.0f; vtxs->z = 1.0f; vtxs->w = 2.0f;
1861 vtxs->diffuse = 0;
1862 vtxs++;
1863 vtxs->x = 0.0f; vtxs->y = 0.0f; vtxs->z = 1.0f; vtxs->w = 2.0f;
1864 vtxs->diffuse = 0;
1865 vtxs++;
1866 vtxs->x = static_cast<float>(pp->Width); vtxs->y = static_cast<float>(pp->Height); vtxs->z = 1.0f; vtxs->w = 2.0f;
1867 vtxs->diffuse = 0;
1868 vtxs++;
1869 vtxs->x = 0.0f; vtxs->y = static_cast<float>(pp->Height); vtxs->z = 1.0f; vtxs->w = 2.0f;
1870 vtxs->diffuse = 0;
1871
1872 V(m_avScreen->Unlock());
1873
1874
1875 pd3dDevice->SetStreamSource(0, m_avScreen, 0, sizeof RiseScreenVertex);
1876 pd3dDevice->DrawPrimitive(Rendering::Primitive::TriangleStrip, 0, 2);
1877
1878
1879 pd3dDevice->SetRenderState(Rendering::RenderState::ALPHABLENDENABLE, false);
1880 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1881 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLOROP, Rendering::TextureOperation::MODULATE);
1882 pd3dDevice->SetTextureStageState(0, Rendering::TextureState::COLORARG1, Rendering::TextureArgument::TEXTURE);
1883
1884 // pd3dDevice->SetRenderState( Rendering::RenderState::ZFUNC, Rendering::Compare::ALWAYS ); // corrected after 2nd half of condition
1885 // pd3dDevice->SetRenderState( Rendering::RenderState::STENCILFUNC, Rendering::Compare::ALWAYS ); // this is how we want it after 2nd
1886
1887 }
1888 }
1889 */
1890#pragma endregion
1891 }
1892
1893 // so outside view is done at this point
1894 UpdateNightVisionRangefinder(pd3dDevice);
1895
1896 // Switch rendertarget
1897 if (playerships[0].isSimulator)
1898 {
1899 logger->AddToCallStack("Viewscreen::OnFrameRender SIM");
1900
1902 {
1903 RECT readloc;
1904 readloc.top = readloc.left = 0;
1905 readloc.right = 1135;
1906 readloc.bottom = 388;
1908 m_pFont->DrawTextW(m_spriteVector, L"FLIGHT FREEZE", -1, &readloc, DT_CENTER | DT_VCENTER, 0xFFFFFFFF);
1910 }
1911
1912 // swap rendertargets
1913 V(m_pRenderToSurfaceNextGen->EndScene(0)); // projection screen
1914 gameclass->beginScene = 0;
1915
1916 V(pd3dDevice->BeginScene());
1917 gameclass->beginScene = 1; // prim is 1
1918
1920 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1924
1925 ptrCockpit->Render(pd3dDevice, strike);
1926 }
1927
1928 if (!dead || playerships[0].isSimulator) // need to keep drawing the windshield and freaking HUD!
1929 {
1930 logger->AddToCallStack("Viewscreen::OnFrameRender ALPHA");
1931
1932 pd3dDevice->SetFVF(RISE_FVF_VERTEX);
1933 pd3dDevice->SetStreamSource(0, polyobjects[5].VB, 0, sizeof(RiseVertexVertex));
1937
1938 if (!playerships[0].isSimulator)
1939 {
1940 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILREF, 4); // 0 is default
1944 }
1945 else
1946 {
1948 }
1949
1950
1952 {
1953 Rendering::ProfileScope11 glassTiming("Glass and cockpit HUD");
1954 // Cockpit ------------------------------------------------------------------------------------
1955 // Cloud windshield overlay and St. Elmo's fire; plasma uses the exterior envelope.
1956#pragma region Windshield1
1957 logger->AddToCallStack("Viewscreen::OnFrameRender WS1");
1958
1959
1960 RiseMath::Vector4 clouduv = RiseMath::Vector4(0, 0, 0, 0);
1961 RiseMath::Vector4 feature = RiseMath::Vector4(0, 0, 0, 0);
1962 if (alphascreen.a > 0.0f) // has to stay on for st. elmo's fire
1963 {
1964 clouduv.x = 1.0f; // mode 1 is clouds
1965 //clouduv.y = alphascreen.a; // unused
1967 V(gameclass->graphics->g_pEffect->SetVector("ambient", &ambient));
1968 }
1969
1970 if (clouduv.x > 0.0f) // has a mode
1971 {
1972 if ((ptrPropulsion->staticBuildup > 1.0f || ptrWeather->elmoOverride) && clouduv.x == 1.0f)
1973 {
1974 V(gameclass->graphics->g_pEffect->SetTexture("ColorMap2", m_pddsElmo[rand() % 4]));
1975
1976 if (ourcockpit.texturelib == VehicleType::E10 || ourcockpit.texturelib == VehicleType::E11) // E-10 or E-11 are same
1977 {
1978 if (rand() % 2 == 0)
1979 {
1980 clouduv.w = 1.0f; // St. Elmo's Fire to right
1981 feature.x = 1066.0f / 2048.0f; feature.y = 491.0f / 1024.0f;
1982 feature.z = 1326.0f / 2048.0f; feature.w = 746.0f / 1024.0f;
1983 }
1984 else
1985 {
1986 clouduv.w = -1.0f; // St. Elmo's Fire to left
1987 feature.x = 716.0f / 2048.0f; feature.y = 491.0f / 1024.0f;
1988 feature.z = 982.0f / 2048.0f; feature.w = 746.0f / 1024.0f;
1989 }
1990 }
1992 {
1993 if (rand() % 2 == 0)
1994 {
1995 clouduv.w = 1.0f; // St. Elmo's Fire to right
1996 feature.x = 48.0f / 1024.0f; feature.y = 311.0f / 1024.0f;
1997 feature.z = 208.0f / 1024.0f; feature.w = 471.0f / 1024.0f;
1998 }
1999 else
2000 {
2001 clouduv.w = -1.0f; // St. Elmo's Fire to left
2002 feature.x = 411.0f / 1024.0f; feature.y = 311.0f / 1024.0f;
2003 feature.z = 571.0f / 1024.0f; feature.w = 471.0f / 1024.0f;
2004 }
2005 }
2007 {
2008 if (rand() % 2 == 0)
2009 {
2010 clouduv.w = 1.0f; // St. Elmo's Fire to right
2011 feature.x = 1348.0f / 2048.0f; feature.y = 423.0f / 1024.0f;
2012 feature.z = 1568.0f / 2048.0f; feature.w = 642.0f / 1024.0f;
2013 }
2014 else
2015 {
2016 clouduv.w = -1.0f; // St. Elmo's Fire to left
2017 feature.x = 504.0f / 2048.0f; feature.y = 423.0f / 1024.0f;
2018 feature.z = 723.0f / 2048.0f; feature.w = 642.0f / 1024.0f;
2019 }
2020 }
2022 {
2023 if (rand() % 2 == 0)
2024 {
2025 clouduv.w = 1.0f; // St. Elmo's Fire to right
2026 feature.x = 1048.0f / 2048.0f; feature.y = 434.5f / 1024.0f;
2027 feature.z = 1303.0f / 2048.0f; feature.w = 689.5f / 1024.0f;
2028 }
2029 else
2030 {
2031 clouduv.w = -1.0f; // St. Elmo's Fire to left
2032 feature.x = 745.0f / 2048.0f; feature.y = 434.5f / 1024.0f;
2033 feature.z = 1000.0f / 2048.0f; feature.w = 689.5f / 1024.0f;
2034 }
2035 }
2037 {
2038 if (rand() % 2 == 0)
2039 {
2040 clouduv.w = 1.0f; // St. Elmo's Fire to right
2041 feature.x = 1066.0f / 2048.0f; feature.y = 491.0f / 1024.0f;
2042 feature.z = 1326.0f / 2048.0f; feature.w = 746.0f / 1024.0f;
2043 }
2044 else
2045 {
2046 clouduv.w = -1.0f; // St. Elmo's Fire to left
2047 feature.x = 746.0f / 2048.0f; feature.y = 491.0f / 1024.0f;
2048 feature.z = 1012.0f / 2048.0f; feature.w = 746.0f / 1024.0f;
2049 }
2050 }
2051
2054
2055
2056 // Features are currently only used by pass 9 for st. elmo
2057 V(gameclass->graphics->g_pEffect->SetVector("Features", &feature));
2058 }
2059
2060 V(gameclass->graphics->g_pEffect->SetVector("clouduv", &clouduv));
2061 // Transparent overlays must not occlude coplanar rain. Keep this state
2062 // out of shared TShader: its End would undo terrain's depth-write enable.
2063 DWORD overlayDepthWrites = TRUE;
2064 V(pd3dDevice->GetRenderState(Rendering::RenderState::ZWRITEENABLE, &overlayDepthWrites));
2066 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
2067 V(gameclass->graphics->g_pEffect->BeginPass(9)); // windshield
2068
2069 for (s = 0; s < ourcockpit.components; s++)
2070 {
2071 if (ourcockpit.componentarray[s].type == 5) // windshield
2072 {
2074 V(gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
2076
2078
2079 const auto drawGlass = [&]() { return pd3dDevice->DrawPrimitive(Rendering::Primitive::TriangleList,
2081 V(WindshieldRainRenderer::DrawCockpitGlass(pd3dDevice, drawGlass));
2082 adDiagnostics.RegisterOverlayDraw(*pd3dDevice, polyobjects[5].VB->Geometry(),
2084 }
2085 }
2086
2089 V(pd3dDevice->SetRenderState(Rendering::RenderState::ZWRITEENABLE, overlayDepthWrites));
2090
2092 {
2094
2095 // restore
2096 if (clouduv.x == 1.0f)
2097 {
2100 }
2101 }
2102 }
2103
2104#pragma endregion
2105 }
2106
2107
2110
2112
2113
2114 if (!camera->outside)
2115 {
2116#pragma region Windshield2
2117 logger->AddToCallStack("Viewscreen::OnFrameRender WS2");
2118
2119 // Rain and fractures share scene refraction and authored-pane visibility.
2121 if (!playerships[0].isSimulator && ourcockpit.texturelib != VehicleType::EVA_SUIT
2123 {
2124 std::vector<RiseMath::Matrix> transforms(ourcockpit.components);
2125 for (int component = 0; component < ourcockpit.components; ++component)
2126 transforms[component] = ourcockpit.componentarray[component].matWorld;
2127 const bool interiorLight = playerships[0].domelight || gameclass->GUI->player[ourcockpit.ourplyrC].frame > 0;
2128 const float wetGlassLight = interiorLight ? (gameclass->GUI->player[ourcockpit.ourplyrC].frame > 0
2129 ? 1.f : (std::clamp)(ourcockpit.power, 0.f, 1.f)) : 0.f;
2130 auto* adExclusion = adDiagnostics.WetGlassExclusionTarget();
2131 const HRESULT waterResult = windshieldRain.Render(pd3dDevice, gameclass->graphics->g_pEffect, transforms, matrixLook * matrixProjCock,
2132 WindshieldRain::AltitudeRainFactor(playerships[0].mslKm), WindshieldRainRenderer::DepthLayout::CockpitAndWorld, wetGlassLight, adExclusion);
2133 if (adExclusion)adDiagnostics.WetGlassResult(waterResult);
2134 V(waterResult);
2135 }
2136
2137 RiseMath::Vector4 radiosity = RiseMath::Vector4(0, 0, 0, 0);
2138 RiseMath::Vector4 Sunlight = RiseMath::Vector4(0, 0, 0, 0);
2139 RiseMath::Vector4 ambient = RiseMath::Vector4(0, 0, 0, 0);
2140 RiseMath::Vector4 Features = RiseMath::Vector4(0, 0, 0, 0);
2142 {
2143 // Block light from sun by Vieneo
2144 if (ptrWeather->shadow > 0.0f)
2145 {
2146 // radiosity
2147 RiseMath::Vec3Scale(&vieneohit, &Xsunlight, radiusC); // Where it hits Vieneo
2148 RiseMath::Vec3Subtract(&result, &playerships[0].position, &vieneohit); // Vector from surface point to this object
2149 RiseMath::Vec3Normalize(&result, &result);
2150 radiosity.x = result.x; radiosity.y = result.y; radiosity.z = result.z;
2151 radiosity.w = fabsf(RiseMath::Vec3Dot(&result, &Xsunlight)); // cos of angle between the two
2152 radiosity.w = 1.0f - radiosity.w; // Compliment, not comparing to surface normal ya know
2153 radiosity.w /= powf(RiseMath::Vec3Length(&playerships[0].position) / radiusC, 2.0f);
2154 if (VolumeCloudsEnabled()) radiosity.w *= ptrWeather->shadow;
2155 }
2156
2157 // Adjust diffuse by shadow
2158 Sunlight.x = -sunlight.Direction.x; Sunlight.y = -sunlight.Direction.y; Sunlight.z = -sunlight.Direction.z;
2159 Sunlight.w = ptrWeather->shadow * (VolumeCloudsEnabled() ? 1.f : 1.0f - alphascreen.a); // only ambient can get through clouds and objects
2160
2161
2162 if (VolumeCloudsEnabled() || f_ACL <= 0.150f)
2163 {
2164 const auto scattered = VolumeCloudsEnabled() ? ptrWeather->cockpitAmbient
2166 ambient.x = scattered.r;
2167 ambient.y = scattered.g;
2168 ambient.z = scattered.b;
2169 if (playerships[0].reference == REF_INANOTHER)
2171 }
2172
2173 if (playerships[0].domelight || gameclass->GUI->player[ourcockpit.ourplyrC].frame > 0)
2174 {
2175 float mod = 1.0f;
2177 mod = ourcockpit.power;
2178
2179 const auto cabinLight = CockpitLighting::LocalLight({191.0f / 255.0f * mod,
2180 181.0f / 255.0f * mod,168.0f / 255.0f * mod},ptrWeather->cockpitVision);
2181 ambient.x += cabinLight.x * (1.0f - ambient.x);
2182 ambient.y += cabinLight.y * (1.0f - ambient.y);
2183 ambient.z += cabinLight.z * (1.0f - ambient.z);
2184 }
2185 }
2186 else // BCL
2187 {
2188 // Adjust diffuse
2189 ambient.x = sunlight.Diffuse.r;
2190 ambient.y = sunlight.Diffuse.g;
2191 ambient.z = sunlight.Diffuse.b;
2192
2193 if (playerships[0].domelight || gameclass->GUI->player[ourcockpit.ourplyrC].frame > 0)
2194 {
2195 float mod = 1.0f;
2197 mod = ourcockpit.power;
2198
2199 const auto cabinLight = CockpitLighting::LocalLight({191.0f / 255.0f * mod,
2200 181.0f / 255.0f * mod,168.0f / 255.0f * mod},ptrWeather->cockpitVision);
2201 ambient.x += cabinLight.x * (1.0f - ambient.x);
2202 ambient.y += cabinLight.y * (1.0f - ambient.y);
2203 ambient.z += cabinLight.z * (1.0f - ambient.z);
2204 }
2205 }
2206
2207 if (!playerships[0].isSimulator && ourcockpit.vdat.holiday > 0)
2208 {
2209 ambient.w = static_cast<float>(ourcockpit.vdat.holiday) / 127.0f;
2211 }
2212
2213 V(gameclass->graphics->g_pEffect->SetVector("ambient", &ambient));
2214
2215 // Preserve simulator and helmet behavior where optical pane rendering is disabled.
2216 if ((playerships[0].isSimulator || ourcockpit.texturelib == VehicleType::EVA_SUIT
2218 {
2219 Features.x = 1.0f;
2220 // Reveal a fixed fracture network linearly from initial cracks to shattered glass.
2221 Features.y = (95.0f - ourcockpit.vdat.windshield) / 95.0f;
2222 }
2223
2224 V(gameclass->graphics->g_pEffect->SetVector("Features", &Features));
2225
2227
2228 V(gameclass->graphics->g_pEffect->SetVector("Radiosity", &radiosity));
2229 V(gameclass->graphics->g_pEffect->SetVector("Sunlight", &Sunlight));
2230
2231
2232 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
2233 V(gameclass->graphics->g_pEffect->BeginPass(8)); // windshield
2234
2235
2236 // Do the actual glass and dirt now, alpha blended ------------------------------
2237 for (s = 0; s < ourcockpit.components; s++)
2238 {
2239 if (ourcockpit.componentarray[s].type == 5) // windshield
2240 {
2241 //pd3dDevice->SetTransform(Rendering::TransformSlot::WORLD, &ourcockpit.componentarray[s].matWorld);
2243 V(gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
2245
2246 //pd3dDevice->SetTexture(1, m_pddsCockpitTexture[ourcockpit.componentarray[s].texture]);
2248
2250
2251 const auto drawGlass = [&]() { return pd3dDevice->DrawPrimitive(Rendering::Primitive::TriangleList,
2253 V(playerships[0].isSimulator ? drawGlass() : WindshieldRainRenderer::DrawCockpitGlass(pd3dDevice, drawGlass));
2254 adDiagnostics.RegisterOverlayDraw(*pd3dDevice, polyobjects[5].VB->Geometry(),
2256 }
2257 }
2258
2261
2262
2263#pragma endregion
2264
2266
2267
2268#pragma region HUD
2269 logger->AddToCallStack("Viewscreen::OnFrameRender HUD");
2270
2271
2272 // gray background mostly transparent in dark, mostly opaque in light
2273 V(gameclass->graphics->g_pEffect->SetVector("Radiosity", &radiosity));
2274 V(gameclass->graphics->g_pEffect->SetVector("Sunlight", &Sunlight));
2275 V(gameclass->graphics->g_pEffect->SetVector("ambient", &ambient));
2276 const RiseMath::Vector4 features = RiseMath::Vector4(ourcockpit.texturelib == EVA_SUIT ? 0.0f : 1.0f, 0, 0, 0);
2277 V(gameclass->graphics->g_pEffect->SetVector("Features", &features));
2278
2279 V(gameclass->graphics->g_pEffect->Begin(NULL, 0));
2280 V(gameclass->graphics->g_pEffect->BeginPass(13)); // hud/windshield?
2281
2282 for (s = 0; s < ourcockpit.components; s++)
2283 {
2284 if (ourcockpit.componentarray[s].type == 51 || ourcockpit.componentarray[s].type == 251) // HUDs
2285 {
2286 // If it is attached... rotate to correct orientation
2288
2289 if (ourcockpit.componentarray[s].type == 251) // HUD that moves with pitch
2290 {
2291 // Animated extensions...
2294 result -= ourcockpit.position;
2295 }
2296 else if (ourcockpit.componentarray[s].extendby.x != 0.0f ||
2297 ourcockpit.componentarray[s].extendby.y != 0.0f ||
2298 ourcockpit.componentarray[s].extendby.z != 0.0f ||
2300 {
2301 // If it is attached... move to correct location
2303
2304 // Animated rotations...
2306 matrixWorld = matrixWorld * matrixTemp;
2308 matrixWorld = matrixWorld * matrixTemp;
2309
2310 // Animated extensions...
2313 result += ourcockpit.componentarray[s].hingeCG;
2314
2315 result -= ourcockpit.position;
2316 }
2317 else
2319 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
2320 matrixWorld = matrixWorld * matrixTemp;
2321
2323 {
2324 RiseMath::MatrixRotationX(&matrixTemp, -RiseMath::HalfPi); // pitch 90 degrees... apparently are normally angled down?
2325 matrixWorld = matrixWorld * matrixTemp;
2327 // matrixWorld = matrixWorld * matrixTemp;
2328 // RiseMath::MatrixScaling(&matrixTemp, 8, 8, 8); // pitch 90 degrees... apparently are normally angled down?
2329 }
2330 else
2331 RiseMath::MatrixRotationX(&matrixTemp, RiseMath::HalfPi); // pitch 90 degrees... apparently are normally angled down?
2332 matrixWorld = matrixWorld * matrixTemp;
2333
2334 RiseMath::MatrixRotationY(&matrixTemp, RiseMath::Pi); // pitch
2335 matrixWorld = matrixWorld * matrixTemp;
2336
2337
2338 RiseMath::MatrixInverse(&matrixTemp, nullptr, &matrixView);
2339 matrixWorld = matrixWorld * matrixTemp;
2340
2341 if (ourcockpit.power >= 0.75f + 0.1f * RandomFloat() - 0.05f)
2342 {
2344 }
2345 else
2346 {
2347 V(gameclass->graphics->g_pEffect->SetTexture("ColorMap", nullptr));
2348 }
2349
2350 RiseMath::Matrix mWorldViewProj = matrixWorld * matrixLook * matrixProjCock;
2351 V(gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
2352 V(gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixWorld));
2353
2355
2357 adDiagnostics.RegisterOverlayDraw(*pd3dDevice, polyobjects[5].VB->Geometry(),
2359 }
2360 }
2361
2364
2365#pragma endregion
2366
2367
2368 // restore
2369 pd3dDevice->SetLight(0, &sunlight);
2371 if (g_bAboveClouds)
2372 {
2373 // Restore
2374 if (ptrWeather->shadow > 0.0f)
2375 pd3dDevice->LightEnable(2, false);
2376 }
2377
2380 // --- End of Cockpit --------------------------------------
2381 }
2382
2383 if (playerships[0].isSimulator)
2385 else
2388
2389#pragma region Inventory View Overlay
2392 {
2393 logger->AddToCallStack("Viewscreen::OnFrameRender SHADES");
2394
2397 V(m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
2398
2399 vtxs->x = static_cast<float>(pp->Width); vtxs->y = 0.0f; vtxs->z = 0.0f; vtxs->w = 1.0f;
2400 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
2401 vtxs++;
2402 vtxs->x = 0.0f; vtxs->y = 0.0f; vtxs->z = 0.0f; vtxs->w = 1.0f;
2403 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
2404 vtxs++;
2405 vtxs->x = static_cast<float>(pp->Width); vtxs->y = static_cast<float>(pp->Height); vtxs->z = 0.0f; vtxs->w = 1.0f;
2406 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
2407 vtxs++;
2408 vtxs->x = 0.0f; vtxs->y = static_cast<float>(pp->Height); vtxs->z = 0.0f; vtxs->w = 1.0f;
2409 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
2410
2412
2413 V(pd3dDevice->SetFVF(RISE_FVF_INSTRUMENT));
2414 V(pd3dDevice->SetStreamSource(0, m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
2415
2416 V(pd3dDevice->SetTexture(0, m_pddsSunglasses));
2417
2421
2424
2426
2429 }
2430 else if (ourcockpit.inventoryItemInUseType == 1 &&
2433 {
2434 logger->AddToCallStack("Viewscreen::OnFrameRender BINOC");
2435
2438 V(m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
2439
2440 vtxs->x = static_cast<float>(pp->Width); vtxs->y = 0.0f; vtxs->z = 0.0f; vtxs->w = 1.0f;
2441 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
2442 vtxs++;
2443 vtxs->x = -1.0f; vtxs->y = 0.0f; vtxs->z = 0.0f; vtxs->w = 1.0f;
2444 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
2445 vtxs++;
2446 vtxs->x = static_cast<float>(pp->Width); vtxs->y = static_cast<float>(pp->Height); vtxs->z = 0.0f; vtxs->w = 1.0f;
2447 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
2448 vtxs++;
2449 vtxs->x = -1.0f; vtxs->y = static_cast<float>(pp->Height); vtxs->z = 0.0f; vtxs->w = 1.0f;
2450 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
2451 vtxs++;
2452
2453 const float stripOffset = lookhdg / 360.0f + 0.05f;
2454 vtxs->x = static_cast<float>(pp->Width) * 0.7f; vtxs->y = static_cast<float>(pp->Height) * 0.021f; vtxs->z = 0.0f; vtxs->w = 1.0f; // top right
2455 vtxs->tu = 0.78f + stripOffset; vtxs->tv = 0.0f;
2456 vtxs++;
2457 vtxs->x = static_cast<float>(pp->Width) * 0.3f; vtxs->y = static_cast<float>(pp->Height) * 0.021f; vtxs->z = 0.0f; vtxs->w = 1.0f; // top left
2458 vtxs->tu = 0.0f + stripOffset; vtxs->tv = 0.0f;
2459 vtxs++;
2460 vtxs->x = static_cast<float>(pp->Width) * 0.7f; vtxs->y = static_cast<float>(pp->Height) * 0.061f; vtxs->z = 0.0f; vtxs->w = 1.0f; // lower right
2461 vtxs->tu = 0.78f + stripOffset; vtxs->tv = 1.0f;
2462 vtxs++;
2463 vtxs->x = static_cast<float>(pp->Width) * 0.3f; vtxs->y = static_cast<float>(pp->Height) * 0.061f; vtxs->z = 0.0f; vtxs->w = 1.0f; // lower left
2464 vtxs->tu = 0.0f + stripOffset; vtxs->tv = 1.0f;
2465 vtxs++;
2466
2467 const float arrowOffset = (lookAzimuthDegrees / 90.0f * 244.0f + 511.0f) * static_cast<float>(pp->Height) / 1024.0f;
2468 const float arrowHeight = static_cast<float>(pp->Height) / 1024.0f * 32.0f;
2469 vtxs->x = static_cast<float>(pp->Width) * 0.029f; vtxs->y = arrowOffset; vtxs->z = 0.0f; vtxs->w = 1.0f; // top right
2470 vtxs->tu = 0.9f; vtxs->tv = 0.0f;
2471 vtxs++;
2472 vtxs->x = static_cast<float>(pp->Width) * 0.019f; vtxs->y = arrowOffset; vtxs->z = 0.0f; vtxs->w = 1.0f; // top left
2473 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
2474 vtxs++;
2475 vtxs->x = static_cast<float>(pp->Width) * 0.029f; vtxs->y = arrowOffset + arrowHeight; vtxs->z = 0.0f; vtxs->w = 1.0f; // lower right
2476 vtxs->tu = 0.9f; vtxs->tv = 1.0f;
2477 vtxs++;
2478 vtxs->x = static_cast<float>(pp->Width) * 0.019f; vtxs->y = arrowOffset + arrowHeight; vtxs->z = 0.0f; vtxs->w = 1.0f; // lower left
2479 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
2480 vtxs++;
2481
2483
2484 V(pd3dDevice->SetFVF(RISE_FVF_INSTRUMENT));
2485 V(pd3dDevice->SetStreamSource(0, m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
2486
2487 const bool usingNightVision = ourcockpit.inventoryItemInUseSubType == KitType::NightVision;
2488
2492
2498
2499 if (usingNightVision && nightVisionOverexposure > 0.0f)
2500 {
2501 DWORD oldTextureFactor = 0;
2502 V(pd3dDevice->GetRenderState(Rendering::RenderState::TEXTUREFACTOR, &oldTextureFactor));
2503 const unsigned char flashAlpha = static_cast<unsigned char>(
2504 255.0f * Clamp(powf(nightVisionOverexposure, 0.65f), 0.0f, 0.98f));
2505
2506 V(pd3dDevice->SetTexture(0, nullptr));
2507 V(pd3dDevice->SetRenderState(Rendering::RenderState::TEXTUREFACTOR, Rendering::ColorARGB(flashAlpha, 242, 252, 255)));
2513 V(pd3dDevice->SetRenderState(Rendering::RenderState::TEXTUREFACTOR, oldTextureFactor));
2514 }
2515
2516 V(pd3dDevice->SetTexture(0, usingNightVision ? m_pddsNightVision : m_pddsBinoculars));
2518
2519 V(pd3dDevice->SetTexture(0, usingNightVision ? m_pddsNightVisionCompass : m_pddsBinocularsCompass));
2521
2522 V(pd3dDevice->SetTexture(0, usingNightVision ? m_pddsNightVisionArrow : m_pddsBinocularsArrow));
2524
2525 if (usingNightVision)
2526 {
2527 char rangeText[32];
2528 if (m_nightVisionRangeKm < 0.0f)
2529 sprintf_s(rangeText, sizeof(rangeText), "RNG ---");
2530 else if (m_nightVisionRangeKm < 1.0f)
2531 sprintf_s(rangeText, sizeof(rangeText), "RNG %.0f m", m_nightVisionRangeKm * 1000.0f);
2532 else if (m_nightVisionRangeKm < 100.0f)
2533 sprintf_s(rangeText, sizeof(rangeText), "RNG %.2f km", m_nightVisionRangeKm);
2534 else
2535 sprintf_s(rangeText, sizeof(rangeText), "RNG %.1f km", m_nightVisionRangeKm);
2536
2537 RECT readloc = {};
2538 readloc.top = static_cast<LONG>(static_cast<float>(pp->Height) * 0.55f);
2539 readloc.right = static_cast<LONG>(pp->Width);
2540 readloc.bottom = readloc.top + 32;
2542 m_pFontHull->DrawTextA(m_spriteVector, rangeText, -1, &readloc, DT_CENTER | DT_VCENTER, 0xFF30F5DC);
2544 }
2545
2548 }
2549
2550#pragma endregion
2551
2552 // for sun flare effects that come into the cockpit
2553 const bool sunglassesEffectsEnabled = InventoryItemEffectsEnabled() &&
2555 if (ptrWeather->betascreen > 0.0f && !sunglassesEffectsEnabled)
2556 {
2557 logger->AddToCallStack("Viewscreen::OnFrameRender BETA");
2558
2559 // Screen
2560 pd3dDevice->SetFVF(RISE_FVF_SCREEN);
2561
2572 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILFUNC, Rendering::Compare::ALWAYS); // was always before cockpit
2574
2575
2576 RiseScreenVertex* vtxs;
2578 // Lock the vertex buffer
2579 V(m_avScreen->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
2580
2581 vtxs->x = static_cast<float>(pp->Width); vtxs->y = 0.0f; vtxs->z = 1.0f; vtxs->w = 2.0f;
2582 vtxs->diffuse = ptrWeather->betascreen;
2583 vtxs++;
2584 vtxs->x = 0.0f; vtxs->y = 0.0f; vtxs->z = 1.0f; vtxs->w = 2.0f;
2585 vtxs->diffuse = ptrWeather->betascreen;
2586 vtxs++;
2587 vtxs->x = static_cast<float>(pp->Width); vtxs->y = (float)pp->Height; vtxs->z = 1.0f; vtxs->w = 2.0f;
2588 vtxs->diffuse = ptrWeather->betascreen;
2589 vtxs++;
2590 vtxs->x = 0.0f; vtxs->y = (float)pp->Height; vtxs->z = 1.0f; vtxs->w = 2.0f;
2591 vtxs->diffuse = ptrWeather->betascreen;
2592
2593 V(m_avScreen->Unlock());
2594
2595
2596 V(pd3dDevice->SetStreamSource(0, m_avScreen, 0, sizeof(RiseScreenVertex)));
2598
2603 V(pd3dDevice->SetFVF(RISE_FVF_VERTEX));
2605 // Screen
2606 }
2607
2608 } // !dead or isSimulator
2609
2610 // A retinal imprint is fixed in screen space, including when the camera
2611 // moves. Composite after the world/optics and before separate instrument/UI draws.
2612 {
2613 Rendering::ProfileScope11 timing("Lightning afterimage");
2614 V(proceduralLightning.CompositeAfterimage(pd3dDevice->Context(),pd3dDevice->Owner().SceneTarget(),
2615 pd3dDevice->Owner().Depth(),pd3dDevice->Draws().Viewport()));
2616 }
2617
2618 //V( pd3dDevice->EndScene() ); do not end scene here
2619
2620 logger->AddToCallStack("Viewscreen::OnFrameRender END");
2621}
2622
2624{
2625 const bool enabled = !dead && InventoryItemEffectsEnabled() &&
2629
2630 if (!enabled)
2631 {
2633 m_nightVisionRangeKm = -1.0f;
2634 return;
2635 }
2636
2638 {
2640 {
2641 DWORD discardedPixels = 0;
2642 if (m_pNightVisionRangeQuery->GetData(&discardedPixels, sizeof(discardedPixels), 0) == S_FALSE)
2643 return;
2645 }
2646
2650 m_nightVisionRangeKm = -1.0f;
2651 }
2652
2654 {
2655 DWORD visiblePixels = 0;
2656 const HRESULT result = m_pNightVisionRangeQuery->GetData(&visiblePixels, sizeof(visiblePixels), 0);
2657 if (result == S_FALSE)
2658 return;
2659
2661 if (FAILED(result))
2662 {
2663 m_nightVisionRangeKm = -1.0f;
2664 return;
2665 }
2666
2667 // A test point that passes the world depth test is still in front of the surface.
2668 if (visiblePixels > 0)
2670 else
2672
2674 {
2675 const bool noWorldHit = m_nightVisionRangeLowKm > farplaneC * 0.95f;
2676 m_nightVisionRangeKm = noWorldHit ? -1.0f : m_nightVisionRangeHighKm;
2679 }
2680 }
2681
2682 // Bisect in logarithmic distance so nearby and distant targets converge equally fast.
2684
2685 Rendering::Viewport viewport = {};
2686 if (FAILED(pd3dDevice->GetViewport(&viewport)))
2687 return;
2688
2689 RiseMath::Matrix identity;
2690 RiseMath::MatrixIdentity(&identity);
2691 const RiseMath::Vector3 viewPoint(0.0f, 0.0f, -m_nightVisionRangeTestKm);
2692 RiseMath::Vector3 projectedPoint;
2694 RiseMath::Vec3Project(&projectedPoint, &viewPoint, &viewport, &projection, &identity, &identity);
2695
2696 struct RangePoint
2697 {
2698 float x, y, z, rhw;
2699 };
2700 const RangePoint point = { projectedPoint.x, projectedPoint.y, projectedPoint.z, 1.0f };
2701
2702 DWORD oldColorWrite = 0, oldZWrite = 0, oldStencilEnable = 0;
2703 DWORD oldZEnable = 0, oldZFunc = 0, oldLighting = 0, oldFvf = 0;
2704 pd3dDevice->GetRenderState(Rendering::RenderState::COLORWRITEENABLE, &oldColorWrite);
2706 pd3dDevice->GetRenderState(Rendering::RenderState::STENCILENABLE, &oldStencilEnable);
2707 pd3dDevice->GetRenderState(Rendering::RenderState::ZENABLE, &oldZEnable);
2708 pd3dDevice->GetRenderState(Rendering::RenderState::ZFUNC, &oldZFunc);
2709 pd3dDevice->GetRenderState(Rendering::RenderState::LIGHTING, &oldLighting);
2710 pd3dDevice->GetFVF(&oldFvf);
2711
2719
2720 m_pNightVisionRangeQuery->Issue(2);
2721 pd3dDevice->DrawPrimitiveUP(Rendering::Primitive::PointList, 1, &point, sizeof(point));
2722 m_pNightVisionRangeQuery->Issue(1);
2724
2725 pd3dDevice->SetFVF(oldFvf);
2726 pd3dDevice->SetRenderState(Rendering::RenderState::LIGHTING, oldLighting);
2727 pd3dDevice->SetRenderState(Rendering::RenderState::ZFUNC, oldZFunc);
2728 pd3dDevice->SetRenderState(Rendering::RenderState::ZENABLE, oldZEnable);
2729 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILENABLE, oldStencilEnable);
2731 pd3dDevice->SetRenderState(Rendering::RenderState::COLORWRITEENABLE, oldColorWrite);
2732}
2733
2734void Viewscreen::OnFrameRender2(Rendering::RenderDevice* pd3dDevice, float fElapsedTime)
2735{
2736 Rendering::ProfileScope11 timing("Dynamic textures total");
2737 logger->AddToCallStack("Viewscreen::OnFrameRender2");
2738
2739 if (!dead || playerships[0].isSimulator)
2740 {
2741#pragma region Instrumentation
2742 // sprintf_s(msg, sizeof(msg), "Narrow down 7" );
2743 // _write(logfile, msg, strlen(msg));
2744 if (advanceframe)
2745 {
2746 Rendering::ProfileScope11 timing("Instrument display textures");
2747 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILENABLE, false); // was always before cockpit
2748 pd3dDevice->SetRenderState(Rendering::RenderState::ZENABLE, false); // was always before cockpit
2749
2750 HRESULT hr;
2751 if (ourcockpit.nextgen)
2752 {
2754 gameclass->beginScene = 3; // nextgen is 3
2755 }
2756 else
2757 {
2759 gameclass->beginScene = 4; // monitor is 4
2760 }
2761
2762 V(pd3dDevice->Clear(0, nullptr, Rendering::ClearFlags::TARGET, 0L, 1.0f, 0));
2763
2764 { Rendering::ProfileScope11 displayTiming("Cockpit display rendering"); gameclass->displays->Render(); }
2765
2767 if (gameclass->GUI->player[ourcockpit.ourplyrC].frame == 0) // in a vehicle
2768 {
2769 Rendering::ProfileScope11 instrumentTiming("Cockpit instrument rendering"); ptrInstruments->Draw(fElapsedTime, pd3dDevice);
2770 }
2771
2772 if (ourcockpit.nextgen)
2773 {
2775 }
2776 else
2777 {
2779 }
2780 gameclass->beginScene = 0;
2781
2782 pd3dDevice->SetRenderState(Rendering::RenderState::ZENABLE, true); // was always before cockpit
2783 pd3dDevice->SetRenderState(Rendering::RenderState::STENCILENABLE, true); // was always before cockpit
2784 }
2785#pragma endregion
2786
2787 PrepareHullTextures(pd3dDevice);
2788 }
2789
2790 logger->AddToCallStack("Viewscreen::OnFrameRender2 END");
2791}
2792
2794{
2795 Rendering::ProfileScope11 timing("Vehicle label preparation");
2796 unsigned created = 0;
2797 bool pending = false;
2798
2799
2800 for (short t = 0; t < MAX_SCAN; t++)
2801 {
2802 if (playerships[t].active && playerships[t].visible &&
2804 (playerships[t].type == VehicleType::E10 || playerships[t].type == VehicleType::E11 ||
2806 playerships[t].type == VehicleType::DIHV ||
2811 {
2813 {
2814 if (created >= budget) { pending = true; continue; }
2815 ++created;
2816 HRESULT hr;
2817 const auto mode = *Rendering::ClientBackBufferDescription();
2818
2819 if (FAILED(hr = Rendering::CreateTexture(pd3dDevice, 256, 128, 1, Rendering::BufferUsage::RENDERTARGET,
2821 {
2822 sprintf_s(msg, sizeof msg, "Render::OnFrameRender2 failed to create m_pddsHullDynamicTexture: %S", Rendering::ErrorString(hr));
2824 // Allocation failure leaves a null texture. Stop dynamic work;
2825 // Present can then route device loss through normal recovery.
2826 return false;
2827 }
2828 else
2829 {
2830 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", t);
2832 }
2833
2834 Rendering::RenderSurface* m_pddsHullDynamicSurface = nullptr;
2835 if (FAILED(hr = m_pddsHullDynamicTexture[t]->GetSurfaceLevel(0, &m_pddsHullDynamicSurface)))
2836 {
2837 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 failed to get m_pddsHullDynamicSurface: %S", Rendering::ErrorString(hr));
2840 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", t);
2842 return false;
2843 }
2844 else
2845 gameclass->AddTrackedResource("m_pddsHullDynamicSurface", Rendering::ResourcePool::Device);
2846
2847 // and dynamic texture
2848 if (FAILED(hr = m_pHullRender2Surface->BeginScene(m_pddsHullDynamicSurface, NULL)))
2849 {
2850 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 could not begin scene for nameplate: %S", Rendering::ErrorString(hr));
2852 SAFE_RELEASE(m_pddsHullDynamicSurface);
2853 gameclass->UpdateTrackedResource("m_pddsHullDynamicSurface", 3);
2855 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", t);
2857 return false;
2858 }
2859 else
2860 gameclass->beginScene = 5; // hull is 5
2861 pd3dDevice->Clear(0, nullptr, Rendering::ClearFlags::TARGET, 0xFF000000, 1.0f, 0);
2862
2863 char hulltext[99];
2864 float arcpos;
2865 RiseMath::Vector3 letterpos;
2866 RECT readloc;
2867 RiseMath::Matrix matrixWorld, matrixTemp;
2868
2869 // this is what was jacking up the W-6 hull plate ... only a problem on first render because someone wasn't cleaning this SetTransform up
2870 RiseMath::MatrixIdentity(&matrixWorld);
2871 m_spriteVector->SetTransform(&matrixWorld);
2872
2873 if (playerships[t].type == VehicleType::E10 || playerships[t].type == VehicleType::E11)
2874 {
2875 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].hullname);
2876 logger->Log(msg);
2877
2878 // For if the letters overlap
2882
2884
2885 float arcwidth;
2886 if (playerships[t].hullname[0] != 0)
2887 {
2888 sprintf_s(hulltext, sizeof(hulltext), "USV");
2889 const short hulltextLen = static_cast<short>(strlen(hulltext));
2890 arcwidth = static_cast<float>(hulltextLen) * 6.4f;
2891 arcpos = -arcwidth * 0.5f;
2892 for (short s = 0; s < hulltextLen; s++)
2893 {
2894 letterpos.x = sinf(RiseMath::ToRadian(arcpos)) * 122.0f + 74.0f;
2895 letterpos.y = cosf(RiseMath::ToRadian(arcpos)) * 122.0f - 52.0f;
2896 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
2897 RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
2898 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
2899 RiseMath::MatrixScaling(&matrixTemp, 0.5f, 0.5f, 1.0f);
2900 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
2901 m_spriteVector->SetTransform(&matrixWorld);
2902 readloc.left = FontOffset(hulltext[s]);
2903 readloc.right = readloc.left + 23;
2904 readloc.top = 0;
2905 readloc.bottom = 12;
2906
2907 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, 0xFFFFFFFF);
2908
2909 arcpos += 6.4f;
2910 }
2911
2912 // single line
2913 if (strlen(playerships[t].hullname) <= 10)
2914 {
2915 strcpy_s(hulltext, sizeof(hulltext), playerships[t].hullname);
2916 const short hulltextLen2 = static_cast<short>(strlen(hulltext));
2917 arcwidth = static_cast<float>(hulltextLen2) * 6.4f;
2918 arcpos = -arcwidth * 0.5f;
2919 for (short s = 0; s < hulltextLen2; s++)
2920 {
2921 letterpos.x = sinf(RiseMath::ToRadian(arcpos)) * 122.0f + 70.0f;
2922 letterpos.y = cosf(RiseMath::ToRadian(arcpos)) * 122.0f - 38.5f;
2923 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
2924 RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
2925 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
2926 m_spriteVector->SetTransform(&matrixWorld);
2927 readloc.left = FontOffset(hulltext[s]);
2928 readloc.right = readloc.left + 23;
2929 readloc.top = 0;
2930 readloc.bottom = 12;
2931
2932 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, 0xFFFFFFFF);
2933
2934 arcpos += 6.4f;
2935 }
2936 }
2937 short lastspace = -1;
2938 if (strlen(playerships[t].hullname) > 10)
2939 {
2940 const short hullnameLen = static_cast<short>(strlen(playerships[t].hullname));
2941 for (short s = 0; s < hullnameLen; s++)
2942 {
2943 if (playerships[t].hullname[s] == 32)
2944 {
2945 lastspace = s;
2946 break;
2947 }
2948 }
2949 }
2950 if (lastspace != -1)
2951 {
2952 // double line
2953 strcpy_s(hulltext, sizeof(hulltext), playerships[t].hullname);
2954 hulltext[lastspace] = 0;
2955
2956 const short hulltextLen3 = static_cast<short>(strlen(hulltext));
2957 arcwidth = static_cast<float>(hulltextLen3) * 6.4f;
2958 arcpos = -arcwidth * 0.5f;
2959 for (short s = 0; s < hulltextLen3; s++)
2960 {
2961 letterpos.x = sinf(RiseMath::ToRadian(arcpos)) * 122.0f + 70.0f;
2962 letterpos.y = cosf(RiseMath::ToRadian(arcpos)) * 122.0f - 45.0f;
2963 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
2964 RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
2965 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
2966 m_spriteVector->SetTransform(&matrixWorld);
2967 readloc.left = FontOffset(hulltext[s]);
2968 readloc.right = readloc.left + 23;
2969 readloc.top = 0;
2970 readloc.bottom = 12;
2971
2972 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, 0xFFFFFFFF);
2973
2974 arcpos += 6.4f;
2975 }
2976
2977 lastspace++;
2978 {
2979 const short nameLen = static_cast<short>(strlen(playerships[t].hullname));
2980 short s;
2981 for (s = lastspace; s < nameLen; s++)
2982 hulltext[s - lastspace] = playerships[t].hullname[s];
2983 hulltext[s - lastspace] = 0;
2984 }
2985 arcwidth = static_cast<float>(hulltextLen3) * 6.4f;
2986 arcpos = -arcwidth * 0.5f;
2987 for (short s = 0; s < hulltextLen3; s++)
2988 {
2989 letterpos.x = sinf(RiseMath::ToRadian(arcpos)) * 122.0f + 70.0f;
2990 letterpos.y = cosf(RiseMath::ToRadian(arcpos)) * 122.0f - 32.0f;
2991 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
2992 RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
2993 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
2994 m_spriteVector->SetTransform(&matrixWorld);
2995 readloc.left = FontOffset(hulltext[s]);
2996 readloc.right = readloc.left + 23;
2997 readloc.top = 0;
2998 readloc.bottom = 12;
2999
3000 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, 0xFFFFFFFF);
3001
3002 arcpos += 6.4f;
3003 }
3004 }
3005 }
3006
3007 sprintf_s(hulltext, sizeof(hulltext), "IVR-%s", playerships[t].IVR);
3008 const short hulltextLen4 = static_cast<short>(strlen(hulltext));
3009 arcwidth = static_cast<float>(hulltextLen4) * 3.2f;
3010 arcpos = -arcwidth * 0.5f;
3011 for (short s = 0; s < hulltextLen4; s++)
3012 {
3013 letterpos.x = sinf(RiseMath::ToRadian(arcpos)) * 122.0f + 74.0f;
3014 letterpos.y = cosf(RiseMath::ToRadian(arcpos)) * 122.0f - 17.0f;
3015 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
3016 RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
3017 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3018 RiseMath::MatrixScaling(&matrixTemp, 0.5f, 0.5f, 1.0f);
3019 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3020 m_spriteVector->SetTransform(&matrixWorld);
3021 readloc.left = FontOffset(hulltext[s]);
3022 readloc.right = readloc.left + 23;
3023 readloc.top = 0;
3024 readloc.bottom = 12;
3025
3026 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, 0xFFFFFFFF);
3027
3028 arcpos += 3.2f;
3029 }
3030
3031 }
3032 else if (playerships[t].type == VehicleType::C98 || playerships[t].type == VehicleType::C2 ||
3034 {
3035 // For if the letters overlap
3039
3041
3042 readloc.left = 3;
3043 readloc.right = 74;
3044 readloc.bottom = 35;
3045 readloc.top = 14;
3046 if (playerships[t].hullname[0])
3047 {
3048 m_pFontLicense->DrawTextA(m_spriteVector, playerships[t].hullname, -1, &readloc, DT_CENTER, 0xFFFFFFFF);
3049 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].hullname);
3050 }
3051 else
3052 {
3053 m_pFontLicense->DrawTextA(m_spriteVector, playerships[t].IVR, -1, &readloc, DT_CENTER, 0xFFFFFFFF);
3054 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3055 }
3056 logger->Log(msg);
3057 }
3058 else if (playerships[t].type == VehicleType::W6Manx)
3059 {
3060 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].hullname);
3061 logger->Log(msg);
3062
3066
3068
3069 if (playerships[t].hullname[0] != 0)
3070 {
3071 sprintf_s(hulltext, sizeof(hulltext), "USV %s", playerships[t].hullname);
3072 _strlwr_s(hulltext, sizeof(hulltext)); // Bill's GIMPy font requires lower case letters
3073 int count = static_cast<int>(strlen(hulltext));
3074 readloc.left = 1;
3075 readloc.right = 181; // 19 in 154px so we need 24 more px
3076 readloc.top = 15;
3077 readloc.bottom = 127;
3078 m_pFontHull->DrawTextA(m_spriteVector, hulltext, count, &readloc, DT_LEFT, 0xFFFFFFFF);
3079 readloc.left = 1;
3080 readloc.right = 181;
3081 readloc.top = 85;
3082 readloc.bottom = 127;
3083 m_pFontHull->DrawTextA(m_spriteVector, hulltext, count, &readloc, DT_RIGHT, 0xFFFFFFFF);
3084 }
3085
3086 sprintf_s(hulltext, sizeof(hulltext), "IVR-%s", playerships[t].IVR);
3087 _strlwr_s(hulltext, sizeof(hulltext)); // Bill's GIMPy font requires lower case letters
3088 int count = static_cast<int>(strlen(hulltext));
3089 readloc.left = 5;
3090 readloc.right = 177;
3091 readloc.top = 35;
3092 readloc.bottom = 127;
3093 m_pFontHull->DrawTextA(m_spriteVector, hulltext, count, &readloc, DT_LEFT, 0xFFFFFFFF);
3094 readloc.left = 5;
3095 readloc.right = 177;
3096 readloc.top = 105;
3097 readloc.bottom = 127;
3098 m_pFontHull->DrawTextA(m_spriteVector, hulltext, count, &readloc, DT_RIGHT, 0xFFFFFFFF);
3099 }
3100 else if (playerships[t].type == VehicleType::DIHV)
3101 {
3102 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].hullname);
3103 logger->Log(msg);
3104
3108
3110
3111 if (playerships[t].hullname[0] != 0)
3112 {
3113 sprintf_s(hulltext, sizeof(hulltext), "%s", playerships[t].hullname);
3114 _strlwr_s(hulltext, sizeof(hulltext));
3115 readloc.left = 0;
3116 readloc.right = 156;
3117 readloc.top = 7;
3118 readloc.bottom = 30;
3119 m_pFontHull->DrawText(m_spriteVector, L"usv", -1, &readloc, DT_CENTER, 0xFF000000);
3120 readloc.left = 0;
3121 readloc.right = 156;
3122 readloc.top = 16;
3123 readloc.bottom = 100;
3124 m_pFontLicense->DrawTextA(m_spriteVector, hulltext, -1, &readloc, DT_CENTER, 0xFF000000);
3125 }
3126
3127 sprintf_s(hulltext, sizeof(hulltext), "IVR %s", playerships[t].IVR);
3128 _strlwr_s(hulltext, sizeof(hulltext));
3129 readloc.left = 0;
3130 readloc.right = 156;
3131 readloc.top = 44;
3132 readloc.bottom = 54;
3133 m_pFontHull->DrawTextA(m_spriteVector, hulltext, -1, &readloc, DT_CENTER, 0xFF000000);
3134 }
3135 else if (playerships[t].type == VehicleType::ARJ_FUEL)
3136 {
3137 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3138 logger->Log(msg);
3139
3143
3145
3146 readloc.left = 3;
3147 readloc.right = 64;
3148 readloc.top = 3;
3149 readloc.bottom = 14;
3150 m_pFontHull->DrawTextA(m_spriteVector, playerships[t].IVR, -1, &readloc, DT_LEFT, 0xFFFFFFFF);
3151 }
3152 else if (playerships[t].type == VehicleType::ARJ_PAX)
3153 {
3154 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3155 logger->Log(msg);
3156
3160
3162
3163 readloc.left = 57;
3164 readloc.right = 160;
3165 readloc.top = 0;
3166 readloc.bottom = 28;
3167 m_pFontLicense->DrawTextA(m_spriteVector, playerships[t].IVR, -1, &readloc, DT_CENTER | DT_VCENTER, 0xFFFFFFFF);
3168 }
3170 {
3171 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3172 logger->Log(msg);
3173
3177
3179
3180 readloc.left = 72;
3181 readloc.right = 133;
3182 readloc.top = 107;
3183 readloc.bottom = 118;
3184 m_pFontHull->DrawTextA(m_spriteVector, playerships[t].IVR, -1, &readloc, DT_LEFT, 0xFFFFFFFF);
3185 }
3186 else if (playerships[t].type == VehicleType::ARJ_MUNITIONS)
3187 {
3188 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3189 logger->Log(msg);
3190
3194
3196
3197 // this gets applied for type 15
3198 readloc.left = 152;
3199 readloc.right = 255;
3200 readloc.top = 1;
3201 readloc.bottom = 53;
3202 m_pFontLicense->DrawTextA(m_spriteVector, playerships[t].IVR, -1, &readloc, DT_CENTER | DT_VCENTER, 0xFFFFFFFF);
3203 }
3204 else if (playerships[t].type == VehicleType::T19)
3205 {
3206 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].IVR);
3207 logger->Log(msg);
3208
3212
3214
3215 sprintf_s(hulltext, sizeof(hulltext), "IVR %s", playerships[t].IVR);
3216 _strlwr_s(hulltext, sizeof(hulltext));
3217 readloc.left = 147;
3218 readloc.right = 255;
3219 readloc.top = 115;
3220 readloc.bottom = 127;
3221 m_pFontHull->DrawTextA(m_spriteVector, hulltext, -1, &readloc, DT_CENTER, 0xFFFFFFFF);
3222 }
3223 else if (playerships[t].type == VehicleType::T27)
3224 {
3225 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 creating m_pddsHullDynamicTexture slot %i (IVR-%s): %s", t, playerships[t].IVR, playerships[t].hullname);
3226 logger->Log(msg);
3227
3228 // For if the letters overlap
3232
3234
3235 char topline[99], botline[99];
3236 strcpy_s(topline, 99, playerships[t].hullname);
3237 const short toplineLen = static_cast<short>(strlen(topline));
3238 for (short s = 0; s < toplineLen; s++)
3239 {
3240 if (topline[s] == ' ')
3241 {
3242 strcpy_s(botline, 99, &topline[s + 1]);
3243 topline[s] = 0;
3244 break;
3245 }
3246 if (topline[s] == 0)
3247 {
3248 botline[0] = 0;
3249 break;
3250 }
3251 }
3252
3253 RiseMath::Vector3 center;
3254 center.x = 23.0f * 0.5f;
3255 center.y = 12.0f * 0.5f;
3256 center.z = 0.0f;
3257 for (short s = 0; s < toplineLen; s++)
3258 {
3259 readloc.left = FontOffset(topline[s]);
3260 readloc.right = readloc.left + 23;
3261 readloc.top = 0;
3262 readloc.bottom = 12;
3263
3264 letterpos.x = 128.0f - 10.0f - toplineLen * 11.0f + s * 11.0f; // right justified
3265 letterpos.y = 5.5f;
3266 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
3267 RiseMath::MatrixScaling(&matrixTemp, 0.8f, 1.6f, 1.0f);
3268 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3269 m_spriteVector->SetTransform(&matrixWorld);
3270
3271 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, playerships[t].trimcolor);
3272
3273 letterpos.x = 61.0f + s * 11.0f; // left justified
3274 letterpos.y = 45.5f;
3275 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
3276 RiseMath::MatrixScaling(&matrixTemp, 0.8f, 1.6f, 1.0f);
3277 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3278 m_spriteVector->SetTransform(&matrixWorld);
3279
3280 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, playerships[t].trimcolor);
3281 }
3282
3283 const short botlineLen = static_cast<short>(strlen(botline));
3284 for (short s = 0; s < botlineLen; s++)
3285 {
3286 readloc.left = FontOffset(botline[s]);
3287 readloc.right = readloc.left + 23;
3288 readloc.top = 0;
3289 readloc.bottom = 12;
3290
3291 letterpos.x = 128.0f - 7.0f - botlineLen * 4.2f + s * 4.2f; // right justified
3292 letterpos.y = 26.5f;
3293 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
3294 //RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
3295 //RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3296 RiseMath::MatrixScaling(&matrixTemp, 0.3f, 0.6f, 1.0f);
3297 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3298 m_spriteVector->SetTransform(&matrixWorld);
3299
3300 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, playerships[t].trimcolor);
3301
3302 letterpos.x = 63.0f + s * 4.2f; // left justified
3303 letterpos.y = 66.5f;
3304 RiseMath::MatrixTranslation(&matrixWorld, letterpos.x, letterpos.y, 0.0f);
3305 //RiseMath::MatrixRotationZ(&matrixTemp, -RiseMath::ToRadian(arcpos + 3.25f));
3306 //RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3307 RiseMath::MatrixScaling(&matrixTemp, 0.3f, 0.6f, 1.0f);
3308 RiseMath::MatrixMultiply(&matrixWorld, &matrixTemp, &matrixWorld);
3309 m_spriteVector->SetTransform(&matrixWorld);
3310
3311 m_spriteVector->Draw(m_pddsLetters, &readloc, nullptr, nullptr, playerships[t].trimcolor);
3312 }
3313 }
3314
3316
3318
3319 RiseMath::MatrixIdentity(&matrixWorld);
3320 m_spriteVector->SetTransform(&matrixWorld);
3322 gameclass->beginScene = 0;
3323
3324 //sprintf_s(msg, sizeof(msg), "hull-%s.bmp", playerships[t].IVR);
3325 //Rendering::SaveSurfaceToFileA(msg, Rendering::ImageFile::BMP, m_pddsHullDynamicSurface, NULL, NULL);
3326
3327 SAFE_RELEASE(m_pddsHullDynamicSurface);
3328 gameclass->UpdateTrackedResource("m_pddsHullDynamicSurface", 3);
3329
3330 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 m_pddsHullDynamicTexture finished!");
3331 logger->Log(msg);
3332 } // NULL texture
3333 }
3334 else if (m_pddsHullDynamicTexture[t] != nullptr) // ineligible ship with a texture assigned
3335 {
3336 sprintf_s(msg, sizeof(msg), "Render::OnFrameRender2 released m_pddsHullDynamicTexture slot %i!", t);
3337 logger->Log(msg);
3339 sprintf_s(msg, sizeof(msg), "m_pddsHullDynamicTexture[%i]", t);
3341 }
3342 }
3343
3344 return !pending;
3345}
#define SAFE_RELEASE(value)
#define V(expression)
SCRIPT_CONTROL SCRIPT_STATE const void int
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
float RandomFloat()
constexpr auto Clamp(T1 val, T2 min, T3 max)
@ 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
@ 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
@ DIHV
Definition ServerTypes.h:62
@ A4
Definition ServerTypes.h:65
@ T121
Definition ServerTypes.h:89
@ ARJ_CARGOTOP
Definition ServerTypes.h:74
#define MAX_WEAPONS
#define MAX_SCAN
@ Binoculars
@ NightVision
@ Sunglasses
const RiseMath::Vector3 centerC
@ REF_BUILDING
Definition ServerTypes.h:46
@ REF_INANOTHER
Definition ServerTypes.h:45
@ REF_WINDOWLESS
Definition ServerTypes.h:50
bool FlightFreeze
Definition Bus.h:474
float VerticalSpeedKms
Definition Bus.h:451
bool HasAnimatedArtwork() const
HRESULT RenderRain(Rendering::RenderDevice *device, const RiseMath::Matrix &world, UINT drops)
void SetLocalLightning(const RiseMath::Vector3 &position, const RiseMath::Color &color, float radius)
static constexpr unsigned MaxHeadlights
void SetHeadlights(const std::vector< Headlight > &lights)
Rendering::CloudRenderer11 * Effect()
HRESULT RenderSkyRing(Rendering::RenderDevice *device, Rendering::RenderTexture *atmosphere, Rendering::RenderBuffer *vertices, const RiseMath::Matrix &world, UINT segments, float physicalScale=1)
HRESULT Render(Rendering::RenderDevice *device, const RiseMath::Matrix &view, const RiseMath::Matrix &projection, const RiseMath::Vector3 &eye, const CloudVolume::Parameters &parameters, const RiseMath::Vector3 &sunlight, const RiseMath::Color &light, const RiseMath::Color &ambient, const RiseMath::Color &airglow=RiseMath::Color(.125f,.375f,.25f, 1), const RiseMath::Vector4 &horizon=RiseMath::Vector4(0, 0, 0, 0), const RiseMath::Vector4 &atmosphere=RiseMath::Vector4(0, 0, 0, 0), const RiseMath::Vector4 &nightVisionGain=RiseMath::Vector4(1, 1, 1, 0))
const std::string & InitializationStatus() const
void Render()
Definition Displays.cpp:570
HRESULT Render(Rendering::RenderDevice *device, Rendering::CloudRenderer11 *clouds=nullptr)
unsigned char beginScene
Definition GameClass.h:128
HRESULT InitializeGameHud()
std::unique_ptr< Bus > bus
Definition GameClass.h:108
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
void AddTrackedResource(const char *name, Rendering::ResourcePool pool=Rendering::ResourcePool::Managed)
void UpdateTrackedResource(const char *name, int status)
std::unique_ptr< Displays > displays
Definition GameClass.h:110
bool timeLapse
Definition GameClass.h:134
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
std::unique_ptr< Graphics > graphics
Definition GameClass.h:105
Rendering::RenderMaterial * g_pEffect
Definition Graphics.h:30
RejoinCountdown rejoinCountdown
Definition gui.h:1103
SPlayerData player[MAX_ONLINEPLAYERS]
Definition gui.h:1093
RiseDialog g_HUD
Definition gui.h:1031
std::wstring strings[L_ENUMERATION]
Definition gui.h:1076
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
void SendTraceFile(bool waitForDelivery=true) const
Definition Logger.cpp:207
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
bool Ready(double now) const
void SetAnimatedInventory(bool value)
void SyncPlacement(unsigned slot, uint64_t entity, const std::string &creative)
void WetGlassResult(HRESULT result)
void BeginFrame(RenderDevice &device, double now, bool eligible, const char *blocker=nullptr)
void RegisterOverlayDraw(RenderDevice &device, Geometry11 &geometry, unsigned first, unsigned count, unsigned material)
ID3D11RenderTargetView * CloudOpacityTarget() const
ID3D11RenderTargetView * WetGlassExclusionTarget() const
HRESULT CaptureScene(RenderDevice &device)
void SetAdOpacityTarget(ID3D11RenderTargetView *target)
Definition CloudPass11.h:49
void SetFogDensity(float value)
ID3D11RenderTargetView * SceneTarget() const
Definition Device11.h:68
const SceneDepth11 & Depth() const
Definition Device11.h:70
const D3D11_VIEWPORT & Viewport() const
FixedState11 & Fixed()
void Scene(int vehicle, double altitude, bool above, bool outside, int dock, int rain)
void CloudScene(bool volume, float base, float top, float density)
void FlightMotion(double verticalSpeedMps, bool valid)
static FrameProfiler11 & Get()
HRESULT CompositeAfterimage(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport)
void BeginAfterimage(double now, bool enabled, float ambient, uint64_t viewer)
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const Matrix &view, const Matrix &projection, Vector observerOrigin, Vector ground, Vector cloud, uint32_t seed, const RiseMath::Color &color, float pulse, float visibilityKm, CloudRenderer11 *atmosphere=nullptr, float growth=1.f)
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const DirectX::XMFLOAT4X4 &view, const DirectX::XMFLOAT4X4 &projection, const ReentryEnvelope::Mesh &mesh, float strength, float time, float transmission, float visibilityKm)
HRESULT Lock(UINT offset, UINT bytes, void **output, DWORD flags)
HRESULT DrawPrimitive(Primitive type, UINT first, UINT count)
HRESULT GetFVF(DWORD *value) const
HRESULT SetIndices(RenderBuffer *buffer)
HRESULT GetViewport(Viewport *value) const
DrawContext11 & Draws()
HRESULT SetStreamSource(UINT stream, RenderBuffer *buffer, UINT offset, UINT stride)
HRESULT LightEnable(DWORD index, BOOL enabled)
HRESULT GetRenderState(DWORD state, DWORD *value) const
HRESULT SetLight(DWORD index, const Light *value)
ID3D11DeviceContext * Context()
HRESULT SetRenderState(DWORD state, DWORD value)
HRESULT SetFVF(DWORD value)
HRESULT SetTransform(DWORD slot, const RiseMath::Matrix *value)
HRESULT DrawPrimitiveUP(Primitive type, UINT count, const void *vertices, UINT stride)
HRESULT Clear(DWORD count, const RECT *rectangles, DWORD flags, PackedColor color, float depth, DWORD stencil)
HRESULT SetTextureStageState(DWORD stage, DWORD state, DWORD value)
HRESULT SetTexture(DWORD stage, RenderTexture *texture)
HRESULT DrawIndexedPrimitive(Primitive type, INT baseVertex, UINT minimum, UINT vertices, UINT startIndex, UINT count)
HRESULT SetSamplerState(DWORD sampler, DWORD state, DWORD value)
INT DrawTextW(RenderSprite *sprite, const wchar_t *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
INT DrawTextA(RenderSprite *sprite, const char *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
HRESULT SetVector(const char *name, const RiseMath::Vector4 *value)
HRESULT SetIntArray(const char *name, const int *value, UINT count)
HRESULT Begin(UINT *count, DWORD flags)
HRESULT BeginPass(UINT pass)
HRESULT SetTexture(const char *name, RenderTexture *value)
HRESULT SetMatrix(const char *name, const RiseMath::Matrix *value)
HRESULT Issue(DWORD flags)
HRESULT GetData(void *destination, DWORD bytes, DWORD flags)
HRESULT Begin(DWORD flags)
HRESULT SetTransform(const RiseMath::Matrix *value)
HRESULT Draw(RenderTexture *image, const RECT *rectangle, const RiseMath::Vector3 *center, const RiseMath::Vector3 *position, PackedColor color)
HRESULT EndScene(DWORD filter)
HRESULT BeginScene(RenderSurface *surface, const Viewport *viewport)
virtual void SetVisible(bool bVisible)
Definition Controls.h:583
virtual void SetEnabled(bool bEnabled)
Definition Controls.h:575
RiseStatic * GetStatic(int ID)
Definition Controls.h:172
RiseButton * GetButton(int ID)
Definition Controls.h:176
HRESULT SetText(LPCWSTR strText)
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
Rendering::RenderFont * m_pFontLicense
Definition Viewscreen.h:130
Rendering::RenderQuery * m_pNightVisionRangeQuery
Definition Viewscreen.h:352
Rendering::ProceduralLightning11 proceduralLightning
Definition Viewscreen.h:397
RiseMath::Vector3 position
Definition Viewscreen.h:382
void EnableLandingLights() const
Definition framemove.cpp:17
Rendering::RenderTexture * m_pddsHullDynamicTexture[MAX_SCAN]
Definition Viewscreen.h:320
float lookAzimuthDegrees
Definition Viewscreen.h:369
Rendering::RenderBuffer * m_avInstrument
Definition Viewscreen.h:229
double cloudprecisiony
Definition Viewscreen.h:371
Rendering::RenderTexture * m_pddsFirework2[firework2C]
Definition Viewscreen.h:255
std::unique_ptr< renderer > ptrRenderer
Definition Viewscreen.h:433
RiseMath::Matrix matrixProjSim
Definition Viewscreen.h:345
Rendering::RenderBuffer * m_avStaticStars
Definition Viewscreen.h:215
void OnFrameRender(Rendering::RenderDevice *pd3dDevice, double fTime) const
Definition render.cpp:16
Rendering::RenderBuffer * m_avSkyDome
Definition Viewscreen.h:226
char msg[199]
Definition Viewscreen.h:50
unsigned activeLandingLightCount
Definition Viewscreen.h:330
bool advanceframe
Definition Viewscreen.h:375
CloudVolumeRenderer cloudVolume
Definition Viewscreen.h:396
Rendering::RenderToTexture * m_pHullRender2Surface
Definition Viewscreen.h:318
Rendering::RenderTexture * m_pddsBinoculars
Definition Viewscreen.h:238
RiseMath::Matrix matrixProjCock
Definition Viewscreen.h:345
bool m_nightVisionRangefinderActive
Definition Viewscreen.h:354
Rendering::RenderBuffer * m_avLocalGrid
Definition Viewscreen.h:222
Rendering::RenderBuffer * m_aiCloudGrid
Definition Viewscreen.h:219
bool m_bPsize
Definition Viewscreen.h:349
bool adWeatherMeasured
Definition Viewscreen.h:402
float pitchInput
Definition Viewscreen.h:372
float H2Ooffsetu
Definition Viewscreen.h:420
Rendering::RenderQuery * m_pLightSunVizQuery
Definition Viewscreen.h:350
Rendering::RenderToTexture * m_pRenderToSurface
Definition Viewscreen.h:316
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
std::vector< std::string > logofiles
Definition Viewscreen.h:308
bool VolumeCloudsEnabled() const
Definition Viewscreen.h:404
GameClass * gameclass
Definition Viewscreen.h:439
Rendering::RenderTexture * m_pddsCloudDetailBelow
Definition Viewscreen.h:237
RiseMath::Matrix matrixLookAdj
Definition Viewscreen.h:346
double cloudprecisionx
Definition Viewscreen.h:371
Rendering::RenderTexture * m_pddsAtmosphere
Definition Viewscreen.h:288
Rendering::RenderTexture * m_pddsNightVisionArrow
Definition Viewscreen.h:243
ReentryEnvelope::State reentryState
Definition Viewscreen.h:399
bool InventoryItemEffectsEnabled() const
Definition Viewscreen.h:169
float rolltilt
Definition Viewscreen.h:447
float m_nightVisionRangeHighKm
Definition Viewscreen.h:356
std::unique_ptr< propulsion > ptrPropulsion
Definition Viewscreen.h:432
bool m_sunVizPending
Definition Viewscreen.h:351
Rendering::RenderTexture * m_pddsWaterNormal
Definition Viewscreen.h:300
RiseMath::Matrix matrixView
Definition Viewscreen.h:346
Rendering::RenderTexture * m_pddsWorld2a1
Definition Viewscreen.h:234
Rendering::RenderTexture * m_pddsCloudDetailAbove
Definition Viewscreen.h:236
float nightVisionOverexposure
Definition Viewscreen.h:366
bool m_bDeviceSupportsVizQuery
Definition Viewscreen.h:349
RiseMath::Matrix matrixLook
Definition Viewscreen.h:346
RiseMath::Vector3 reentryWindward
Definition Viewscreen.h:400
std::unique_ptr< weather > ptrWeather
Definition Viewscreen.h:434
size_t cameraOrdinal
Definition Viewscreen.h:139
RiseMath::Vector3 posnorml
Definition Viewscreen.h:383
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
Rendering::RenderTexture * m_pddsBinocularsCompass
Definition Viewscreen.h:240
float lookhdg
Definition Viewscreen.h:369
void OnFrameRender2(Rendering::RenderDevice *pd3dDevice, float fElapsedTime)
Definition render.cpp:2734
Rendering::Light sunlight
Definition Viewscreen.h:328
Rendering::RenderTexture * m_pddsLetters
Definition Viewscreen.h:286
Rendering::RenderFont * m_pFontHull
Definition Viewscreen.h:132
Rendering::RenderTexture * m_pddsNightVisionCompass
Definition Viewscreen.h:242
std::unique_ptr< instruments > ptrInstruments
Definition Viewscreen.h:436
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
short dockTexture
Definition Viewscreen.h:421
CityCampaignLogos cityCampaignLogos
Definition Viewscreen.h:309
RiseMath::Color alphascreen
Definition Viewscreen.h:364
Rendering::RenderSprite * m_spriteVector
Definition Viewscreen.h:325
Rendering::RenderTexture * m_pddsCockpitTexture[cockpittextureC]
Definition Viewscreen.h:275
short BCLoffsetv
Definition Viewscreen.h:419
Rendering::RenderTexture * m_pddsLandform[landformtextureC]
Definition Viewscreen.h:298
Rendering::RenderBuffer * m_avBillboardVertices
Definition Viewscreen.h:217
short BCLoffsetu
Definition Viewscreen.h:419
void QueueCloudFallbackWarning() const
std::unique_ptr< buildings > ptrBuildings
Definition Viewscreen.h:428
long FontOffset(char letter) const
double cloudprecisionz
Definition Viewscreen.h:371
float radperseg
Definition Viewscreen.h:451
Rendering::RenderBuffer * m_avScreen
Definition Viewscreen.h:228
Rendering::RenderTexture * m_pddsSunglasses
Definition Viewscreen.h:244
short raindrops
Definition Viewscreen.h:394
double terprecisionx
Definition Viewscreen.h:370
Rendering::RenderBuffer * m_avCloudGrid
Definition Viewscreen.h:220
std::unique_ptr< cockpit > ptrCockpit
Definition Viewscreen.h:435
bool m_nightVisionRangeQueryPending
Definition Viewscreen.h:353
Rendering::RenderSurface * m_pddsDynamicSurface
Definition Viewscreen.h:313
s_polygon_extras2 polyextras2
Definition Viewscreen.h:390
WindshieldRainRenderer windshieldRain
Definition Viewscreen.h:395
SCamera * cockpitCamera
Definition Viewscreen.h:138
Rendering::RenderSurface * m_pddsProjectionSurface
Definition Viewscreen.h:315
RiseMath::Vector3 forwardVector
Definition Viewscreen.h:363
Rendering::RenderTexture * m_pddsFirework1[firework1C]
Definition Viewscreen.h:254
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
Rendering::RenderTexture * m_pddsHolidayTexture
Definition Viewscreen.h:247
float m_nightVisionRangeKm
Definition Viewscreen.h:358
ExteriorRainRenderer exteriorRainRenderer
Definition Viewscreen.h:403
Logger * logger
Definition Viewscreen.h:440
void UpdateNightVisionRangefinder(Rendering::RenderDevice *pd3dDevice) const
Definition render.cpp:2623
Rendering::RenderTexture * m_pddsBinocularsArrow
Definition Viewscreen.h:241
Rendering::RenderTexture * m_pddsTransition[transitiontextureC]
Definition Viewscreen.h:299
Rendering::RenderTexture * m_pddsSunTexture
Definition Viewscreen.h:245
Rendering::RenderToTexture * m_pRenderToSurfaceNextGen
Definition Viewscreen.h:317
RiseMath::Matrix matrixProj
Definition Viewscreen.h:345
SCamera * camera
Definition Viewscreen.h:137
bool PrepareHullTextures(Rendering::RenderDevice *pd3dDevice, unsigned budget=2)
Definition render.cpp:2793
Rendering::RenderTexture * m_pddsFirework3[firework3C]
Definition Viewscreen.h:256
Rendering::ReentryEnvelope11 reentryRenderer
Definition Viewscreen.h:398
float m_nightVisionRangeTestKm
Definition Viewscreen.h:357
Rendering::RenderFont * m_pFont
Definition Viewscreen.h:129
Rendering::RenderTexture * m_pddsDynamicTexture
Definition Viewscreen.h:312
float m_nightVisionRangeLowKm
Definition Viewscreen.h:355
HRESULT Render(Rendering::RenderDevice *device, Rendering::RenderMaterial *material, const std::vector< RiseMath::Matrix > &world, const RiseMath::Matrix &viewProjection, float opacity=1, DepthLayout layout=DepthLayout::Unified, float cockpitLight=0, ID3D11RenderTargetView *adExclusion=nullptr)
void SetGlassCondition(int condition)
static HRESULT DrawCockpitGlass(Rendering::RenderDevice *device, Draw draw)
void RenderRocks(Rendering::RenderDevice *pd3dDevice) const
void Render(Rendering::RenderDevice *pd3dDevice, double *fTime, bool drawTransparancy) const
void RenderRts(Rendering::RenderDevice *pd3dDevice, float lightFromStreet) const
void RenderCurbs(Rendering::RenderDevice *pd3dDevice, float lightFromStreet) const
void Render(Rendering::RenderDevice *pd3dDevice, const LocalLightning::Frame &strike={}) const
Definition cockpit.cpp:2586
void Draw(float fElapsedTime, Rendering::RenderDevice *pd3dDevice) const
float staticDensity
Definition propulsion.h:94
float staticBuildup
Definition propulsion.h:83
void SetSceneShipLights(const GeometryBounds &bounds, const RiseMath::Matrix &world)
void ClearSceneShipLights()
void PrepareShipSurfaceLights()
void RenderShips(Rendering::RenderDevice *pd3dDevice, const RiseMath::Vector3 *Xsunlight, ThrustConeRender::Pass pass=ThrustConeRender::Pass::All, bool attenuateThrust=false)
void RenderLights(Rendering::RenderDevice *pd3dDevice, const double *fTime)
void RenderDocks(Rendering::RenderDevice *pd3dDevice, const RiseMath::Vector3 *Xsunlight)
void Render(Rendering::RenderDevice *pd3dDevice, RiseMath::Matrix *matrixLookAtLocal)
Definition weapon.cpp:860
RiseMath::Color dwFogFactorZenith
Definition weather.h:194
float alphascreenOverride
Definition weather.h:224
float cloudHorizonAngle
Definition weather.h:196
float GetRenderVisibilityKm() const
Definition weather.h:176
RiseMath::Color solarHorizon
Definition weather.h:199
RiseMath::Color dwFogColorZenith
Definition weather.h:193
bool IsSpatialFogRendering() const
Definition weather.h:174
float shadow
Definition weather.h:213
RiseMath::Vector4 TerrainSnowTint(int u, int v) const
Definition weather.cpp:1324
RiseMath::Color cockpitAmbient
Definition weather.h:190
float cloudHorizonDistance
Definition weather.h:196
NightVisionGain::Response cockpitVision
Definition weather.h:189
RiseMath::Color sunAppearance
Definition weather.h:121
RiseMath::Color betascreen
Definition weather.h:200
void PrepareRainCurtains(bool exteriorView)
Definition weather.cpp:1375
DWORD m_dwSunViz
Definition weather.h:204
RiseMath::Vector4 nightVisionCloudGain
Definition weather.h:116
RiseMath::Color colorhorizon
Definition weather.h:198
bool elmoOverride
Definition weather.h:226
CloudVolume::Parameters cloudParameters
Definition weather.h:216
float GetCloudCeilingMslKm() const
Definition weather.cpp:1483
float solarVisibility
Definition weather.h:214
RiseMath::Color dwFogColorHorizon
Definition weather.h:195
float GetVisibilityKm() const
Definition weather.cpp:1411
float lightningAfterimageAmbient
Definition weather.h:185
float cloudDensity
Definition weather.h:217
float fFogEndHorizon
Definition weather.h:207
unsigned char ourplanetC
Definition globals.cpp:25
DeathType dead
Definition globals.cpp:37
float f_ACL
Definition globals.cpp:11
float f_AGL
Definition globals.cpp:9
FIREWORKS fireworks[fireworksC]
Definition globals.cpp:118
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
unsigned char ourmoonC
Definition globals.cpp:21
float f_BCL
Definition globals.cpp:12
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
BATCHINDEX2 drawlist[drawlistC]
Definition globals.cpp:104
unsigned char cloudBaseObjC
Definition globals.cpp:22
bool g_bAboveClouds
Definition globals.cpp:16
LIGHTNINGBELOW lightningbelow
Definition globals.cpp:116
s_polygon_object polyobjects[maxpolyC]
Definition globals.cpp:106
LOCALGRID2 gridarray[64][64]
Definition globals.cpp:100
unsigned char ourstarC
Definition globals.cpp:24
#define maxpolyC
Definition globals.h:32
#define drawlistC
Definition globals.h:65
#define ScaleHeightC
Definition globals.h:98
#define radiusC
Definition globals.h:87
#define RISE_FVF_SKYDOME
Definition globals.h:120
#define RISE_FVF_INSTRUMENT
Definition globals.h:127
#define farplaneC
Definition globals.h:27
#define cloudTopsMslC
Definition globals.h:110
#define RISE_FVF_VERTEX
Definition globals.h:118
#define cutplaneC
Definition globals.h:28
#define RISE_FVF_NONORMAL
Definition globals.h:125
#define RISE_FVF_LOCALGRID
Definition globals.h:129
#define fireworksC
Definition globals.h:769
#define RISE_FVF_RAINDROP
Definition globals.h:121
#define skydomeC
Definition globals.h:90
#define RISE_FVF_VERTEX2
Definition globals.h:119
#define RISE_FVF_STATICSTARS
Definition globals.h:123
#define nearplaneC
Definition globals.h:29
#define RISE_FVF_SCREEN
Definition globals.h:126
#define maxstarC
Definition globals.h:33
#define sunColorC
Definition globals.h:116
#define starsC
Definition globals.h:76
#define aftersdC
Definition globals.h:113
@ L_DEAD_COUNTDOWN
Definition gui.h:418
@ L_DEAD_REJOIN
Definition gui.h:417
@ L_DEAD_BUTTON
Definition gui.h:405
@ IDC_REJOINTEXT
Definition gui.h:979
@ IDC_REJOINBTN
Definition gui.h:980
constexpr float SolarCoreScale
float AtmosphericHazeDistanceKm(float nominalTop)
float BackgroundZenithWeight(float altitude, const Parameters &params)
Definition CloudVolume.h:52
float Transmittance(Point from, Point to, const Parameters &params, uint32_t seed=DefaultSeed)
float ScreenOpacity(bool volumeEnabled, float cloudOpacity, float overrideOpacity)
CloudVolume::Point LocalLight(CloudVolume::Point light, const NightVisionGain::Response &vision)
Light Configure(Light light, unsigned char type, const RiseMath::Matrix &modelBase)
Light Transform(const Light &source, const RiseMath::Matrix &modelToWorld)
Frame Build(const RiseMath::Vector3 &ground, const RiseMath::Vector3 &top, const RiseMath::Vector3 &origin, const RiseMath::Vector3 &camera, const RiseMath::Color &color, float brightness, float visibilityKm, bool enabled, bool separateFog=false)
float Gain(const NightVisionGain::Response &vision)
Mesh Attached(std::vector< Sphere > hull, Vector3 windward, const RiseMath::Matrix &worldToBody, Vector3 origin)
void AppendPart(std::vector< Sphere > &hull, const Component &part, const std::vector< uint8_t > &bytes, size_t stride, const RiseMath::Matrix &world)
std::vector< Sphere > ExteriorHull(const Component *parts, size_t count, const std::vector< uint8_t > &bytes, size_t stride)
constexpr uint32_t INVSRCALPHA
constexpr uint32_t INVDESTCOLOR
constexpr uint32_t SRCCOLOR
constexpr uint32_t INVSRCCOLOR
constexpr uint32_t ONE
constexpr uint32_t SRCALPHA
constexpr uint32_t DESTCOLOR
constexpr uint32_t RENDERTARGET
constexpr uint32_t TARGET
constexpr uint32_t ZBUFFER
constexpr uint32_t STENCIL
constexpr uint32_t RED
constexpr uint32_t GREEN
constexpr uint32_t BLUE
constexpr uint32_t EQUAL
constexpr uint32_t GREATER
constexpr uint32_t GREATEREQUAL
constexpr uint32_t LESS
constexpr uint32_t ALWAYS
constexpr uint32_t LESSEQUAL
constexpr uint32_t CW
constexpr uint32_t NONE
constexpr uint32_t CCW
constexpr uint32_t POINT
constexpr uint32_t LINEAR
constexpr uint32_t NONE
constexpr uint32_t DIRECTIONAL
constexpr uint32_t DISCARD
constexpr uint32_t COLORWRITEENABLE
constexpr uint32_t FOGEND
constexpr uint32_t SRCBLEND
constexpr uint32_t STENCILFUNC
constexpr uint32_t CULLMODE
constexpr uint32_t STENCILREF
constexpr uint32_t ALPHABLENDENABLE
constexpr uint32_t STENCILENABLE
constexpr uint32_t STENCILPASS
constexpr uint32_t FOGENABLE
constexpr uint32_t POINTSIZE
constexpr uint32_t DESTBLEND
constexpr uint32_t TEXTUREFACTOR
constexpr uint32_t LIGHTING
constexpr uint32_t ZFUNC
constexpr uint32_t ZWRITEENABLE
constexpr uint32_t ZENABLE
constexpr uint32_t FOGCOLOR
constexpr uint32_t MIPFILTER
constexpr uint32_t MAGFILTER
constexpr uint32_t MINFILTER
constexpr DWORD AlphaBlend
constexpr uint32_t REPLACE
constexpr uint32_t TFACTOR
constexpr uint32_t DIFFUSE
constexpr uint32_t TEXTURE
constexpr uint32_t SPECULAR
constexpr uint32_t CURRENT
constexpr uint32_t DISABLE
constexpr uint32_t MODULATE2X
constexpr uint32_t SELECTARG1
constexpr uint32_t ADDSMOOTH
constexpr uint32_t MODULATE
constexpr uint32_t SELECTARG2
constexpr uint32_t BLENDFACTORALPHA
constexpr uint32_t COLOROP
constexpr uint32_t COLORARG1
constexpr uint32_t ALPHAARG2
constexpr uint32_t ALPHAARG1
constexpr uint32_t ALPHAOP
constexpr uint32_t COLORARG2
constexpr uint32_t TEXTURETRANSFORMFLAGS
constexpr uint32_t COUNT2
constexpr uint32_t DISABLE
constexpr uint32_t VIEW
constexpr uint32_t PROJECTION
constexpr uint32_t WORLD
constexpr uint32_t TEXTURE1
constexpr uint32_t XYZRHW
HWND ClientWindow()
double ClientTime()
double ClientAbsoluteTime()
const wchar_t * ErrorString(HRESULT code)
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
const SurfaceDescription * ClientBackBufferDescription()
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
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
Matrix * MatrixLookAtRH(Matrix *out, const Vector3 *eye, const Vector3 *at, const Vector3 *up)
Definition ClientMath.h:141
Vector3 * Vec3Add(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:96
Matrix * MatrixRotationX(Matrix *out, float value)
Definition ClientMath.h:126
Vector3 * Vec3Project(Vector3 *out, const Vector3 *value, const Viewport *viewport, const Matrix *projection, const Matrix *view, const Matrix *world)
Definition ClientMath.h:222
Matrix * MatrixMultiply(Matrix *out, const Matrix *a, const Matrix *b)
Definition ClientMath.h:116
Color * ColorLerp(Color *out, const Color *a, const Color *b, float t)
Definition ClientMath.h:173
Matrix * MatrixRotationQuaternion(Matrix *out, const Quaternion *q)
Definition ClientMath.h:135
float Vec3LengthSq(const Vector3 *a)
Definition ClientMath.h:94
Vector3 * Vec3Subtract(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:97
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 * MatrixRotationYawPitchRoll(Matrix *out, float yaw, float pitch, float roll)
Definition ClientMath.h:137
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Definition ClientMath.h:118
constexpr float Tau
Definition ClientMath.h:12
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
Matrix * MatrixRotationAxis(Matrix *out, const Vector3 *axis, float angle)
Definition ClientMath.h:129
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
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
constexpr float HalfPi
Definition ClientMath.h:12
HRESULT Draw(Rendering::RenderDevice *device, Rendering::RenderTexture *texture, Rendering::RenderBuffer *vertices, const RiseMath::Matrix &world, UINT segments, Rendering::RenderMaterial *volumeEffect=nullptr, float physicalScale=1)
constexpr unsigned Segments
bool Defer(bool volumeClouds, bool simulator)
constexpr bool AcrossCloudDeck(float observerMslKm, float targetMslKm, float topMslKm=10.f)
float AltitudeRainFactor(float altitudeKm)
unsigned char u
Definition globals.h:330
unsigned char pri_landform
Definition globals.h:334
unsigned char v
Definition globals.h:330
unsigned char sec_transition
Definition globals.h:334
unsigned char pri_transition
Definition globals.h:334
unsigned char roads
Definition globals.h:331
unsigned char sec_landform
Definition globals.h:334
unsigned char primitives
Definition globals.h:333
unsigned short startindex
Definition globals.h:329
unsigned char ter_landform
Definition globals.h:334
RiseMath::Vector3 position
Definition globals.h:776
RiseMath::Color color
Definition globals.h:764
float intensity
Definition globals.h:763
RiseMath::Vector3 position
Definition globals.h:273
std::array< Segment, LightningTiming::MaxChainedBolts+1 > segments
RiseMath::Vector4 eye
RiseMath::Vector4 ground
RiseMath::Vector4 up
RiseMath::Vector4 top
RiseMath::Vector4 color
DirectX::XMFLOAT4 nightVisionSurface
RiseMath::Vector3 Direction
RiseMath::Color Diffuse
RiseMath::Color Ambient
char windshield
float startupextend
Definition globals.h:599
int inventoryItemInUseSubType
Definition globals.h:700
short texturelib
Definition globals.h:602
short ourplyrC
Definition globals.h:682
float power
Definition globals.h:599
unsigned short components
Definition globals.h:626
bool nextgen
Definition globals.h:706
SVesselDC vdat
Definition globals.h:664
int inventoryItemInUseType
Definition globals.h:699
s_mesh_component * componentarray
Definition globals.h:704
RiseMath::Vector3 position
Definition globals.h:616
float hingeextent
Definition globals.h:421
RiseMath::Vector3 nominalxyz
Definition globals.h:413
RiseMath::Matrix matWorld
Definition globals.h:425
RiseMath::Vector3 nominalypr
Definition globals.h:414
RiseMath::Vector3 hingeCG
Definition globals.h:420
unsigned char type
Definition globals.h:403
RiseMath::Vector3 hingeaxis
Definition globals.h:420
RiseMath::Vector3 extendby
Definition globals.h:419
RiseMath::Vector3 position
Definition globals.h:511
double precisionz
Definition globals.h:512
unsigned short vehicleId
Definition globals.h:537
double precisiony
Definition globals.h:512
unsigned char inarray
Definition globals.h:509
float baydoorextent
Definition globals.h:539
RiseMath::Matrix matrixExterior
Definition globals.h:518
RiseMath::Matrix matrixWorld
Definition globals.h:517
RiseVertexVertex * vertexbackup
Definition globals.h:341
Rendering::RenderBuffer * VB
Definition globals.h:360
RiseMath::Matrix matrixWorld
Definition globals.h:452