//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <simgear/math/point3d.hxx>
#include <math.h>
+#include "AIFlightPlan.hxx"
#include "AIShip.hxx"
-FGAIShip::FGAIShip(FGAIManager* mgr) {
- manager = mgr;
- _type_str = "ship";
- _otype = otShip;
-
+FGAIShip::FGAIShip(object_type ot) : FGAIBase(ot) {
}
FGAIShip::~FGAIShip() {
}
+void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
+ if (!scFileNode)
+ return;
+
+ FGAIBase::readFromScenario(scFileNode);
+
+ setRudder(scFileNode->getFloatValue("rudder", 0.0));
+ setName(scFileNode->getStringValue("name", "Titanic"));
+
+ std::string flightplan = scFileNode->getStringValue("flightplan");
+ if (!flightplan.empty()){
+ FGAIFlightPlan* fp = new FGAIFlightPlan(flightplan);
+ setFlightPlan(fp);
+ }
+}
bool FGAIShip::init() {
* speed * 1.686 / ft_per_deg_lon;
// set new position
- pos.setlat( pos.lat() + speed_north_deg_sec * dt);
- pos.setlon( pos.lon() + speed_east_deg_sec * dt);
+ pos.setLatitudeDeg( pos.getLatitudeDeg() + speed_north_deg_sec * dt);
+ pos.setLongitudeDeg( pos.getLongitudeDeg() + speed_east_deg_sec * dt);
// adjust heading based on current rudder angle
- if (rudder <= -0.25 or rudder >= 0.25) {
+ if (rudder <= -0.25 || rudder >= 0.25) {
/* turn_radius_ft = 0.088362 * speed * speed
/ tan( fabs(rudder) / SG_RADIANS_TO_DEGREES );
turn_circum_ft = SGD_2PI * turn_radius_ft;
//low pass filter
roll = (raw_roll * roll_constant) + (roll * (1 - roll_constant));
- cout << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
- cout << " hdg: " << hdg << endl ;
+ /*cout << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
+ cout << " hdg: " << hdg << endl ;*/
// adjust target rudder angle if heading lock engaged
if (hdg_lock) {