FGViewer *loop_view = (FGViewer *)get_view(current);
SGPropertyNode *n = config_list[current];
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
+ SGVec3f velocity = SGVec3f(0,0,0);
// Set up view location and orientation
} else {
// force recalc in viewer
loop_view->set_dirty();
+
+ // get the model velocity for the in-cockpit view
+ FGAircraftModel *aircraft = globals->get_aircraft_model();
+ velocity = aircraft->getVelocity();
}
// if lookat (type 1) then get target data...
// set the viewer posotion in Cartesian coordinates in meters
smgr->set_position(abs_viewer_position);
smgr->set_orientation(loop_view->getViewOrientation());
- smgr->set_velocity(SGVec3f(0,0,0)); // TODO: in meters per second
+ smgr->set_velocity(velocity);
}
void
FGAircraftModel::FGAircraftModel ()
: _aircraft(0),
+ _velocity(SGVec3f::zeros()),
_fx(0),
_lon(0),
_lat(0),
_pitch(0),
_roll(0),
_heading(0),
- _speed_north(0),
- _speed_east(0),
+ _speed(0),
_speed_up(0)
{
SGSoundMgr *smgr;
_pitch = fgGetNode("orientation/pitch-deg", true);
_roll = fgGetNode("orientation/roll-deg", true);
_heading = fgGetNode("orientation/heading-deg", true);
- _speed_north = fgGetNode("/velocities/speed-north-fps", true);
- _speed_east = fgGetNode("/velocities/speed-east-fps", true);
- _speed_up = fgGetNode("/velocities/vertical-speed-fps", true);
+ _speed = fgGetNode("velocities/true-airspeed-kt", true);
+ _speed_up = fgGetNode("velocities/vertical-speed-fps", true);
}
void
_heading->getDoubleValue());
_aircraft->update();
- // update model's sample group values
+ // update model's audio sample values
// Get the Cartesian coordinates in meters
SGVec3d pos = SGVec3d::fromGeod(_aircraft->getPosition());
_fx->set_position( pos );
orient_m *= SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
_pitch->getDoubleValue(),
_roll->getDoubleValue());
- SGVec3d orient = orient_m.rotateBack(SGVec3d::e1());
+ SGVec3d orient = -orient_m.rotate(SGVec3d::e1());
_fx->set_orientation( toVec3f(orient) );
- SGVec3f vel = SGVec3f( _speed_north->getFloatValue(),
- _speed_east->getFloatValue(),
- _speed_up->getFloatValue());
-// TODO: rotate to properly align with the model orientation
-
- _fx->set_velocity( vel*SG_FEET_TO_METER );
+ // For now assume the aircraft speed is always along the longitudinal
+ // axis, so sideslipping is not taken into account. This should be fine
+ // for audio.
+ _velocity = toVec3f(orient * _speed->getDoubleValue() * SG_KT_TO_FPS);
+ // _velocity[2] = _speed_up->getFloatValue();
+ _velocity *= SG_FEET_TO_METER;
+ _fx->set_velocity( _velocity );
}
virtual void unbind ();
virtual void update (double dt);
virtual SGModelPlacement * get3DModel() { return _aircraft; }
+ virtual SGVec3f getVelocity() { return _velocity; }
private:
SGModelPlacement * _aircraft;
+ SGVec3f _velocity;
FGFX * _fx;
SGPropertyNode * _lon;
SGPropertyNode * _pitch;
SGPropertyNode * _roll;
SGPropertyNode * _heading;
- SGPropertyNode * _speed_north;
- SGPropertyNode * _speed_east;
+ SGPropertyNode * _speed;
SGPropertyNode * _speed_up;
};