Mathias Frhlich:
I have done some cleanup where I moved some values out of classes where they do not belong and such stuff. Also the fols offsets are now named in the carrier xml file with a more verbose name (flols-pos/offset-*) than before (only offset-*). There is a little preparation for definitions of parking positions on the carrier which should later be used for starting flightgear directly on the carrier.
This commit is contained in:
parent
ecfaa79b9e
commit
50bdf6098a
8 changed files with 112 additions and 72 deletions
|
@ -73,12 +73,13 @@ typedef struct {
|
|||
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;
|
||||
|
||||
|
||||
|
@ -91,7 +92,7 @@ public:
|
|||
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!!!
|
||||
|
||||
|
@ -131,12 +132,6 @@ protected:
|
|||
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;
|
||||
|
||||
|
@ -238,17 +233,6 @@ inline void FGAIBase::setRadius( double radius ) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
|
||||
FGAICarrier::FGAICarrier(FGAIManager* mgr) : FGAIShip(mgr) {
|
||||
_type_str = "carrier";
|
||||
_otype = otCarrier;
|
||||
}
|
||||
|
||||
FGAICarrier::~FGAICarrier() {
|
||||
|
@ -51,6 +53,18 @@ void FGAICarrier::setCatapultObjects(const list<string>& co) {
|
|||
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 );
|
||||
}
|
||||
|
@ -96,28 +110,31 @@ bool FGAICarrier::init() {
|
|||
|
||||
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;
|
||||
|
@ -300,6 +317,20 @@ bool FGAICarrier::mark_cat(ssgEntity* e, const list<string>& cat_objects, bool m
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -326,9 +357,9 @@ void FGAICarrier::UpdateFlols( double dt) {
|
|||
<< "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
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
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();
|
||||
|
@ -86,6 +89,8 @@ public:
|
|||
|
||||
bool init();
|
||||
|
||||
static SGPropertyNode* getStartPosition(const string& id);
|
||||
|
||||
private:
|
||||
|
||||
void update(double dt);
|
||||
|
@ -97,29 +102,18 @@ private:
|
|||
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;
|
||||
|
||||
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;
|
||||
// these describe the flols
|
||||
Point3D flols_off;
|
||||
|
||||
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
|
||||
|
|
|
@ -51,7 +51,7 @@ FGAIManager::FGAIManager() {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -105,7 +105,7 @@ void FGAIManager::update(double dt) {
|
|||
|
||||
_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());
|
||||
|
@ -191,6 +191,7 @@ FGAIManager::createShip( FGAIModelEntity *entity ) {
|
|||
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);
|
||||
|
@ -209,7 +210,7 @@ FGAIManager::createCarrier( FGAIModelEntity *entity ) {
|
|||
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());
|
||||
|
@ -220,10 +221,11 @@ FGAIManager::createCarrier( FGAIModelEntity *entity ) {
|
|||
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);
|
||||
|
@ -298,7 +300,7 @@ FGAIManager::createThermal( FGAIModelEntity *entity ) {
|
|||
}
|
||||
|
||||
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];
|
||||
|
|
|
@ -69,7 +69,6 @@ private:
|
|||
// 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:
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
#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)
|
||||
{
|
||||
|
@ -96,13 +98,14 @@ 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 != ""){
|
||||
|
@ -139,7 +142,7 @@ int FGAIScenario::nEntries( void )
|
|||
}
|
||||
|
||||
static list<string>
|
||||
getAllNodeVals(const char* name, SGPropertyNode * entry_node)
|
||||
getAllStringNodeVals(const char* name, SGPropertyNode * entry_node)
|
||||
{
|
||||
list<string> retval;
|
||||
int i=0;
|
||||
|
@ -157,6 +160,22 @@ getAllNodeVals(const char* name, SGPropertyNode * entry_node)
|
|||
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
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ void FGAIShip::bind() {
|
|||
|
||||
props->tie("surface-positions/rudder-pos-deg",
|
||||
SGRawValuePointer<double>(&rudder));
|
||||
|
||||
props->setStringValue("name", name.c_str());
|
||||
}
|
||||
|
||||
void FGAIShip::unbind() {
|
||||
|
@ -194,6 +196,10 @@ void FGAIShip::setFlightPlan(FGAIFlightPlan* f) {
|
|||
fp = f;
|
||||
}
|
||||
|
||||
void FGAIShip::setName(const string& n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
void FGAIShip::ProcessFlightPlan(double dt) {
|
||||
// not implemented yet
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
virtual void unbind();
|
||||
void update(double dt);
|
||||
void setFlightPlan(FGAIFlightPlan* f);
|
||||
void setName(const string&);
|
||||
void ProcessFlightPlan( double dt );
|
||||
|
||||
void AccelTo(double speed);
|
||||
|
@ -45,6 +46,10 @@ public:
|
|||
void ClimbTo(double altitude);
|
||||
void TurnTo(double heading);
|
||||
|
||||
protected:
|
||||
|
||||
string name; // The name of this ship.
|
||||
|
||||
private:
|
||||
|
||||
bool hdg_lock;
|
||||
|
|
Loading…
Add table
Reference in a new issue