Re: [osg-users] How to detect rotating image

2012-02-27 Thread Robert Osfield
Hi Clement,

On 27 February 2012 06:26,  clement@csiro.au wrote:
   I would like to know how to detect the image is rotating.  For example, we 
 can use the mouse to rotate the image on viewer.  If we drag on the viewer, 
 the image will automatically rotate.  Any event I can get the image is 
 rotating by itself?  Thanks.

It's not possible to know precisely what you mean given the above.
What exactly do you mean by image?  A texture on a quad?  The whole
framebuffer? Are we talking about an object in the scene graph being
rotated by a transform, or simply an object moving because the camera
is moving.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Robert Osfield
Hi Clement,

The osgViewer::ViewerBase (base class for Viewer) has a FrameScheme
hint for the run() method which enables ON_DEMAND or CONTINUOUS,
ON_DEMAND is the approach you'd want.  You'll be calling frame()
yourself rather than run() so won't be able to utilize this feature,
but you should be able to learn from it.  Have a look at the
ViewerBase::run() method in
OpenSceneGraph/src/osgViewer/ViewerBase.cpp, in particular the use of
checkNeedToDoFrame() which is used to decide whether a frame is needed
or not.

Robert.

On 27 February 2012 09:57,  clement@csiro.au wrote:
 Hi Robert,

    I mentioned before I got much cpu usage on MFC window.  In osgMFC example, 
 it uses a thread and for loop to keep calling _osgViewer-frame().  It is a 
 reason why the cpu keeps loading and it also depended on how large of volume 
 data loaded.  Now I have changed to call frame() on MFC OnPaint event. It can 
 decrease much cpu usage.  I also added to call frame() on mouse move, mouse 
 wheel and size events for zooming and rotating the image.  But all MFC events 
 cannot be fired if the image is rotating by itself.  Thus, I am thinking 
 whether osg has an event to detect the image is rotating.

  I just found a solution to add MFC mouse button up and down to detect 
 whether the user wants to rotate the image.  Then I can do it all on MFC 
 event.


 Regards,
 Clement
 
 From: osg-users-boun...@lists.openscenegraph.org 
 [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
 [robert.osfi...@gmail.com]
 Sent: Monday, 27 February 2012 8:17 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] How to detect rotating image

 Hi Clement,

 On 27 February 2012 06:26,  clement@csiro.au wrote:
   I would like to know how to detect the image is rotating.  For example, we 
 can use the mouse to rotate the image on viewer.  If we drag on the viewer, 
 the image will automatically rotate.  Any event I can get the image is 
 rotating by itself?  Thanks.

 It's not possible to know precisely what you mean given the above.
 What exactly do you mean by image?  A texture on a quad?  The whole
 framebuffer? Are we talking about an object in the scene graph being
 rotated by a transform, or simply an object moving because the camera
 is moving.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Clement.Chu
Hi Robert,

  Thanks for your suggestion.  I checked the source code viewerbase.cpp.  There 
is attribute called _runFrameScheme, but the value is assigned by 
getenv(OSG_RUN_FRAME_SCHEME).  Except to set the environment variable, any 
method I can assign the value to _runFrameScheme?  Thanks.


Regards,
Clement

From: osg-users-boun...@lists.openscenegraph.org 
[osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
[robert.osfi...@gmail.com]
Sent: Monday, 27 February 2012 9:55 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] How to detect rotating image

Hi Clement,

The osgViewer::ViewerBase (base class for Viewer) has a FrameScheme
hint for the run() method which enables ON_DEMAND or CONTINUOUS,
ON_DEMAND is the approach you'd want.  You'll be calling frame()
yourself rather than run() so won't be able to utilize this feature,
but you should be able to learn from it.  Have a look at the
ViewerBase::run() method in
OpenSceneGraph/src/osgViewer/ViewerBase.cpp, in particular the use of
checkNeedToDoFrame() which is used to decide whether a frame is needed
or not.

Robert.

On 27 February 2012 09:57,  clement@csiro.au wrote:
 Hi Robert,

I mentioned before I got much cpu usage on MFC window.  In osgMFC example, 
 it uses a thread and for loop to keep calling _osgViewer-frame().  It is a 
 reason why the cpu keeps loading and it also depended on how large of volume 
 data loaded.  Now I have changed to call frame() on MFC OnPaint event. It can 
 decrease much cpu usage.  I also added to call frame() on mouse move, mouse 
 wheel and size events for zooming and rotating the image.  But all MFC events 
 cannot be fired if the image is rotating by itself.  Thus, I am thinking 
 whether osg has an event to detect the image is rotating.

  I just found a solution to add MFC mouse button up and down to detect 
 whether the user wants to rotate the image.  Then I can do it all on MFC 
 event.


 Regards,
 Clement
 
 From: osg-users-boun...@lists.openscenegraph.org 
 [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
 [robert.osfi...@gmail.com]
 Sent: Monday, 27 February 2012 8:17 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] How to detect rotating image

 Hi Clement,

 On 27 February 2012 06:26,  clement@csiro.au wrote:
   I would like to know how to detect the image is rotating.  For example, we 
 can use the mouse to rotate the image on viewer.  If we drag on the viewer, 
 the image will automatically rotate.  Any event I can get the image is 
 rotating by itself?  Thanks.

 It's not possible to know precisely what you mean given the above.
 What exactly do you mean by image?  A texture on a quad?  The whole
 framebuffer? Are we talking about an object in the scene graph being
 rotated by a transform, or simply an object moving because the camera
 is moving.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Robert Osfield
On 27 February 2012 11:26,  clement@csiro.au wrote:
 Hi Robert,

  Thanks for your suggestion.  I checked the source code viewerbase.cpp.  
 There is attribute called _runFrameScheme, but the value is assigned by 
 getenv(OSG_RUN_FRAME_SCHEME).  Except to set the environment variable, any 
 method I can assign the value to _runFrameScheme?  Thanks.

You have the source code, your hopefully are a programmer so should be
capable of looking at the API and reading what the methods are.
Please try it before asking lots of low level questions that could be
answered with a quick look with an editor.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Robert Osfield
Hi Clement,

If you want to find out what is going on use a debugger.  A modicum of
self reliance is key element of being a successful programmer.  You
can't expect others to keep hand walking your through every little
feature one by one.

Robert.

On 27 February 2012 13:11,  clement@csiro.au wrote:
 Hi Robert,

  Do you know how to test the osgViewer is using ON_DEMAND flag?  Here is my 
 code:

 void cOSG::Render(void* ptr)
 {
    cOSG* osg = (cOSG*)ptr;
    osgViewer::Viewer* viewer = osg-getViewer();
    viewer-run();
 }

 void cOSG::initOSGViewer()
 {
        putenv(OSG_RUN_FRAME_SCHEME=ON_DEMAND);
        osgViewer::Viewer* osgViewer = new osgViewer::Viewer();
        ...
        ...
 }


   Before I create osgViewer, I added environment variable.  But I can't see 
 any different compare without environment variable setting.  I am not sure 
 whether osg viewer is using ON_DEMAND.


 Regards,
 Clement


 
 From: osg-users-boun...@lists.openscenegraph.org 
 [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
 [robert.osfi...@gmail.com]
 Sent: Monday, 27 February 2012 10:35 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] How to detect rotating image

 On 27 February 2012 11:26,  clement@csiro.au wrote:
 Hi Robert,

  Thanks for your suggestion.  I checked the source code viewerbase.cpp.  
 There is attribute called _runFrameScheme, but the value is assigned by 
 getenv(OSG_RUN_FRAME_SCHEME).  Except to set the environment variable, any 
 method I can assign the value to _runFrameScheme?  Thanks.

 You have the source code, your hopefully are a programmer so should be
 capable of looking at the API and reading what the methods are.
 Please try it before asking lots of low level questions that could be
 answered with a quick look with an editor.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Tomlinson, Gordon
You could do a setenv(..), in you code on startup 




Gordon Tomlinson
Chief Engineer(Remoteview)
Overwatch
An Operating Unit of Textron Systems
__

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of 
clement@csiro.au
Sent: Monday, February 27, 2012 6:27 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] How to detect rotating image

Hi Robert,

  Thanks for your suggestion.  I checked the source code viewerbase.cpp.  There 
is attribute called _runFrameScheme, but the value is assigned by 
getenv(OSG_RUN_FRAME_SCHEME).  Except to set the environment variable, any 
method I can assign the value to _runFrameScheme?  Thanks.


Regards,
Clement

From: osg-users-boun...@lists.openscenegraph.org 
[osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
[robert.osfi...@gmail.com]
Sent: Monday, 27 February 2012 9:55 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] How to detect rotating image

Hi Clement,

The osgViewer::ViewerBase (base class for Viewer) has a FrameScheme hint for 
the run() method which enables ON_DEMAND or CONTINUOUS, ON_DEMAND is the 
approach you'd want.  You'll be calling frame() yourself rather than run() so 
won't be able to utilize this feature, but you should be able to learn from it. 
 Have a look at the
ViewerBase::run() method in
OpenSceneGraph/src/osgViewer/ViewerBase.cpp, in particular the use of
checkNeedToDoFrame() which is used to decide whether a frame is needed or not.

Robert.

On 27 February 2012 09:57,  clement@csiro.au wrote:
 Hi Robert,

I mentioned before I got much cpu usage on MFC window.  In osgMFC example, 
 it uses a thread and for loop to keep calling _osgViewer-frame().  It is a 
 reason why the cpu keeps loading and it also depended on how large of volume 
 data loaded.  Now I have changed to call frame() on MFC OnPaint event. It can 
 decrease much cpu usage.  I also added to call frame() on mouse move, mouse 
 wheel and size events for zooming and rotating the image.  But all MFC events 
 cannot be fired if the image is rotating by itself.  Thus, I am thinking 
 whether osg has an event to detect the image is rotating.

  I just found a solution to add MFC mouse button up and down to detect 
 whether the user wants to rotate the image.  Then I can do it all on MFC 
 event.


 Regards,
 Clement
 
 From: osg-users-boun...@lists.openscenegraph.org 
 [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert 
 Osfield [robert.osfi...@gmail.com]
 Sent: Monday, 27 February 2012 8:17 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] How to detect rotating image

 Hi Clement,

 On 27 February 2012 06:26,  clement@csiro.au wrote:
   I would like to know how to detect the image is rotating.  For example, we 
 can use the mouse to rotate the image on viewer.  If we drag on the viewer, 
 the image will automatically rotate.  Any event I can get the image is 
 rotating by itself?  Thanks.

 It's not possible to know precisely what you mean given the above.
 What exactly do you mean by image?  A texture on a quad?  The whole 
 framebuffer? Are we talking about an object in the scene graph being 
 rotated by a transform, or simply an object moving because the camera 
 is moving.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
 org ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
 org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to detect rotating image

2012-02-27 Thread Clement.Chu
Hi Robert,

   Sorry for the mass email.  I have debugged the program and I am sure 
ON_DEMAND is set to OSG_RUN_FRAME_SCHEME, but I can't see any different.  The 
cpu usage is still used 25% on idle.


Regards,
Clement


From: osg-users-boun...@lists.openscenegraph.org 
[osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
[robert.osfi...@gmail.com]
Sent: Tuesday, 28 February 2012 12:41 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] How to detect rotating image

Hi Clement,

If you want to find out what is going on use a debugger.  A modicum of
self reliance is key element of being a successful programmer.  You
can't expect others to keep hand walking your through every little
feature one by one.

Robert.

On 27 February 2012 13:11,  clement@csiro.au wrote:
 Hi Robert,

  Do you know how to test the osgViewer is using ON_DEMAND flag?  Here is my 
 code:

 void cOSG::Render(void* ptr)
 {
cOSG* osg = (cOSG*)ptr;
osgViewer::Viewer* viewer = osg-getViewer();
viewer-run();
 }

 void cOSG::initOSGViewer()
 {
putenv(OSG_RUN_FRAME_SCHEME=ON_DEMAND);
osgViewer::Viewer* osgViewer = new osgViewer::Viewer();
...
...
 }


   Before I create osgViewer, I added environment variable.  But I can't see 
 any different compare without environment variable setting.  I am not sure 
 whether osg viewer is using ON_DEMAND.


 Regards,
 Clement


 
 From: osg-users-boun...@lists.openscenegraph.org 
 [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield 
 [robert.osfi...@gmail.com]
 Sent: Monday, 27 February 2012 10:35 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] How to detect rotating image

 On 27 February 2012 11:26,  clement@csiro.au wrote:
 Hi Robert,

  Thanks for your suggestion.  I checked the source code viewerbase.cpp.  
 There is attribute called _runFrameScheme, but the value is assigned by 
 getenv(OSG_RUN_FRAME_SCHEME).  Except to set the environment variable, any 
 method I can assign the value to _runFrameScheme?  Thanks.

 You have the source code, your hopefully are a programmer so should be
 capable of looking at the API and reading what the methods are.
 Please try it before asking lots of low level questions that could be
 answered with a quick look with an editor.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org