[Gcblue-commits] gcb_wx/src/graphics tc3DModel.cpp,1.35,1.36 tc3DViewer.cpp,1.33,1.34 tcButton.cpp,1
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2006-04-21 23:29:13
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8677/src/graphics Modified Files: tc3DModel.cpp tc3DViewer.cpp tcButton.cpp tcDatabaseInfoWindow.cpp tcDatabaseViewer.cpp tcNetworkView.cpp Log Message: Index: tcDatabaseViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseViewer.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcDatabaseViewer.cpp 28 Mar 2006 23:58:12 -0000 1.3 --- tcDatabaseViewer.cpp 21 Apr 2006 23:29:09 -0000 1.4 *************** *** 58,61 **** --- 58,62 ---- { SetClassificationMask(PTYPE_SURFACE); + SetButtonOn(0); } *************** *** 63,66 **** --- 64,68 ---- { SetClassificationMask(PTYPE_SUBMARINE); + SetButtonOn(1); } *************** *** 68,71 **** --- 70,74 ---- { SetClassificationMask(PTYPE_FIXEDWING); + SetButtonOn(2); } *************** *** 73,76 **** --- 76,80 ---- { SetClassificationMask(PTYPE_HELO); + SetButtonOn(3); } *************** *** 78,81 **** --- 82,86 ---- { SetClassificationMask(PTYPE_FIXED); + SetButtonOn(4); } *************** *** 83,86 **** --- 88,92 ---- { SetClassificationMask(PTYPE_MISSILE); + SetButtonOn(5); } *************** *** 88,91 **** --- 94,98 ---- { SetClassificationMask(PTYPE_TORPEDO); + SetButtonOn(6); } *************** *** 93,96 **** --- 100,104 ---- { SetClassificationMask(PTYPE_BALLISTIC); + SetButtonOn(7); } *************** *** 121,124 **** --- 129,137 ---- } + const std::string& tcDatabaseViewer::GetDisplayClass() const + { + return displayClassName; + } + /** * *************** *** 231,239 **** float width = 64.0f; for (size_t n=0; n<nButtons; n++) { tcButton* button = new tcButton(this, wxPoint(x, y), wxSize(width, width)); ! button->LoadImages("test_button_off.png", "test_button_on.png", ! "test_button_on.png", "test_button_on.png"); button->SetActive(true); button->SetCommand(101 + n); --- 244,255 ---- float width = 64.0f; + wxASSERT(buttons.size() == 0); + buttons.clear(); + for (size_t n=0; n<nButtons; n++) { tcButton* button = new tcButton(this, wxPoint(x, y), wxSize(width, width)); ! buttons.push_back(button); ! button->SetActive(true); button->SetCommand(101 + n); *************** *** 245,257 **** switch (n) { ! case 0: caption = "Surface naval"; break; ! case 1: caption = "Submarine"; break; ! case 2: caption = "Air, fixed wing"; break; ! case 3: caption = "Air, rotary wing"; break; ! case 4: caption = "Land"; break; ! case 5: caption = "Missile"; break; ! case 6: caption = "Torpedo"; break; ! case 7: caption = "Ballistic"; break; ! default: caption = "Error"; break; } --- 261,309 ---- switch (n) { ! case 0: ! caption = "Surface naval"; ! button->LoadImages("dbviewer\\surface_off.png", "dbviewer\\surface_on.png", ! "dbviewer\\surface_over.png", "dbviewer\\surface_on.png"); ! break; ! case 1: ! caption = "Submarine"; ! button->LoadImages("dbviewer\\sub_off.png", "dbviewer\\sub_on.png", ! "dbviewer\\sub_over.png", "dbviewer\\sub_on.png"); ! break; ! case 2: ! caption = "Air, fixed wing"; ! button->LoadImages("dbviewer\\air_off.png", "dbviewer\\air_on.png", ! "dbviewer\\air_over.png", "dbviewer\\air_on.png"); ! break; ! case 3: ! caption = "Air, rotary wing"; ! button->LoadImages("dbviewer\\helo_off.png", "dbviewer\\helo_on.png", ! "dbviewer\\helo_over.png", "dbviewer\\helo_on.png"); ! break; ! case 4: ! caption = "Land"; ! button->LoadImages("dbviewer\\land_off.png", "dbviewer\\land_on.png", ! "dbviewer\\land_over.png", "dbviewer\\land_on.png"); ! break; ! case 5: ! caption = "Missile"; ! button->LoadImages("dbviewer\\missile_off.png", "dbviewer\\missile_on.png", ! "dbviewer\\missile_over.png", "dbviewer\\missile_on.png"); ! break; ! case 6: ! caption = "Torpedo"; ! button->LoadImages("dbviewer\\torpedo_off.png", "dbviewer\\torpedo_on.png", ! "dbviewer\\torpedo_over.png", "dbviewer\\torpedo_on.png"); ! break; ! case 7: ! caption = "Ballistic"; ! button->LoadImages("dbviewer\\ballistic_off.png", "dbviewer\\ballistic_on.png", ! "dbviewer\\ballistic_over.png", "dbviewer\\ballistic_on.png"); ! break; ! default: ! caption = "Error"; ! button->LoadImages("dbviewer\\test_button_off.png", "dbviewer\\test_button_on.png", ! "dbviewer\\test_button_on.png", "dbviewer\\test_button_on.png"); ! break; } *************** *** 302,308 **** --- 354,382 ---- } + void tcDatabaseViewer::SetButtonOn(size_t idx) + { + wxASSERT(buttons.size() == 8); + + // first set all buttons off + for (size_t n=0; n<buttons.size(); n++) + { + buttons[n]->SetOn(false); + } + + // set indicated button on + if (idx < buttons.size()) + { + buttons[idx]->SetOn(true); + } + else + { + wxASSERT(false); + } + + } void tcDatabaseViewer::SelectDisplayClass(const std::string& className) { + displayClassName = className; databaseInfoWindow->SetDatabaseClassName(className); if (viewer) *************** *** 347,355 **** } - - SetClassificationMask(PTYPE_SURFACE); - InitializeButtons(); InitializeDatabaseInfoWindow(); } --- 421,429 ---- } InitializeButtons(); InitializeDatabaseInfoWindow(); + + SetClassificationMask(PTYPE_SURFACE); + SetButtonOn(0); } Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tc3DModel.cpp 28 Mar 2006 02:44:55 -0000 1.35 --- tc3DModel.cpp 21 Apr 2006 23:29:08 -0000 1.36 *************** *** 414,417 **** --- 414,422 ---- } + const std::string& tc3DModel::GetAuthor() const + { + return author; + } + /** * Retrieves launcher info for launcher <idx> *************** *** 563,567 **** * @param model_name model file name with extension */ ! void tc3DModel::Load(std::string model_name) { if (modelNode.valid()) return; // model already loaded --- 568,572 ---- * @param model_name model file name with extension */ ! void tc3DModel::Load(const std::string& model_name) { if (modelNode.valid()) return; // model already loaded *************** *** 636,639 **** --- 641,646 ---- ProcessAnimations(); + LoadXmlInfo(doc); + delete doc; } *************** *** 702,705 **** --- 709,727 ---- /** + * Loads author info if available + */ + void tc3DModel::LoadXmlInfo(TiXmlDocument* doc) + { + TiXmlNode* node = doc->FirstChild("Info"); + if (node) + { + TiXmlElement* element = node->ToElement(); + wxASSERT(element); + author = element->Attribute("Author"); + } + } + + + /** * */ *************** *** 953,957 **** tc3DModel::tc3DModel() : gameObj(0), ! sensorTrack(0) { } --- 975,980 ---- tc3DModel::tc3DModel() : gameObj(0), ! sensorTrack(0), ! author("") { } *************** *** 964,968 **** : distanceFromCamera(1e10), gameObj(source->gameObj), ! sensorTrack(source->sensorTrack) { static int addCount = 0; --- 987,992 ---- : distanceFromCamera(1e10), gameObj(source->gameObj), ! sensorTrack(source->sensorTrack), ! author(source->author) { static int addCount = 0; Index: tcDatabaseInfoWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseInfoWindow.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcDatabaseInfoWindow.cpp 28 Mar 2006 23:58:12 -0000 1.5 --- tcDatabaseInfoWindow.cpp 21 Apr 2006 23:29:09 -0000 1.6 *************** *** 28,31 **** --- 28,36 ---- #include "tcDatabaseInfoWindow.h" #include "tcDatabaseObject.h" + #include "tcGenericDBObject.h" + #include "tcLauncherDBObject.h" + #include "tcMissileDBObject.h" + #include "tcTorpedoDBObject.h" + #include "tc3DModel.h" #include "tcSensorMap.h" #include "tcSimState.h" *************** *** 123,143 **** if (databaseObj == 0) return; ! s.Printf("Unit cost: %s", databaseObj->GetCostString()); ! DrawTextR(s.c_str(), textx, texty, ! defaultFont.get(), color, fontSize, LEFT_BASE_LINE, maxWidth, textBox); ! texty += textBox.yMax() - textBox.yMin() + 5.0f; ! s.Printf("%s", databaseObj->mzDescription); ! DrawTextR(s.c_str(), textx, texty, ! defaultFont.get(), color, fontSize, LEFT_BASE_LINE, maxWidth - 150.0f, textBox); - DrawDatabaseImages(); ! } void tcDatabaseInfoWindow::DrawDatabaseImages() { --- 128,339 ---- if (databaseObj == 0) return; ! DrawDatabaseImages(); ! PrintText(textx, texty, "Unit cost: %s", databaseObj->GetCostString()); + PrintText(textx, texty, "%s", databaseObj->mzDescription); ! texty += 5.0f; ! ! if (tcGenericDBObject* generic = dynamic_cast<tcGenericDBObject*>(databaseObj)) ! { ! DrawDatabaseInfo(generic, texty); ! } ! else if (tcMissileDBObject* missile = dynamic_cast<tcMissileDBObject*>(databaseObj)) ! { ! DrawDatabaseInfo(missile, texty); ! } ! else if (tcTorpedoDBObject* torpedo = dynamic_cast<tcTorpedoDBObject*>(databaseObj)) ! { ! DrawDatabaseInfo(torpedo, texty); ! } ! ! textx = xImage + 10.0f; ! texty = float(mnHeight) - 15.0f; ! const std::string& artists = databaseObj->Get3DModel()->GetAuthor(); ! if (artists.size() > 0) ! { ! PrintText(textx, texty, "3D Artist(s): %s", artists.c_str()); ! } } + void tcDatabaseInfoWindow::DrawDatabaseInfo(database::tcGenericDBObject* genericData, float yStart) + { + float textx = 10.0f; + float maxWidth = float(mnWidth) - textx - 5.0f; + float texty = yStart; + osg::BoundingBox textBox; + osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); + + + PrintText(textx, texty, "Max speed: %.0f kts", genericData->mfMaxSpeed_kts); + + if (IsEmbedded()) + { + PrintText(textx, texty, "Turn rate: %.1f deg/s", genericData->mfTurnRate_degps); + } + + + PrintText(textx, texty, "Survivability: %.0f", genericData->mfToughness); + + PrintText(textx, texty, "RCS %.0f dBsm", genericData->mfRcs_dbsm); + + if ((genericData->mfFuelRate_kgps > 0) && IsEmbedded()) + { + float fuelTimeHours = 2.778e-4 * genericData->mfFuelCapacity_kg / genericData->mfFuelRate_kgps; + + switch (genericData->mnModelType) + { + case MTYPE_SURFACE: + case MTYPE_CARRIER: + case MTYPE_AIR: + PrintText(textx, texty, "Cruise range %.0f km", fuelTimeHours * genericData->mfMaxSpeed_kts * C_NMITOKM); + break; + case MTYPE_FIXEDWINGX: + PrintText(textx, texty, "Fuel capacity %.0f kg", genericData->mfFuelCapacity_kg); + break; + case MTYPE_HELO: + PrintText(textx, texty, "Endurance %.1f hrs", 2.0f * fuelTimeHours); + break; + case MTYPE_SUBMARINE: + PrintText(textx, texty, "Fuel capacity %.0f kg", genericData->mfFuelCapacity_kg); + break; + } + } + + texty += 10.0f; + DrawLauncherInfo(genericData, texty); + + texty += 10.0f; + DrawSensorInfo(genericData, texty); + } + + + void tcDatabaseInfoWindow::DrawDatabaseInfo(database::tcMissileDBObject* missileData, float yStart) + { + wxASSERT(missileData); + + float textx = 10.0f; + float texty = yStart; + + PrintText(textx, texty, "Nominal range %.0f km", missileData->mfRange_km); + + PrintText(textx, texty, "Max speed Mach %.1f", missileData->mfMsupm); + + PrintText(textx, texty, "Warhead %.0f kg", missileData->mfDamage); + + PrintText(textx, texty, "Seeker FOV %.0f deg", missileData->GetSeekerFOV()); + + } + + void tcDatabaseInfoWindow::DrawDatabaseInfo(database::tcTorpedoDBObject* torpedoData, float yStart) + { + wxASSERT(torpedoData); + + float textx = 10.0f; + float texty = yStart; + + if (torpedoData->batteryRate_kW > 0) + { + float range_km = 2.778e-4f * C_NMITOKM * torpedoData->maxSpeed_kts * torpedoData->battery_kJ / + torpedoData->batteryRate_kW; + PrintText(textx, texty, "Range %.0f km", range_km); + } + else + { + PrintText(textx, texty, "Nominal range %.0f km", torpedoData->mfRange_km); + } + + PrintText(textx, texty, "Max speed %.0f kts", torpedoData->maxSpeed_kts); + + PrintText(textx, texty, "Warhead %.0f kg", torpedoData->mfDamage); + + } + + + void tcDatabaseInfoWindow::DrawLauncherInfo(database::tcGenericDBObject* genericData, float& y) + { + wxASSERT(genericData != 0); + + int nLaunchers = genericData->mnNumLaunchers; + if (nLaunchers <= 0) return; + + PrintText(10.0, y, "MOUNTS"); + + database::tcDatabase* database = tcDatabase::Get(); + + for (int n=0; n<nLaunchers; n++) + { + std::string launcherClass = genericData->maLauncherClass[n].c_str(); + database::tcLauncherDBObject* launcherData = + dynamic_cast<database::tcLauncherDBObject*>( + database->GetObject(launcherClass)); + wxString s = launcherData->GetConfigurationDescription(); + PrintText(20.0, y, "%s", s.c_str()); + } + + } + + void tcDatabaseInfoWindow::DrawSensorInfo(database::tcGenericDBObject* genericData, float& y) + { + wxASSERT(genericData != 0); + + int nSensors = genericData->sensorClass.size(); + if (nSensors <= 0) return; + + database::tcDatabase* database = tcDatabase::Get(); + + PrintText(10.0, y, "SENSORS"); + + for (int n=0; n<nSensors; n++) + { + std::string& sensorClass = genericData->sensorClass[n]; + database::tcRadarDBObject* radarData = dynamic_cast<database::tcRadarDBObject*>( + database->GetObject(sensorClass)); + if (radarData) + { + float displayRange = 0; + if (radarData->mbDetectsAir) displayRange = 2.0f * radarData->mfRefRange_km; // 12 dBsm assumed + else displayRange = 5.66f * radarData->mfRefRange_km; // 30 dBsm assumed + + PrintText(20.0, y, "%s (%.0f km)", sensorClass.c_str(), displayRange); + } + else + { + PrintText(20.0, y, "%s", sensorClass.c_str()); + } + } + + } + + void tcDatabaseInfoWindow::PrintText(float x, float& y, const char* formatString, ...) + { + enum {STR_LENGTH = 256}; + static char textBuffer[STR_LENGTH]; + static osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); + static osg::BoundingBox textBox; + + const float textFontSize = 12.0f; + + if (y > float(mnHeight) - 15.0f) return; + + va_list arguments; + + va_start(arguments, formatString); + _vsnprintf(textBuffer, STR_LENGTH, formatString, arguments); + va_end(arguments); + + float maxWidth = (y < yImage) ? xImage - x : float(mnWidth) - x; + + DrawTextR(textBuffer, x, y, + defaultFont.get(), color, textFontSize, LEFT_BASE_LINE, maxWidth, textBox); + + y += textBox.yMax() - textBox.yMin() + 2.0f; + + } + void tcDatabaseInfoWindow::DrawDatabaseImages() { *************** *** 155,158 **** --- 351,357 ---- } + xImage = imagex - 5.0f; + yImage = imagey + imageHeight; + size_t nImages = imageList.size(); *************** *** 372,376 **** databaseClassName(""), currentImageIdx(0), ! imageTime(0) { --- 571,577 ---- databaseClassName(""), currentImageIdx(0), ! imageTime(0), ! xImage(0), ! yImage(0) { Index: tcNetworkView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcNetworkView.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcNetworkView.cpp 23 Mar 2006 01:11:02 -0000 1.12 --- tcNetworkView.cpp 21 Apr 2006 23:29:09 -0000 1.13 *************** *** 2,7 **** ** @file tcNetworkView.cpp */ ! /* ! ** Copyright (C) 2004-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. --- 2,6 ---- ** @file tcNetworkView.cpp */ ! /* Copyright (C) 2004-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. Index: tcButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcButton.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcButton.cpp 28 Mar 2006 23:58:12 -0000 1.23 --- tcButton.cpp 21 Apr 2006 23:29:09 -0000 1.24 *************** *** 125,129 **** float y = (float)mouseOverCaptionPosition.y; osg::Vec4 color(1.0f, 1.0f, 1.0f, 1.0f); ! float mouseOverCaptionFontSize = 11.0f; DrawText(mouseOverCaption.c_str(), x, y, defaultFont.get(), color, mouseOverCaptionFontSize, CENTER_CENTER); --- 125,129 ---- float y = (float)mouseOverCaptionPosition.y; osg::Vec4 color(1.0f, 1.0f, 1.0f, 1.0f); ! float mouseOverCaptionFontSize = 12.0f; DrawText(mouseOverCaption.c_str(), x, y, defaultFont.get(), color, mouseOverCaptionFontSize, CENTER_CENTER); *************** *** 266,270 **** forceDisable(false), mouseOverCaption(""), ! mouseOverCaptionPosition(0, -5) { --- 266,270 ---- forceDisable(false), mouseOverCaption(""), ! mouseOverCaptionPosition(0, 0) { *************** *** 397,401 **** forceDisable(false), mouseOverCaption(""), ! mouseOverCaptionPosition(size.GetWidth()/2, -5) { --- 397,401 ---- forceDisable(false), mouseOverCaption(""), ! mouseOverCaptionPosition(size.GetWidth()/2, 0) { Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tc3DViewer.cpp 28 Mar 2006 23:58:12 -0000 1.33 --- tc3DViewer.cpp 21 Apr 2006 23:29:08 -0000 1.34 *************** *** 65,68 **** --- 65,69 ---- #include "tcSensorTrackIterator.h" #include "tcDatabase.h" + #include "tcTime.h" *************** *** 624,627 **** --- 625,633 ---- } + void tc3DViewer::SetCameraSpinRate(float rate) + { + cameraSpinRate = rate; + } + /** * Set the origin (0,0) of 3D world coordinates and *************** *** 1060,1063 **** --- 1066,1071 ---- void tc3DViewer::UpdateCameraDatabaseView() { + UpdateCameraSpin(); + float camx = cosf(cameraEl)*sinf(cameraAz); float camy = cosf(cameraEl)*cosf(cameraAz); *************** *** 1076,1079 **** --- 1084,1089 ---- osg::Vec3 targetPosition = GetHookedObjectPositionAndType(objClassification); + UpdateCameraSpin(); + if (moveWithTarget) { *************** *** 1181,1184 **** --- 1191,1206 ---- } + void tc3DViewer::UpdateCameraSpin() + { + if (cameraSpinRate == 0) return; + + unsigned currentTimeCount = tcTime::Get()->Get30HzCount(); + if (currentTimeCount - lastSpinCount >= 1) + { + SetCameraAz(GetCameraAz() + cameraSpinRate); + lastSpinCount = currentTimeCount; + } + } + /** * Load models for new child objects. *************** *** 2068,2072 **** wxWindow(parent, -1, pos, size, wxTRANSPARENT_WINDOW | wxNO_FULL_REPAINT_ON_RESIZE, name), mnHeight(size.GetHeight()), mnWidth(size.GetWidth()), ! cameraWalkOffset(0, 0, 0) { glCanvas = parent; --- 2090,2096 ---- wxWindow(parent, -1, pos, size, wxTRANSPARENT_WINDOW | wxNO_FULL_REPAINT_ON_RESIZE, name), mnHeight(size.GetHeight()), mnWidth(size.GetWidth()), ! cameraWalkOffset(0, 0, 0), ! cameraSpinRate(0), ! lastSpinCount(0) { glCanvas = parent; |