[osg-users] Missile Path Visualization Problem
bryan.thrall at flightsafety.com
Thu Oct 11 11:04:14 PDT 2007
Jeffrey M Short wrote on Thursday, October 11, 2007 12:28 PM:
> First off, I'm still using OSG 1.0 with osgProducer::Viewer.
> I am using a vector of osg::Vec3d to represent a missile path in
> Earth-Centered Earth-Fixed coordinates and a vector of doubles to
> store the time associated with each point of the missile path.
> Even if I take out the if statement in DrawTrajectoryPath (so that the
> entire missile path is drawn and not just the trail) the "jumping"
> still occurs, so the problem isn't with the linear interpolation in
> the code.
> I have a strong suspicion that the problem is related to decimal
> precision even though the if I truncate the Vec3d to a Vec3f in the
> UpdateCallback my problem still occurs (the missile trail still
> doesn't end at the center of the 3d model).
> Any ideas?
You are probably correct about the precision problems. Most (if not all)
OpenGL implementations are limited to float precision, which is going to
be a problem in an Earth-Centered coordinate system. If you truncate the
Vec3d to Vec3f you're pretty much doing the same thing the OpenGL driver
is doing, which is cutting off your precision.
The solution is to transform the geometry to a coordinate system whose
origin is close enough that you don't lose precision. In my own app, I
transform everything to eye coordinates before passing it to OpenGL.
Another possibility would be OSGDEM; I'm not familiar with it, but I
think it divides Earth into a bunch of regions sized to avoid precision
problems, with a TransformNode for each region to transform the geometry
Bryan.Thrall at flightsafety.com
More information about the osg-users