list<string> solid_objects; // List of solid object names
list<string> wire_objects; // List of wire object names
list<string> catapult_objects; // List of catapult object names
- double radius; // used by ship ojects, in feet
- double x_offset; // used by ship ojects, in meters
- double y_offset; // used by ship ojects, in meters
- double z_offset; // used by ship ojects, in meters
- string acType; // used by aircraft objects
- string company; // used by aircraft objects
+ list<Point3D> ppositions; // List of positions on a carrier where an aircraft can start.
+ Point3D flols_offset; // used by carrier objects, in meters
+ double radius; // used by ship objects, in feet
+ string name; // used by carrier objects
+ string pennant_number; // used by carrier objects
+ string acType; // used by aircraft objects
+ string company; // used by aircraft objects
} FGAIModelEntity;
virtual void update(double dt);
inline Point3D GetPos() { return(pos); }
- enum object_type { otNull = 0, otAircraft, otShip, otBallistic,
+ enum object_type { otNull = 0, otAircraft, otShip, otCarrier, otBallistic,
otRocket, otStorm, otThermal,
MAX_OBJECTS }; // Needs to be last!!!
double vs; // vertical speed, feet per minute
double turn_radius_ft; // turn radius ft at 15 kts rudder angle 15 degrees
- // these describe the flols
- Point3D flolspos; // WGS84 lat & lon in degrees, elev above sea-level in meters
- double flols_x_offset; // longitudinal distance, in meters
- double flols_y_offset; // lateral distance, in meters
- double flols_z_offset; // height, in meters
-
double ft_per_deg_lon;
double ft_per_deg_lat;
turn_radius_ft = radius;
}
-inline void FGAIBase::setXoffset( double x_offset ) {
- flols_x_offset = x_offset;
-}
-
-inline void FGAIBase::setYoffset( double y_offset ) {
- flols_y_offset = y_offset;
-}
-
-inline void FGAIBase::setZoffset( double z_offset ) {
- flols_z_offset = z_offset;
-}
inline void FGAIBase::setHeading( double heading ) {
hdg = tgt_heading = heading;
}
FGAICarrier::FGAICarrier(FGAIManager* mgr) : FGAIShip(mgr) {
+ _type_str = "carrier";
+ _otype = otCarrier;
}
FGAICarrier::~FGAICarrier() {
catapult_objects = co;
}
+void FGAICarrier::setParkingPositions(const list<Point3D>& p) {
+ ppositions = p;
+}
+
+void FGAICarrier::setSign(const string& s) {
+ sign = s;
+}
+
+void FGAICarrier::setFlolsOffset(const Point3D& off) {
+ flols_off = off;
+}
+
void FGAICarrier::getVelocityWrtEarth(sgVec3 v) {
sgCopyVec3(v, vel_wrt_earth );
}
return true;
}
+
void FGAICarrier::bind() {
- FGAIBase::bind();
+ FGAIShip::bind();
props->tie("controls/flols/source-lights",
SGRawValuePointer<int>(&source));
props->tie("controls/flols/distance-m",
- SGRawValuePointer<double>(&dist));
+ SGRawValuePointer<double>(&dist));
props->tie("controls/flols/angle-degs",
- SGRawValuePointer<double>(&angle));
+ SGRawValuePointer<double>(&angle));
props->setBoolValue("controls/flols/cut-lights", false);
props->setBoolValue("controls/flols/wave-off-lights", false);
- props->setBoolValue("controls/flols/cond-datum-lights", true);
- props->setBoolValue("controls/crew", false);
- }
+ props->setBoolValue("controls/flols/cond-datum-lights", true);
+ props->setBoolValue("controls/crew", false);
+
+ props->setStringValue("sign", sign.c_str());
+}
void FGAICarrier::unbind() {
- FGAIBase::unbind();
+ FGAIShip::unbind();
props->untie("controls/flols/source-lights");
- props->untie("controls/flols/distance-m");
- props->untie("controls/flols/angle-degs");
+ props->untie("controls/flols/distance-m");
+ props->untie("controls/flols/angle-degs");
}
-
+
void FGAICarrier::mark_nohot(ssgEntity* e) {
if (e->isAKindOf(ssgTypeBranch())) {
ssgBranch* br = (ssgBranch*)e;
}
void FGAICarrier::UpdateFlols( double dt) {
+
+ float trans[3][3];
+ float in[3];
+ float out[3];
+
+ float cosRx, sinRx;
+ float cosRy, sinRy;
+ float cosRz, sinRz;
+
+ double flolsXYZ[3], eyeXYZ[3];
+ double lat, lon, alt;
+ Point3D eyepos;
+ Point3D flolspos;
+
/* cout << "x_offset " << flols_x_offset
<< " y_offset " << flols_y_offset
<< " z_offset " << flols_z_offset << endl;
<< "flols_y_offset " << flols_y_offset << endl
<< "flols_z_offset " << flols_z_offset << endl;*/
- in[0] = flols_x_offset;
- in[1] = flols_y_offset;
- in[2] = flols_z_offset;
+ in[0] = flols_off.x();
+ in[1] = flols_off.y();
+ in[2] = flols_off.z();
// pre-process the trig functions
void setSolidObjects(const list<string>& solid_objects);
void setWireObjects(const list<string>& wire_objects);
void setCatapultObjects(const list<string>& catapult_objects);
+ void setParkingPositions(const list<Point3D>& p);
+ void setSign(const string& );
+ void setFlolsOffset(const Point3D& off);
void getVelocityWrtEarth(sgVec3 v);
virtual void bind();
bool init();
+ static SGPropertyNode* getStartPosition(const string& id);
+
private:
void update(double dt);
list<string> solid_objects; // List of solid object names
list<string> wire_objects; // List of wire object names
list<string> catapult_objects; // List of catapult object names
+ list<Point3D> ppositions; // List of positions where an aircraft can start.
+ string sign; // The sign of this carrier.
// Velocity wrt earth.
sgVec3 vel_wrt_earth;
+
+ // these describe the flols
+ Point3D flols_off;
- float trans[3][3];
- float in[3];
- float out[3];
-
- double Rx, Ry, Rz;
- double Sx, Sy, Sz;
- double Tx, Ty, Tz;
-
- float cosRx, sinRx;
- float cosRy, sinRy;
- float cosRz, sinRz;
-
- double flolsXYZ[3], eyeXYZ[3];
- double lat, lon, alt;
- double dist, angle;
- int source;
-
- Point3D eyepos;
- Point3D flolspos;
+ double dist; // the distance of the eyepoint from the flols
+ double angle;
+ int source; // the flols light which is visible at the moment
};
#endif // _FG_AICARRIER_HXX
}
FGAIManager::~FGAIManager() {
- ai_list_itr = ai_list.begin();
+ ai_list_iterator ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
(*ai_list_itr)->unbind();
delete (*ai_list_itr);
_dt = dt;
- ai_list_itr = ai_list.begin();
+ ai_list_iterator ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
if ((*ai_list_itr)->getDie()) {
tmgr->release((*ai_list_itr)->getID());
ai_ship->setLongitude(entity->longitude);
ai_ship->setLatitude(entity->latitude);
ai_ship->setBank(entity->rudder);
+ ai_ship->setName(entity->name);
if ( entity->fp ) {
ai_ship->setFlightPlan(entity->fp);
FGAICarrier* ai_carrier = new FGAICarrier(this);
ai_list.push_back(ai_carrier);
++numObjects[0];
- ++numObjects[FGAIBase::otShip];
+ ++numObjects[FGAIBase::otCarrier];
ai_carrier->setHeading(entity->heading);
ai_carrier->setSpeed(entity->speed);
ai_carrier->setPath(entity->path.c_str());
ai_carrier->setSolidObjects(entity->solid_objects);
ai_carrier->setWireObjects(entity->wire_objects);
ai_carrier->setCatapultObjects(entity->catapult_objects);
+ ai_carrier->setParkingPositions(entity->ppositions);
ai_carrier->setRadius(entity->radius);
- ai_carrier->setXoffset(entity->x_offset);
- ai_carrier->setYoffset(entity->y_offset);
- ai_carrier->setZoffset(entity->z_offset);
+ ai_carrier->setSign(entity->pennant_number);
+ ai_carrier->setName(entity->name);
+ ai_carrier->setFlolsOffset(entity->flols_offset);
if ( entity->fp ) {
ai_carrier->setFlightPlan(entity->fp);
}
void FGAIManager::destroyObject( void* ID ) {
- ai_list_itr = ai_list.begin();
+ ai_list_iterator ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
if ((*ai_list_itr)->getID() == ID) {
--numObjects[0];
// Everything put in this list should be created dynamically
// on the heap and ***DELETED WHEN REMOVED!!!!!***
ai_list_type ai_list;
- ai_list_iterator ai_list_itr;
ModelVec loadedModels;
public:
#include "AIFlightPlan.hxx"
static list<string>
-getAllNodeVals(const char* name, SGPropertyNode * entry_node);
+getAllStringNodeVals(const char* name, SGPropertyNode * entry_node);
+static list<Point3D>
+getAllOffsetNodeVals(const char* name, SGPropertyNode * entry_node);
FGAIScenario::FGAIScenario(string &filename)
{
en->cd = entry_node->getDoubleValue("cd", 0.029);
en->mass = entry_node->getDoubleValue("mass", 0.007);
en->radius = entry_node->getDoubleValue("turn-radius-ft", 2000);
- en->x_offset = entry_node->getDoubleValue("x-offset-m", 5.5);
- en->y_offset = entry_node->getDoubleValue("y-offset-m", 1.0);
- en->z_offset = entry_node->getDoubleValue("z-offset-m", 1.0);
- /* en->name = entry_node->getStringValue("name", "");*/
- en->wire_objects = getAllNodeVals("wire", entry_node);
- en->catapult_objects = getAllNodeVals("catapult", entry_node);
- en->solid_objects = getAllNodeVals("solid", entry_node);
+ en->name = entry_node->getStringValue("name", "");
+ en->pennant_number = entry_node->getStringValue("pennant-number", "");
+ en->wire_objects = getAllStringNodeVals("wire", entry_node);
+ en->catapult_objects = getAllStringNodeVals("catapult", entry_node);
+ en->solid_objects = getAllStringNodeVals("solid", entry_node);
+ en->ppositions = getAllOffsetNodeVals("parking-pos", entry_node);
+ list<Point3D> flolspos = getAllOffsetNodeVals("flols-pos", entry_node);
+ en->flols_offset = flolspos.front();
en->fp = NULL;
if (en->flightplan != ""){
}
static list<string>
-getAllNodeVals(const char* name, SGPropertyNode * entry_node)
+getAllStringNodeVals(const char* name, SGPropertyNode * entry_node)
{
list<string> retval;
int i=0;
return retval;
}
+static list<Point3D>
+getAllOffsetNodeVals(const char* name, SGPropertyNode * entry_node)
+{
+ list<Point3D> retval;
+
+ vector<SGPropertyNode_ptr>::iterator it;
+ vector<SGPropertyNode_ptr> children = entry_node->getChildren(name);
+ for (it = children.begin(); it != children.end(); ++it) {
+ double offset_x = (*it)->getDoubleValue("x-offset-m", 0);
+ double offset_y = (*it)->getDoubleValue("y-offset-m", 0);
+ double offset_z = (*it)->getDoubleValue("z-offset-m", 0);
+ retval.push_back(Point3D(offset_x, offset_y, offset_z));
+ }
+
+ return retval;
+}
// end scenario.cxx
props->tie("surface-positions/rudder-pos-deg",
SGRawValuePointer<double>(&rudder));
+
+ props->setStringValue("name", name.c_str());
}
void FGAIShip::unbind() {
fp = f;
}
+void FGAIShip::setName(const string& n) {
+ name = n;
+}
+
void FGAIShip::ProcessFlightPlan(double dt) {
// not implemented yet
}
virtual void unbind();
void update(double dt);
void setFlightPlan(FGAIFlightPlan* f);
+ void setName(const string&);
void ProcessFlightPlan( double dt );
void AccelTo(double speed);
void ClimbTo(double altitude);
void TurnTo(double heading);
+protected:
+
+ string name; // The name of this ship.
+
private:
bool hdg_lock;