Mathias:
have done a patch to eliminate the jitter of 3D-objects near the viewpoint (for example 3D cockpit objects). The problem is the roundoff accuracy of the float values used in the scenegraph together with the transforms of the eyepoint relative to the scenery center. The solution will be to move the scenery center near the view point. This way floats relative accuracy is enough to show a stable picture. To get that right I have introduced a transform node for the scenegraph which is responsible for that shift and uses double values as long as possible. The scenery subsystem now has a list of all those transforms required to place objects in the world and will tell all those transforms that the scenery center has changed when the set_scenery_center() of the scenery subsystem is called. The problem was not solvable by SGModelPlacement and SGLocation, since not all objects, especially the scenery, are placed using these classes. The first approach was to have the scenery center exactly at the eyepoint. This works well for the cockpit. But then the ground jitters a bit below the aircraft. With our default views you can't see that, but that F-18 has a camera view below the left engine intake with the nose gear and the ground in its field of view, here I could see that. Having the scenery center constant will still have this roundoff problems, but like it is now too, the roundoff error here is exactly the same in each frame, so you will not notice any jitter. The real solution is now to keep the scenery center constant as long as it is in a ball of 30m radius around the view point. If the scenery center is outside this ball, just put it at the view point. As a sideeffect of now beeing able to switch the scenery center in the whole scenegraph with one function call, I was able to remove a one half of a problem when switching views, where the scenery center was far off for one or two frames past switching from one view to the next. Also included is a fix to the other half of this problem, where the view position was not yet copied into a view when it is switched (at least under glut). This was responsible for the 'Error: ...' messages of the cloud subsystem when views were switched.
This commit is contained in:
parent
100927f16c
commit
e0decf1233
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -11,18 +11,15 @@
|
||||
|
||||
#include <string.h> // for strcmp()
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/ul.h>
|
||||
|
||||
#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
|
||||
|
@ -11,10 +11,6 @@
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
SG_USING_STD(vector);
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user