Rise
The Vieneo Province
Loading...
Searching...
No Matches
instruments.cpp
Go to the documentation of this file.
1#include "instruments.h"
2#include "Viewscreen.h"
3#include "../MathUtilities.h"
5
7{
8 viewscreen = ptr;
9 logger = ptr->logger;
10 logger->AddToCallStack("instruments::ctor");
11}
12
14
15void instruments::FrameMove(float fElapsedTime) const
16{
17 logger->AddToCallStack("instruments::FrameMove");
18
19 // Velocity vector in 10 seconds
20 // our position plus the velocity (maybe minus barycentric) in 10 seconds
21 if (playerships[0].reference != REF_ONGROUND)
22 {
23 RiseMath::Vector3 velocityVec;
25 RiseMath::Vec3Scale(&velocityVec, &velocityVec, -10.0f); // 10 seconds
26 RiseMath::Vec3TransformNormal(&velocityVec, &velocityVec, &viewscreen->matrixView);
27 if (velocityVec.z != 0.0f)
28 {
29 viewscreen->gameclass->bus->FlightPathVectorDegrees.x = RiseMath::ToDegree(atanf(velocityVec.x / velocityVec.z));
30 viewscreen->gameclass->bus->FlightPathVectorDegrees.y = RiseMath::ToDegree(atanf(velocityVec.y / velocityVec.z));
31 /*float f_temp = sqrtf(markVel * markVel + bearVel * bearVel);
32 if (f_temp > 180.0f)
33 {
34 f_temp = 180.0f / f_temp;
35 markVel *= f_temp;
36 bearVel *= f_temp;
37 }*/
38 if (velocityVec.z > 0.0f) // Behind us
39 {
42 else
45 }
46 }
47 else // directly above or below
48 {
50 if (velocityVec.y < 0.0f)
52 else
54 }
55 }
56 else
58
59
60 // Bearing and mark calculations
61 RiseMath::Vector3 result1;
62 const float ourPositionLength = RiseMath::Vec3Length(&playerships[0].position);
63 bool isValid = true;
64
65 if (viewscreen->gameclass->bus->targetC == -1) // waypoint
66 {
67 if (viewscreen->gameclass->bus->WPtargetC < 0 || viewscreen->gameclass->bus->WPtargetC >= static_cast<long>(viewscreen->gameclass->bus->waypoint.size()))
68 {
69 char msg[199];
70 sprintf_s(msg, sizeof msg, "Trying to perform bearing and mark calculation on a waypoint that doesn't exist in collection: %i (%zu)", viewscreen->gameclass->bus->WPtargetC, viewscreen->gameclass->bus->waypoint.size());
73 }
74
75 const RiseMath::Vector3 waypointPosition = viewscreen->gameclass->bus->waypoint.at(viewscreen->gameclass->bus->WPtargetC).location;
76
77 if (waypointPosition.x == 0.0f)
78 isValid = false;
79 else
80 {
81 RiseMath::Vec3Subtract(&result1, &playerships[0].position, &waypointPosition);
82 const float doNotUseDist = GetArcDist(playerships[0].position, waypointPosition, false);
83 const float altd = RiseMath::Vec3Length(&waypointPosition) - ourPositionLength;
84 result1 = GetArcBear(result1, doNotUseDist, altd, viewscreen->posnorml);
85 }
86 }
87 else if (viewscreen->gameclass->bus->targetC > -1) // ships
88 {
92 isValid = false;
93 else
95 }
96 else // docks
97 {
98 const short t = -viewscreen->gameclass->bus->targetC - 2;
99 if (playerships[0].portassigned != -1 && playerships[0].reference == (t + REF_DOCKENUMCPOC))
100 {
101 if (playerships[0].docked)
102 RiseMath::Vec3Subtract(&result1, &playerships[0].dockoffset, &dockInterface);
103 else
104 RiseMath::Vec3Subtract(&result1, &playerships[0].dockoffset, &dockMarker);
105 }
106 else
107 {
108 RiseMath::Vec3Subtract(&result1, &playerships[0].position, &allobjects[t].position);
109 const float doNotUseDist = GetArcDist(playerships[0].position, allobjects[t].position, false);
110 const float altd = RiseMath::Vec3Length(&allobjects[t].position) - ourPositionLength;
111 result1 = GetArcBear(result1, doNotUseDist, altd, viewscreen->posnorml);
112 }
113 }
114
115 if (isValid)
116 {
118
119 if (result1.z != 0.0f)
120 {
121 viewscreen->gameclass->bus->TargetBearingDeg = RiseMath::ToDegree(atanf(result1.x / result1.z));
122 mark = RiseMath::ToDegree(atanf(result1.y / result1.z));
124 if (f_temp > 180.0f)
125 {
126 f_temp = 180.0f / f_temp;
128 mark *= f_temp;
129 }
130 if (result1.z > 0.0f) // Behind us
131 {
134 else
136 mark = -mark;
137 }
138 }
139 else // directly above or below
140 {
142 if (result1.y < 0.0f)
143 mark = 90.0f;
144 else
145 mark = -90.0f;
146 }
147 // sprintf_s( msg, sizeof(msg), "TGT %+06.1f M %+05.1f", bear, mark );
148 // m_pFont->DrawText( 415.0f, 480.0f, Rendering::ColorARGB(255,0,255,0), msg );
149 }
150 else
152
153
155 {
157 const float doNotUseDist = GetArcDist(playerships[0].position, viewscreen->gameclass->bus->lastWaypointLocation, false);
158 const float altd = RiseMath::Vec3Length(&viewscreen->gameclass->bus->lastWaypointLocation) - ourPositionLength;
159 result1 = GetArcBear(result1, doNotUseDist, altd, viewscreen->posnorml);
161 viewscreen->gameclass->bus->LastBearingDeg = RiseMath::ToDegree(atanf(result1.x / result1.z));
162 }
163 else
165
166
167 // prepare the north vector since it is shared
168 RiseMath::Vector3 compassnorth;
169 RiseMath::Vec3Add(&compassnorth, &northpoleK, &playerships[0].position);
170 RiseMath::Vec3Normalize(&compassnorth, &compassnorth);
171 RiseMath::Vec3Scale(&compassnorth, &compassnorth, ourPositionLength);
172 RiseMath::Vec3Subtract(&compassnorth, &compassnorth, &playerships[0].position);
173 RiseMath::Vec3Normalize(&compassnorth, &compassnorth);
174
175 // Compass Heading ----------------------------------------------------------------------------------------------------
176 RiseMath::Vec3Add(&result1, &viewscreen->forwardVector, &playerships[0].position); // it is now a point 1 km ahead
177
178 // snap to present altitude
179 RiseMath::Vec3Normalize(&result1, &result1);
180 RiseMath::Vec3Scale(&result1, &result1, ourPositionLength);
181
182 // our up vector snapped to the grid plane
183 RiseMath::Vec3Subtract(&result1, &result1, &playerships[0].position);
184 RiseMath::Vec3Normalize(&result1, &result1);
185
186 // Now this one can be compared with the vector viewnorth
187 float f_temp = RiseMath::Vec3Dot(&result1, &compassnorth);
188 if (f_temp >= 1.0f) // caused a nan at == 1.0f
190 else if (f_temp <= -1.0f)
191 viewscreen->insthdgDegrees = 180.0f;
192 else
194
195 // Adjust for the 3rd and 4th quadrants
196 RiseMath::Vec3Cross(&result1, &result1, &compassnorth);
197 RiseMath::Vec3Add(&result1, &result1, &playerships[0].position);
198 if (RiseMath::Vec3Length(&result1) > ourPositionLength)
200
202 viewscreen->insthdgDegrees += RiseMath::HalfPi; // not sure why I should have to do this
203
207
208
209 // track
211 const float trackLen = viewscreen->UniverseRelativeSpeedKms;
212 if (playerships[0].reference != REF_ONGROUND && trackLen > 0.001f)
213 {
214 track = -track;
215 RiseMath::Vec3Normalize(&track, &track);
216 RiseMath::Vec3Add(&track, &track, &playerships[0].position); // it is now a point 1 km ahead
217
218 // snap to present altitude
219 RiseMath::Vec3Normalize(&track, &track);
220 RiseMath::Vec3Scale(&track, &track, ourPositionLength);
221
222 // our up vector snapped to the grid plane
223 RiseMath::Vec3Subtract(&track, &track, &playerships[0].position);
224 RiseMath::Vec3Normalize(&track, &track);
225
226 f_temp = RiseMath::Vec3Dot(&track, &compassnorth);
227 if (f_temp >= 1.0f) // caused a nan at == 1.0f
228 viewscreen->insttrk = 0.0f;
229 else if (f_temp <= -1.0f)
230 viewscreen->insttrk = 180.0f;
231 else
232 viewscreen->insttrk = RiseMath::ToDegree(acosf(f_temp));
233
234 // Adjust for the 3rd and 4th quadrants
235 RiseMath::Vec3Cross(&track, &track, &compassnorth);
236 RiseMath::Vec3Add(&track, &track, &playerships[0].position);
237 if (RiseMath::Vec3Length(&track) > ourPositionLength)
240 }
241 else
243
244
245 // Attitude subsection ----------------------------------------------------------------------
246 RiseMath::Matrix matrixInverse;
247 RiseMath::MatrixInverse(&matrixInverse, nullptr, &playerships[0].matrixWorld);
248 RiseMath::MatrixMultiply(&matrixInverse, &allobjects[ourmoonC].matrixWorld, &matrixInverse);
249
250 // Planetary core
251 RiseMath::Vector3 result;
252 result.x = matrixInverse._41;
253 result.y = matrixInverse._42;
254 result.z = matrixInverse._43;
255
256 if (fabsf(result.y) > FLT_EPSILON)
257 {
258 if (result.y > 0.0f) // Right-side up
259 viewscreen->gameclass->bus->RollAttitudeRadians = -atanf(result.x / result.y);
260 else if (result.x < 0.0f)
261 viewscreen->gameclass->bus->RollAttitudeRadians = RiseMath::Pi - atanf(result.x / result.y);
262 else
263 viewscreen->gameclass->bus->RollAttitudeRadians = -RiseMath::Pi - atanf(result.x / result.y);
264 viewscreen->gameclass->bus->PitchAttitudeRadians = atanf(result.z / sqrtf(result.y * result.y + result.x * result.x));
265 }
266 else
268
269
270
271#pragma region Fuel
272
273 if (playerships[0].groundvehicle)
274 {
275 // was moved back here after https://jira.risetvp.com/view.php?id=188
276 // 3% for non-ground, 10% for ground vehicles
277 const bool oldlowfuel = ourcockpit.lowfuel;
278 if (playerships[0].groundvehicle && fuel < ourcockpit.fuelmax * 0.1f)
279 ourcockpit.lowfuel = true;
280 else
281 ourcockpit.lowfuel = false;
282 if (ourcockpit.lowfuel && !oldlowfuel && ourcockpit.power > 0.5f)
283 {
284 Command command;
285 command.name = "AuralLowFuel"; // this is just the chime in the ground vehicles
286 viewscreen->gameclass->bus->commandStream.emplace_back(command);
287 }
288 }
289
290#pragma endregion
291
292}
293
294void instruments::Draw(float fElapsedTime, Rendering::RenderDevice* pd3dDevice) const
295{
296 logger->AddToCallStack("instruments::Draw");
297
298 RiseMath::Vector3 result;
299 float f_temp;
300 RiseMath::Matrix matrixWorld;
301
302 WCHAR str[99];
303 short t;
304 HRESULT hr;
305
306
307 if (playerships[0].groundvehicle && ourcockpit.texturelib != VehicleType::T27) // (gv) ground vehicle backgrounds
308 {
309 // background for tachometer
310 result.x = 0.0f;
311 result.y = 0.0f;
312 result.z = 0.0f;
313 RECT rect;
314 rect.left = -1;
315 rect.top = -1;
316 rect.right = 139;
317 rect.bottom = 137;
318
320 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
321
322 if (ourcockpit.texturelib == VehicleType::T120 || ourcockpit.texturelib == VehicleType::T121) // background for speedometer 2 steerhead
323 {
324 result.x = 139.0f;
325 result.y = 0.0f;
326 result.z = 0.0f;
327 rect.left = 275;
328 rect.top = 0;
329 rect.right = 415;
330 rect.bottom = 139;
331
332 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
333 }
334 else // background for speedometer 1 dasher
335 {
336 result.x = 140.0f;
337 result.y = 0.0f;
338 result.z = 0.0f;
339 rect.left = 137;
340 rect.top = -1;
341 rect.right = 275;
342 rect.bottom = 137;
343
344 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
345 }
346
347
348
349 // Temp, charge, GPS and GPS-direction
350 result.x = 0.0f;
351 result.y = 283.0f;
352 result.z = 0.0f;
353 rect.left = 0;
354 rect.top = 283;
355 rect.right = 207;
356 rect.bottom = 352;
357 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
358
360 {
361 // small tach, small speedometer
362 result.x = 207.0f;
363 result.y = 283.0f;
364 result.z = 0.0f;
365 rect.left = 207;
366 rect.top = 283;
367 rect.right = 344;
368 rect.bottom = 352;
369 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
370 }
371
372 // nidar, new combined battery/temp
373 result.x = 207.0f;
374 result.y = 214.0f;
375 result.z = 0.0f;
376 rect.left = 345;
377 rect.top = 283;
378 rect.right = 483;
379 rect.bottom = 352;
380 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
381
382 // Compass
383 result.x = 1.0f;
384 result.y = 151.0f;
385 result.z = 0.0f;
386 rect.left = 1;
387 rect.top = 151;
388 rect.right = 69;
389 rect.bottom = 168;
390 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
391
392 // flush now for overlays
394
395 if (viewscreen->lampTest > 0.0f)
396 {
398 {
399 result.x = 145.0f;
400 result.y = 6.0f;
401 result.z = 0.0f;
402 rect.left = 0;
403 rect.right = 14;
404 rect.top = 0;
405 rect.bottom = 15;
406 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsLightsCruiseIcons, &rect, nullptr, &result, 0xFF0000FF);
407 }
408 else
409 {
410 // high beams
411 result.x = 145.0f;
412 result.y = 6.0f;
413 result.z = 0.0f;
414 rect.left = 0;
415 rect.right = 14;
416 rect.top = 0;
417 rect.bottom = 15;
418 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsLightsCruiseIcons, &rect, nullptr, &result, 0xFF0000FF);
419
420 // cruise control
421 result.x = 250.0f;
422 result.y = 6.0f;
423 result.z = 0.0f;
424 rect.left = 14;
425 rect.right = 36;
426 rect.top = 0;
427 rect.bottom = 6;
428 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsLightsCruiseIcons, &rect, nullptr, &result, 0xFF00FF00);
429 }
430 }
431
433 } // end of gv
434
435
436#pragma region Interior Nameplate
437
439 {
441
443 {
444 RiseMath::Matrix transform;
445 RiseMath::MatrixTranslation(&transform, 102, 44, 0);
447 }
448
449 RECT rect;
450 rect.top = 0;
451 rect.left = 0;
452 rect.right = 273;
453 rect.bottom = 74;
454 result.x = 138.0f;
455 result.y = 276.0f;
456 result.z = 0.0f;
457 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsNamePlate, &rect, nullptr, &result, 0xFFFFFFFF);
458
460
461 if (playerships[0].hullname[0] != 0 && !playerships[0].isSimulator)
462 {
463 WCHAR str[99];
464 swprintf_s(str, 99, L"U.S.V. %S", playerships[0].hullname);
465 rect.left = 156;//+(232-letters*9)/2;
466 rect.top = 295;
467 rect.right = 392;
468 rect.bottom = 308;
469 viewscreen->m_pFontNamePlate->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_CENTER, Rendering::ColorARGB(255, 0, 0, 0));
470 }
471 if (!playerships[0].isSimulator)
472 swprintf_s(str, 99, L"IVR %S", playerships[0].IVR);
473 else
474 swprintf_s(str, 99, L"FFS-%S", playerships[0].IVR);
475 rect.left = 156;//+(232-letters*8)/2;
476 rect.top = 308;
477 rect.right = 392;
478 rect.bottom = 320;
479 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_CENTER, Rendering::ColorARGB(255, 0, 0, 0));
480
481 // restore
483 {
484 RiseMath::Matrix transform;
485 RiseMath::MatrixIdentity(&transform);
487 }
488
490 }
491
492#pragma endregion
493
494
495 if (playerships[0].groundvehicle && ourcockpit.texturelib != VehicleType::T27) // ground vehicles except the Mammoth
496 {
497 // speedometer dials, -135 to +135 deg, km/s to km/h
498 // speedometer dial
499
500 // spinny dials!
505 V(pd3dDevice->SetFVF(RISE_FVF_INSTRUMENT));
509 float x, y;
510 x = 208.0f;
511 y = 69.0f;
512
513
514 RiseMath::Vector2 corner[4];
515 corner[0].x = 64.0f; corner[0].y = -64.0f; // ur
516 corner[1].x = -64.0f; corner[1].y = -64.0f; // ul
517 corner[2].x = 64.0f; corner[2].y = 64.0f; // lr
518 corner[3].x = -64.0f; corner[3].y = 64.0f; // ll
519
521
522 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
523 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
524 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
525 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
526
528 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
529
530 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
531 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
532 vtxs++;
533 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
534 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
535 vtxs++;
536 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
537 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
538 vtxs++;
539 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
540 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
541
543
544 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
545 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsAOA[0]));
546
548
549
550 // small speedometer
552 {
553 x = 310.0f;
554 y = 317.0f;
555
556 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
557 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
558 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
559 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
560
561 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-90.0f + viewscreen->gameclass->bus->SpeedometerKPH * 0.692307692307692307692307692307f));
562
563 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
564 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
565 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
566 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
567
568 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
569
570 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
571 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
572 vtxs++;
573 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
574 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
575 vtxs++;
576 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
577 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
578 vtxs++;
579 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
580 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
581
583
584 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
585 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsGVDialSmall));
586
588 }
589
590 static float tach = 0.0f;
591 tach += (ourcockpit.tach - tach) * fElapsedTime * 3.0f;
592 // tachometer (big)
594 {
595 x = 69.0f;
596 y = 69.0f;
597
598 corner[0].x = 64.0f; corner[0].y = -64.0f; // ur
599 corner[1].x = -64.0f; corner[1].y = -64.0f; // ul
600 corner[2].x = 64.0f; corner[2].y = 64.0f; // lr
601 corner[3].x = -64.0f; corner[3].y = 64.0f; // ll
602
603 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-150.0f + 300.0f * tach));
604
605 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
606 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
607 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
608 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
609
610 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
611
612 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
613 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
614 vtxs++;
615 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
616 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
617 vtxs++;
618 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
619 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
620 vtxs++;
621 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
622 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
623
625
626 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
627 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsAOA[0]));
628
630 }
631
632 // small tachometer
634 {
635 x = 241.0f;
636 y = 317.0f;
637
638 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
639 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
640 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
641 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
642
643 float smallTachDisplay = tach;
644 if (ourcockpit.tachDisplayMaxRPM > 0.0f)
645 {
646 smallTachDisplay = Clamp(
648 0.0f,
649 1.0f);
650 }
651
652 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-90.0f + 180.0f * smallTachDisplay));
653
654 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
655 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
656 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
657 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
658
659 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
660
661 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
662 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
663 vtxs++;
664 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
665 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
666 vtxs++;
667 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
668 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
669 vtxs++;
670 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
671 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
672
674
675 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
676 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsGVDialSmall));
677
679 }
680
681 // temp
682 {
683 x = 104.0f;
684 y = 318.0f;
685 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
686 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
687 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
688 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
689
690 f_temp = 0.0f;
691 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-115.0f + 230.0f * f_temp));
692
693 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
694 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
695 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
696 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
697
698 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
699
700 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
701 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
702 vtxs++;
703 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
704 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
705 vtxs++;
706 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
707 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
708 vtxs++;
709 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
710 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
711
713
714 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
715 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsGVDialSmall));
716
718 }
719
720 // The C-2A mesh uses the full temperature gauge, not this auxiliary dial.
722 {
723 x = 310.0f;
724 y = 254.0f;
725 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
726 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
727 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
728 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
729
730 f_temp = 0.0f;
731 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-90.0f - 180.0f * f_temp));
732
733 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
734 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
735 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
736 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
737
738 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
739
740 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
741 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
742 vtxs++;
743 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
744 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
745 vtxs++;
746 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
747 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
748 vtxs++;
749 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
750 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
751
753
754 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
755 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsAOA[1]));
756
758 }
759
760 // fuel gauge needle
761 {
762 x = 35.0f;
763 y = 318.0f;
764 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
765 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
766 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
767 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
768
770 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-120.0f + 240.0f * f_temp));
771
772 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
773 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
774 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
775 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
776
777 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
778
779 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
780 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
781 vtxs++;
782 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
783 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
784 vtxs++;
785 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
786 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
787 vtxs++;
788 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
789 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
790
792
793 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
794 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsGVDialSmall));
795
797 }
798
799 // The C-2A uses the street-map bearing readout instead of this legacy dial.
801 {
802 x = 172.0f;
803 y = 318.0f;
804 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
805 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
806 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
807 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
808
810
811 // RiseMath::MatrixTranslation( &matrixTemp, -0.5f, tvstart, 0.0f );
812 // RiseMath::MatrixMultiply( &matrixWorld, &matrixWorld, &matrixTemp );
813
814 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
815 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
816 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
817 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
818
819 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
820
821 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
822 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
823 vtxs++;
824 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
825 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
826 vtxs++;
827 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
828 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
829 vtxs++;
830 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
831 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
832
834
835 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
836 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsGVDirection));
837
839 }
840
842 // pd3dDevice->SetTextureStageState( 0, Rendering::TextureState::ALPHAOP, Rendering::TextureOperation::DISABLE ); benjey2
843
847
849
850
851
852
854
855
856
857
858 // compass
859 result.x = 4.0f;
860 result.y = 154.0f;
861 result.z = 0.0f;
862 short offsetx = (short)(viewscreen->insthdgDegrees / 360.0f * 720.0f);
863 RECT rect;
864 rect.left = 0 + offsetx;
865 rect.right = 63 + offsetx;
866 rect.top = 0;
867 rect.bottom = 12;
868
869
870 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVCompass, &rect, nullptr, &result, 0xFFFFFFFF);
871
872 // icons
873 if (ourcockpit.lowfuel || viewscreen->lampTest > 0.2f) // 1/8th tank
874 {
875 result.x = 118.0f;
876 result.y = 117.0f;
877 result.z = 0.0f;
878 rect.left = 0;
879 rect.right = 15;
880 rect.top = 0;
881 rect.bottom = 15;
882 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsFuelIcon, &rect, nullptr, &result, 0xFFFF0000);
883 // pd3dDevice->SetRenderState( Rendering::RenderState::ALPHABLENDENABLE, true );
884 // pd3dDevice->SetRenderState( Rendering::RenderState::SRCBLEND, Rendering::Blend::SRCCOLOR );
885 // pd3dDevice->SetRenderState( Rendering::RenderState::DESTBLEND, Rendering::Blend::ONE );
886 if (ourcockpit.texturelib != VehicleType::C2A) // auxiliary gauge is not sampled by this cockpit
887 {
888 result.x = 303.0f;
889 result.y = 223.0f;
890 result.z = 0.0f;
891 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsFuelIcon, &rect, nullptr, &result, 0xFFFF0000);
892 }
893 // pd3dDevice->SetRenderState( Rendering::RenderState::ALPHABLENDENABLE, false );
894 }
895
896 // Gears: the C-2A only samples the indicator inside the tachometer.
897 if (ourcockpit.power > 0.0f)
898 {
900 {
901 if (ourcockpit.gearshift == -2) swprintf_s(str, 99, L"P");
902 else if (ourcockpit.gearshift == -1) swprintf_s(str, 99, L"R");
903 else if (ourcockpit.gearshift == 0) swprintf_s(str, 99, L"N");
904 else swprintf_s(str, 99, L"%i", ourcockpit.gearshift);
905 rect.left = 234; rect.top = 325; rect.right = 250; rect.bottom = 345;
906 viewscreen->m_pFontNamePlate->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_CENTER, Rendering::ColorARGB(255, 230, 89, 33));
907 }
908 else
909 {
910 if (ourcockpit.gearshift == -2 || viewscreen->lampTest > 0.3f) // P
911 {
912 result.x = 54.0f;
913 result.y = 117.0f;
914 result.z = 0.0f;
915 rect.left = 0;
916 rect.top = 138;
917 rect.right = 10;
918 rect.bottom = 145;
919 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
921 {
922 result.x = 226.0f;
923 result.y = 326.0f;
924 result.z = 0.0f;
925 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
926 }
927 }
928 if (ourcockpit.gearshift == -1 || viewscreen->lampTest > 0.3f) // R
929 {
930 result.x = 77.0f;
931 result.y = 117.0f;
932 result.z = 0.0f;
933 rect.left = 10;
934 rect.top = 138;
935 rect.right = 19;
936 rect.bottom = 145;
937 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
939 {
940 result.x = 249.0f;
941 result.y = 326.0f;
942 result.z = 0.0f;
943 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
944 }
945 }
946 if (ourcockpit.gearshift == 0 || viewscreen->lampTest > 0.3f) // N
947 {
948 result.x = 65.0f;
949 result.y = 117.0f;
950 result.z = 0.0f;
951 rect.left = 20;
952 rect.top = 138;
953 rect.right = 30;
954 rect.bottom = 145;
955 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
957 {
958 result.x = 237.0f;
959 result.y = 326.0f;
960 result.z = 0.0f;
961 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
962 }
963 }
964 if (ourcockpit.gearshift == 1 || viewscreen->lampTest > 0.3f) // 1
965 {
966 result.x = 65.0f;
967 result.y = 109.0f;
968 result.z = 0.0f;
969 rect.left = 30;
970 rect.top = 138;
971 rect.right = 36;
972 rect.bottom = 145;
973 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
975 {
976 result.x = 229.0f;
977 result.y = 335.0f;
978 result.z = 0.0f;
979 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
980 }
981 }
982 if (ourcockpit.gearshift == 2 || viewscreen->lampTest > 0.3f) // 2
983 {
984 result.x = 66.0f;
985 result.y = 100.0f;
986 result.z = 0.0f;
987 rect.left = 38;
988 rect.top = 138;
989 rect.right = 46;
990 rect.bottom = 145;
991 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
993 {
994 result.x = 237.0f;
995 result.y = 335.0f;
996 result.z = 0.0f;
997 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
998 }
999 }
1000 if (ourcockpit.gearshift == 3 || viewscreen->lampTest > 0.3f) // 3
1001 {
1002 result.x = 65.0f;
1003 result.y = 91.0f;
1004 result.z = 0.0f;
1005 rect.left = 47;
1006 rect.top = 138;
1007 rect.right = 56;
1008 rect.bottom = 145;
1009 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
1011 {
1012 result.x = 247.0f;
1013 result.y = 335.0f;
1014 result.z = 0.0f;
1015 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
1016 }
1017 }
1018 }
1019 }
1020
1021 // GV CONTACTS
1022 // Playerships display ----------------------------------------------------------------------
1023 RiseMath::Color hi;
1025 if (viewscreen->gameclass->bus->targetC < -1)
1026 {
1027 viewscreen->gameclass->bus->targetC = -1; // if stations, select user WP
1029 }
1030
1031 //float dist = 999.0f;
1032 for (t = -1; t < 2; t++)
1033 {
1034 // User Waypoint
1035 if ((t + viewscreen->gameclass->bus->targetC) == -1)
1036 {
1037 if (viewscreen->gameclass->bus->targetC == -1)
1038 {
1039 swprintf_s(str, 99, L">WAYPT");
1041 {
1046 }
1047 }
1048 else
1049 {
1050 swprintf_s(str, 99, L" WAYPT");
1051 }
1052 rect.left = 0; rect.top = 170 + 10 * (t + 1); rect.right = rect.bottom = 0;
1053 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 255, 255));
1054
1055 /*if (viewscreen->gameclass->bus->WPtargetC < 0 || viewscreen->gameclass->bus->WPtargetC >= (long)viewscreen->gameclass->bus->waypoint.size())
1056 {
1057 char msg[199];
1058 sprintf_s(msg, sizeof msg, "Trying to GV display contact list with a waypoint that doesn't exist in collection: %i (%i)", viewscreen->gameclass->bus->WPtargetC, viewscreen->gameclass->bus->waypoint.size());
1059 logger->Log(msg, Logger::Level::Error);
1060 viewscreen->gameclass->bus->WPtargetC = 0;
1061 }
1062
1063 if (viewscreen->gameclass->bus->waypoint.at(viewscreen->gameclass->bus->WPtargetC).location.x != 0.0f)
1064 {
1065 dist = GetArcDist(playerships[0].position, viewscreen->gameclass->bus->waypoint.at(viewscreen->gameclass->bus->WPtargetC).location, true);
1066 }*/
1067 }
1069 {
1073 {
1075 hi = Rendering::ColorARGB(255, 255, 127, 0); // orange
1076 else
1077 {
1079 hi = Rendering::ColorARGB(255, 192, 192, 0); // yellow
1081 hi = Rendering::ColorARGB(255, 192, 0, 192); // new color
1083 hi = Rendering::ColorARGB(255, 0, 192, 0); // green
1085 hi = Rendering::ColorARGB(255, 192, 0, 0); // red
1086 else
1087 hi = Rendering::ColorARGB(255, 192, 192, 192); // white // neutral
1089 {
1090 hi.r *= 1.328125f;
1091 hi.g *= 1.328125f;
1092 hi.b *= 1.328125f;
1093 }
1094 }
1095 if (t == 0)
1096 {
1097 swprintf_s(str, 99, L">%-6S", playerships[viewscreen->gameclass->bus->scanslot[t + viewscreen->gameclass->bus->targetC]].IVR);
1098 //dist = viewscreen->scandist[t + viewscreen->gameclass->bus->targetC];
1099 }
1100 else
1101 swprintf_s(str, 99, L" %-6S", playerships[viewscreen->gameclass->bus->scanslot[t + viewscreen->gameclass->bus->targetC]].IVR);
1106 {
1108 wcscat_s(str, 99, L"TOW");
1109 else
1110 wcscat_s(str, 99, L"TUG");
1111 }
1112 rect.left = 0; rect.top = 170 + 10 * (t + 1); rect.right = rect.bottom = 0;
1113 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_NOCLIP, hi);
1114 }
1115 }
1117 {
1118 swprintf_s(str, 99, L" WAYPT");
1119 rect.left = 0; rect.top = 170 + 10 * (t + 1); rect.right = rect.bottom = 0;
1120 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 255, 255));
1121 }
1122 }
1123
1124 // The C-2A mesh does not sample this legacy distance/proximity readout.
1126 {
1127 if (viewscreen->gameclass->bus->TargetDistanceKm > 1.0f) // km
1128 {
1129 swprintf_s(str, 99, L"%05.3f", viewscreen->gameclass->bus->TargetDistanceKm);
1130 rect.left = 169; rect.top = 323; rect.right = rect.bottom = 0;
1131 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, L"K", -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 0, 0));
1132 }
1133 else
1134 {
1135 swprintf_s(str, 99, L"%05.3f", viewscreen->gameclass->bus->TargetDistanceKm * 1000.0f);
1136 rect.left = 169; rect.top = 323; rect.right = rect.bottom = 0;
1137 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, L"M", -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 0, 0));
1138 }
1139
1140 for (unsigned t = 0; t < 5; t++)
1141 {
1142 WCHAR tempmsg[2];
1143 tempmsg[1] = 0;
1144 tempmsg[0] = str[t];
1145 rect.left = 153 + t * 8; rect.top = 310; rect.right = rect.bottom = 0;
1146 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, tempmsg, -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
1147 }
1148
1149
1150 // green close interaction requirement 25 meters
1151 // yellow same plot or certain range 250 meters
1152 // red is 2.5km
1153 if (viewscreen->gameclass->bus->TargetDistanceKm > 0.250f)
1154 {
1155 result.x = 162.0f;
1156 result.y = 304.0f;
1157 result.z = 0.0f;
1158 rect.left = 381;
1159 rect.right = 384;
1160 rect.top = 280;
1161 rect.bottom = 283;
1162
1163 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
1164 }
1165 else if (viewscreen->gameclass->bus->TargetDistanceKm > 0.025f)
1166 {
1167 result.x = 171.0f;
1168 result.y = 304.0f;
1169 result.z = 0.0f;
1170 rect.left = 384;
1171 rect.right = 387;
1172 rect.top = 280;
1173 rect.bottom = 283;
1174
1175 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
1176 }
1177 else
1178 {
1179 result.x = 180.0f;
1180 result.y = 304.0f;
1181 result.z = 0.0f;
1182 rect.left = 387;
1183 rect.right = 390;
1184 rect.top = 280;
1185 rect.bottom = 283;
1186
1187 viewscreen->m_spriteVector->Draw(viewscreen->m_pddsGVBackground, &rect, nullptr, &result, 0xFFFFFFFF);
1188 }
1189 }
1190
1191 if (viewscreen->gameclass->bus->targetC == -1)
1192 {
1194 swprintf_s(str, 99, L"WAYPT ►%.0f° %.3f km", fabsf(viewscreen->gameclass->bus->TargetBearingDeg), viewscreen->gameclass->bus->TargetDistanceKm);
1195 else if (viewscreen->gameclass->bus->TargetBearingDeg <= -0.5f)
1196 swprintf_s(str, 99, L"WAYPT ◄%.0f° %.3f km", fabsf(viewscreen->gameclass->bus->TargetBearingDeg), viewscreen->gameclass->bus->TargetDistanceKm);
1197 else
1198 swprintf_s(str, 99, L"WAYPT ▲%.0f° %.3f km", fabsf(viewscreen->gameclass->bus->TargetBearingDeg), viewscreen->gameclass->bus->TargetDistanceKm);
1199 }
1200 else
1201 {
1204 else if (viewscreen->gameclass->bus->TargetBearingDeg <= -0.5f)
1205 swprintf_s(str, 99, L"%S ◄%.0f° %.3f km", playerships[viewscreen->gameclass->bus->scanslot[viewscreen->gameclass->bus->targetC]].IVR, fabsf(viewscreen->gameclass->bus->TargetBearingDeg), viewscreen->gameclass->bus->TargetDistanceKm);
1206 else
1208 }
1209 rect.left = 0; rect.top = 264; rect.right = rect.bottom = 0;
1210 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, str, -1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 255, 0));
1211
1212
1213
1214 // Odometer
1215 swprintf_s(str, 99, L"%08.1f", ourcockpit.usage);
1217 ourcockpit.texturelib == VehicleType::T120 || ourcockpit.texturelib == VehicleType::T121) // dasher and steerhead use top left area
1218 {
1220 {
1221 for (unsigned t1 = 0; t1 < 6; t1++) // 000106.1
1222 {
1223 rect.left = 180 + t1 * 8; rect.top = 102; rect.right = rect.bottom = 0;
1224 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[t1], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
1225 }
1226 // Skip the decimal and do the last number in black
1227 rect.left = 180 + 6 * 8; rect.top = 102; rect.right = rect.bottom = 0;
1228 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[7], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 0, 0));
1229 }
1230 else
1231 {
1232 for (unsigned t2 = 0; t2 < 7; t2++)
1233 {
1234 rect.left = 178 + t2 * 8; rect.top = 102; rect.right = rect.bottom = 0;
1235 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[t2], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
1236 }
1237 rect.left = 176 + 7 * 8; rect.top = 102; rect.right = rect.bottom = 0;
1238 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[7], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
1239 }
1240 }
1241 else if (ourcockpit.texturelib == VehicleType::C98) // small speedo
1242 {
1243 for (unsigned t3 = 0; t3 < 6; t3++)
1244 {
1245 rect.left = 286 + t3 * 7; rect.top = 320; rect.right = rect.bottom = 0;
1246 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[t3], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 255, 255, 255));
1247 }
1248 // Skip the decimal and do the last number in black
1249 rect.left = 286 + 6 * 7; rect.top = 320; rect.right = rect.bottom = 0;
1250 viewscreen->m_pFont->DrawText(viewscreen->m_spriteVector, &str[7], 1, &rect, DT_NOCLIP, Rendering::ColorARGB(255, 0, 0, 0));
1251 }
1252
1253
1254
1256
1257
1258
1260 {
1262
1263 // Auxiliary fuel gauge; the C-2A mesh only samples the full gauge.
1264 x = 310.0f;
1265 y = 242.0f;
1266 corner[0].x = 32.0f; corner[0].y = -32.0f; // ur
1267 corner[1].x = -32.0f; corner[1].y = -32.0f; // ul
1268 corner[2].x = 32.0f; corner[2].y = 32.0f; // lr
1269 corner[3].x = -32.0f; corner[3].y = 32.0f; // ll
1270
1271 f_temp = fuel / ourcockpit.fuelmax * ourcockpit.power;
1272 RiseMath::MatrixRotationZ(&matrixWorld, RiseMath::ToRadian(-90.0f + 180.0f * f_temp));
1273
1274 RiseMath::Vec2TransformCoord(&corner[0], &corner[0], &matrixWorld);
1275 RiseMath::Vec2TransformCoord(&corner[1], &corner[1], &matrixWorld);
1276 RiseMath::Vec2TransformCoord(&corner[2], &corner[2], &matrixWorld);
1277 RiseMath::Vec2TransformCoord(&corner[3], &corner[3], &matrixWorld);
1278
1279 V(viewscreen->m_avInstrument->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
1280
1281 vtxs->x = x + corner[0].x; vtxs->y = y + corner[0].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
1282 vtxs->tu = 1.0f; vtxs->tv = 0.0f;
1283 vtxs++;
1284 vtxs->x = x + corner[1].x; vtxs->y = y + corner[1].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
1285 vtxs->tu = 0.0f; vtxs->tv = 0.0f;
1286 vtxs++;
1287 vtxs->x = x + corner[2].x; vtxs->y = y + corner[2].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
1288 vtxs->tu = 1.0f; vtxs->tv = 1.0f;
1289 vtxs++;
1290 vtxs->x = x + corner[3].x; vtxs->y = y + corner[3].y; vtxs->z = 0.0f; vtxs->w = 1.0f;
1291 vtxs->tu = 0.0f; vtxs->tv = 1.0f;
1292
1294
1295 V(pd3dDevice->SetStreamSource(0, viewscreen->m_avInstrument, 0, sizeof(RiseInstrumentVertex)));
1296 V(pd3dDevice->SetTexture(0, viewscreen->m_pddsAOA[1]));
1297
1299 }
1300
1301 }
1302}
1303
1305 logger->AddToCallStack("instruments::OnCreateDevice");
1306}
1307
1309 logger->AddToCallStack("instruments::OnResetDevice");
1310}
1311
1313 logger->AddToCallStack("instruments::OnLostDevice");
1314}
1315
1317 logger->AddToCallStack("instruments::OnDestroyDevice");
1318}
@ TaxiService50
Definition ActiveHelp.h:403
@ TaxiService52
Definition ActiveHelp.h:405
@ TaxiService51
Definition ActiveHelp.h:404
@ TaxiService49
Definition ActiveHelp.h:402
@ TaxiService48
Definition ActiveHelp.h:401
#define V(expression)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
constexpr auto Clamp(T1 val, T2 min, T3 max)
RiseMath::Vector3 GetArcBear(RiseMath::Vector3 vec2, float dist, float altd, RiseMath::Vector3 posnorml)
float GetArcDist(RiseMath::Vector3 from, RiseMath::Vector3 to, bool includeAltDiff)
@ EVENT_SELECT_TARGET
Definition Networking.h:59
@ W6Manx
Definition ServerTypes.h:84
@ C98
Definition ServerTypes.h:61
@ ControlTower
Definition ServerTypes.h:86
@ C2
Definition ServerTypes.h:66
@ C2A
Definition ServerTypes.h:81
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ E10
Definition ServerTypes.h:63
@ T120
Definition ServerTypes.h:67
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ T121
Definition ServerTypes.h:89
const RiseMath::Vector3 northpoleK
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_ONGROUND
Definition ServerTypes.h:43
float TargetDistanceKm
Definition Bus.h:502
float RollAttitudeRadians
Definition Bus.h:48
float PitchAttitudeRadians
Definition Bus.h:47
float HeadingTrackDegrees
Definition Bus.h:303
float LastBearingDeg
Definition Bus.h:504
short targetC
Definition Bus.h:480
RiseMath::Vector3 lastWaypointLocation
Definition Bus.h:501
float HeadingTrueDegrees
Definition Bus.h:41
std::vector< Swaypoint > waypoint
Definition Bus.h:500
float SpeedometerKPH
Definition Bus.h:180
short scanslot[MAX_SCAN]
Definition Bus.h:485
int WPtargetC
Definition Bus.h:499
long scanscroll
Definition Bus.h:483
RiseMath::Vector2 FlightPathVectorDegrees
Definition Bus.h:452
float TargetBearingDeg
Definition Bus.h:503
std::vector< Command > commandStream
Definition Bus.h:442
std::unique_ptr< Bus > bus
Definition GameClass.h:108
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
std::unique_ptr< Networking > networking
Definition GameClass.h:103
InformationDialog * informationDialog
Definition gui.h:1120
bool DismissHelp(int helpId, int nControlID=GUI_UNDERSTOOD)
bool PopUpHelp(short helpId, bool allowDismiss=true, bool isLearnMore=false)
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
@ Error
Definition Logger.h:28
void SendEvent(EventType eventType, float extent=0.0f) const
HRESULT Lock(UINT offset, UINT bytes, void **output, DWORD flags)
HRESULT DrawPrimitive(Primitive type, UINT first, UINT count)
HRESULT SetStreamSource(UINT stream, RenderBuffer *buffer, UINT offset, UINT stride)
HRESULT SetRenderState(DWORD state, DWORD value)
HRESULT SetFVF(DWORD value)
HRESULT SetTextureStageState(DWORD stage, DWORD state, DWORD value)
HRESULT SetTexture(DWORD stage, RenderTexture *texture)
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)
Rendering::RenderBuffer * m_avInstrument
Definition Viewscreen.h:229
Rendering::RenderTexture * m_pddsNamePlate
Definition Viewscreen.h:269
Rendering::RenderTexture * m_pddsFuelIcon
Definition Viewscreen.h:273
RiseMath::Vector3 UniverseRelativeVelocityKms
Definition Viewscreen.h:125
GameClass * gameclass
Definition Viewscreen.h:439
RiseMath::Matrix matrixView
Definition Viewscreen.h:346
float lampTest
Definition Viewscreen.h:424
RiseMath::Vector3 posnorml
Definition Viewscreen.h:383
Rendering::RenderTexture * m_pddsGVCompass
Definition Viewscreen.h:270
float UniverseRelativeSpeedKms
Definition Viewscreen.h:126
Rendering::RenderTexture * m_pddsGVBackground
Definition Viewscreen.h:268
Rendering::RenderSprite * m_spriteVector
Definition Viewscreen.h:325
Rendering::RenderTexture * m_pddsGVDialSmall
Definition Viewscreen.h:267
float insthdgDegrees
Definition Viewscreen.h:369
Rendering::RenderTexture * m_pddsGVDirection
Definition Viewscreen.h:271
float insttrk
Definition Viewscreen.h:369
RiseMath::Vector3 forwardVector
Definition Viewscreen.h:363
Logger * logger
Definition Viewscreen.h:440
Rendering::RenderTexture * m_pddsLightsCruiseIcons
Definition Viewscreen.h:272
Rendering::RenderTexture * m_pddsAOA[3]
Definition Viewscreen.h:274
Rendering::RenderFont * m_pFontNamePlate
Definition Viewscreen.h:131
Rendering::RenderFont * m_pFont
Definition Viewscreen.h:129
Viewscreen * viewscreen
Definition instruments.h:24
Logger * logger
Definition instruments.h:25
void FrameMove(float fElapsedTime) const
void Draw(float fElapsedTime, Rendering::RenderDevice *pd3dDevice) const
void OnLostDevice()
void OnResetDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc)
instruments(Viewscreen *ptr)
void OnDestroyDevice()
void OnCreateDevice(Rendering::RenderDevice *pd3dDevice)
float fuel
Definition globals.cpp:90
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
RiseMath::Vector3 dockMarker
Definition globals.cpp:34
unsigned char ourmoonC
Definition globals.cpp:21
float mark
Definition globals.cpp:45
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
RiseMath::Vector3 dockInterface
Definition globals.cpp:35
#define RISE_FVF_INSTRUMENT
Definition globals.h:127
constexpr uint32_t INVSRCALPHA
constexpr uint32_t SRCALPHA
constexpr uint32_t LESS
constexpr uint32_t ALWAYS
constexpr uint32_t DISCARD
constexpr uint32_t SRCBLEND
constexpr uint32_t ALPHABLENDENABLE
constexpr uint32_t DESTBLEND
constexpr uint32_t ZFUNC
constexpr DWORD AlphaBlend
constexpr DWORD SortTexture
constexpr uint32_t TEXTURE
constexpr uint32_t SELECTARG1
constexpr uint32_t MODULATE
constexpr uint32_t COLOROP
constexpr uint32_t ALPHAARG1
constexpr uint32_t ALPHAOP
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
auto ToRadian(T value)
Definition ClientMath.h:13
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
constexpr float Pi
Definition ClientMath.h:12
Vector3 * Vec3Cross(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:105
Vector2 * Vec2TransformCoord(Vector2 *out, const Vector2 *a, const Matrix *m)
Definition ClientMath.h:111
Vector3 * Vec3TransformCoord(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:109
Vector3 * Vec3Add(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:96
Matrix * MatrixMultiply(Matrix *out, const Matrix *a, const Matrix *b)
Definition ClientMath.h:116
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 * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Definition ClientMath.h:118
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
float Vec3Dot(const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:93
Vector3 * Vec3Normalize(Vector3 *out, const Vector3 *a)
Definition ClientMath.h:103
Vector3 * Vec3Scale(Vector3 *out, const Vector3 *a, float scale)
Definition ClientMath.h:98
Matrix * MatrixRotationZ(Matrix *out, float value)
Definition ClientMath.h:128
auto ToDegree(T value)
Definition ClientMath.h:14
Matrix * MatrixTranslation(Matrix *out, float x, float y, float z)
Definition ClientMath.h:125
constexpr float HalfPi
Definition ClientMath.h:12
std::string name
Definition Command.h:11
short scanDisplayVesselLimit
Definition globals.h:725
short texturelib
Definition globals.h:602
float tachDisplayMaxRPM
Definition globals.h:679
float power
Definition globals.h:599
float fuelmax
Definition globals.h:647
float redlineRPM
Definition globals.h:679
bool nextgen
Definition globals.h:706
char gearshift
Definition globals.h:677
float tach
Definition globals.h:676
bool lowfuel
Definition globals.h:730
float usage
Definition globals.h:670
RiseMath::Vector3 position
Definition globals.h:511