[Gcblue-commits] gcb_wx/src/sim tcBallisticWeapon.cpp,1.1,1.2 tcLauncherState.cpp,1.13,1.14 tcRadar.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-07-29 00:14:30
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29425/src/sim Modified Files: tcBallisticWeapon.cpp tcLauncherState.cpp tcRadar.cpp tcSimState.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** tcSimState.cpp 27 Jul 2004 00:16:24 -0000 1.48 --- tcSimState.cpp 29 Jul 2004 00:14:19 -0000 1.49 *************** *** 1,20 **** ! /* ! * Copyright (C) 2003 Dewitt "Cole" 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,22 ---- ! /** ! ** @file tcSimState.cpp */ + /* Copyright (C) 2003-2004 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" *************** *** 37,40 **** --- 39,45 ---- #include "tcAirfieldObject.h" #include "tcAeroAirObject.h" + #include "tcBallisticWeapon.h" + #include "tcBallisticDBObject.h" + #include "tcLauncher.h" #include "tcAirDBObject.h" *************** *** 1316,1319 **** --- 1321,1328 ---- missile->LaunchFrom(launchingPlatform, nLauncher); } + else if (tcBallisticWeapon* ballistic = dynamic_cast<tcBallisticWeapon*>(launched)) + { + ballistic->LaunchFrom(launchingPlatform, nLauncher); + } else { *************** *** 1372,1375 **** --- 1381,1388 ---- return new tcMissileObject(pMissileData); } + else if (tcBallisticDBObject* ballisticData = dynamic_cast<tcBallisticDBObject*>(apDBObject)) + { + return new tcBallisticWeapon(ballisticData); + } else { Index: tcBallisticWeapon.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcBallisticWeapon.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcBallisticWeapon.cpp 27 Jul 2004 23:26:07 -0000 1.1 --- tcBallisticWeapon.cpp 29 Jul 2004 00:14:18 -0000 1.2 *************** *** 1,24 **** ! /** @file tcBallisticWeapon.cpp */ /* ! * Copyright (C) 2003-2004 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 "tcBallisticWeapon.h" #include "common/tcStream.h" #include "common/tcObjStream.h" --- 1,26 ---- ! /** ! ** @file tcBallisticWeapon.cpp */ /* ! ** Copyright (C) 2003-2004 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 "tcBallisticWeapon.h" + #include "tcBallisticDBObject.h" #include "common/tcStream.h" #include "common/tcObjStream.h" *************** *** 48,52 **** --- 50,80 ---- } + /** + * Gets elevation for ballistic shell to hit (non-moving) target at a + * horizontal range of range_m and altitude difference of dz_m + * (Altitude difference is ignored for now.) + */ + float tcBallisticWeapon::GetGunneryElevation(float range_m, float dz_m) + { + wxASSERT(mpDBObject); + + float launchSpeed = mpDBObject->launchSpeed_mps; + float c = 0.25f * range_m * range_m * C_G * C_G; + float b = -launchSpeed * launchSpeed; + float b2 = b * b; + float fac = 4.0f * c; + if (b2 < fac) + { + fprintf(stdout, "Warning - Gun out of range\n"); + return 0.25f * C_PI; + } + + float vz = sqrtf( 0.5f * (-b + sqrt(b2 - fac)) ); + + float elevation_rad = asinf(vz / launchSpeed); + + return elevation_rad; + } /** *************** *** 66,72 **** --- 94,110 ---- mcKin.mfPitch_rad += pLauncher->pointingElevation; + // assume non-zero launch speed means shell, set az and el to intercept target datum + // TODO, add this option directly to ballistic DB obj if (mpDBObject->launchSpeed_mps != 0) { mcKin.mfSpeed_kts = C_MPSTOKTS * mpDBObject->launchSpeed_mps; + + tsGeoPoint targetDatum = pLauncher->msDatum; + mcKin.mfHeading_rad = obj->mcKin.HeadingToGeoRad(&targetDatum); + + float range_m = 1000.0f * obj->mcKin.RangeToKm(&targetDatum); + float dz_m = targetDatum.mfAlt_m - obj->mcKin.mfAlt_m; + + mcKin.mfPitch_rad = GetGunneryElevation(range_m, dz_m); } *************** *** 76,79 **** --- 114,119 ---- mnAlliance = obj->mnAlliance; + + simState->AddPlatform(static_cast<tcGameObject*>(this)); *************** *** 83,86 **** --- 123,128 ---- } + + /** * *************** *** 90,93 **** --- 132,137 ---- float dt_s = (float)(afStatusTime - mfStatusTime); + mfStatusTime = afStatusTime; + wxASSERT(mpDBObject); *************** *** 114,118 **** mcKin.mfAlt_m += vz_mps * dt_s; ! mcKin.mfPitch_rad = atan2f(vxy_mps, vz_mps); mcKin.mfClimbAngle_rad = mcKin.mfPitch_rad; mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vxy_mps*vxy_mps + vz_mps*vz_mps); --- 158,162 ---- mcKin.mfAlt_m += vz_mps * dt_s; ! mcKin.mfPitch_rad = atan2f(vz_mps, vxy_mps); mcKin.mfClimbAngle_rad = mcKin.mfPitch_rad; mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vxy_mps*vxy_mps + vz_mps*vz_mps); *************** *** 124,131 **** if (terrainHeight_m < 0) terrainHeight_m = 0; ! float dz = mcTerrain.mfHeight_m - mcKin.mfAlt_m; // height above ground or sea level float t_impact = dz / vz_mps; ! if (t_impact <= 0.03f) { Detonate(t_impact); --- 168,176 ---- if (terrainHeight_m < 0) terrainHeight_m = 0; ! float dz = terrainHeight_m - mcKin.mfAlt_m; // height above ground or sea level ! float t_impact = dz / vz_mps; ! if ((vz_mps < 0)&&(t_impact <= 0.03f)) { Detonate(t_impact); *************** *** 200,203 **** --- 245,249 ---- mnModelType = MTYPE_BALLISTIC; + mpDBObject = 0; } *************** *** 209,212 **** --- 255,259 ---- { mnModelType = MTYPE_BALLISTIC; + mpDBObject = o.mpDBObject; vz_mps = o.vz_mps; vxy_mps = o.vxy_mps; *************** *** 216,220 **** * Constructor that initializes using info from database entry. */ ! tcBallisticWeapon::tcBallisticWeapon(tcWeaponDBObject* obj) : tcWeaponObject(obj), vz_mps(0), --- 263,267 ---- * Constructor that initializes using info from database entry. */ ! tcBallisticWeapon::tcBallisticWeapon(tcBallisticDBObject* obj) : tcWeaponObject(obj), vz_mps(0), *************** *** 222,225 **** --- 269,273 ---- { mnModelType = MTYPE_BALLISTIC; + mpDBObject = obj; } Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcLauncherState.cpp 27 Jul 2004 23:26:07 -0000 1.13 --- tcLauncherState.cpp 29 Jul 2004 00:14:19 -0000 1.14 *************** *** 107,113 **** new_launcher.mnTargetFlags = pMissileDBObj->mnTargetFlags; } ! else { ! new_launcher.mnTargetFlags = LAND_TARGET; } launchers.push_back(new_launcher); --- 107,114 ---- new_launcher.mnTargetFlags = pMissileDBObj->mnTargetFlags; } ! else // assume ballistic vs. land (TODO rework this) { ! new_launcher.meLaunchMode = DATUM_ONLY; ! new_launcher.mnTargetFlags = SURFACE_TARGET | LAND_TARGET; } launchers.push_back(new_launcher); Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcRadar.cpp 19 Jul 2004 00:53:01 -0000 1.9 --- tcRadar.cpp 29 Jul 2004 00:14:19 -0000 1.10 *************** *** 26,29 **** --- 26,30 ---- #include "tcMissileObject.h" #include "tcAirfieldObject.h" + #include "tcBallisticWeapon.h" #include "tcGenericDBObject.h" *************** *** 141,144 **** --- 142,149 ---- isGround = true; } + else if (const tcBallisticWeapon* ball = dynamic_cast<const tcBallisticWeapon*>(target)) + { + return false; + } else { |