[Gcblue-commits] gcb_wx/src/sim Game.cpp, 1.157, 1.158 tcGameObject.cpp, 1.45, 1.46 tcMapData.cpp,
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-08-17 01:28:09
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv21820/src/sim Modified Files: Game.cpp tcGameObject.cpp tcMapData.cpp tcMissileObject.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorPlatform.cpp tcStores.cpp Log Message: Update for server name change Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tcMissileObject.cpp 18 Jun 2006 00:45:03 -0000 1.35 --- tcMissileObject.cpp 17 Aug 2006 01:28:05 -0000 1.36 *************** *** 584,589 **** break; case AM_AGL: ! fGoalAltitude_m = pSegmentInfo->mfAltitude_m + ! mcTerrain.mfHeight_m; break; case AM_INTERCEPT: // use seeker data or maintain altitude --- 584,591 ---- break; case AM_AGL: ! { ! float effectiveTerrainHeight_m = (mcTerrain.mfHeight_m > 0) ? mcTerrain.mfHeight_m : 0; ! fGoalAltitude_m = pSegmentInfo->mfAltitude_m + effectiveTerrainHeight_m; ! } break; case AM_INTERCEPT: // use seeker data or maintain altitude Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** Game.cpp 18 Jun 2006 00:45:01 -0000 1.157 --- Game.cpp 17 Aug 2006 01:28:05 -0000 1.158 *************** *** 107,110 **** --- 107,111 ---- EVT_COMMAND(ID_SETBRIEFING, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::SetBriefingMode) EVT_COMMAND(ID_MULTIPLAYERMODE, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SetMultiplayerMode) + EVT_COMMAND(ID_REFRESHMAPS, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::RefreshMaps) EVT_COMMAND(ID_SETPAUSE, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::SetPauseMode) EVT_COMMAND(ID_SETTIMEACCEL, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::SetTimeAccel) *************** *** 327,330 **** --- 328,353 ---- /** + * If game mode is GM_START do nothing, since map isn't instantiated. Otherwise + * reload the high resolution map with the new color mode. + */ + void tcGame::RefreshMaps() + { + if (meGameMode == GM_START) return; + + if (tacticalMap == 0) + { + wxASSERT(false); + return; + } + + tacticalMap->Refresh(); + } + + void tcGame::RefreshMaps(wxCommandEvent& event) + { + RefreshMaps(); + } + + /** * Skips to the end of the briefing and starts game */ *************** *** 759,763 **** startView->AttachOptions(tcOptions::Get()); ! startView->LoadBackgroundImage("start_background.jpg"); if (startView->Init() == false) --- 782,786 ---- startView->AttachOptions(tcOptions::Get()); ! startView->LoadBackgroundImage("start_background_dev.jpg"); if (startView->Init() == false) *************** *** 1534,1541 **** break; case DATABASEVIEW: - databaseViewer->SetActive(true); - databaseViewer->Draw(); viewer->SetActive(true); viewer->SetDatabaseView(true); if (lastMode != DATABASEVIEW) { --- 1557,1566 ---- break; case DATABASEVIEW: viewer->SetActive(true); viewer->SetDatabaseView(true); + databaseViewer->SetActive(true); + databaseViewer->Raise(); + databaseViewer->Draw(); + if (lastMode != DATABASEVIEW) { *************** *** 1815,1818 **** --- 1840,1844 ---- viewer->SetDatabaseView(true); viewer->SetActive(true); + databaseViewer->Raise(); if (lastMode != DATABASEVIEW) { *************** *** 2364,2377 **** if (objectControl) objectControl->SetHookID(hookID); viewer->SetHookID(hookID); if (hookID != NULL_INDEX) { tcSound::Get()->PlayEffect("ShortBeep"); - pythonInterface->SetMenuPlatform(hookID); } - tcGameObject::SetHookedId(hookID); - hookedUnits.clear(); - hookedUnits.push_back(hookID); } --- 2390,2404 ---- if (objectControl) objectControl->SetHookID(hookID); viewer->SetHookID(hookID); + pythonInterface->SetMenuPlatform(hookID); + tcGameObject::SetHookedId(hookID); + + hookedUnits.clear(); + hookedUnits.push_back(hookID); if (hookID != NULL_INDEX) { tcSound::Get()->PlayEffect("ShortBeep"); } } *************** *** 2823,2826 **** --- 2850,2868 ---- } } + else if (s == "CopperMap") + { + tcOptions::Get()->mnMapMode = 0; + RefreshMaps(); + } + else if (s == "YellowBlueMap") + { + tcOptions::Get()->mnMapMode = 1; + RefreshMaps(); + } + else if (s == "BlackBlueMap") + { + tcOptions::Get()->mnMapMode = 2; + RefreshMaps(); + } } *************** *** 2884,2888 **** commandQueue = tcCommandQueue::Get(); ! glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", 0, wxNullPalette); glCanvas->SetBackgroundColour(*wxBLACK); --- 2926,2944 ---- commandQueue = tcCommandQueue::Get(); ! ! int attribList[15]; ! attribList[0] = WX_GL_RGBA; ! attribList[1] = 1; ! attribList[2] = WX_GL_DEPTH_SIZE; ! attribList[3] = 16; ! attribList[4] = WX_GL_MIN_ALPHA; ! attribList[5] = 8; ! attribList[6] = WX_GL_STENCIL_SIZE; ! attribList[7] = 8; ! attribList[8] = WX_GL_DOUBLEBUFFER; ! attribList[9] = 1; ! attribList[10] = 0; ! ! glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", attribList, wxNullPalette); glCanvas->SetBackgroundColour(*wxBLACK); Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** tcRadar.cpp 18 Jun 2006 00:45:03 -0000 1.38 --- tcRadar.cpp 17 Aug 2006 01:28:05 -0000 1.39 *************** *** 226,229 **** --- 226,230 ---- bool isGround = false; float rcs_dBsm; + float targetHeight_m = target->mcKin.mfAlt_m; // equivalent height of target for radar horizon // Need more efficient implementation here, gotta be a better way to do this! *************** *** 232,235 **** --- 233,237 ---- rcs_dBsm = surfaceObj->mpDBObject->mfRcs_dbsm; isSurface = true; + targetHeight_m = 0.5f * surfaceObj->GetZmaxConst(); // use half max for equivalent radar height } else if (const tcAirObject* airObj = dynamic_cast<const tcAirObject*>(target)) *************** *** 262,265 **** --- 264,268 ---- rcs_dBsm = sub->mpDBObject->mfRcs_dbsm; isSurface = true; + targetHeight_m += 2.0f + 0.4f * surfaceObj->GetZmaxConst(); } else *************** *** 294,300 **** } ! float fRadarHorizon = C_RADARHOR*(sqrtf(tgt_kin->mfAlt_m) +sqrtf(rdr_kin->mfAlt_m + mfSensorHeight_m)); fTargetRange_km = C_RADTOKM*nsNav::GCDistanceApprox_rad(rdr_kin->mfLat_rad, rdr_kin->mfLon_rad, ! tgt_kin->mfLat_rad,tgt_kin->mfLon_rad); range_km = fTargetRange_km; last_range_km = range_km; --- 297,304 ---- } ! float fRadarHorizon = C_RADARHOR*(sqrtf(targetHeight_m) +sqrtf(rdr_kin->mfAlt_m + mfSensorHeight_m)); ! fTargetRange_km = C_RADTOKM*nsNav::GCDistanceApprox_rad(rdr_kin->mfLat_rad, rdr_kin->mfLon_rad, ! tgt_kin->mfLat_rad,tgt_kin->mfLon_rad, rdr_kin->mfAlt_m, tgt_kin->mfAlt_m); range_km = fTargetRange_km; last_range_km = range_km; Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** tcGameObject.cpp 18 Jun 2006 00:45:02 -0000 1.45 --- tcGameObject.cpp 17 Aug 2006 01:28:05 -0000 1.46 *************** *** 499,502 **** --- 499,521 ---- /** + * @return the maximum vertical coordinate of the 3D model for this object + * Useful for estimating radar antenna height and effective height for radar horizon + */ + float tcGameObject::GetZmax() + { + return model->GetBoundingBox().zMax(); + } + + /** + * @return the maximum vertical coordinate of the 3D model for this object + * Useful for estimating radar antenna height and effective height for radar horizon + * Workaround for const-ness requirements + */ + float tcGameObject::GetZmaxConst() const + { + return model->GetBoundingBoxConst().zMax(); + } + + /** * Linear search to verify child */ Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcOpticalSensor.cpp 26 Mar 2006 00:32:15 -0000 1.11 --- tcOpticalSensor.cpp 17 Aug 2006 01:28:05 -0000 1.12 *************** *** 129,133 **** float horizonRange_km = C_VISUALHOR*(sqrtf(tgt_kin->mfAlt_m) +sqrtf(rdr_kin->mfAlt_m)); targetRange_km = C_RADTOKM*nsNav::GCDistanceApprox_rad(rdr_kin->mfLat_rad, rdr_kin->mfLon_rad, ! tgt_kin->mfLat_rad,tgt_kin->mfLon_rad); range_km = targetRange_km; if ((targetRange_km > horizonRange_km) || (targetRange_km > mpDBObj->mfMaxRange_km)) --- 129,133 ---- float horizonRange_km = C_VISUALHOR*(sqrtf(tgt_kin->mfAlt_m) +sqrtf(rdr_kin->mfAlt_m)); targetRange_km = C_RADTOKM*nsNav::GCDistanceApprox_rad(rdr_kin->mfLat_rad, rdr_kin->mfLon_rad, ! tgt_kin->mfLat_rad,tgt_kin->mfLon_rad, rdr_kin->mfAlt_m, tgt_kin->mfAlt_m); range_km = targetRange_km; if ((targetRange_km > horizonRange_km) || (targetRange_km > mpDBObj->mfMaxRange_km)) Index: tcSensorPlatform.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorPlatform.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcSensorPlatform.cpp 18 Jun 2006 00:45:03 -0000 1.12 --- tcSensorPlatform.cpp 17 Aug 2006 01:28:05 -0000 1.13 *************** *** 417,421 **** wxASSERT(sensor); ! sensor->mfSensorHeight_m = 0.1f * parent->GetSpan(); //< guess sensor height is 10% of length sensor->SetMountAz(0); sensorState.push_back(sensor); --- 417,421 ---- wxASSERT(sensor); ! sensor->mfSensorHeight_m = 0.8f * parent->GetZmax(); //< guess sensor height is 80% of zmax sensor->SetMountAz(0); sensorState.push_back(sensor); Index: tcMapData.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMapData.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** tcMapData.cpp 18 Jun 2006 00:45:03 -0000 1.27 --- tcMapData.cpp 17 Aug 2006 01:28:05 -0000 1.28 *************** *** 1006,1012 **** } /** ! * use anMapID = 0 for low res, 1 for high res ! * TODO: fix */ void tcMapData::CreateMapImage(int anMode, int anMapID, UINT32 *apData) --- 1006,1085 ---- } + + UINT32 tcMapData::BlackBlueMap(long pval) const + { + bool subZero = (pval < 0); + bool missingData = pval == MISSING_DATA_VAL; + + + if (subZero && (!missingData)) + { + return 0xFFBF2010; + } + else if (subZero && missingData) + { + return 0xFF000040; // set missing data to red + } + else + { + return 0xFF000000; + } + } + + UINT32 tcMapData::CopperBlueMap(long pval) const + { + if (pval > 1000) pval = 1000; + + if (pval <= 0) + { + if (pval != MISSING_DATA_VAL) + { + return 0xFF700000; + } + else + { + return 0xFF000000; + } + } + else + { + pval = pval/20; + if (pval > 115) + { + pval = 115; + } + return 0x010102*pval + 0xFF252515; + } + } + + UINT32 tcMapData::YellowBlueMap(long pval) const + { + int nPaletteIndex = (pval/10) + 100; + + if (nPaletteIndex > 247) // TODO bug here that needs fixing, higher values distort on texture + { + nPaletteIndex = 247; + } + else if (nPaletteIndex < 0) + { + nPaletteIndex = 0; + } + + if (pval != MISSING_DATA_VAL) + { + return maPalette1[nPaletteIndex]; + } + else + { + return 0xFF000000; + } + } + + + + + /** ! * Use anMapID = 0 for low res, 1 for high res */ void tcMapData::CreateMapImage(int anMode, int anMapID, UINT32 *apData) *************** *** 1027,1137 **** } ! if (apData == NULL) {return;} ! ! // create map image using map data ! switch (anMode) { ! case 0: ! for(m=0;m<M;m++) ! { ! for(n=0;n<N;n++) ! { ! pval = (anMapID==0) ? maGlobal[m][n] : maTheater[m][n]; ! if (pval > 1000) pval = 1000; ! if (pval <= 0) ! { ! if (pval == MISSING_DATA_VAL) ! { ! pval = 0x000000; ! } ! else ! { ! pval = 0x700000; ! } ! } ! else ! { ! pval = pval/20; ! if (pval > 115) ! { ! pval = 115; ! } ! pval = 0x010102*pval + 0x252515; ! } ! apData[(M-1-m)*N + n] = pval + nAlphaOffset; ! } ! } ! break; ! case 1: ! int nPaletteIndex; ! for(m=0;m<M;m++) { ! for(n=0;n<N;n++) { ! pval = (anMapID==0) ? maGlobal[m][n] : maTheater[m][n]; // TODO: move out of loop somehow ! nPaletteIndex = (pval/10) + 100; ! if (nPaletteIndex > 247) // TODO bug here that needs fixing, higher values distort on texture ! { ! nPaletteIndex = 247; ! } ! else if (nPaletteIndex < 0) ! { ! nPaletteIndex = 0; ! } ! ! if (pval == MISSING_DATA_VAL) ! { ! apData[(M-1-m)*N + n] = 0x00000000 + nAlphaOffset; ! } ! else ! { ! pval = maPalette1[nPaletteIndex]; ! apData[(M-1-m)*N + n] = (0x00FFFFFF & pval) + nAlphaOffset; ! } ! //apWindow->SetPixel(n,M-1-m,pval + nAlphaOffset); } } ! break; ! case 2: ! for(m=0;m<M;m++) { ! for(n=0;n<N;n++) { ! pval = (anMapID==0) ? maGlobal[m][n] : maTheater[m][n]; ! if (pval < 0) ! { ! if (pval == MISSING_DATA_VAL) // set missing data to red ! { ! apData[(M-1-m)*N + n] = 0x00000040 + nAlphaOffset; ! } ! else ! { ! apData[(M-1-m)*N + n] = 0x00BF2010 + nAlphaOffset; ! } ! } ! else ! { ! apData[(M-1-m)*N + n] = 0x00000000 + nAlphaOffset; ! //apWindow->SetPixel(n,M-1-m,0x00000000 + nAlphaOffset); ! } } } - break; - default: - break; } - /* - // draw longitude and latitude points for debug - for(m=0;m<M;m+=(M/18)) { - for(n=0;n<N;n+=(N/36)) { - apWindow->SetPixel(n,m,pval + 0xFE00FF00); - } - } - */ // for low res map, darken the unavailable tiles if (anMapID == 0) --- 1100,1147 ---- } ! if (apData == NULL) return; ! UINT32 (tcMapData::*MapOperator)(long) const = 0; ! switch (anMode) { ! case 0: MapOperator = &tcMapData::CopperBlueMap; break; ! case 1: MapOperator = &tcMapData::YellowBlueMap; break; ! case 2: MapOperator = &tcMapData::BlackBlueMap; break; ! default: ! wxASSERT(false); ! fprintf(stderr, "tcMapData::CreateMapImage -- bad mode (%d)\n", anMode); ! return; ! } ! ! // create map image using map data ! if (anMapID == 0) // global map ! { ! for(m=0; m<M; m++) { ! size_t rowIndex = (M-1-m)*N; ! for(n=0; n<N; n++) { ! pval = maGlobal[m][n]; ! apData[rowIndex + n] = (this->*MapOperator)(pval); } } ! } ! else // theater map ! { ! for(m=0; m<M; m++) { ! size_t rowIndex = (M-1-m)*N; ! for(n=0; n<N; n++) { ! pval = maTheater[m][n]; ! ! apData[rowIndex + n] = (this->*MapOperator)(pval); } } } // for low res map, darken the unavailable tiles if (anMapID == 0) *************** *** 1140,1144 **** } ! //LabelLowRes(); // TODO: add country and geopol labels fprintf(stdout, "tcMapData - CreateMapImage - success\n"); --- 1150,1154 ---- } ! //LabelLowRes(); // TODO: add country and geopol labels fprintf(stdout, "tcMapData - CreateMapImage - success\n"); Index: tcStores.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcStores.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcStores.cpp 18 Jun 2006 00:45:04 -0000 1.10 --- tcStores.cpp 17 Aug 2006 01:28:05 -0000 1.11 *************** *** 815,819 **** } ! long fuelNeeded_kg = long(platform->mpDBObject->mfFuelCapacity_kg - platform->fuel_kg); if (fuelNeeded_kg <= 0) --- 815,819 ---- } ! long fuelNeeded_kg = long(ceilf((platform->mpDBObject->mfFuelCapacity_kg - platform->fuel_kg))); if (fuelNeeded_kg <= 0) |