Hello YangXiao,

2. I have another question, when viewer.frame() which thread listening windows message(example mouse clicked,keyboard down ,up etc) ,and when i update my scene node in updatecallback,How threads guarantee sequence?

To avoid threading problems I suggest you use an EventHandler to do this.

For example:

    class MyEventHandler : public osgGA::GUIEventHandler
    {
    public:

        MyEventHandler() {}

        ~MyEventHandler() {}

        bool handle(const osgGA::GUIEventAdapter& ea,
                    osgGA::GUIActionAdapter& aa)
        {
            switch(ea.getEventType())
            {
                // Mouse button press
                case(osgGA::GUIEventAdapter::PUSH):
                {
                    // ... do what you want here
                    return false;
                }
                // Mouse button release
                case(osgGA::GUIEventAdapter::RELEASE):
                {
                    // ... do what you want here
                    return false;
                }
                default:
                    return false;
            }
        }
    };

Then add this handler to the viewer:

    viewer.addEventHandler(new MyEventHandler);

See the osgpick example for an example of a mouse event handler, and the osgkeyboard example for a keyboard event handler - of course you can combine both if you want (the same handle() method can be used for mouse and keyboard events). See the docs for the return values of ea.getEventType().

I suggest you read the OSG Quick Start Guide (free from http://www.osgbooks.com/) and then go around the reference docs (http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/) and the many included examples in the OSG source tree to get a feel for things. These are pretty basic questions that you could answer yourself by reading a bit (not that we don't want to answer them, but you'll wait longer for an answer).

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                               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