27 #include <Overlay/OgreOverlayManager.h>
28 #include <Overlay/OgreOverlay.h>
29 #include <Overlay/OgreFontManager.h>
57 OverlayWrapper::OverlayWrapper()
63 OverlayWrapper::~OverlayWrapper()
65 showDashboardOverlays(
false,
nullptr);
69 void OverlayWrapper::resizePanel(OverlayElement* oe)
73 oe->setHeight(oe->getHeight() * (Real)win->getWidth() / (Real)win->getHeight());
74 oe->setTop(oe->getTop() * (Real)win->getWidth() / (Real)win->getHeight());
77 void OverlayWrapper::reposPanel(OverlayElement* oe)
81 oe->setTop(oe->getTop() * (Real)win->getWidth() / (Real)win->getHeight());
84 void OverlayWrapper::placeNeedle(SceneNode* node,
float x,
float y,
float len)
86 node->setPosition((
x - 640.0) / 444.0, (512 -
y) / 444.0, -2.0);
87 node->setScale(0.0025, 0.007 * len, 0.007);
90 Overlay* OverlayWrapper::loadOverlay(String name,
bool autoResizeRation)
92 Overlay* o = OverlayManager::getSingleton().getByName(name);
103 m_loaded_overlays.push_back(lo);
112 float w = win->getWidth();
113 float h = win->getHeight();
114 float s = (4.0f / 3.0f) / (
w / h);
118 s = (3.0f / 4.0f) / (h /
w);
122 lo.
o->setScroll(0, 0);
125 lo.
o->setScale(s, s);
126 lo.
o->scroll(1 - s, s - 1);
129 void OverlayWrapper::windowResized()
131 for (
auto it = m_loaded_overlays.begin(); it != m_loaded_overlays.end(); it++)
137 OverlayElement* OverlayWrapper::loadOverlayElement(String name)
139 return OverlayManager::getSingleton().getOverlayElement(name);
142 Ogre::TextureUnitState*
GetTexUnit(Ogre::String material_name)
144 return MaterialManager::getSingleton().getByName(material_name)->getTechnique(0)->getPass(0)->getTextureUnitState(0);
147 int OverlayWrapper::init()
149 m_machine_dashboard_overlay = loadOverlay(
"tracks/MachineDashboardOverlay");
150 m_aerial_dashboard.dash_overlay = loadOverlay(
"tracks/AirDashboardOverlay",
false);
151 m_aerial_dashboard.needles_overlay = loadOverlay(
"tracks/AirNeedlesOverlay",
false);
152 m_marine_dashboard_overlay = loadOverlay(
"tracks/BoatDashboardOverlay");
153 m_marine_dashboard_needles_overlay = loadOverlay(
"tracks/BoatNeedlesOverlay");
157 resizePanel(loadOverlayElement(
"tracks/pressureo"));
158 resizePanel(loadOverlayElement(
"tracks/pressureneedle"));
159 MaterialPtr m = MaterialManager::getSingleton().getByName(
"tracks/pressureneedle_mat");
161 pressuretexture = m->getTechnique(0)->getPass(0)->getTextureUnitState(0);
163 pressuretexture =
nullptr;
165 resizePanel(loadOverlayElement(
"tracks/machineinstructions"));
166 resizePanel(loadOverlayElement(
"tracks/machinehelppanel"));
168 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/machinedashbar"));
169 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/machinedashfiller"));
171 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/airdashbar"));
172 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/airdashfiller"));
174 OverlayElement* tempoe;
175 resizePanel(tempoe = OverlayManager::getSingleton().getOverlayElement(
"tracks/thrusttrack1"));
177 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/thrusttrack2"));
178 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/thrusttrack3"));
179 resizePanel(OverlayManager::getSingleton().getOverlayElement(
"tracks/thrusttrack4"));
181 resizePanel(m_aerial_dashboard.engines[0].thr_element = loadOverlayElement(
"tracks/thrust1"));
182 resizePanel(m_aerial_dashboard.engines[1].thr_element = loadOverlayElement(
"tracks/thrust2"));
183 resizePanel(m_aerial_dashboard.engines[2].thr_element = loadOverlayElement(
"tracks/thrust3"));
184 resizePanel(m_aerial_dashboard.engines[3].thr_element = loadOverlayElement(
"tracks/thrust4"));
186 thrtop = 1.0f + tempoe->getTop() + m_aerial_dashboard.engines[0].thr_element->getHeight() * 0.5f;
187 thrheight = tempoe->getHeight() - m_aerial_dashboard.engines[0].thr_element->getHeight() * 2.0f;
188 throffset = m_aerial_dashboard.engines[0].thr_element->getHeight() * 0.5f;
190 m_aerial_dashboard.thrust_track_top = thrtop;
191 m_aerial_dashboard.thrust_track_height = thrheight;
193 m_aerial_dashboard.engines[0].engfire_element = loadOverlayElement(
"tracks/engfire1");
194 m_aerial_dashboard.engines[1].engfire_element = loadOverlayElement(
"tracks/engfire2");
195 m_aerial_dashboard.engines[2].engfire_element = loadOverlayElement(
"tracks/engfire3");
196 m_aerial_dashboard.engines[3].engfire_element = loadOverlayElement(
"tracks/engfire4");
197 m_aerial_dashboard.engines[0].engstart_element = loadOverlayElement(
"tracks/engstart1");
198 m_aerial_dashboard.engines[1].engstart_element = loadOverlayElement(
"tracks/engstart2");
199 m_aerial_dashboard.engines[2].engstart_element = loadOverlayElement(
"tracks/engstart3");
200 m_aerial_dashboard.engines[3].engstart_element = loadOverlayElement(
"tracks/engstart4");
201 resizePanel(loadOverlayElement(
"tracks/airrpm1"));
202 resizePanel(loadOverlayElement(
"tracks/airrpm2"));
203 resizePanel(loadOverlayElement(
"tracks/airrpm3"));
204 resizePanel(loadOverlayElement(
"tracks/airrpm4"));
205 resizePanel(loadOverlayElement(
"tracks/airpitch1"));
206 resizePanel(loadOverlayElement(
"tracks/airpitch2"));
207 resizePanel(loadOverlayElement(
"tracks/airpitch3"));
208 resizePanel(loadOverlayElement(
"tracks/airpitch4"));
209 resizePanel(loadOverlayElement(
"tracks/airtorque1"));
210 resizePanel(loadOverlayElement(
"tracks/airtorque2"));
211 resizePanel(loadOverlayElement(
"tracks/airtorque3"));
212 resizePanel(loadOverlayElement(
"tracks/airtorque4"));
213 resizePanel(loadOverlayElement(
"tracks/airspeed"));
214 resizePanel(loadOverlayElement(
"tracks/vvi"));
215 resizePanel(loadOverlayElement(
"tracks/altimeter"));
216 resizePanel(loadOverlayElement(
"tracks/altimeter_val"));
217 m_aerial_dashboard.alt_value_textarea = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/altimeter_val");
218 boat_depth_value_taoe = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/boatdepthmeter_val");
219 resizePanel(loadOverlayElement(
"tracks/adi-tape"));
220 resizePanel(loadOverlayElement(
"tracks/adi"));
221 resizePanel(loadOverlayElement(
"tracks/adi-bugs"));
222 m_aerial_dashboard.adibugstexture =
GetTexUnit(
"tracks/adi-bugs");
223 m_aerial_dashboard.aditapetexture =
GetTexUnit(
"tracks/adi-tape");
224 resizePanel(loadOverlayElement(
"tracks/aoa"));
225 resizePanel(loadOverlayElement(
"tracks/hsi"));
226 resizePanel(loadOverlayElement(
"tracks/hsi-rose"));
227 resizePanel(loadOverlayElement(
"tracks/hsi-bug"));
228 resizePanel(loadOverlayElement(
"tracks/hsi-v"));
229 resizePanel(loadOverlayElement(
"tracks/hsi-h"));
230 m_aerial_dashboard.hsirosetexture =
GetTexUnit(
"tracks/hsi-rose");
231 m_aerial_dashboard.hsibugtexture =
GetTexUnit(
"tracks/hsi-bug");
232 m_aerial_dashboard.hsivtexture =
GetTexUnit(
"tracks/hsi-v");
233 m_aerial_dashboard.hsihtexture =
GetTexUnit(
"tracks/hsi-h");
235 reposPanel(loadOverlayElement(
"tracks/ap_hdg_pack"));
236 reposPanel(loadOverlayElement(
"tracks/ap_wlv_but"));
237 reposPanel(loadOverlayElement(
"tracks/ap_nav_but"));
238 reposPanel(loadOverlayElement(
"tracks/ap_alt_pack"));
239 reposPanel(loadOverlayElement(
"tracks/ap_vs_pack"));
240 reposPanel(loadOverlayElement(
"tracks/ap_ias_pack"));
241 reposPanel(loadOverlayElement(
"tracks/ap_gpws_but"));
242 reposPanel(loadOverlayElement(
"tracks/ap_brks_but"));
243 m_aerial_dashboard.hdg.Setup(
"tracks/ap_hdg_but",
"tracks/hdg-on",
"tracks/hdg-off");
244 m_aerial_dashboard.hdg_trim.Setup(
"tracks/ap_hdg_up",
"tracks/ap_hdg_dn",
"tracks/ap_hdg_val");
245 m_aerial_dashboard.wlv.Setup(
"tracks/ap_wlv_but",
"tracks/wlv-on",
"tracks/wlv-off");
246 m_aerial_dashboard.nav.Setup(
"tracks/ap_nav_but",
"tracks/nav-on",
"tracks/nav-off");
247 m_aerial_dashboard.alt.Setup(
"tracks/ap_alt_but",
"tracks/hold-on",
"tracks/hold-off");
248 m_aerial_dashboard.alt_trim.Setup(
"tracks/ap_alt_up",
"tracks/ap_alt_dn",
"tracks/ap_alt_val");
249 m_aerial_dashboard.vs.Setup(
"tracks/ap_vs_but",
"tracks/vs-on",
"tracks/vs-off");
250 m_aerial_dashboard.vs_trim.Setup(
"tracks/ap_vs_up",
"tracks/ap_vs_dn",
"tracks/ap_vs_val");
251 m_aerial_dashboard.ias.Setup(
"tracks/ap_ias_but",
"tracks/athr-on",
"tracks/athr-off");
252 m_aerial_dashboard.ias_trim.Setup(
"tracks/ap_ias_up",
"tracks/ap_ias_dn",
"tracks/ap_ias_val");
253 m_aerial_dashboard.gpws.Setup(
"tracks/ap_gpws_but",
"tracks/gpws-on",
"tracks/gpws-off");
254 m_aerial_dashboard.brks.Setup(
"tracks/ap_brks_but",
"tracks/brks-on",
"tracks/brks-off");
257 resizePanel(loadOverlayElement(
"tracks/boatdashbar"));
258 resizePanel(loadOverlayElement(
"tracks/boatdashfiller"));
259 resizePanel(loadOverlayElement(
"tracks/boatthrusttrack1"));
260 resizePanel(loadOverlayElement(
"tracks/boatthrusttrack2"));
265 resizePanel(bthro1 = loadOverlayElement(
"tracks/boatthrust1"));
266 resizePanel(bthro2 = loadOverlayElement(
"tracks/boatthrust2"));
268 resizePanel(loadOverlayElement(
"tracks/boatspeed"));
269 resizePanel(loadOverlayElement(
"tracks/boatsteer"));
270 resizePanel(loadOverlayElement(
"tracks/boatspeedneedle"));
271 resizePanel(loadOverlayElement(
"tracks/boatsteer/fg"));
272 boatspeedtexture = ((MaterialPtr)(MaterialManager::getSingleton().getByName(
"tracks/boatspeedneedle_mat")))->getTechnique(0)->getPass(0)->getTextureUnitState(0);
273 boatsteertexture = ((MaterialPtr)(MaterialManager::getSingleton().getByName(
"tracks/boatsteer/fg_mat")))->getTechnique(0)->getPass(0)->getTextureUnitState(0);
276 speedotexture = ((MaterialPtr)(MaterialManager::getSingleton().getByName(
"tracks/speedoneedle_mat")))->getTechnique(0)->getPass(0)->getTextureUnitState(0);
277 tachotexture = ((MaterialPtr)(MaterialManager::getSingleton().getByName(
"tracks/tachoneedle_mat"))) ->getTechnique(0)->getPass(0)->getTextureUnitState(0);
279 resizePanel(loadOverlayElement(
"tracks/airspeedneedle"));
280 m_aerial_dashboard.airspeedtexture =
GetTexUnit(
"tracks/airspeedneedle_mat");
282 resizePanel(loadOverlayElement(
"tracks/altimeterneedle"));
283 m_aerial_dashboard.altimetertexture =
GetTexUnit(
"tracks/altimeterneedle_mat");
285 resizePanel(loadOverlayElement(
"tracks/vvineedle"));
286 m_aerial_dashboard.vvitexture =
GetTexUnit(
"tracks/vvineedle_mat");
288 resizePanel(loadOverlayElement(
"tracks/aoaneedle"));
289 m_aerial_dashboard.aoatexture =
GetTexUnit(
"tracks/aoaneedle_mat");
291 resizePanel(loadOverlayElement(
"tracks/airrpm1needle"));
292 m_aerial_dashboard.engines[0].rpm_texture =
GetTexUnit(
"tracks/airrpm1needle_mat");
293 resizePanel(loadOverlayElement(
"tracks/airrpm2needle"));
294 m_aerial_dashboard.engines[1].rpm_texture =
GetTexUnit(
"tracks/airrpm2needle_mat");
295 resizePanel(loadOverlayElement(
"tracks/airrpm3needle"));
296 m_aerial_dashboard.engines[2].rpm_texture =
GetTexUnit(
"tracks/airrpm3needle_mat");
297 resizePanel(loadOverlayElement(
"tracks/airrpm4needle"));
298 m_aerial_dashboard.engines[3].rpm_texture =
GetTexUnit(
"tracks/airrpm4needle_mat");
300 resizePanel(loadOverlayElement(
"tracks/airpitch1needle"));
301 m_aerial_dashboard.engines[0].pitch_texture =
GetTexUnit(
"tracks/airpitch1needle_mat");
302 resizePanel(loadOverlayElement(
"tracks/airpitch2needle"));
303 m_aerial_dashboard.engines[1].pitch_texture =
GetTexUnit(
"tracks/airpitch2needle_mat");
304 resizePanel(loadOverlayElement(
"tracks/airpitch3needle"));
305 m_aerial_dashboard.engines[2].pitch_texture =
GetTexUnit(
"tracks/airpitch3needle_mat");
306 resizePanel(loadOverlayElement(
"tracks/airpitch4needle"));
307 m_aerial_dashboard.engines[3].pitch_texture =
GetTexUnit(
"tracks/airpitch4needle_mat");
309 resizePanel(loadOverlayElement(
"tracks/airtorque1needle"));
310 m_aerial_dashboard.engines[0].torque_texture =
GetTexUnit(
"tracks/airtorque1needle_mat");
311 resizePanel(loadOverlayElement(
"tracks/airtorque2needle"));
312 m_aerial_dashboard.engines[1].torque_texture =
GetTexUnit(
"tracks/airtorque2needle_mat");
313 resizePanel(loadOverlayElement(
"tracks/airtorque3needle"));
314 m_aerial_dashboard.engines[2].torque_texture =
GetTexUnit(
"tracks/airtorque3needle_mat");
315 resizePanel(loadOverlayElement(
"tracks/airtorque4needle"));
316 m_aerial_dashboard.engines[3].torque_texture =
GetTexUnit(
"tracks/airtorque4needle_mat");
318 guiGear = loadOverlayElement(
"tracks/Gear");
319 guiGear3D = loadOverlayElement(
"tracks/3DGear");
321 guiAuto[0] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/AGearR");
322 guiAuto[1] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/AGearN");
323 guiAuto[2] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/AGearD");
324 guiAuto[3] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/AGear2");
325 guiAuto[4] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/AGear1");
327 guiAuto3D[0] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/3DAGearR");
328 guiAuto3D[1] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/3DAGearN");
329 guiAuto3D[2] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/3DAGearD");
330 guiAuto3D[3] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/3DAGear2");
331 guiAuto3D[4] = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/3DAGear1");
333 m_truck_pressure_overlay = loadOverlay(
"tracks/PressureOverlay");
334 m_truck_pressure_needle_overlay = loadOverlay(
"tracks/PressureNeedleOverlay");
336 m_racing_overlay = loadOverlay(
"tracks/Racing",
false);
337 laptime = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/Racing/LapTime");
338 bestlaptime = (TextAreaOverlayElement*)loadOverlayElement(
"tracks/Racing/BestLapTime");
345 void OverlayWrapper::update(
float dt)
347 if (mTimeUntilNextToggle > 0)
348 mTimeUntilNextToggle -= dt;
351 void OverlayWrapper::showPressureOverlay(
bool show)
353 if (m_truck_pressure_overlay)
357 m_truck_pressure_overlay->show();
358 m_truck_pressure_needle_overlay->show();
359 BITMASK_SET_1(m_visible_overlays, VisibleOverlays::TRUCK_TIRE_PRESSURE_OVERLAY);
363 m_truck_pressure_overlay->hide();
364 m_truck_pressure_needle_overlay->hide();
365 BITMASK_SET_0(m_visible_overlays, VisibleOverlays::TRUCK_TIRE_PRESSURE_OVERLAY);
370 void OverlayWrapper::ToggleDashboardOverlays(
ActorPtr actor)
372 showDashboardOverlays(!m_dashboard_visible, actor);
375 void OverlayWrapper::showDashboardOverlays(
bool show,
ActorPtr actor)
377 m_dashboard_visible = show;
392 m_aerial_dashboard.needles_overlay->show();
393 m_aerial_dashboard.dash_overlay->show();
395 else if (mode ==
BOAT)
397 m_marine_dashboard_needles_overlay->show();
398 m_marine_dashboard_overlay->show();
402 Ogre::OverlayElement* help_elem = OverlayManager::getSingleton().getOverlayElement(
"tracks/machinehelppanel");
409 help_elem->setMaterialName(
"tracks/black");
411 m_machine_dashboard_overlay->show();
416 m_aerial_dashboard.needles_overlay->hide();
417 m_aerial_dashboard.dash_overlay->hide();
419 m_marine_dashboard_needles_overlay->hide();
420 m_marine_dashboard_overlay->hide();
422 m_machine_dashboard_overlay->hide();
426 void OverlayWrapper::updateStats(
bool detailed)
428 static UTFString currFps =
_L(
"Current FPS: ");
429 static UTFString avgFps =
_L(
"Average FPS: ");
430 static UTFString bestFps =
_L(
"Best FPS: ");
431 static UTFString worstFps =
_L(
"Worst FPS: ");
432 static UTFString tris =
_L(
"Triangle Count: ");
433 const RenderTarget::FrameStats& stats = win->getStatistics();
438 OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement(
"Core/AverageFps");
439 OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement(
"Core/CurrFps");
440 OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement(
"Core/BestFps");
441 OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement(
"Core/WorstFps");
443 guiAvg->setCaption(avgFps +
TOSTRING(stats.avgFPS));
444 guiCurr->setCaption(currFps +
TOSTRING(stats.lastFPS));
445 guiBest->setCaption(bestFps +
TOSTRING(stats.bestFPS) +
U(
" ") +
TOSTRING(stats.bestFrameTime) +
U(
" ms"));
446 guiWorst->setCaption(worstFps +
TOSTRING(stats.worstFPS) +
U(
" ") +
TOSTRING(stats.worstFrameTime) +
U(
" ms"));
448 OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement(
"Core/NumTris");
449 UTFString triss = tris +
TOSTRING(stats.triangleCount);
450 if (stats.triangleCount > 1000000)
451 triss = tris +
TOSTRING(stats.triangleCount/1000000.0f) +
U(
" M");
452 else if (stats.triangleCount > 1000)
453 triss = tris +
TOSTRING(stats.triangleCount/1000.0f) +
U(
" k");
454 guiTris->setCaption(triss);
457 UTFString memoryText;
458 if (TextureManager::getSingleton().getMemoryUsage() > 1)
459 memoryText = memoryText +
_L(
"Textures: ") +
formatBytes(TextureManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(TextureManager::getSingleton().getMemoryBudget()) +
U(
"\n");
460 if (CompositorManager::getSingleton().getMemoryUsage() > 1)
461 memoryText = memoryText +
_L(
"Compositors: ") +
formatBytes(CompositorManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(CompositorManager::getSingleton().getMemoryBudget()) +
U(
"\n");
462 if (FontManager::getSingleton().getMemoryUsage() > 1)
463 memoryText = memoryText +
_L(
"Fonts: ") +
formatBytes(FontManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(FontManager::getSingleton().getMemoryBudget()) +
U(
"\n");
464 if (GpuProgramManager::getSingleton().getMemoryUsage() > 1)
465 memoryText = memoryText +
_L(
"GPU Program: ") +
formatBytes(GpuProgramManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(GpuProgramManager::getSingleton().getMemoryBudget()) +
U(
"\n");
466 if (HighLevelGpuProgramManager::getSingleton().getMemoryUsage() > 1)
467 memoryText = memoryText +
_L(
"HL GPU Program: ") +
formatBytes(HighLevelGpuProgramManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(HighLevelGpuProgramManager::getSingleton().getMemoryBudget()) +
U(
"\n");
468 if (MaterialManager::getSingleton().getMemoryUsage() > 1)
469 memoryText = memoryText +
_L(
"Materials: ") +
formatBytes(MaterialManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(MaterialManager::getSingleton().getMemoryBudget()) +
U(
"\n");
470 if (MeshManager::getSingleton().getMemoryUsage() > 1)
471 memoryText = memoryText +
_L(
"Meshes: ") +
formatBytes(MeshManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(MeshManager::getSingleton().getMemoryBudget()) +
U(
"\n");
472 if (SkeletonManager::getSingleton().getMemoryUsage() > 1)
473 memoryText = memoryText +
_L(
"Skeletons: ") +
formatBytes(SkeletonManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(SkeletonManager::getSingleton().getMemoryBudget()) +
U(
"\n");
474 if (MaterialManager::getSingleton().getMemoryUsage() > 1)
475 memoryText = memoryText +
_L(
"Materials: ") +
formatBytes(MaterialManager::getSingleton().getMemoryUsage()) +
U(
" / ") +
formatBytes(MaterialManager::getSingleton().getMemoryBudget()) +
U(
"\n");
476 memoryText = memoryText +
U(
"\n");
478 OverlayElement* memoryDbg = OverlayManager::getSingleton().getOverlayElement(
"Core/MemoryText");
479 memoryDbg->setCaption(memoryText);
481 float sumMem = TextureManager::getSingleton().getMemoryUsage() + CompositorManager::getSingleton().getMemoryUsage() + FontManager::getSingleton().getMemoryUsage() + GpuProgramManager::getSingleton().getMemoryUsage() + HighLevelGpuProgramManager::getSingleton().getMemoryUsage() + MaterialManager::getSingleton().getMemoryUsage() + MeshManager::getSingleton().getMemoryUsage() + SkeletonManager::getSingleton().getMemoryUsage() + MaterialManager::getSingleton().getMemoryUsage();
482 String sumMemoryText =
_L(
"Memory (Ogre): ") +
formatBytes(sumMem) +
U(
"\n");
484 OverlayElement* memorySumDbg = OverlayManager::getSingleton().getOverlayElement(
"Core/CurrMemory");
485 memorySumDbg->setCaption(sumMemoryText);
493 bool OverlayWrapper::handleMouseMoved()
495 if (!m_aerial_dashboard.needles_overlay->isVisible())
508 float mouseX = ms.X.abs / (float)ms.width;
509 float mouseY = ms.Y.abs / (
float)ms.height;
517 OverlayElement* element = m_aerial_dashboard.needles_overlay->findElementAt(mouseX, mouseY);
521 float thr_value = 1.0f - ((mouseY - thrtop - throffset) / thrheight);
522 for (
int i = 0; i < num_engines; ++i)
524 if (element == m_aerial_dashboard.engines[i].thr_element)
531 element = m_aerial_dashboard.dash_overlay->findElementAt(mouseX, mouseY);
535 for (
int i = 0; i < num_engines; ++i)
537 if (element == m_aerial_dashboard.engines[i].engstart_element)
542 if (player_actor->
ar_autopilot && mTimeUntilNextToggle <= 0)
545 if (element == m_aerial_dashboard.hdg.element)
547 mTimeUntilNextToggle = 0.2;
550 if (element == m_aerial_dashboard.wlv.element)
552 mTimeUntilNextToggle = 0.2;
555 if (element == m_aerial_dashboard.nav.element)
557 mTimeUntilNextToggle = 0.2;
561 if (element == m_aerial_dashboard.alt.element)
563 mTimeUntilNextToggle = 0.2;
566 if (element == m_aerial_dashboard.vs.element)
568 mTimeUntilNextToggle = 0.2;
572 if (element == m_aerial_dashboard.ias.element)
574 mTimeUntilNextToggle = 0.2;
578 if (element == m_aerial_dashboard.gpws.element)
580 mTimeUntilNextToggle = 0.2;
584 if (element == m_aerial_dashboard.brks.element)
586 mTimeUntilNextToggle = 0.2;
590 if (element == m_aerial_dashboard.hdg_trim.up_button)
592 mTimeUntilNextToggle = 0.1;
595 if (element == m_aerial_dashboard.hdg_trim.dn_button)
597 mTimeUntilNextToggle = 0.1;
600 if (element == m_aerial_dashboard.alt_trim.up_button)
602 mTimeUntilNextToggle = 0.1;
605 if (element == m_aerial_dashboard.alt_trim.dn_button)
607 mTimeUntilNextToggle = 0.1;
610 if (element == m_aerial_dashboard.vs_trim.up_button)
612 mTimeUntilNextToggle = 0.1;
615 if (element == m_aerial_dashboard.vs_trim.dn_button)
617 mTimeUntilNextToggle = 0.1;
620 if (element == m_aerial_dashboard.ias_trim.up_button)
622 mTimeUntilNextToggle = 0.1;
625 if (element == m_aerial_dashboard.ias_trim.dn_button)
627 mTimeUntilNextToggle = 0.1;
636 bool OverlayWrapper::handleMousePressed()
638 return handleMouseMoved();
641 bool OverlayWrapper::handleMouseReleased()
643 return handleMouseMoved();
650 this->showPressureOverlay(
true);
652 Real angle = 135.0 - pressure * 2.7;
653 pressuretexture->setTextureRotate(Degree(angle));
657 this->showPressureOverlay(
false);
665 if (vehicle_getgear > 0)
669 guiGear->setCaption(gearstr);
670 guiGear3D->setCaption(gearstr);
672 else if (vehicle_getgear == 0)
674 guiGear->setCaption(
"N");
675 guiGear3D->setCaption(
"N");
679 guiGear->setCaption(
"R");
680 guiGear3D->setCaption(
"R");
685 for (
int i = 0; i < 5; i++)
691 guiAuto[i]->setColourTop(ColourValue(1.0, 0.2, 0.2, 1.0));
692 guiAuto[i]->setColourBottom(ColourValue(0.8, 0.1, 0.1, 1.0));
693 guiAuto3D[i]->setColourTop(ColourValue(1.0, 0.2, 0.2, 1.0));
694 guiAuto3D[i]->setColourBottom(ColourValue(0.8, 0.1, 0.1, 1.0));
698 guiAuto[i]->setColourTop(ColourValue(1.0, 1.0, 1.0, 1.0));
699 guiAuto[i]->setColourBottom(ColourValue(0.8, 0.8, 0.8, 1.0));
700 guiAuto3D[i]->setColourTop(ColourValue(1.0, 1.0, 1.0, 1.0));
701 guiAuto3D[i]->setColourBottom(ColourValue(0.8, 0.8, 0.8, 1.0));
708 guiAuto[i]->setColourTop(ColourValue(0.4, 0.05, 0.05, 1.0));
709 guiAuto[i]->setColourBottom(ColourValue(0.3, 0.02, 0.2, 1.0));
710 guiAuto3D[i]->setColourTop(ColourValue(0.4, 0.05, 0.05, 1.0));
711 guiAuto3D[i]->setColourBottom(ColourValue(0.3, 0.02, 0.2, 1.0));
715 guiAuto[i]->setColourTop(ColourValue(0.4, 0.4, 0.4, 1.0));
716 guiAuto[i]->setColourBottom(ColourValue(0.3, 0.3, 0.3, 1.0));
717 guiAuto3D[i]->setColourTop(ColourValue(0.4, 0.4, 0.4, 1.0));
718 guiAuto3D[i]->setColourBottom(ColourValue(0.3, 0.3, 0.3, 1.0));
726 angle = std::max(-140.0f, angle);
727 speedotexture->setTextureRotate(Degree(angle));
730 Real tachoFactor = 0.072;
736 angle = std::max(-120.0f, angle);
737 angle = std::min(angle, 121.0f);
738 tachotexture->setTextureRotate(Degree(angle));
747 int num_ae =
static_cast<int>( simbuf_ae.size() );
750 m_aerial_dashboard.SetThrottle(0,
true, simbuf_ae[0].simbuf_ae_throttle);
751 m_aerial_dashboard.SetThrottle(1, (num_ae > 1), (num_ae > 1) ? simbuf_ae[1].simbuf_ae_throttle : 0.f);
752 m_aerial_dashboard.SetThrottle(2, (num_ae > 2), (num_ae > 2) ? simbuf_ae[2].simbuf_ae_throttle : 0.f);
753 m_aerial_dashboard.SetThrottle(3, (num_ae > 3), (num_ae > 3) ? simbuf_ae[3].simbuf_ae_throttle : 0.f);
756 m_aerial_dashboard.SetEngineFailed(0, simbuf_ae[0].simbuf_ae_failed);
757 m_aerial_dashboard.SetEngineFailed(1, num_ae > 1 && simbuf_ae[1].simbuf_ae_failed);
758 m_aerial_dashboard.SetEngineFailed(2, num_ae > 2 && simbuf_ae[2].simbuf_ae_failed);
759 m_aerial_dashboard.SetEngineFailed(3, num_ae > 3 && simbuf_ae[3].simbuf_ae_failed);
766 float altitude =
nodes[0].AbsPosition.y;
768 float sea_level_pressure = 101325;
770 float airpressure = sea_level_pressure * pow(1.0 - 0.0065 * altitude / 288.15, 5.24947);
771 float airdensity = airpressure * 0.0000120896;
773 float kt = ground_speed_kt * sqrt(airdensity / 1.225);
777 angle = ((kt - 23.0) / 1.111);
779 angle = (24.0 + (kt - 50.0) / 0.8621);
781 angle = (82.0 + (kt - 100.0) / 0.8065);
785 m_aerial_dashboard.airspeedtexture->setTextureRotate(Degree(-angle));
791 float absangle = angle;
793 absangle = -absangle;
806 m_aerial_dashboard.aoatexture->setTextureRotate(Degree(-angle * 4.7 + 90.0));
809 angle =
nodes[0].AbsPosition.y * 1.1811;
810 m_aerial_dashboard.altimetertexture->setTextureRotate(Degree(-angle));
812 sprintf(altc,
"%03u", (
int)(
nodes[0].AbsPosition.y / 30.48));
813 m_aerial_dashboard.alt_value_textarea->setCaption(altc);
819 float rollangle = asin(rollv.dotProduct(Vector3::UNIT_Y));
823 float pitchangle = asin(dirv.dotProduct(Vector3::UNIT_Y));
824 Vector3 upv = dirv.crossProduct(-rollv);
826 rollangle = 3.14159 - rollangle;
827 m_aerial_dashboard.adibugstexture->setTextureRotate(Radian(-rollangle));
828 m_aerial_dashboard.aditapetexture->setTextureVScroll(-pitchangle * 0.25);
829 m_aerial_dashboard.aditapetexture->setTextureRotate(Radian(-rollangle));
832 float dirangle = atan2(dirv.dotProduct(Vector3::UNIT_X), dirv.dotProduct(-Vector3::UNIT_Z));
833 m_aerial_dashboard.hsirosetexture->setTextureRotate(Radian(dirangle));
849 m_aerial_dashboard.hsivtexture->setTextureUScroll(-hdev * 0.02);
854 m_aerial_dashboard.hsihtexture->setTextureVScroll(-vdev * 0.02);
858 if (vvi < 1000.0 && vvi > -1000.0)
860 if (vvi > 1000.0 && vvi < 6000.0)
861 angle = 47.0 + (vvi - 1000.0) * 0.01175;
864 if (vvi < -1000.0 && vvi > -6000.0)
865 angle = -47.0 + (vvi + 1000.0) * 0.01175;
868 m_aerial_dashboard.vvitexture->setTextureRotate(Degree(-angle + 90.0));
870 const bool is_prop = simbuf_ae[0].simbuf_ae_type == AeroEngineType::AE_XPROP;
873 m_aerial_dashboard.SetEngineRpm(0, simbuf_ae[0].simbuf_ae_rpmpc);
874 m_aerial_dashboard.SetEngineRpm(1, (num_ae > 1) ? simbuf_ae[1].simbuf_ae_rpmpc : 0.f);
875 m_aerial_dashboard.SetEngineRpm(2, (num_ae > 2) ? simbuf_ae[2].simbuf_ae_rpmpc : 0.f);
876 m_aerial_dashboard.SetEngineRpm(3, (num_ae > 3) ? simbuf_ae[3].simbuf_ae_rpmpc : 0.f);
879 m_aerial_dashboard.SetEnginePitch(0, (is_prop) ? simbuf_ae[0].simbuf_tp_aepitch : 0.f);
880 m_aerial_dashboard.SetEnginePitch(1, (num_ae > 1 && is_prop) ? simbuf_ae[1].simbuf_tp_aepitch : 0.f);
881 m_aerial_dashboard.SetEnginePitch(2, (num_ae > 2 && is_prop) ? simbuf_ae[2].simbuf_tp_aepitch : 0.f);
882 m_aerial_dashboard.SetEnginePitch(3, (num_ae > 3 && is_prop) ? simbuf_ae[3].simbuf_tp_aepitch : 0.f);
885 m_aerial_dashboard.SetEngineTorque(0, (is_prop) ? simbuf_ae[0].simbuf_tp_aetorque : 0.f);
886 m_aerial_dashboard.SetEngineTorque(1, (num_ae > 1 && is_prop) ? simbuf_ae[1].simbuf_tp_aetorque : 0.f);
887 m_aerial_dashboard.SetEngineTorque(2, (num_ae > 2 && is_prop) ? simbuf_ae[2].simbuf_tp_aetorque : 0.f);
888 m_aerial_dashboard.SetEngineTorque(3, (num_ae > 3 && is_prop) ? simbuf_ae[3].simbuf_tp_aetorque : 0.f);
891 m_aerial_dashboard.SetIgnition(0,
true, simbuf_ae[0].simbuf_ae_ignition);
892 m_aerial_dashboard.SetIgnition(1, num_ae > 1, num_ae > 1 && simbuf_ae[1].simbuf_ae_ignition);
893 m_aerial_dashboard.SetIgnition(2, num_ae > 2, num_ae > 2 && simbuf_ae[2].simbuf_ae_ignition);
894 m_aerial_dashboard.SetIgnition(3, num_ae > 3, num_ae > 3 && simbuf_ae[3].simbuf_ae_ignition);
915 m_aerial_dashboard.vs_trim.display->setCaption(
"000");
922 void OverlayWrapper::UpdateMarineHUD(
ActorPtr vehicle)
934 if (height > 0.1 && height < 99.9)
936 sprintf(tmp,
"%2.1f", height);
937 boat_depth_value_taoe->setCaption(tmp);
941 boat_depth_value_taoe->setCaption(
"--.-");
947 float kt = cam_dir.dotProduct(velocity) * 1.9438;
948 float angle = kt * 4.2;
949 boatspeedtexture->setTextureRotate(Degree(-angle));
953 void OverlayWrapper::ShowRacingOverlay()
955 m_racing_overlay->show();
959 void OverlayWrapper::HideRacingOverlay()
961 m_racing_overlay->hide();
968 UTFString txt =
StringUtil::format(
"%.2i'%.2i.%.2i", (
int)(time) / 60, (
int)(time) % 60, (
int)(time * 100.0) % 100);
969 this->laptime->setCaption(txt);
973 txt =
StringUtil::format(
"%.2i'%.2i.%.2i", (
int)(time) / 60, (
int)(time) % 60, (
int)(time * 100.0) % 100);
974 this->bestlaptime->setCaption(txt);
975 this->bestlaptime->show();
979 this->bestlaptime->hide();
983 Ogre::ColourValue colour = Ogre::ColourValue::White;
984 if (time_diff > 0.0f)
986 colour = ColourValue(0.8, 0.0, 0.0);
988 else if (time_diff < 0.0f)
990 colour = ColourValue(0.0, 0.8, 0.0);
992 this->laptime->setColourTop(colour);
993 this->laptime->setColourBottom(colour);
996 void AeroDashOverlay::SetThrottle(
int engine,
bool visible,
float value)
1000 engines[engine].thr_element->show();
1001 engines[engine].thr_element->setTop(
1002 thrust_track_top + thrust_track_height * (1.0 - value) - 1.0);
1006 engines[engine].thr_element->hide();
1010 void AeroDashOverlay::SetEngineFailed(
int engine,
bool value)
1012 engines[engine].engfire_element->setMaterialName(
1013 value ?
"tracks/engfire-on" :
"tracks/engfire-off");
1016 void AeroDashOverlay::SetEngineRpm(
int engine,
float pcent)
1020 angle = -5.0 + pcent * 1.9167;
1021 else if (pcent < 110.0)
1022 angle = 110.0 + (pcent - 60.0) * 4.075;
1025 engines[engine].rpm_texture->setTextureRotate(Ogre::Degree(-angle));
1028 void AeroDashOverlay::SetEnginePitch(
int engine,
float value)
1030 engines[engine].pitch_texture->setTextureRotate(Degree(-value * 2.0));
1033 void AeroDashOverlay::SetEngineTorque(
int engine,
float pcent)
1037 angle = -5.0 + pcent * 1.9167;
1038 else if (pcent < 110.0)
1039 angle = 110.0 + (pcent - 60.0) * 4.075;
1042 engines[engine].torque_texture->setTextureRotate(Degree(-angle));
1045 void AeroDashOverlay::SetIgnition(
int engine,
bool visible,
bool ignited)
1049 engines[engine].engstart_element->show();
1050 engines[engine].engstart_element->setMaterialName(
1051 ignited ?
"tracks/engstart-on" :
"tracks/engstart-off");
1055 engines[engine].engstart_element->hide();
1059 void AeroSwitchOverlay::SetActive(
bool value)
1061 element->setMaterial(value ? on_material : off_material);
1064 void AeroSwitchOverlay::Setup(std::string
const & elem_name, std::string
const & mat_on, std::string
const & mat_off)
1066 element = Ogre::OverlayManager::getSingleton().getOverlayElement(elem_name);
1067 on_material = Ogre::MaterialManager::getSingleton().getByName(mat_on);
1068 off_material = Ogre::MaterialManager::getSingleton().getByName(mat_off);
1071 void AeroTrimOverlay::Setup(std::string
const & up, std::string
const & dn, std::string
const & disp)
1073 display = Ogre::OverlayManager::getSingleton().getOverlayElement(disp);
1074 up_button = Ogre::OverlayManager::getSingleton().getOverlayElement(up);
1075 dn_button = Ogre::OverlayManager::getSingleton().getOverlayElement(dn);
1078 void AeroTrimOverlay::DisplayFormat(
const char* fmt, ...)
1080 char buffer[500] = {};
1083 va_start(args, fmt);
1084 vsprintf(buffer, fmt, args);
1087 display->setCaption(buffer);