[osg-users] Missile Path Visualization Problem

Philip Hahn everphilski at gmail.com
Thu Oct 11 14:35:55 PDT 2007


Jeff-

Another thing to check is that the same time is being used by your path
code, your model code and your camera code.

I'm doing something very similar and I ran into that problem twice. Both
times it was that the time stamp my camera was using differed slightly from
the time stamp my missile model used. It may very well be a precision issue
but wouldn't hurt to check.

Philip Hahn



On 10/11/07, Jeffrey M Short <jshort8 at csc.com> wrote:
>
>
> 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.
>
> I am using these 2bvectors to draw 2 things when playing back the missile
> path in a real-time simulation:
>
> (A) A 3d model at the current location
> (B) A line which shows the previous track of the missile path
>
> Of course because my data for the missile path is at discrete intervals I
> have to interpolate the location of the missile.  I am using linear
> interpolation.
>
> Now my problem is that when I'm viewing the missile with an
> osgGA::NodeTrackerManipulator the track of the missile "jumps" all over
> the
> place (it doesn't end at the center of the 3d model, which is should be
> doing).  This "jumping" occurs when the animation is being played and it
> also occurs when the animation is paused and I rotate around the 3d
> missile
> model.  An UpdateCallback is use to update a MatrixTransfrom which the 3d
> model is a child of.  A class derived from Drawable is used to draw the
> track of the missile
>
> Here is all the relevant code:
>
> public: virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)  //
> Implements the callback
>   {
>     osg::MatrixTransform* posNode = static_cast
> <osg::MatrixTransform*>(node);
>
>
> posNode->setMatrix(osg::Matrixd::translate(_ms->get_Position(ScenarioClock::instance()->getScenarioTime())));
>
>     osg::NodeCallback::traverse(node, nv);
>   }
>
> osg::Vec3d get_Position(double time)
>   {
>     std::vector<double>::iterator itr = ephemerisTime->begin();
>
>     for (int i = 0; itr != ephemerisTime->end(); itr++, i++)
>     {
>       if (*itr >= time)
>       {
>         if (itr == ephemerisTime->begin())
>           return (*position)[0];
>
>         // Linear Interpolation
>         double ratio = time - (*ephemerisTime)[i - 1];  // Numerator
>         ratio /= ((*ephemerisTime)[i] - (*ephemerisTime)[i - 1]);  //
> Divide by denominator
>
>         osg::Vec3d pos = (*position)[i] * ratio + (*position)[i - 1] * (1
> -
> ratio);
>         return pos;
>       }
>     }
>
>     return (*position)[position->size() - 1];
>   }
>
> private: void DrawTrajectoryPath()
>   {
>     glColor4fv(colorVec.ptr());
>
>     glBegin(GL_LINE_STRIP);
>     std::vector<double>::iterator itr = ephemerisTime->begin();
>     for (int i = 0; itr != ephemerisTime->end(); itr++, i++)
>     {
>       // Calculate the interpolated point
>       if (*itr > ScenarioClock::instance()->getScenarioTime())
>       {
>         // Draw nothing if the 1st ephemeris point hasn't occurred
>         if (i == 0)
>           break;
>
>         // Linear Interpolation
>         double ratio = ScenarioClock::instance()->getScenarioTime() -
> (*ephemerisTime)[i - 1];  // Numerator
>         ratio /= ((*ephemerisTime)[i] - (*ephemerisTime)[i - 1]);  //
> Divide by denominator
>
>         osg::Vec3d lastPoint = (*position)[i] * ratio + (*position)[i - 1]
> * (1 - ratio);
>
>         glVertex3dv(lastPoint.ptr());
>         break;
>       }
>
>       glVertex3dv((*position)[i].ptr());
>     }
>     glEnd();
>   }
>
> 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?
>
>
>
> Thanks
>      Jeff
>
>
>
> Computer Sciences Corporation
> Registered Office: 2100 East Grand Avenue, El Segundo California 90245,
> USA
> Registered in USA No: C-489-59
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery.
> NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
> any order or other contract unless pursuant to explicit written agreement
> or government initiative expressly permitting the use of e-mail for such
> purpose.
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071011/1952e5fa/attachment-0003.htm>


More information about the osg-users mailing list