[Gcblue-commits] gcb_wx/src/graphics tcBoundingBoxVisitor.cpp, NONE, 1.1 tcDatabaseBrowsePanel.cpp,
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv21820/src/graphics Modified Files: tc3DModel.cpp tc3DViewer.cpp tc3DWindow.cpp tcContainerGui.cpp tcCreditView.cpp tcDatabaseInfoWindow.cpp tcDatabaseViewer.cpp tcGameView.cpp tcGraphicsEngine.cpp tcMapObject.cpp tcMapOverlay.cpp tcMapView.cpp tcOOBView.cpp tcPopupControl.cpp tcStoresGui.cpp Added Files: tcBoundingBoxVisitor.cpp tcDatabaseBrowsePanel.cpp tcDatabaseInfoPanel.cpp tcScrollBar.cpp Log Message: Update for server name change --- NEW FILE: tcDatabaseInfoPanel.cpp --- /** ** @file tcDatabaseInfoPanel.cpp */ /* Copyright (C) 2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcDatabaseInfoPanel.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" #include "common/tinyxml.h" #include "tcTime.h" #include "tcScrollBar.h" #include <osg/Geometry> #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_EVENT_TABLE(tcDatabaseInfoPanel, tc3DWindow) EVT_COMMAND(-1, wxEVT_COMMAND_SCROLLBAR_UPDATED, tcDatabaseInfoPanel::OnScrollbarUpdated) END_EVENT_TABLE() using database::tcDatabaseObject; void tcDatabaseInfoPanel::Draw() { DrawChildren(); //if (!IsBackgroundEnabled()) //{ // DrawRectangleR(0, 0, mnWidth, mnHeight, osg::Vec4(0.15, 0.15, 0.15, 1.0f), // FILL_ON); //} DrawDatabaseInfo(); //DrawBorder(); HideUnusedObjects(); } void tcDatabaseInfoPanel::DrawDatabaseInfo() { wxString s; tcDatabaseObject* databaseObj = GetDatabaseObject(); if (databaseObj == 0) return; const float yStart = 20.0f; const float maxSpan = float(mnHeight); float textx = 2.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); texty -= yOffset; 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); } // update scroll bar (only need to do this once per database object) float ySpan = yCurrent + yOffset - yStart + 25.0f; scrollBar->SetBarFraction(maxSpan / ySpan); } void tcDatabaseInfoPanel::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); yCurrent = texty; } void tcDatabaseInfoPanel::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", C_180OVERPI*missileData->GetSeekerFOV()); yCurrent = texty; } void tcDatabaseInfoPanel::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); yCurrent = texty; } void tcDatabaseInfoPanel::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; if (launcherData != 0) { s = launcherData->GetConfigurationDescription(); } else { s.Printf("ERROR: Launcher not found (%s)", launcherClass.c_str()); } PrintText(20.0, y, "%s", s.c_str()); } } void tcDatabaseInfoPanel::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 tcDatabaseInfoPanel::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 = float(mnWidth - 20) - x; DrawTextR(textBuffer, x, y, defaultFont.get(), color, textFontSize, LEFT_BASE_LINE, maxWidth, textBox); y += textBox.yMax() - textBox.yMin() + 2.0f; } void tcDatabaseInfoPanel::OnScrollbarUpdated(wxCommandEvent& event) { yOffset = 0.25 * float(event.m_extraLong); } database::tcDatabaseObject* tcDatabaseInfoPanel::GetDatabaseObject() { if (databaseClassName.size() > 1) { return tcDatabase::Get()->GetObject(databaseClassName); } tcSimState* simState = tcSimState::Get(); tcGameObject* obj = simState->GetObject(objId); if ((obj != 0) && (obj->IsOwnAlliance())) { databaseClassName = obj->mpDBObject->mzClass.c_str(); return obj->mpDBObject; } else { tcSensorMap* sensorMap = simState->GetSensorMap(); wxASSERT(sensorMap != 0); tcSensorMapTrack* track = sensorMap->GetSensorMapTrack(objId, tcUserInfo::Get()->GetOwnAlliance()); if (track) { return tcDatabase::Get()->GetObject(track->GetDatabaseId()); } else { return 0; } } } bool tcDatabaseInfoPanel::IsEmbedded() const { return (viewMode == EMBED); } bool tcDatabaseInfoPanel::IsPopup() const { return (viewMode == POPUP); } void tcDatabaseInfoPanel::SetDatabaseClassName(const std::string& className) { databaseClassName = className; yOffset = 0; } void tcDatabaseInfoPanel::SetDatabaseObject(long id) { objId = id; databaseClassName = ""; yOffset = 0; } void tcDatabaseInfoPanel::SetViewMode(int mode) { viewMode = (ViewMode)mode; } /** * if hostParent argument is not used then static method SetParent must be called first */ tcDatabaseInfoPanel::tcDatabaseInfoPanel(wxWindow* parent, const wxPoint& pos, const wxSize& size, const wxString& name, tc3DWindow* graphicsHost) : tc3DWindow(parent, pos, size, name, graphicsHost), objId(-1), databaseClassName(""), viewMode(EMBED), yOffset(0) { wxASSERT(hostParent != 0); // put gui window on top SetBaseRenderBin(hostParent->GetBaseRenderBin() + 10); wxWindow::Raise(); SetBackgroundColor(osg::Vec4(0, 0, 0.1, 0.1)); SetBackgroundDraw(true); SetActive(true); SetStencilLayer(hostParent->GetBaseRenderBin()/ 8); int scrollBarWidth = 16; scrollBar = new tcScrollBar(this, wxPoint(mnWidth-scrollBarWidth, 0), wxSize(scrollBarWidth, mnHeight)); scrollBar->SetBackgroundAlpha(0.25f); } tcDatabaseInfoPanel::~tcDatabaseInfoPanel() { } Index: tcDatabaseViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseViewer.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcDatabaseViewer.cpp 18 Jun 2006 00:45:00 -0000 1.5 --- tcDatabaseViewer.cpp 17 Aug 2006 01:28:04 -0000 1.6 *************** *** 37,40 **** --- 37,41 ---- #include "tcDatabaseIterator.h" #include "tcDatabaseInfoWindow.h" + #include "tcDatabaseBrowsePanel.h" #include "tc3DViewer.h" *************** *** 43,46 **** --- 44,48 ---- #endif + BEGIN_EVENT_TABLE(tcDatabaseViewer, tcXmlWindow) EVT_COMMAND(101, wxEVT_COMMAND_BUTTON_CLICKED, tcDatabaseViewer::BrowseSurface) *************** *** 52,55 **** --- 54,58 ---- EVT_COMMAND(107, wxEVT_COMMAND_BUTTON_CLICKED, tcDatabaseViewer::BrowseTorpedo) EVT_COMMAND(108, wxEVT_COMMAND_BUTTON_CLICKED, tcDatabaseViewer::BrowseBallistic) + EVT_COMMAND(-1, wxEVT_COMMAND_TEXT_UPDATED, tcDatabaseViewer::SelectDisplayClass) END_EVENT_TABLE() *************** *** 105,131 **** - /** - * Updates browse info data based on classificationMask - * Should be called after changing classificationMask - */ - void tcDatabaseViewer::BuildBrowseInfo() - { - browseInfo.clear(); - - database::tcDatabaseIterator iter(classificationMask); - - for (iter.First(); !iter.IsDone(); iter.Next()) - { - database::tcDatabaseObject* obj = iter.Get(); - wxASSERT(obj); - wxASSERT(obj->mnKey != -1); - - BrowseItem item; - item.className = obj->mzClass.c_str(); - - browseInfo.push_back(item); - } - - } const std::string& tcDatabaseViewer::GetDisplayClass() const --- 108,111 ---- *************** *** 134,156 **** } - /** - * - */ - bool tcDatabaseViewer::ProcessMouseClick(std::vector<BrowseItem>& info, wxPoint pos) - { - for (size_t n=0; n < info.size(); ++n) - { - wxRect r(info[n].drawBox.x, info[n].drawBox.y, - info[n].drawBox.width, info[n].drawBox.height); - - if (r.Inside(pos)) - { - SelectDisplayClass(info[n].className); - return true; - } - } - return false; - } void tcDatabaseViewer::SetClassificationMask(unsigned int mask) --- 114,118 ---- *************** *** 160,234 **** classificationMask = mask; ! BuildBrowseInfo(); ! UpdateDrawInfo(browseInfo); ! } /** - * Update drawing info of browseInfo vector - */ - void tcDatabaseViewer::UpdateDrawInfo(std::vector<BrowseItem>& info) - { - - float x = 50.0f; - float y = 150.0f; - float xWidth = 100.0f; - float yHeight = 15.0f; - - for (size_t n=0; n < info.size(); ++n) - { - BrowseItem& item = info[n]; - - item.drawBox.x = x; - item.drawBox.y = y; - item.drawBox.height = yHeight - 2; - item.drawBox.width = xWidth; - - y += yHeight; - - wxRect r(item.drawBox.x, item.drawBox.y, - item.drawBox.width, item.drawBox.height); - - int oldState = item.drawState; - - if (item.className == displayClassName) - { - item.drawState = BrowseItem::ON; - item.color = osg::Vec4(1, 1, 1, 1); - if (item.drawState != oldState) tcSound::Get()->PlayEffect("Beep2"); - } - else if (r.Inside(mousePosition)) - { - item.drawState = BrowseItem::OVER; - item.color = osg::Vec4(0.6, 0.6, 1, 1); - if (item.drawState != oldState) tcSound::Get()->PlayEffect("Thuck"); - } - else - { - item.drawState = BrowseItem::OFF; - item.color = osg::Vec4(0.5, 0.5, 0.5, 1); - } - } - } - - /** * */ void tcDatabaseViewer::Draw() { - DrawChildren(); - - for (size_t n=0; n<browseInfo.size(); n++) - { - BrowseItem& item = browseInfo[n]; - - DrawTextR(item.className.c_str(), item.drawBox.x, - item.drawBox.y + item.drawBox.height - 3, defaultFont.get(), - item.color, 16.0f, LEFT_BASE_LINE); - } - DrawBorder(); --- 122,136 ---- classificationMask = mask; ! browsePanel->SetClassificationMask(mask); } /** * */ void tcDatabaseViewer::Draw() { DrawChildren(); DrawBorder(); *************** *** 314,317 **** --- 216,225 ---- } + void tcDatabaseViewer::InitializeBrowsePanel() + { + browsePanel = new tcDatabaseBrowsePanel(this, wxPoint(50, 150), wxSize(220, 500), "BrowsePanel", this); + } + + void tcDatabaseViewer::InitializeDatabaseInfoWindow() { *************** *** 324,327 **** --- 232,236 ---- } + /** * *************** *** 330,335 **** { mousePosition = event.GetPosition(); - - UpdateDrawInfo(browseInfo); } --- 239,242 ---- *************** *** 346,355 **** mousePosition = event.GetPosition(); - - if (ProcessMouseClick(browseInfo, mousePosition)) - { - UpdateDrawInfo(browseInfo); - return; - } } --- 253,256 ---- *************** *** 376,379 **** --- 277,287 ---- } + void tcDatabaseViewer::SelectDisplayClass(wxCommandEvent& event) + { + std::string className = event.GetString().c_str(); + + SelectDisplayClass(className); + } + void tcDatabaseViewer::SelectDisplayClass(const std::string& className) { *************** *** 422,426 **** --- 330,336 ---- InitializeButtons(); + InitializeBrowsePanel(); InitializeDatabaseInfoWindow(); + SetClassificationMask(PTYPE_SURFACE); Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tc3DModel.cpp 18 Jun 2006 00:45:00 -0000 1.37 --- tc3DModel.cpp 17 Aug 2006 01:28:04 -0000 1.38 *************** *** 38,41 **** --- 38,42 ---- #include "tcSimState.h" #include "tc3DViewer.h" + #include "tcBoundingBoxVisitor.h" #include "common/tinyxml.h" #include <osg/MatrixTransform> *************** *** 46,49 **** --- 47,51 ---- #include <osgParticle/ExplosionDebrisEffect> + //#include <osgAL/SoundNode> //#include <osgAL/SoundRoot> *************** *** 556,589 **** * GetBoundingBox does not exist for osg::Node. */ ! const osg::BoundingBox& tc3DModel::GetBoundingBox() const { ! static osg::BoundingBox bb(0, 0, 0, 0, 0, 0); ! bb.set(0, 0, 0, 0, 0, 0); ! ! wxASSERT(false); // this does not work! ! return bb; ! if (const osg::Group* group = modelNode.get()->asGroup()) ! { ! // initialize with first child ! if (const osg::Geode* geode = dynamic_cast<const osg::Geode*>(group->getChild(0))) ! { ! bb = geode->getBoundingBox(); ! } ! // expand to include remaining children ! for (size_t n=1; n<group->getNumChildren(); n++) ! { ! if (const osg::Geode* geode = dynamic_cast<const osg::Geode*>(group->getChild(0))) ! { ! bb.expandBy(geode->getBoundingBox()); ! } ! } ! return bb; ! } ! wxASSERT(false); ! return bb; } tcSensorMapTrack* tc3DModel::GetSensorTrack() const --- 558,598 ---- * GetBoundingBox does not exist for osg::Node. */ ! const osg::BoundingBox& tc3DModel::GetBoundingBox() { ! if (boundingBoxComputed) ! { ! return boundingBox; ! } ! osg::Matrix matrix; ! matrix.makeIdentity(); ! tcBoundingBoxVisitor bbvis(matrix); ! modelNode->accept(bbvis); ! ! boundingBox = bbvis.getBound(); ! ! boundingBoxComputed = true; ! return boundingBox; } + /** + * Workaround for const-ness requirements. + */ + const osg::BoundingBox& tc3DModel::GetBoundingBoxConst() const + { + static osg::BoundingBox zeroBox(0, 0, 0, 0, 0, 0); + + if (boundingBoxComputed) + { + return boundingBox; + } + else + { + wxASSERT(false); + return zeroBox; + } + + } tcSensorMapTrack* tc3DModel::GetSensorTrack() const *************** *** 627,630 **** --- 636,648 ---- fprintf(stdout, "tc3DModel--Loaded 3D model: %s\n", model_name.c_str()); + + #ifdef _DEBUG + osg::BoundingBox bb = GetBoundingBox(); + fprintf(stdout, " Bounding box dimensions X: %f %f, Y: %f %f, Z: %f %f\n", + bb.xMin(), bb.xMax(), bb.yMin(), bb.yMax(), bb.zMin(), bb.zMax()); + + #endif + + } *************** *** 1010,1014 **** : gameObj(0), sensorTrack(0), ! author("") { } --- 1028,1033 ---- : gameObj(0), sensorTrack(0), ! author(""), ! boundingBoxComputed(false) { } *************** *** 1022,1026 **** gameObj(source->gameObj), sensorTrack(source->sensorTrack), ! author(source->author) { static int addCount = 0; --- 1041,1047 ---- gameObj(source->gameObj), sensorTrack(source->sensorTrack), ! author(source->author), ! boundingBox(source->boundingBox), ! boundingBoxComputed(source->boundingBoxComputed) { static int addCount = 0; --- NEW FILE: tcBoundingBoxVisitor.cpp --- /** ** @file tcBoundingBoxVisitor.cpp */ /* Copyright (C) 2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** ** Based on code by Farshid Lashkari posted to the osg-users list on April 18, 2006 */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP #include "tcBoundingBoxVisitor.h" #include <osg/BoundingBox> #include <osg/Geode> #include <osg/Transform> #ifdef _DEBUG #define new DEBUG_NEW #endif void tcBoundingBoxVisitor::apply(osg::Node &node) { traverse(node); } void tcBoundingBoxVisitor::apply(osg::Geode &geode) { for(unsigned int i = 0; i < geode.getNumDrawables(); i++) { osg::BoundingBox bb = geode.getDrawable(i)->getBound(); m_bb.expandBy(bb.corner(0)*m_curMatrix); m_bb.expandBy(bb.corner(1)*m_curMatrix); m_bb.expandBy(bb.corner(2)*m_curMatrix); m_bb.expandBy(bb.corner(3)*m_curMatrix); m_bb.expandBy(bb.corner(4)*m_curMatrix); m_bb.expandBy(bb.corner(5)*m_curMatrix); m_bb.expandBy(bb.corner(6)*m_curMatrix); m_bb.expandBy(bb.corner(7)*m_curMatrix); } traverse(geode); } void tcBoundingBoxVisitor::apply(osg::Transform& node) { osg::Matrix matrix; node.computeLocalToWorldMatrix(matrix, this); osg::Matrix prevMatrix = m_curMatrix; m_curMatrix.preMult(matrix); traverse(node); m_curMatrix = prevMatrix; } osg::BoundingBox tcBoundingBoxVisitor::getBound() const { return m_bb; } tcBoundingBoxVisitor::tcBoundingBoxVisitor(const osg::Matrix &mat) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) { m_curMatrix = mat; } Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcOOBView.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcOOBView.cpp 18 Jun 2006 00:45:00 -0000 1.14 --- tcOOBView.cpp 17 Aug 2006 01:28:04 -0000 1.15 *************** *** 405,409 **** DrawRectangleR(0, 0, mnWidth, mnHeight, ! osg::Vec4(0, 0, 0, 0.5f), FILL_ON); DrawBorder(); --- 405,409 ---- DrawRectangleR(0, 0, mnWidth, mnHeight, ! osg::Vec4(0, 0, 0, 0.7f), FILL_ON); DrawBorder(); Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** tcMapView.cpp 4 May 2006 22:47:26 -0000 1.45 --- tcMapView.cpp 17 Aug 2006 01:28:04 -0000 1.46 *************** *** 1524,1527 **** --- 1524,1531 ---- osg::Geometry* pSurface = DrawNTDSSurface((teAffiliation)nAffiliation); + // carrier symbol + osg::Geometry* pCarrier = DrawNTDSSurface((teAffiliation)nAffiliation); + + // fixed ground symbol osg::Geometry* pGround = DrawNTDSGround((teAffiliation)nAffiliation); *************** *** 1560,1563 **** --- 1564,1570 ---- pSymbol = pSurface; break; + case SYMBOL_CARRIER: + pSymbol = pCarrier; + break; case SYMBOL_MISSILE: pSymbol = pMissile; *************** *** 1578,1581 **** --- 1585,1589 ---- break; case SYMBOL_FIXED: + case SYMBOL_AIRFIELD: pSymbol = pGround; break; *************** *** 1624,1627 **** --- 1632,1638 ---- osg::Geometry* pSurface = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"carrier%s",zAffil); + osg::Geometry* pCarrier = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"air_fw%s",zAffil); osg::Geometry* pAir = CreateTexturedSymbol(zBuff); *************** *** 1636,1639 **** --- 1647,1653 ---- osg::Geometry* pFixed = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"airfield%s",zAffil); + osg::Geometry* pAirfield = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"sub%s",zAffil); osg::Geometry* pSub = CreateTexturedSymbol(zBuff); *************** *** 1660,1663 **** --- 1674,1680 ---- pSymbol = pSurface; break; + case SYMBOL_CARRIER: + pSymbol = pCarrier; + break; case SYMBOL_MISSILE: pSymbol = pMissile; *************** *** 1680,1683 **** --- 1697,1703 ---- pSymbol = pFixed; break; + case SYMBOL_AIRFIELD: + pSymbol = pAirfield; + break; case SYMBOL_MARK: pSymbol = pMark; *************** *** 1811,1814 **** --- 1831,1835 ---- /** * Version that uses pre-drawn images to draw symbols + * This is a mess, clean this up (draw out of symbol class perhaps) */ void tcTacticalMapView::DrawSymbol2(tcMapObj* pMO) *************** *** 2018,2023 **** if (mbShowTrackID && !suppressTrackId) { ! wxString s = wxString::Format("%04d", pMO->mnID); ! DrawTextR(s.c_str(), x-9.0f, y+15.0f, defaultFont.get(), symbolColor, 10.0, LEFT_BASE_LINE); } --- 2039,2052 ---- if (mbShowTrackID && !suppressTrackId) { ! wxString s; ! if (pMO->speed_kts > 0) ! { ! s = wxString::Format("%04d\n%04.0f", pMO->mnID, pMO->speed_kts); ! } ! else ! { ! s = wxString::Format("%04d", pMO->mnID); ! } ! DrawTextR(s.c_str(), x-9.0f, y+16.0f, defaultFont.get(), symbolColor, 11.0, LEFT_BASE_LINE); } *************** *** 2325,2328 **** --- 2354,2359 ---- Build2525(); CreateAlternateSymbols(); + + UpdateMapObjectColors(); } *************** *** 2342,2345 **** --- 2373,2415 ---- RefreshTerrainView(); + + UpdateMapObjectColors(); + } + + /** + * Update color of map objects based on map color mode. + */ + void tcTacticalMapView::UpdateMapObjectColors() + { + osg::Vec4 color; + switch (tcOptions::Get()->mnMapMode) + { + case 0 : + color = osg::Vec4(0, 0, 0, 1); + tcMapObject::LoadMarker("black_marker.png"); + break; + case 1 : + color = osg::Vec4(0, 0, 0, 1); + tcMapObject::LoadMarker("black_marker.png"); + break; + case 2 : + color = osg::Vec4(1, 1, 1, 1); + tcMapObject::LoadMarker("white_marker.png"); + break; + default: + wxASSERT(false); + color = osg::Vec4(1, 0, 0, 1); + break; + } + + int nObjects = (int)specialGraphics.size(); + for(int n=0; n<nObjects; n++) + { + tcMapObject* obj = specialGraphics[n]; + obj->SetColor(color); + } + + if (overlay != 0) overlay->SetColor(color); + } Index: tcMapObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapObject.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcMapObject.cpp 23 Mar 2006 01:11:02 -0000 1.10 --- tcMapObject.cpp 17 Aug 2006 01:28:04 -0000 1.11 *************** *** 84,88 **** } ! void tcMapObject::LoadMarker() { float w = 10.0f; --- 84,88 ---- } ! void tcMapObject::LoadMarker(const std::string& filename) { float w = 10.0f; *************** *** 127,131 **** // add texture ! osg::Image* image = tc3DWindow::LoadImage("marker.png"); osg::Texture2D* texture = new osg::Texture2D; --- 127,136 ---- // add texture ! osg::Image* image = tc3DWindow::LoadImage(filename.c_str()); ! if (image == 0) ! { ! fprintf(stderr, "tcMapObject::LoadMarker -- image not found (%s)\n", filename.c_str()); ! } ! osg::Texture2D* texture = new osg::Texture2D; *************** *** 200,204 **** markerEnabled = true; ! if (!marker.valid()) LoadMarker(); } --- 205,209 ---- markerEnabled = true; ! if (!marker.valid()) LoadMarker("black_marker.png"); } Index: tcContainerGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcContainerGui.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcContainerGui.cpp 23 Mar 2006 01:11:02 -0000 1.9 --- tcContainerGui.cpp 17 Aug 2006 01:28:04 -0000 1.10 *************** *** 455,458 **** --- 455,460 ---- wxWindow::Raise(); + tc3DWindow::SetStencilLayer(windowLayer-3); // assumes windowLayer starts at 4 + windowLayer++; --- NEW FILE: tcDatabaseBrowsePanel.cpp --- /** ** @file tcDatabaseBrowsePanel.cpp */ /* Copyright (C) 2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcDatabaseBrowsePanel.h" #include <osg/Texture2D> #include <osg/Vec4> #include "wxcommands.h" #include "common/tinyxml.h" #include "tcDatabase.h" #include "tcDatabaseObject.h" #include "tcDatabaseIterator.h" #include "tcScrollBar.h" #include "tcSound.h" #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_EVENT_TABLE(tcDatabaseBrowsePanel, tc3DWindow) EVT_COMMAND(-1, wxEVT_COMMAND_SCROLLBAR_UPDATED, tcDatabaseBrowsePanel::OnScrollbarUpdated) END_EVENT_TABLE() /** * Updates browse info data based on classificationMask * Should be called after changing classificationMask */ void tcDatabaseBrowsePanel::BuildBrowseInfo() { yOffset = 0; browseInfo.clear(); database::tcDatabaseIterator iter(classificationMask); for (iter.First(); !iter.IsDone(); iter.Next()) { database::tcDatabaseObject* obj = iter.Get(); wxASSERT(obj); wxASSERT(obj->mnKey != -1); BrowseItem item; item.className = obj->mzClass.c_str(); browseInfo.push_back(item); } } const std::string& tcDatabaseBrowsePanel::GetDisplayClass() const { return displayClassName; } /** * */ bool tcDatabaseBrowsePanel::ProcessMouseClick(const wxPoint& pos) { std::vector<BrowseItem>& info = browseInfo; for (size_t n=0; n < info.size(); ++n) { wxRect r(info[n].drawBox.x, info[n].drawBox.y, info[n].drawBox.width, info[n].drawBox.height); if (r.Inside(pos)) { SelectDisplayClass(info[n].className); return true; } } return false; } void tcDatabaseBrowsePanel::SetClassificationMask(unsigned int mask) { if (mask == classificationMask) return; classificationMask = mask; BuildBrowseInfo(); UpdateDrawInfo(); } void tcDatabaseBrowsePanel::ClearMouseOver() { std::vector<BrowseItem>& info = browseInfo; for (size_t n=0; n < info.size(); ++n) { BrowseItem& item = info[n]; if (item.className == displayClassName) { item.drawState = BrowseItem::ON; item.color = osg::Vec4(1, 1, 1, 1); } else { item.drawState = BrowseItem::OFF; item.color = osg::Vec4(0.5, 0.5, 0.5, 1); } } } /** * Update drawing info of browseInfo vector */ void tcDatabaseBrowsePanel::UpdateDrawInfo() { std::vector<BrowseItem>& info = browseInfo; float x = 5.0f; float y = 15.0f; float xWidth = float(mnWidth); float yHeight = 15.0f; for (size_t n=0; n < info.size(); ++n) { BrowseItem& item = info[n]; item.drawBox.x = x; item.drawBox.y = y - yOffset; item.drawBox.height = yHeight - 2; item.drawBox.width = xWidth; y += yHeight; wxRect r(item.drawBox.x, item.drawBox.y, item.drawBox.width, item.drawBox.height); int oldState = item.drawState; if (item.className == displayClassName) { item.drawState = BrowseItem::ON; item.color = osg::Vec4(1, 1, 1, 1); if (item.drawState != oldState) tcSound::Get()->PlayEffect("Beep2"); } else if (mouseOver && (r.Inside(mousePosition))) { item.drawState = BrowseItem::OVER; item.color = osg::Vec4(0.6, 0.6, 1, 1); if (item.drawState != oldState) tcSound::Get()->PlayEffect("Thuck"); } else { item.drawState = BrowseItem::OFF; item.color = osg::Vec4(0.5, 0.5, 0.5, 1); } } // update scroll bar (only need to do this once per browse change) float ySpan = 50.0f + float(info.size())*yHeight; float maxSpan = float(mnHeight); scrollBar->SetBarFraction(maxSpan / ySpan); } /** * */ void tcDatabaseBrowsePanel::Draw() { DrawChildren(); for (size_t n=0; n<browseInfo.size(); n++) { BrowseItem& item = browseInfo[n]; DrawTextR(item.className.c_str(), item.drawBox.x, item.drawBox.y + item.drawBox.height - 3, defaultFont.get(), item.color, 16.0f, LEFT_BASE_LINE); } HideUnusedObjects(); } /** * */ void tcDatabaseBrowsePanel::OnMouseMove(wxMouseEvent& event) { mousePosition = event.GetPosition(); UpdateDrawInfo(); } /** * */ void tcDatabaseBrowsePanel::OnLButtonDown(wxMouseEvent& event) { if (!mbActive) { event.Skip(); return; } mousePosition = event.GetPosition(); if (ProcessMouseClick(mousePosition)) { UpdateDrawInfo(); return; } } void tcDatabaseBrowsePanel::OnEnterWindow(wxMouseEvent& event) { mouseOver = true; } void tcDatabaseBrowsePanel::OnLeaveWindow(wxMouseEvent& event) { ClearMouseOver(); mouseOver = false; } void tcDatabaseBrowsePanel::OnScrollbarUpdated(wxCommandEvent& event) { yOffset = 0.25 * float(event.m_extraLong); UpdateDrawInfo(); } void tcDatabaseBrowsePanel::SelectDisplayClass(const std::string& className) { displayClassName = className; wxCommandEvent cmd(wxEVT_COMMAND_TEXT_UPDATED, 1); cmd.SetEventObject(this); cmd.m_cmdString = className.c_str(); AddPendingEvent(cmd); } tcDatabaseBrowsePanel::tcDatabaseBrowsePanel(wxWindow* parent, const wxPoint& pos, const wxSize& size, const wxString& name, tc3DWindow* graphicsHost) : tc3DWindow(parent, pos, size, name, graphicsHost), classificationMask(0), displayClassName(""), yOffset(0), mouseOver(false) { SetBackgroundColor(osg::Vec4(0, 0, 0, 0.01)); // 0.01 so it doesn't get culled !? SetBackgroundDraw(true); // put gui window on top SetBaseRenderBin(hostParent->GetBaseRenderBin() + 10); wxWindow::Raise(); SetStencilLayer(1 + hostParent->GetBaseRenderBin()/ 8); // 1+ hack to ensure different than tcDatabaseInfoPanel int scrollBarWidth = 16; scrollBar = new tcScrollBar(this, wxPoint(mnWidth-scrollBarWidth, 0), wxSize(scrollBarWidth, mnHeight)); scrollBar->SetBackgroundAlpha(0.25f); } tcDatabaseBrowsePanel::~tcDatabaseBrowsePanel() { } --- NEW FILE: tcScrollBar.cpp --- /** ** @file tcScrollBar.cpp */ /* Copyright (C) 2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcScrollBar.h" #include "tcTime.h" #include <osg/Texture2D> #include <osg/Vec4> #include "wxcommands.h" #include <iostream> #ifdef _DEBUG #define new DEBUG_NEW #endif /** * Drawing Graphics object is based on parent's window since * button is sharing a surface with the parent. * This also allows the button to draw outside of its wxWindow * screen area. */ void tcScrollBar::Draw() { if ((!mbActive) || (barFraction > 1)) return; UpdateAutoScroll(); float w = float(mnWidth); float h = float(mnHeight); if (!overArrowUp) { DrawImageR(arrowUp.get(), 0, 0, w, w, ALIGN_BOTTOM_LEFT); } else { DrawImageR(arrowUpOver.get(), 0, 0, w, w, ALIGN_BOTTOM_LEFT); } if (!overArrowDown) { DrawImageR(arrowDown.get(), 0, h-w, w, w, ALIGN_BOTTOM_LEFT); } else { DrawImageR(arrowDownOver.get(), 0, h-w, w, w, ALIGN_BOTTOM_LEFT); } osg::Vec4 barColor; if (!scrollDrag) { if (!overScrollBar) { barColor.set(0.2, 0.5, 0.2, backgroundAlpha); } else { barColor.set(0.4, 1, 0.4, backgroundAlpha); } } else { barColor.set(1, 1, 1, backgroundAlpha); } osg::Vec4 baseColor(0.2, 0.5, 0.2, backgroundAlpha); //DrawRectangle(0, w, mnWidth, mnHeight-w, backgroundColor, FILL_ON); DrawRectangle(0, 0, w, h, baseColor, FILL_OFF); DrawLine(0, w, w, w, baseColor); DrawLine(0, h-w, w, h-w, baseColor); // draw scroll bar rectangle float barHeight = barFraction*(h - 2*w); barRect.Set(0, w, w+ybar, w+ybar+barHeight); buttonUpRect.Set(0, w, 0, w); buttonDownRect.Set(0, w, h-w, h); DrawRectangleR(barRect, barColor, FILL_ON); HideUnusedObjects(); } void tcScrollBar::LoadImages() { arrowUp = tc3DWindow::LoadTexture("up_arrow.png"); arrowDown = tc3DWindow::LoadTexture("down_arrow.png"); arrowUpOver = tc3DWindow::LoadTexture("up_arrow_over.png"); arrowDownOver = tc3DWindow::LoadTexture("down_arrow_over.png"); } /** * */ void tcScrollBar::OnEnterWindow(wxMouseEvent& event) { isMouseOver = true; } /** * Treat double click as single click */ void tcScrollBar::OnLButtonDClick(wxMouseEvent& event) { OnLButtonDown(event); } /** * */ void tcScrollBar::OnLButtonDown(wxMouseEvent& event) { wxPoint pos = event.GetPosition(); autoScrollIncrement = 0; leftButtonDown = true; if (barRect.ContainsPoint(pos.x, pos.y)) { scrollDrag = true; scrollDragStart = pos; ybarStart = ybar; CaptureMouse(); } else if (buttonUpRect.ContainsPoint(pos.x, pos.y)) { UpdateYbar(ybar - clickScrollAmount); buttonDownTime = tcTime::Get()->Get30HzCount(); autoScrollIncrement = -clickScrollAmount; } else if (buttonDownRect.ContainsPoint(pos.x, pos.y)) { UpdateYbar(ybar + clickScrollAmount); buttonDownTime = tcTime::Get()->Get30HzCount(); autoScrollIncrement = clickScrollAmount; } } /** * */ void tcScrollBar::OnLButtonUp(wxMouseEvent& event) { if (scrollDrag) { ReleaseMouse(); } leftButtonDown = false; scrollDrag = false; autoScrollIncrement = 0; autoScroll = false; } /** * */ void tcScrollBar::OnLeaveWindow(wxMouseEvent& event) { autoScrollIncrement = 0; autoScroll = false; overScrollBar = false; overArrowUp = false; overArrowDown = false; } /** * */ void tcScrollBar::OnMouseMove(wxMouseEvent& event) { wxPoint pos = event.GetPosition(); overScrollBar = false; overArrowUp = false; overArrowDown = false; if (barRect.ContainsPoint(pos.x, pos.y)) { overScrollBar = true; } else if (buttonUpRect.ContainsPoint(pos.x, pos.y)) { overArrowUp = true; } else if (buttonDownRect.ContainsPoint(pos.x, pos.y)) { overArrowDown = true; } if (!scrollDrag) return; float dy = float(pos.y - scrollDragStart.y); UpdateYbar(ybarStart + dy); } void tcScrollBar::SendScrollbarUpdated() { if (ybar == lastybar) return; lastybar = ybar; wxCommandEvent cmd(wxEVT_COMMAND_SCROLLBAR_UPDATED, 1); cmd.SetEventObject(this); cmd.m_extraLong = long(ybar * 4.0f / barFraction); AddPendingEvent(cmd); } /** * */ void tcScrollBar::SetBackgroundAlpha(float val) { backgroundAlpha = val; } void tcScrollBar::SetBarFraction(float val) { if (barFraction == val) return; barFraction = val; if (barFraction < 0.005) barFraction = 0.005; SetActive(barFraction < 1.0); ybar = 0; } /** * Check if mouse button down long enough and * periodically increment / decrement val if so * Allows user to change value quickly by holding mouse * button down. * * Similar to method in tcNumberWidget * @see tcNumberWidget::UpdateAutoChange */ void tcScrollBar::UpdateAutoScroll() { if (autoScrollIncrement == 0) return; unsigned currentTime = tcTime::Get()->Get30HzCount(); if (currentTime - buttonDownTime > 20) { autoScroll = true; } if (autoScroll) { UpdateYbar(ybar + autoScrollIncrement); } } void tcScrollBar::UpdateYbar(float ynew) { ybar = ynew; float ybarMax = float(mnHeight) - float(2*mnWidth) - barRect.Height(); if (ybar < 0) ybar = 0; else if (ybar > ybarMax) ybar = ybarMax; SendScrollbarUpdated(); } /** * */ tcScrollBar::tcScrollBar(tc3DWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : tc3DWindow(parent, pos, size, name, parent), isMouseOver(false), leftButtonDown(false), overArrowUp(false), overArrowDown(false), overScrollBar(false), scrollDrag(false), backgroundAlpha(0.8f), barFraction(1.1f), ybar(0), lastybar(9999.9f), clickScrollAmount(5.0f), autoScroll(false), autoScrollIncrement(0), buttonDownTime(0) { LoadImages(); SetBaseRenderBin(parent->GetBaseRenderBin() + 10); wxWindow::Raise(); SetActive(false); } tcScrollBar::~tcScrollBar() { #ifdef _DEBUG fprintf(stdout, "Destroying tcScrollBar\n"); #endif } Index: tcDatabaseInfoWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcDatabaseInfoWindow.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcDatabaseInfoWindow.cpp 21 Apr 2006 23:29:09 -0000 1.6 --- tcDatabaseInfoWindow.cpp 17 Aug 2006 01:28:04 -0000 1.7 *************** *** 37,40 **** --- 37,41 ---- #include "common/tinyxml.h" #include "tcTime.h" + #include "tcDatabaseInfoPanel.h" #include <osg/Geometry> *************** *** 51,54 **** --- 52,56 ---- using database::tcDatabaseObject; + tc3DWindow* tcDatabaseInfoWindow::parent = 0; *************** *** 130,157 **** 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()); --- 132,139 ---- DrawDatabaseImages(); textx = xImage + 10.0f; texty = float(mnHeight) - 15.0f; const std::string& artists = databaseObj->Get3DModel()->GetAuthor(); ! if ((artists.size() > 0) && IsEmbedded()) { PrintText(textx, texty, "3D Artist(s): %s", artists.c_str()); *************** *** 161,312 **** - 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, ...) --- 143,146 ---- *************** *** 340,345 **** float imageWidth = 150.0f; float imageHeight = 100.0f; ! float imagex = float(mnWidth) - imageWidth - 20.0f; ! float imagey = 10.0f; if (IsEmbedded()) --- 174,179 ---- float imageWidth = 150.0f; float imageHeight = 100.0f; ! float imagex = float(mnWidth) - imageWidth - 10.0f; ! float imagey = 25.0f; if (IsEmbedded()) *************** *** 348,352 **** imageHeight = 200.0f; imagex = float(mnWidth) - imageWidth - 10.0f; ! imagey = 10.0f; } --- 182,186 ---- imageHeight = 200.0f; imagex = float(mnWidth) - imageWidth - 10.0f; ! imagey = 25.0f; } *************** *** 394,397 **** --- 228,233 ---- } + + database::tcDatabaseObject* tcDatabaseInfoWindow::GetDatabaseObject() { *************** *** 521,524 **** --- 357,362 ---- databaseClassName = className; LoadImageList(); + + infoPanel->SetDatabaseClassName(className); } *************** *** 532,535 **** --- 370,375 ---- LoadImageList(); + + infoPanel->SetDatabaseObject(id); } *************** *** 606,609 **** --- 446,463 ---- SetActive(true); + + + int panelWidth = mnWidth - 175; + int panely = 25; + int panelHeight = mnHeight - panely - 10.0f; + + if (viewMode == EMBED) + { + panelWidth = mnWidth - 330; + } + + infoPanel = new tcDatabaseInfoPanel(this, wxPoint(10, panely), wxSize(panelWidth, panelHeight), "DBpanel", this); + + } Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tc3DViewer.cpp 18 Jun 2006 00:45:00 -0000 1.35 --- tc3DViewer.cpp 17 Aug 2006 01:28:04 -0000 1.36 *************** *** 40,43 **** --- 40,44 ---- #include <osg/PolygonMode> #include <osg/PositionAttitudeTransform> + #include <osg/Stencil> #include <osgDB/Registry> #include <osgDB/ReadFile> *************** *** 49,52 **** --- 50,54 ---- #include <osgUtil/SceneView> #include <osgUtil/UpdateVisitor> + #include <osgUtil/DisplayRequirementsVisitor> //#include <osgAL/SoundNode> *************** *** 451,455 **** if (modeCode == 1) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT); } else if (modeCode == 2) --- 453,457 ---- if (modeCode == 1) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } else if (modeCode == 2) *************** *** 457,465 **** if (useFarSceneView) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT); } else { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } } --- 459,467 ---- if (useFarSceneView) { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } else { ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } } *************** *** 474,482 **** if (modeCode == 1) { ! stageFar->setClearMask(GL_DEPTH_BUFFER_BIT); } else if (modeCode == 2) { ! stageFar->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } else --- 476,484 ---- if (modeCode == 1) { ! stageFar->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } else if (modeCode == 2) { ! stageFar->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } else *************** *** 860,863 **** --- 862,867 ---- } + + terrainManager = new tc3DTerrain(); osg::ref_ptr<osg::Node> terrainNode = terrainManager->GetTerrainNode().get(); *************** *** 988,992 **** } ! //guiView->update(); // necessary? guiView->cull(); guiView->draw(); --- 992,996 ---- } ! guiView->update(); // necessary? guiView->cull(); guiView->draw(); *************** *** 1439,1442 **** --- 1443,1448 ---- displaySettings = new osg::DisplaySettings; displaySettings->setDepthBuffer(true); + displaySettings->setMinimumNumStencilBits(8); + displaySettings->setDoubleBuffer(true); } *************** *** 1478,1487 **** wxASSERT(guiView->getDisplaySettings()==NULL); - displaySettings = new osg::DisplaySettings; - displaySettings->setDepthBuffer(false); ! guiView->setDisplaySettings(displaySettings.get()); guiView->setDefaults(); ! guiView->setState(sceneView->getState()); //guiView->getState()->setContextID(0); --- 1484,1498 ---- wxASSERT(guiView->getDisplaySettings()==NULL); ! osg::DisplaySettings* guiDisplaySettings = new osg::DisplaySettings; ! guiDisplaySettings->setDepthBuffer(false); ! guiDisplaySettings->setMinimumNumStencilBits(8); ! guiDisplaySettings->setDoubleBuffer(true); ! ! ! ! guiView->setDisplaySettings(guiDisplaySettings); guiView->setDefaults(); ! //guiView->setState(sceneView->getState()); //guiView->getState()->setContextID(0); *************** *** 1503,1507 **** // set up the clear mask. osgUtil::RenderStage *stage = guiView->getRenderStage(); ! stage->setClearMask(0); guiFrameStamp = new osg::FrameStamp; --- 1514,1518 ---- // set up the clear mask. osgUtil::RenderStage *stage = guiView->getRenderStage(); ! stage->setClearMask(GL_STENCIL_BUFFER_BIT); guiFrameStamp = new osg::FrameStamp; *************** *** 1531,1536 **** --- 1542,1549 ---- wxASSERT(sceneView->getDisplaySettings()==NULL); + displaySettings = new osg::DisplaySettings; displaySettings->setDepthBuffer(true); + displaySettings->setMinimumNumStencilBits(8); // displaySettings->setRGB(true); *************** *** 1542,1545 **** --- 1555,1565 ---- sceneView->getState()->setContextID(0); + + osg::StateSet* stateSet = sceneView->getGlobalStateSet(); + + //stateSet->setMode(GL_STENCIL_TEST, osg::StateAttribute::ON); + + + wxWindow *parent = wxWindow::GetParent(); wxSize parentSize = parent->GetSize(); *************** *** 1577,1581 **** stage->setClearDepth(1.0f); //stage->setClearColor(osg::Vec4(0,0,0,1.0f)); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT); frameStamp = new osg::FrameStamp; --- 1597,1601 ---- stage->setClearDepth(1.0f); //stage->setClearColor(osg::Vec4(0,0,0,1.0f)); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); frameStamp = new osg::FrameStamp; *************** *** 1603,1606 **** --- 1623,1627 ---- displaySettings = new osg::DisplaySettings; displaySettings->setDepthBuffer(true); + displaySettings->setMinimumNumStencilBits(8); } *************** *** 1611,1615 **** sceneViewFar->setDisplaySettings(displaySettings.get()); sceneViewFar->setDefaults(); ! sceneViewFar->setState(sceneView->getState()); //sceneViewFar->getState()->setContextID(0); --- 1632,1636 ---- sceneViewFar->setDisplaySettings(displaySettings.get()); sceneViewFar->setDefaults(); ! //sceneViewFar->setState(sceneView->getState()); //sceneViewFar->getState()->setContextID(0); *************** *** 1646,1650 **** // set up the clear mask. osgUtil::RenderStage *stage = sceneViewFar->getRenderStage(); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); stage->setClearDepth(1.0f); stage->setClearColor(osg::Vec4(0,0,0,1.0f)); --- 1667,1671 ---- // set up the clear mask. osgUtil::RenderStage *stage = sceneViewFar->getRenderStage(); ! stage->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); stage->setClearDepth(1.0f); stage->setClearColor(osg::Vec4(0,0,0,1.0f)); *************** *** 1669,1684 **** globalStateSet = new osg::StateSet; sceneView->setGlobalStateSet(globalStateSet); } { ! #if 1 //globalStateSet->setGlobalDefaults(); // enable depth testing by default. osg::Depth* depth = new osg::Depth(osg::Depth::LESS, 0, 1); globalStateSet->setAttributeAndModes(depth, osg::StateAttribute::ON ); //globalStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); ! #endif osg::PolygonMode *pm = new osg::PolygonMode(); pm->setMode(osg::PolygonMode::Face::FRONT_AND_BACK, osg::PolygonMode::FILL); --- 1690,1708 ---- globalStateSet = new osg::StateSet; sceneView->setGlobalStateSet(globalStateSet); + //globalStateSet->setGlobalDefaults(); } { ! #if 0 //globalStateSet->setGlobalDefaults(); // enable depth testing by default. osg::Depth* depth = new osg::Depth(osg::Depth::LESS, 0, 1); globalStateSet->setAttributeAndModes(depth, osg::StateAttribute::ON ); + + //globalStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); ! osg::PolygonMode *pm = new osg::PolygonMode(); pm->setMode(osg::PolygonMode::Face::FRONT_AND_BACK, osg::PolygonMode::FILL); *************** *** 1704,1708 **** globalStateSet->setAttributeAndModes(alphafunc, osg::StateAttribute::ON); ! //globalStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::INHERIT); //globalStateSet->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::INHERIT); --- 1728,1735 ---- globalStateSet->setAttributeAndModes(alphafunc, osg::StateAttribute::ON); ! ! ! ! //globalStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::INHERIT); //globalStateSet->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::INHERIT); *************** *** 1710,1713 **** --- 1737,1742 ---- globalStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::PROTECTED | osg::StateAttribute::ON); + #endif + } } *************** *** 1734,1738 **** textState->setMode(GL_FOG, osg::StateAttribute::OFF); textState->setMode(GL_DEPTH, osg::StateAttribute::OFF); ! textState->setMode(GL_BLEND, osg::StateAttribute::OFF); /* --- 1763,1768 ---- textState->setMode(GL_FOG, osg::StateAttribute::OFF); textState->setMode(GL_DEPTH, osg::StateAttribute::OFF); ! textState->setMode(GL_BLEND, osg::StateAttribute::OFF ); ! /* *************** *** 1987,1990 **** --- 2017,2021 ---- } + if (useFarSceneView) { *************** *** 2171,2175 **** // to suppress "Number display lists deleted" stdout text // doesn't work with OSG 0.9.5, should work with 0.9.6 and beyond ! osg::setNotifyLevel(osg::NOTICE); /* ALWAYS=0, --- 2202,2206 ---- // to suppress "Number display lists deleted" stdout text // doesn't work with OSG 0.9.5, should work with 0.9.6 and beyond ! osg::setNotifyLevel(osg::NOTICE); // NOTICE /* ALWAYS=0, Index: tcStoresGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStoresGui.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcStoresGui.cpp 18 Jun 2006 00:45:00 -0000 1.8 --- tcStoresGui.cpp 17 Aug 2006 01:28:04 -0000 1.9 *************** *** 104,108 **** wxString captionText = wxString::Format("%s: %s", unitName, storesDisplayName.c_str()); DrawTextR(captionText.c_str(), 10.0f, 20.0f, defaultFont.get(), ! captionColor, 18.0f, LEFT_BASE_LINE, guiWidth - 20.0f); --- 104,108 ---- wxString captionText = wxString::Format("%s: %s", unitName, storesDisplayName.c_str()); DrawTex... [truncated message content] |