[Gcblue-commits] gcb_wx/src/database tcBallisticDBObject.cpp,1.8,1.9 tcDatabaseObject.cpp,1.15,1.16
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/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20374/src/database Modified Files: tcBallisticDBObject.cpp tcDatabaseObject.cpp tcGenericDBObject.cpp Log Message: Moved launcher position to 3D model animation xml file Added tcGroundObject for ground SAM site Index: tcBallisticDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcBallisticDBObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcBallisticDBObject.cpp 29 Nov 2004 03:55:04 -0000 1.8 --- tcBallisticDBObject.cpp 31 Jan 2005 01:33:07 -0000 1.9 *************** *** 32,35 **** --- 32,36 ---- #include "common/tinyxml.h" #include "database/tcSqlReader.h" + #include <sstream> #ifdef _DEBUG *************** *** 108,111 **** --- 109,128 ---- /** + * @return true if this obj is a gravity bomb + */ + bool tcBallisticDBObject::IsGravityBomb() const + { + return (ballisticType == GRAVITY_BOMB); + } + + /** + * @return true if this obj is a gun round + */ + bool tcBallisticDBObject::IsGunRound() const + { + return (ballisticType == GUN_ROUND); + } + + /** * workaround for write serialization issue * @return true if db obj is a leaf obj *************** *** 185,188 **** --- 202,208 ---- tcWeaponDBObject::AddSqlColumns(columnString); + columnString += ","; + + columnString += "BallisticType number(5)"; } *************** *** 190,193 **** --- 210,215 ---- { tcWeaponDBObject::ReadSql(entry); + + ballisticType = entry.GetInt("BallisticType"); } *************** *** 196,203 **** tcWeaponDBObject::WriteSql(valueString); } ! tcBallisticDBObject::tcBallisticDBObject() : tcWeaponDBObject() { mzClass = "Default Ballistic"; --- 218,233 ---- tcWeaponDBObject::WriteSql(valueString); + std::stringstream s; + + s << ","; + + s << ballisticType; + + valueString += s.str(); } ! tcBallisticDBObject::tcBallisticDBObject() : tcWeaponDBObject(), ! ballisticType(GUN_ROUND) { mzClass = "Default Ballistic"; *************** *** 206,210 **** tcBallisticDBObject::tcBallisticDBObject(tcBallisticDBObject& obj) ! : tcWeaponDBObject(obj) { mnClassID = DTYPE_BALLISTIC; --- 236,241 ---- tcBallisticDBObject::tcBallisticDBObject(tcBallisticDBObject& obj) ! : tcWeaponDBObject(obj), ! ballisticType(obj.ballisticType) { mnClassID = DTYPE_BALLISTIC; Index: tcDatabaseObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcDatabaseObject.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcDatabaseObject.cpp 16 Jan 2005 18:36:28 -0000 1.15 --- tcDatabaseObject.cpp 31 Jan 2005 01:33:07 -0000 1.16 *************** *** 108,112 **** /***************************** tcDatabaseObject ***********************************/ ! tc3DModel* tcDatabaseObject::Get3DModel() { if (model) --- 108,116 ---- /***************************** tcDatabaseObject ***********************************/ ! ! /** ! * ! */ ! tc3DModel* tcDatabaseObject::Copy3DModel() { if (model) *************** *** 130,133 **** --- 134,161 ---- /** + * + */ + tc3DModel* tcDatabaseObject::Get3DModel() + { + if (model) + { + return model; + } + else + { + Load3DModel(); + if (model) + { + return model; + } + else + { + wxASSERT(false); + return NULL; + } + } + } + + /** * workaround for write serialization issue * @return true if db obj is a leaf obj Index: tcGenericDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcGenericDBObject.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcGenericDBObject.cpp 16 Jan 2005 18:36:28 -0000 1.18 --- tcGenericDBObject.cpp 31 Jan 2005 01:33:07 -0000 1.19 *************** *** 63,76 **** /** * @returns a tc3DPoint object with (x,y,z) relative position of launcher n */ tc3DPoint tcGenericDBObject::GetLauncherPosition(unsigned n) { if ((int)n >= mnNumLaunchers) { fprintf(stderr, "Error - GetLauncherPosition - bad launcher index\n"); ! return tc3DPoint(0, 0, 0); } ! return launcherPosition[n]; } --- 63,114 ---- /** + * @return relative az of launcher n or 0 for default or if error + */ + float tcGenericDBObject::GetLauncherAz(unsigned n) + { + float az = 0; + + if ((int)n >= mnNumLaunchers) + { + fprintf(stderr, "Error - GetLauncherAz - bad launcher index\n"); + return az; + } + + if (tc3DModel* model = Get3DModel()) + { + float az; + osg::Vec3 pos; + model->GetLauncherInfo(n, pos, az); + } + + return az; + + } + + /** * @returns a tc3DPoint object with (x,y,z) relative position of launcher n + * (0, 0, 0) is default */ tc3DPoint tcGenericDBObject::GetLauncherPosition(unsigned n) { + tc3DPoint p; + if ((int)n >= mnNumLaunchers) { fprintf(stderr, "Error - GetLauncherPosition - bad launcher index\n"); ! return p; } ! ! if (tc3DModel* model = Get3DModel()) ! { ! float az; ! osg::Vec3 pos; ! model->GetLauncherInfo(n, pos, az); ! p.x = pos.x(); ! p.y = pos.y(); ! p.z = pos.z(); ! } ! ! return p; } *************** *** 284,299 **** for(i=0;i<MAXLAUNCHERS;i++) { - float az; - tc3DPoint loc; *csv >> s; ! *csv >> az; ! *csv >> loc.x; ! *csv >> loc.y; ! *csv >> loc.z; if (s.size() > 0) { maLauncherClass[mnNumLaunchers] = s.c_str(); - launcherAz[mnNumLaunchers] = az; - launcherPosition[mnNumLaunchers++] = loc; } } --- 322,330 ---- for(i=0;i<MAXLAUNCHERS;i++) { *csv >> s; ! if (s.size() > 0) { maLauncherClass[mnNumLaunchers] = s.c_str(); } } *************** *** 350,365 **** { *csv << string(maLauncherClass[i].mz); - *csv << launcherAz[i]; - *csv << launcherPosition[i].x; - *csv << launcherPosition[i].y; - *csv << launcherPosition[i].z; } else { *csv << ""; - *csv << ""; - *csv << ""; - *csv << ""; - *csv << ""; } } --- 381,388 ---- *************** *** 442,449 **** TiXmlElement* childNode = node->InsertEndChild(TiXmlElement("launcher"))->ToElement(); childNode->SetAttribute("class", maLauncherClass[i].mz); - childNode->SetAttribute("az", launcherAz[i]); - childNode->SetAttribute("x", launcherPosition[i].x); - childNode->SetAttribute("y", launcherPosition[i].y); - childNode->SetAttribute("z", launcherPosition[i].z); } --- 465,468 ---- *************** *** 499,510 **** s.Format("Lau%d",i+1); *csv << s.GetBuffer(); - s.Format("Lau%d-angle",i+1); - *csv << s.GetBuffer(); - s.Format("Lau%d-x",i+1); - *csv << s.GetBuffer(); - s.Format("Lau%d-y",i+1); - *csv << s.GetBuffer(); - s.Format("Lau%d-z",i+1); - *csv << s.GetBuffer(); } for(i=0;i<MAXSENSORS;i++) --- 518,521 ---- *************** *** 593,609 **** s.Format("L%d_name varchar(30),",i+1); columnString += s.GetBuffer(); - - s.Format("L%d_az number(8),",i+1); - columnString += s.GetBuffer(); - - s.Format("L%d_x number(8),",i+1); - columnString += s.GetBuffer(); - - s.Format("L%d_y number(8),",i+1); - columnString += s.GetBuffer(); - - s.Format("L%d_z number(8),",i+1); - columnString += s.GetBuffer(); - } --- 604,607 ---- *************** *** 688,703 **** launcherName.push_back(displayName); - s.Format("L%d_az",i+1); - launcherAz[mnNumLaunchers] = entry.GetDouble(s.GetBuffer()); - - s.Format("L%d_x",i+1); - launcherPosition[mnNumLaunchers].x = entry.GetDouble(s.GetBuffer()); - - s.Format("L%d_y",i+1); - launcherPosition[mnNumLaunchers].y = entry.GetDouble(s.GetBuffer()); - - s.Format("L%d_z",i+1); - launcherPosition[mnNumLaunchers].z = entry.GetDouble(s.GetBuffer()); - mnNumLaunchers++; } --- 686,689 ---- *************** *** 742,765 **** } - // read animations - for(i=0;i<MAXANIMATIONS;i++) - { - tcString s; - animationDBInfo ai; - s.Format("Anim%d_obj", i+1); - ai.objectName = entry.GetString(s.GetBuffer()); - - if (ai.objectName.size() > 0) - { - s.Format("Anim%d_type", i+1); - ai.animationType = entry.GetString(s.GetBuffer()); - - s.Format("Anim%d_param", i+1); - ai.param = entry.GetInt(s.GetBuffer()); - - animationInfo.push_back(ai); - } - } } --- 728,732 ---- *************** *** 799,806 **** s << "'" << string(maLauncherClass[i].mz) << "',"; s << "'" << launcherName[i].c_str() << "',"; - s << launcherAz[i] << ","; - s << launcherPosition[i].x << ","; - s << launcherPosition[i].y << ","; - s << launcherPosition[i].z << ","; } else --- 766,769 ---- *************** *** 808,819 **** s << "'',"; s << "'',"; - s << "0,"; - s << "0,"; - s << "0,"; - s << "0,"; } ! ! //if (i < MAXLAUNCHERS - 1) s << ","; ! } --- 771,776 ---- s << "'',"; s << "'',"; } ! } *************** *** 836,866 **** { s << "'" << string(maSensorClass[i].mz) << "',"; ! s << sensorAz[i] << ","; ! } ! else ! { ! s << "'',"; ! s << "0,"; ! } ! } ! ! size_t nAnimations = animationInfo.size(); ! for(size_t i=0;i<MAXANIMATIONS;i++) ! { ! if (i < nAnimations) ! { ! animationDBInfo& ai = animationInfo[i]; ! s << "'" << ai.objectName << "',"; ! s << "'" << ai.animationType << "',"; ! s << (long)ai.param; } else { s << "'',"; - s << "'',"; s << "0"; } ! if (i < MAXANIMATIONS - 1) s << ","; } valueString += s.str(); --- 793,807 ---- { s << "'" << string(maSensorClass[i].mz) << "',"; ! s << sensorAz[i]; } else { s << "'',"; s << "0"; } ! if (i < MAXSENSORS - 1) s << ","; } + + valueString += s.str(); *************** *** 921,926 **** maLauncherClass[i] = obj.maLauncherClass[i]; launcherName[i] = obj.launcherName[i]; - launcherAz[i] = obj.launcherAz[i]; - launcherPosition[i] = obj.launcherPosition[i]; } --- 862,865 ---- |