[Gcblue-commits] gcb_wx/src/sim tcGroundObject.cpp,NONE,1.1 Game.cpp,1.117,1.118 tcAirObject.cpp,1.1
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-01-31 01:33:28
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20374/src/sim Modified Files: Game.cpp tcAirObject.cpp tcBallisticWeapon.cpp tcFlightPort.cpp tcGameObject.cpp tcHeloObject.cpp tcPlatformObject.cpp tcRadar.cpp tcSimState.cpp Added Files: tcGroundObject.cpp Log Message: Moved launcher position to 3D model animation xml file Added tcGroundObject for ground SAM site --- NEW FILE: tcGroundObject.cpp --- /** ** @file tcGroundObject.cpp */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** 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 "tcGroundObject.h" #include "tcGenericDBObject.h" #ifdef _DEBUG #define new DEBUG_NEW #endif void tcGroundObject::Clear() { tcPlatformObject::Clear(); } /** * Randomly initializes object */ void tcGroundObject::RandInitNear(float afLon_deg, float afLat_deg) { if (mpDBObject == NULL) {return;} strcpy(mzClass.mz, mpDBObject->mzClass.mz); mzUnit = "GR_"; mzUnit.AssignRandomSuffix(); mnAlliance = 0; mfStatusTime = 0; mcKin.mfLon_rad = C_PIOVER180*(afLon_deg + randfc(1.1f)); mcKin.mfLat_rad = C_PIOVER180*(afLat_deg + randfc(1.1f)); mcKin.mfAlt_m = 0.0f; mcKin.mfHeading_rad = C_TWOPI*randf(); mcKin.mfSpeed_kts = 0; mfDamageLevel = 0; } void tcGroundObject::PrintToFile(tcFile& file) { tcPlatformObject::PrintToFile(file); } void tcGroundObject::SaveToFile(tcFile& file) { tcPlatformObject::SaveToFile(file); } void tcGroundObject::LoadFromFile(tcFile& file) { tcPlatformObject::LoadFromFile(file); } void tcGroundObject::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); } else { SaveToFile(file); } } /** * Update method calls updates that are not * related to motion from tcPlatformObject. (tcGroundObject does * not move. ) * TODO: extract sensor and launcher functionality from * tcPlatformObject and use as parent classes instead. Then any * class that needs sensors or launchers can derive from the * appropriate parent class. Same thing needs to be done with * tcAirfieldObject */ void tcGroundObject::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); if (dt_s <= min_update_s) {return;} // added for pause case UpdateEffects(); wxASSERT(mpDBObject); UpdateLauncherState(dt_s); UpdateSensors(afStatusTime); mfStatusTime = afStatusTime; } #pragma warning (disable : 4355) /** * */ tcGroundObject::tcGroundObject() { wxASSERT(false); Clear(); mpDBObject = NULL; mnModelType = MTYPE_FIXED; } /** * Constructor that initializes using info from database entry. */ tcGroundObject::tcGroundObject(tcGenericDBObject *obj) : tcPlatformObject(obj) { mpDBObject = obj; mcKin.mfSpeed_kts = 0; // make sure this doesn't move (shouldn't be necessary) mnModelType = MTYPE_FIXED; } tcGroundObject::~tcGroundObject() { } Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** tcSimState.cpp 27 Jan 2005 01:02:06 -0000 1.64 --- tcSimState.cpp 31 Jan 2005 01:33:09 -0000 1.65 *************** *** 2,6 **** ** @file tcSimState.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** --- 2,6 ---- ** @file tcSimState.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** *************** *** 42,45 **** --- 42,46 ---- #include "tcBallisticWeapon.h" #include "tcBallisticDBObject.h" + #include "tcGroundObject.h" #include "tcTorpedoObject.h" #include "tcTorpedoDBObject.h" *************** *** 1461,1465 **** if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) { ! tcSound::Get()->PlayEffect("NavalGun1"); } } --- 1462,1469 ---- if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) { ! if (ballistic->IsGunRound()) ! { ! tcSound::Get()->PlayEffect("NavalGun1"); ! } } } *************** *** 1515,1522 **** return new tcSubObject(pGenericData); } ! else { return new tcSurfaceObject(pGenericData); } } else if (tcMissileDBObject *pMissileData = dynamic_cast<tcMissileDBObject*>(apDBObject)) --- 1519,1536 ---- return new tcSubObject(pGenericData); } ! else if (apDBObject->mnModelType == MTYPE_FIXED) ! { ! return new tcGroundObject(pGenericData); ! } ! else if (apDBObject->mnModelType == MTYPE_SURFACE) { return new tcSurfaceObject(pGenericData); } + else + { + fprintf(stderr, "tcSimState::CreateGameObject - " + "Unrecognized model type for generic DB obj (%d)\n", apDBObject->mnModelType); + return NULL; + } } else if (tcMissileDBObject *pMissileData = dynamic_cast<tcMissileDBObject*>(apDBObject)) Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcAirObject.cpp 23 Nov 2004 23:31:12 -0000 1.15 --- tcAirObject.cpp 31 Jan 2005 01:33:08 -0000 1.16 *************** *** 310,323 **** float dh_min, dh_max; ! if (roll_min < roll_max) { ! dh_min = -roll_max*roll_to_rps*dt_s; ! dh_max = -roll_min*roll_to_rps*dt_s; } ! else { ! dh_min = -roll_min*roll_to_rps*dt_s; ! dh_max = -roll_max*roll_to_rps*dt_s; } ! if (dh > dh_max) { mcKin.mfHeading_rad = heading_start + dh_max; if (mcKin.mfHeading_rad >= C_TWOPI) {mcKin.mfHeading_rad -= C_TWOPI;} --- 310,326 ---- float dh_min, dh_max; ! if (roll_min < roll_max) ! { ! dh_min = roll_min*roll_to_rps*dt_s; ! dh_max = roll_max*roll_to_rps*dt_s; } ! else ! { ! dh_min = roll_max*roll_to_rps*dt_s; ! dh_max = roll_min*roll_to_rps*dt_s; } ! if (dh > dh_max) ! { mcKin.mfHeading_rad = heading_start + dh_max; if (mcKin.mfHeading_rad >= C_TWOPI) {mcKin.mfHeading_rad -= C_TWOPI;} *************** *** 325,329 **** dh = dh_max; } ! else if (dh < dh_min) { mcKin.mfHeading_rad = heading_start + dh_min; if (mcKin.mfHeading_rad >= C_TWOPI) {mcKin.mfHeading_rad -= C_TWOPI;} --- 328,333 ---- dh = dh_max; } ! else if (dh < dh_min) ! { mcKin.mfHeading_rad = heading_start + dh_min; if (mcKin.mfHeading_rad >= C_TWOPI) {mcKin.mfHeading_rad -= C_TWOPI;} *************** *** 333,337 **** float dh_rps = dh*dtinv; ! mcKin.mfRoll_rad = -dh_rps*rps_to_roll; } --- 337,341 ---- float dh_rps = dh*dtinv; ! mcKin.mfRoll_rad = dh_rps*rps_to_roll; } Index: tcFlightPort.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightPort.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcFlightPort.cpp 2 Nov 2004 04:23:56 -0000 1.12 --- tcFlightPort.cpp 31 Jan 2005 01:33:08 -0000 1.13 *************** *** 482,490 **** unit->mcKin = parent->mcKin; unit->mcKin.mfHeading_rad += unit->rel_pos.yaw; ! unit->mcKin.mfAlt_m += unit->rel_pos.dy; unit->SetHeading(unit->mcKin.mfHeading_rad); unit->mfStatusTime = parent->mfStatusTime; // correct latitude and longitude for relative position on parent float parent_hdg = parent->mcKin.mfHeading_rad; float cos_parent_hdg = cosf(parent_hdg); --- 482,496 ---- unit->mcKin = parent->mcKin; unit->mcKin.mfHeading_rad += unit->rel_pos.yaw; ! unit->mcKin.mfAlt_m += unit->rel_pos.dz; unit->SetHeading(unit->mcKin.mfHeading_rad); unit->mfStatusTime = parent->mfStatusTime; + tsGeoPoint childPos = parent->RelPosToLatLonAlt(unit->rel_pos); + unit->mcKin.mfAlt_m = childPos.mfAlt_m; + unit->mcKin.mfLat_rad = childPos.mfLat_rad; + unit->mcKin.mfLon_rad = childPos.mfLon_rad; + // correct latitude and longitude for relative position on parent + /* float parent_hdg = parent->mcKin.mfHeading_rad; float cos_parent_hdg = cosf(parent_hdg); *************** *** 497,500 **** --- 503,507 ---- unit->mcKin.mfLat_rad += delta_lat; unit->mcKin.mfLon_rad += delta_lon; + */ if (tcAeroAirObject* aa_unit = dynamic_cast<tcAeroAirObject*>(unit)) Index: tcHeloObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcHeloObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcHeloObject.cpp 2 Nov 2004 04:23:56 -0000 1.2 --- tcHeloObject.cpp 31 Jan 2005 01:33:09 -0000 1.3 *************** *** 140,143 **** --- 140,151 ---- } + /** + * No min speed for helo, can hover + */ + void tcHeloObject::UpdateSpeed(float dt_s) + { + tcPlatformObject::UpdateSpeed(dt_s); + } + void tcHeloObject::Update(double afStatusTime) Index: tcBallisticWeapon.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcBallisticWeapon.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcBallisticWeapon.cpp 2 Nov 2004 04:23:56 -0000 1.6 --- tcBallisticWeapon.cpp 31 Jan 2005 01:33:08 -0000 1.7 *************** *** 253,256 **** --- 253,266 ---- } + bool tcBallisticWeapon::IsGravityBomb() const + { + return mpDBObject->IsGravityBomb(); + } + + bool tcBallisticWeapon::IsGunRound() const + { + return mpDBObject->IsGunRound(); + } + /** * Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tcPlatformObject.cpp 7 Dec 2004 04:00:43 -0000 1.33 --- tcPlatformObject.cpp 31 Jan 2005 01:33:09 -0000 1.34 *************** *** 920,927 **** mcLauncherState.mnCount = 0; ! for(int nLauncher=0;nLauncher<mpDBObject->mnNumLaunchers;nLauncher++) { tnPoolIndex nLauncherKey = database->GetKey(mpDBObject->maLauncherClass[nLauncher]); ! float launcherAz_deg = mpDBObject->launcherAz[nLauncher]; mcLauncherState.AddFullLauncher(nLauncherKey, C_PIOVER180*launcherAz_deg, mpDBObject->launcherName[nLauncher]); --- 920,927 ---- mcLauncherState.mnCount = 0; ! for (int nLauncher=0; nLauncher<mpDBObject->mnNumLaunchers; nLauncher++) { tnPoolIndex nLauncherKey = database->GetKey(mpDBObject->maLauncherClass[nLauncher]); ! float launcherAz_deg = mpDBObject->GetLauncherAz(nLauncher); mcLauncherState.AddFullLauncher(nLauncherKey, C_PIOVER180*launcherAz_deg, mpDBObject->launcherName[nLauncher]); Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** Game.cpp 27 Jan 2005 01:01:52 -0000 1.117 --- Game.cpp 31 Jan 2005 01:33:08 -0000 1.118 *************** *** 299,302 **** --- 299,304 ---- viewer->SetClearMode(2); // depth and color buffer clearing viewer->ClearDefaultTextObjects(); + size3D = MODE3D_SMALL; + Update3DSize(); // clear message center Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcGameObject.cpp 2 Dec 2004 04:17:26 -0000 1.26 --- tcGameObject.cpp 31 Jan 2005 01:33:08 -0000 1.27 *************** *** 1,20 **** /* ! * Copyright (C) 2003 Dewitt Colclough (de...@tw...) ! * 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" --- 1,23 ---- + /** + ** @file tcGameObject.cpp + */ /* ! ** Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ! ** 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" *************** *** 128,136 **** /** ! * Gets relative model coordinates of obj relative to this GameObject ! * Not tested yet. ! * ! * @param rel_pos Relative position structure to store results in. ! */ void tcGameObject::GetRelPosOf(tcGameObject *obj, tsRelativePosition& rel_pos) { --- 131,140 ---- /** ! * Gets relative model coordinates of obj relative to this GameObject ! * Modified to new coord system: dx right, dy forward, dz up ! * Old system was: dx is right, dy is up, and dz is back ! * ! * @param rel_pos Relative position structure to store results in. ! */ void tcGameObject::GetRelPosOf(tcGameObject *obj, tsRelativePosition& rel_pos) { *************** *** 138,142 **** rel_pos.roll = 0; rel_pos.yaw = 0; ! rel_pos.dy = obj->mcKin.mfAlt_m - mcKin.mfAlt_m; double delta_lat = obj->mcKin.mfLat_rad - mcKin.mfLat_rad; double delta_lon = obj->mcKin.mfLon_rad - mcKin.mfLon_rad; --- 142,147 ---- rel_pos.roll = 0; rel_pos.yaw = 0; ! rel_pos.dz = obj->mcKin.mfAlt_m - mcKin.mfAlt_m; ! double delta_lat = obj->mcKin.mfLat_rad - mcKin.mfLat_rad; double delta_lon = obj->mcKin.mfLon_rad - mcKin.mfLon_rad; *************** *** 149,156 **** float sin_hdg = sinf(hdg); float dx = cos_hdg*delta_lon_m - sin_hdg*delta_lat_m; ! float dz = -cos_hdg*delta_lat_m - sin_hdg*delta_lon_m; rel_pos.dx = dx; ! rel_pos.dz = dz; } --- 154,161 ---- float sin_hdg = sinf(hdg); float dx = cos_hdg*delta_lon_m - sin_hdg*delta_lat_m; ! float dy = cos_hdg*delta_lat_m + sin_hdg*delta_lon_m; rel_pos.dx = dx; ! rel_pos.dy = dy; } *************** *** 197,202 **** /** ! * Looking forward from the object, dx is right, dy is up, and dz is back ! * TODO fix this system to use dx right, dy forward, dz up */ tsGeoPoint tcGameObject::RelPosToLatLonAlt(const float& dx, --- 202,207 ---- /** ! * Modified to new coord system: dx right, dy forward, dz up ! * Old system was: dx is right, dy is up, and dz is back */ tsGeoPoint tcGameObject::RelPosToLatLonAlt(const float& dx, *************** *** 209,216 **** float sin_hdg = sinf(hdg); ! p.mfAlt_m = mcKin.mfAlt_m + dy; p.mfLon_rad = (C_MTORAD / cosf((float)mcKin.mfLat_rad)) * ! (cos_hdg * dx - sin_hdg * dz) + mcKin.mfLon_rad; ! p.mfLat_rad = C_MTORAD * (-cos_hdg * dz - sin_hdg * dx) + mcKin.mfLat_rad; return p; --- 214,221 ---- float sin_hdg = sinf(hdg); ! p.mfAlt_m = mcKin.mfAlt_m + dz; p.mfLon_rad = (C_MTORAD / cosf((float)mcKin.mfLat_rad)) * ! (cos_hdg * dx + sin_hdg * dy) + mcKin.mfLon_rad; ! p.mfLat_rad = C_MTORAD * (cos_hdg * dy - sin_hdg * dx) + mcKin.mfLat_rad; return p; *************** *** 541,545 **** mpDBObject = obj; mnID = NULL_INDEX; // remains NULL index for child ! model = obj->Get3DModel(); if (model) model->SetupUpdate(this); } --- 546,550 ---- mpDBObject = obj; mnID = NULL_INDEX; // remains NULL index for child ! model = obj->Copy3DModel(); if (model) model->SetupUpdate(this); } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcRadar.cpp 27 Jan 2005 01:02:06 -0000 1.22 --- tcRadar.cpp 31 Jan 2005 01:33:09 -0000 1.23 *************** *** 26,35 **** #include "tcRadar.h" #include "tcGameObject.h" ! #include "tcSurfaceObject.h" ! #include "tcAirObject.h" ! #include "tcMissileObject.h" #include "tcAirfieldObject.h" #include "tcBallisticWeapon.h" #include "tcSubObject.h" #include "tcGenericDBObject.h" --- 26,37 ---- #include "tcRadar.h" #include "tcGameObject.h" ! #include "tcAirfieldObject.h" + #include "tcAirObject.h" #include "tcBallisticWeapon.h" + #include "tcGroundObject.h" + #include "tcMissileObject.h" #include "tcSubObject.h" + #include "tcSurfaceObject.h" #include "tcGenericDBObject.h" *************** *** 107,110 **** --- 109,113 ---- float rcs_dBsm; + // Need more efficient implementation here, gotta be a better way to do this! if (const tcSurfaceObject* surfaceObj = dynamic_cast<const tcSurfaceObject*>(target)) { *************** *** 122,125 **** --- 125,133 ---- isAir = true; } + else if (const tcGroundObject* groundObj = dynamic_cast<const tcGroundObject*>(target)) + { + rcs_dBsm = groundObj->mpDBObject->mfRcs_dbsm; + isGround = true; + } else if (const tcAirfieldObject* fieldObj = dynamic_cast<const tcAirfieldObject*>(target)) { |