Arif,
You haven't really said _what_ was jittering - is it your scene entities, or
your camera? If it is your entities, then what I am about to say won't really
apply to you. If it is your camera, then maybe it will give at least help to
give you a clue. You might want to check the order in which you perform your
updates. Here is a scenario I ran into a while back:
1. Had an osg::OperationThread that pulled in data from network to update
positions of objects
2. Had an osgGA::GUIEventHandler that performed node tracking and updated the
camera matrixTransform
If you look at osgViewer::ViewerBase::frame, you will see
void ViewerBase::frame(double simulationTime)
{
...
eventTraversal();
// *** OperationThreads get called in updateTraversal before the update
visitor.
updateTraversal();
renderingTraversals();
}
In my case I was repositioning my camera in the eventHandler, but new object
position information was coming in during the updateTraversal. This caused my
camera to always calculate based on the old position and therefore be one frame
behind. I changed the logic so that the calculation of the camera position
happened during the call to my camera manipulator's getInverseMatrix() and that
fixed my problem.
So as long as everything coming in is updated and "sync'ed" in the same way,
you shouldn't see jitter.
Hope that helps
--
Chuck Seberino
On Jan 24, 2011, at 1:45 AM, Arif Yetkin Sarı wrote:
> Hello everyone.
>
> We have been using OSG with nvidia physx for a driving simulation and we have
> jitter problem, where the cars and other objects in the scene (controlled by
> the physics) jitter annoyingly :). We believe that we update the scenegraph
> in a wrong way.
>
> In our code :
> There is a physx thread.
> There is an OSG library thread where we can add new entities, remove them,
> start rain effects, call an animation of a skeleton character etc.
> There is an OSG render loop thread, where osgviewer::...frame() is called.
>
> Our Nvidia physx thread produces new "x y z pitch head roll" values for the
> scene entities at 60Hz (or any other frequency we want).
> Physx thread calls the updateEntity() function of our OSG library thread.
> This function simply updates scene entities with matrixtransform::void
> setMatrix(const Matrix& mat).
>
> In other words, we move an object with this chunk of code:
>
> Code:
> osg::Matrixd mxT = createTransformMatrix(x,y,z,h,p,r);
> mt->setMatrix(mx);
>
>
>
> Here what we tried:
> 1-we fed OSG lib directly whenever a physx output is produced (every 16.6 ms
> or so - 60Hz): there is jitter.
> 2-we maintained a queue of frames on OSG lib, fed OSG at the end of each
> frame() : there is jitter.
> 3-we implemented a sampling mechanism on this queue, where OSG requests the
> interpolated frame from the queue for the current timestamp : there is jitter.
> 4-we saved a few minutes long log of the physx to a file (many frames).
> Started a dummy thread, and fed OSG from this log. : there is jitter.
>
> When OSG works with 60FPS, and physx thread is running at 60Hz, there seems
> to be quite low jitter (sometimes unnoticeable) .
>
> Thanks in advance for any hints or advices.
> Arif Yetkin
>
> ------------------------
> http://www.youtube.com/watch?v=naX3hOkDx8w
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=35912#35912
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org