Hi Ash,

for (int pos = 0; pos < 80; pos+=10)

Here you're simulating 8 frames (0 to less than 80, in steps of 10, so 0 to 70). On modern systems, depending on your geometry and your vsync settings, 8 frames should go by in about 0.13 seconds (if you have vsync on and are at a refresh rate of 60hz, and have a simple scene that does not break frame) or even less (if you have vsync disabled and have a very simple scene). So it's kind of normal that you only see the last frame, what you're actually seeing is all 8 frames too fast to see and then the render stops at the last frame.

To make a more significant test, try something like:

float frame = 0.0f;
while (!pViewer->done())
{
    // set the matrix so that the object turns in circles,
    // for example :
    mat.setTrans(sin(osg::DegreesToRadians(frame)),
                 cos(osg::DegreesToRadians(frame)),
                 0.0);
    pXform->setMatrix(mat);

    frame++;
    pViewer->frame();
}

(note, untested)

This will make the object go in a circle at a rate of about 1 degree per frame, which is a movement you'll be able to see, and it will loop around... the while (!pViewer->done()) means that the viewer will run until you press Esc (or close the window) which sets the viewer's done condition to true.

You can mess around with the increment to get different speeds, or even modify the speed based on the frame time so that it moves the same amount per second independently of frame rate. That's left as an exercise to the reader :-)

See the Quick Start Guide (free download) and the OSG wiki for more examples and information.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to