http://wiki.flightgear.org/Howto:Projec ... top_canvas
WIki entry is done. Feel free to improve it.
Viewer/view.cxx:330: _tiedProperties.Tie("raw-orientation", 0, this, &View::getRawOrientation_w);
Viewer/view.cxx:331: _tiedProperties.Tie("raw-orientation", 1, this, &View::getRawOrientation_x);
Viewer/view.cxx:332: _tiedProperties.Tie("raw-orientation", 2, this, &View::getRawOrientation_y);
Viewer/view.cxx:333: _tiedProperties.Tie("raw-orientation", 3, this, &View::getRawOrientation_z);
class View : public SGSubsystem
{
...
SGQuatd mViewOrientation;
SGVec3d _absolute_view_pos;
const SGVec3d& getViewPosition() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
const SGQuatd& getViewOrientation() { if ( _dirty ) { recalc(); } return mViewOrientation; }
...
}
void
View::bind ()
{
...
_tiedProperties.Tie("raw-orientation", 0, this, &View::getRawOrientation_w);
_tiedProperties.Tie("raw-orientation", 1, this, &View::getRawOrientation_x);
_tiedProperties.Tie("raw-orientation", 2, this, &View::getRawOrientation_y);
_tiedProperties.Tie("raw-orientation", 3, this, &View::getRawOrientation_z);
_tiedProperties.Tie("viewer-x-m", this, &View::getAbsolutePosition_x);
_tiedProperties.Tie("viewer-y-m", this, &View::getAbsolutePosition_y);
_tiedProperties.Tie("viewer-z-m", this, &View::getAbsolutePosition_z);
...
}
double View::getAbsolutePosition_x() const
{
return _absolute_view_pos.x();
}
... analog for y z
double View::getRawOrientation_w() const
{
return mViewOrientation.w();
}
... analog for x y z
void fgCreateSubsystems(bool duringReset) {
... all other subsystem's initialization
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
}
class FGGlobals
{
...
void add_subsystem (const char * name,
SGSubsystem * subsystem,
SGSubsystemMgr::GroupType
type = SGSubsystemMgr::GENERAL,
double min_time_sec = 0);
template<class T>
T* add_new_subsystem (SGSubsystemMgr::GroupType
type = SGSubsystemMgr::GENERAL,
double min_time_sec = 0)
{
T* sub = new T;
add_subsystem(T::staticSubsystemClassId(), sub, type, min_time_sec);
return sub;
}
...
}
void
FGGlobals::add_subsystem (const char * name,
SGSubsystem * subsystem,
SGSubsystemMgr::GroupType type,
double min_time_sec)
{
subsystem_mgr->add(name, subsystem, type, min_time_sec);
}
void
FGViewMgr::update (double dt)
{
flightgear::View* currentView = get_current_view();
if (!currentView) {
return;
}
// Update the current view
currentView->update(dt);
// update the camera now
osg::ref_ptr<flightgear::CameraGroup> cameraGroup = flightgear::CameraGroup::getDefault();
cameraGroup->setCameraParameters(currentView->get_v_fov(),
cameraGroup->getMasterAspectRatio());
cameraGroup->update(toOsg(currentView->getViewPosition()),
toOsg(currentView->getViewOrientation()));
}
Users browsing this forum: No registered users and 4 guests