roll_offset_deg, fov_deg, aspect_ratio_multiplier,
target_x_offset_m, target_y_offset_m,
target_z_offset_m, near_m, internal );
+ if (!from_model) {
+ v->_targetProperties = PositionAttitudeProperties(config, "target-");
+ }
} else {
v = new View ( FG_LOOKFROM, from_model, from_model_index,
false, 0, 0.0, 0.0, 0.0,
0, 0, 0, near_m, internal );
}
+ if (!from_model) {
+ v->_eyeProperties = PositionAttitudeProperties(config, "eye-");
+ }
+
v->_name = config->getParent()->getStringValue("name");
v->_typeString = type;
v->_configHeadingOffsetDeg = config->getDoubleValue("default-heading-offset-deg");
return 0.0;
}
+void
+View::updateData()
+{
+ if (!_from_model) {
+ SGVec3d pos = _eyeProperties.position();
+ SGVec3d att = _eyeProperties.attitude();
+
+ setPosition(pos.x(), pos.y(), pos.z());
+ setOrientation(att[2], att[1], att[0]);
+ } else {
+ set_dirty();
+ }
+
+ // if lookat (type 1) then get target data...
+ if (getType() == FG_LOOKAT) {
+ if (!_from_model) {
+ SGVec3d pos = _targetProperties.position();
+ SGVec3d att = _targetProperties.attitude();
+ setTargetPosition(pos.x(), pos.y(), pos.z());
+ setTargetOrientation(att[2], att[1], att[0]);
+ } else {
+ set_dirty();
+ }
+ }
+}
+
void
View::update (double dt)
{
{
return flightgear::CameraGroup::getDefault()->getMasterAspectRatio();
}
+
+View::PositionAttitudeProperties::PositionAttitudeProperties()
+{
+}
+
+View::PositionAttitudeProperties::PositionAttitudeProperties(SGPropertyNode_ptr parent, const std::string& prefix)
+{
+ _lonProp = parent->getNode(prefix + "lon-deg-path", 0, true);
+ _latProp = parent->getNode(prefix + "lat-deg-path", 0, true);
+ _altProp = parent->getNode(prefix + "alt-ft-path", 0, true);
+ _headingProp = parent->getNode(prefix + "heading-deg-path", 0, true);
+ _pitchProp = parent->getNode(prefix + "pitch-deg-path", 0, true);
+ _rollProp = parent->getNode(prefix + "roll-deg-path", 0, true);
+}
+
+SGVec3d View::PositionAttitudeProperties::position() const
+{
+ return SGVec3d(_lonProp->getDoubleValue(),
+ _latProp->getDoubleValue(),
+ _altProp->getDoubleValue());
+}
+
+SGVec3d View::PositionAttitudeProperties::attitude() const
+{
+ return SGVec3d(_headingProp->getDoubleValue(),
+ _pitchProp->getDoubleValue(),
+ _rollProp->getDoubleValue());
+}
//////////////////////////////////////////////////////////////////////
void resetOffsetsAndFOV();
-
+ void updateData();
+
ViewType getType() const { return _type; }
void setType( int type );
// multiplied into the aspect_ratio to get the actual vertical fov
double _aspect_ratio_multiplier;
+ class PositionAttitudeProperties
+ {
+ public:
+ PositionAttitudeProperties();
+
+ PositionAttitudeProperties(SGPropertyNode_ptr parent, const std::string& prefix);
+
+ SGVec3d position() const;
+ SGVec3d attitude() const; // as heading pitch roll
+ private:
+ SGPropertyNode_ptr _lonProp,
+ _latProp,
+ _altProp,
+ _headingProp,
+ _pitchProp,
+ _rollProp;
+ };
+
+ PositionAttitudeProperties _eyeProperties;
+ PositionAttitudeProperties _targetProperties;
+
//////////////////////////////////////////////////////////////////
// private functions //
//////////////////////////////////////////////////////////////////
// Set up view location and orientation
- if (!config->getBoolValue("from-model")) {
- lon_deg = fgGetDouble(config->getStringValue("eye-lon-deg-path"));
- lat_deg = fgGetDouble(config->getStringValue("eye-lat-deg-path"));
- alt_ft = fgGetDouble(config->getStringValue("eye-alt-ft-path"));
- roll_deg = fgGetDouble(config->getStringValue("eye-roll-deg-path"));
- pitch_deg = fgGetDouble(config->getStringValue("eye-pitch-deg-path"));
- heading_deg = fgGetDouble(config->getStringValue("eye-heading-deg-path"));
-
- currentView->setPosition(lon_deg, lat_deg, alt_ft);
- currentView->setOrientation(roll_deg, pitch_deg, heading_deg);
- } else {
- // force recalc in viewer
- currentView->set_dirty();
- }
-
- // if lookat (type 1) then get target data...
- if (currentView->getType() == flightgear::View::FG_LOOKAT) {
- if (!config->getBoolValue("from-model")) {
- lon_deg = fgGetDouble(config->getStringValue("target-lon-deg-path"));
- lat_deg = fgGetDouble(config->getStringValue("target-lat-deg-path"));
- alt_ft = fgGetDouble(config->getStringValue("target-alt-ft-path"));
- roll_deg = fgGetDouble(config->getStringValue("target-roll-deg-path"));
- pitch_deg = fgGetDouble(config->getStringValue("target-pitch-deg-path"));
- heading_deg = fgGetDouble(config->getStringValue("target-heading-deg-path"));
-
- currentView->setTargetPosition(lon_deg, lat_deg, alt_ft);
- currentView->setTargetOrientation(roll_deg, pitch_deg, heading_deg);
- } else {
- currentView->set_dirty();
- }
- }
+ currentView->updateData();
// these properties aren't tied - manually propogate them to the
// currently active view
void
FGViewMgr::copyToCurrent()
{
+
}
void FGViewMgr::clear()