diff --git a/simgear/scene/model/Makefile.am b/simgear/scene/model/Makefile.am index d376bdb2..e12c5829 100644 --- a/simgear/scene/model/Makefile.am +++ b/simgear/scene/model/Makefile.am @@ -11,7 +11,8 @@ include_HEADERS = \ model.hxx \ modellib.hxx \ personality.hxx \ - placement.hxx + placement.hxx \ + placementtrans.hxx libsgmodel_a_SOURCES = \ animation.cxx \ @@ -20,6 +21,7 @@ libsgmodel_a_SOURCES = \ model.cxx \ modellib.cxx \ personality.cxx \ - placement.cxx + placement.cxx \ + placementtrans.cxx INCLUDES = -I$(top_srcdir) diff --git a/simgear/scene/model/location.hxx b/simgear/scene/model/location.hxx index 4c2ac30f..f1da39ca 100644 --- a/simgear/scene/model/location.hxx +++ b/simgear/scene/model/location.hxx @@ -109,19 +109,21 @@ public: void set_cur_elev_m ( double elev ) { _cur_elev_m = elev; } inline double get_cur_elev_m () { return _cur_elev_m; } // Interface to current buckets for use with tilemgr... - void set_tile_center ( Point3D tile_center ) { _tile_center = tile_center; } + void set_tile_center ( Point3D tile_center ) { set_dirty(); _tile_center = tile_center; } inline Point3D get_tile_center () { return _tile_center; } // Matrices... virtual const sgVec4 *getTransformMatrix( const Point3D scenery_center ) { - if ( _dirty ) { + if ( _dirty || scenery_center != _scenery_center ) { + _scenery_center = scenery_center; recalc( scenery_center ); } return TRANS; } virtual const sgVec4 *getCachedTransformMatrix() { return TRANS; } virtual const sgVec4 *getUpMatrix( const Point3D scenery_center ) { - if ( _dirty ) { + if ( _dirty || scenery_center != _scenery_center ) { + _scenery_center = scenery_center; recalc( scenery_center ); } return UP; @@ -153,6 +155,7 @@ private: // elevation of ground under this location... double _cur_elev_m; Point3D _tile_center; + Point3D _scenery_center; // surface vector heading south sgVec3 _surface_south; diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index cbee20f5..38a622ad 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -11,18 +11,15 @@ #include // for strcmp() -#include - #include #include #include #include "location.hxx" +#include "placementtrans.hxx" #include "placement.hxx" -SG_USING_STD(vector); - //////////////////////////////////////////////////////////////////////// @@ -37,7 +34,7 @@ SGModelPlacement::SGModelPlacement () _pitch_deg(0), _heading_deg(0), _selector(new ssgSelector), - _position(new ssgTransform), + _position(new ssgPlacementTransform), _location(new SGLocation) { } @@ -73,7 +70,12 @@ SGModelPlacement::update( const Point3D scenery_center ) POS[i][j] += (tmp * trans[j]); } } - _position->setTransform(POS); +// _position->setTransform(POS); + _position->setTransform(_location->get_absolute_view_pos(scenery_center), POS); + sgdVec3 center; + sgdSetVec3(center, + scenery_center.x(), scenery_center.y(), scenery_center.z()); + _position->setSceneryCenter(center); } bool diff --git a/simgear/scene/model/placement.hxx b/simgear/scene/model/placement.hxx index cf399676..99919a41 100644 --- a/simgear/scene/model/placement.hxx +++ b/simgear/scene/model/placement.hxx @@ -11,10 +11,6 @@ # error This library requires C++ #endif -#include - -SG_USING_STD(vector); - #include #include @@ -24,6 +20,7 @@ SG_USING_STD(vector); // Don't pull in the headers, since we don't need them here. class SGLocation; +class ssgPlacementTransform; // Has anyone done anything *really* stupid, like making min and max macros? @@ -86,6 +83,9 @@ public: // Allows multiplayer to get players position transform virtual const sgVec4 *get_POS() { return POS; } + ssgPlacementTransform * getTransform(void) + { return _position; } + private: // Geodetic position @@ -99,7 +99,8 @@ private: double _heading_deg; ssgSelector * _selector; - ssgTransform * _position; +// ssgTransform * _position; + ssgPlacementTransform * _position; // Location SGLocation * _location;