Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Sebas, On 10 January 2012 20:17, Sebas Walther sebas.walt...@googlemail.com wrote: I am not sure if I understand you correctly. I do have limited access to the viewer. It is for example possible to change the viewMatrix of the camera permanently if no camera manipulator is attached. The Problem is that my changes of the viewmatrix are overwritten if I use for example a TrackballManipulator. That is nothing new. That is the way it works. Then it's inappropriate for the Viewer to be using a TrackballManipulator in this case. What is wrong with attaching a callback to my camera? I wrote a class that inherits from osg::Camera::DrawCallback(). So now I have the opportunity to set this callback as preDrawCallback to the camera. Isn't is possible that I change the viewmatrix in the operator()-method of my class if it is necessary? Or do I have an error in reasoning here? The potential problem is that any other traversals that want to use the projection and view matrix of the Camera will use a different value to than that set in the draw traversal. For instance picking is going to be off. Logically it's also not ideal, and could lead to some head scratching for those down the line trying to debug application behaviour and not aware of your tricks. I want to change the viewMatrix AFTER the manipulator changed it but right BEFORE the frame is rendered. You should either not being using a manipulator, using a custom manipulator, or modifying the value of the manipulator so it's the one that is passing on the data. Alternatively you could use a custom Viewer that overrides the frame() or renderingTraversals() method to do the extra check on whether to ignore the camera manipulator or not. However, you might well be able to use a initial draw callback but it'll always be hack and open to potential maintenance problems down the line. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Robert, The potential problem is that any other traversals that want to use the projection and view matrix of the Camera will use a different value to than that set in the draw traversal. For instance picking is going to be off. thank you for this explanation. It is really helpful because I was getting trouble with a cullvisitor which found some NAN-Values in the matrix. It seems that this are the problems to expect when trying it my way. So it will be a custom manipulator! Thanks again! Cheers, Sebas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44757#44757 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi robert, I know that this is possible in general. The Problem is that all the views and viewers are managed by a main application. I do not have access to this while-loop of the viewer. Besides I need the Manipulator. I just have to manipulate the viewMatrix sometimes. Anyway, thanks for your attendance. I may have found the solution. I just can't test it right now. Instead of setting a cameraCallback with: Code: ...-getViewerCamera()-setInitilDrawCallback(new MyInitialDrawCallback()); I should have used: Code: ...-getViewerCamera()-setPreDrawCallback(new MyPreDrawCallback()); It sounds way better. I didn't know that this callback exists. I hope this helps somebody.[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44732#44732 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
HI Sebas, On 10 January 2012 15:38, Sebas Walther sebas.walt...@googlemail.com wrote: Hi robert, I know that this is possible in general. The Problem is that all the views and viewers are managed by a main application. I do not have access to this while-loop of the viewer. Besides I need the Manipulator. I just have to manipulate the viewMatrix sometimes. Anyway, thanks for your attendance. Why not use a custom camera manipulator? Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Robert, Why not use a custom camera manipulator? The main application manages the camera manipulators itself. My program is only a plugin for this application. What if another programer wants to build a new camera manipulator for the main application? It will be difficult and annoying to write a custom manipulator for every manipulator the main application knows and uses. Cheers, Sebas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44736#44736 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Sebas, On 10 January 2012 17:54, Sebas Walther sebas.walt...@googlemail.com wrote: The main application manages the camera manipulators itself. My program is only a plugin for this application. What if another programer wants to build a new camera manipulator for the main application? It will be difficult and annoying to write a custom manipulator for every manipulator the main application knows and uses. There is a limit to how much one can provide in just a plugin, if you want to modify the viewer then you really need access to the viewer. You can be access to the current view in the event and cull traversals so perhaps this would the way forward. Or have the application publish an API for you to use to modify the views. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Robert, if you want to modify the viewer then you really need access to the viewer I am not sure if I understand you correctly. I do have limited access to the viewer. It is for example possible to change the viewMatrix of the camera permanently if no camera manipulator is attached. The Problem is that my changes of the viewmatrix are overwritten if I use for example a TrackballManipulator. That is nothing new. That is the way it works. What is wrong with attaching a callback to my camera? I wrote a class that inherits from osg::Camera::DrawCallback(). So now I have the opportunity to set this callback as preDrawCallback to the camera. Isn't is possible that I change the viewmatrix in the operator()-method of my class if it is necessary? Or do I have an error in reasoning here? I want to change the viewMatrix AFTER the manipulator changed it but right BEFORE the frame is rendered. Thank you! Cheers, Sebas[/quote] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44741#44741 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Okay, thank you for sharing your idea but this solution isn't the best one for my plugin. The main program should change the camera manipulator as it wants. All I want is to adept the view if the camera is too far away from the action. I think all I need to do is to overwrite the viewmatrix right after the view manipulator updates the view matrix but before the frame is rendered, Isn't there a updatecallback or something like this? Thanks again, Sebas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44612#44612 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi Sebas, If you do want the result of the camera manipulator simply don't attach one to your viewer and then just set the Camera's ViewMatrix on each frame. i.e. osgViewer viewer; viewer.setSceneData(osgDB::readNodeFile(cow.osg)); viewer.realize(); while(!viewer.done()); { viewer.setViewMatrix(myViewMatrix); viewer.frame(); } Robert. On 3 January 2012 12:42, Sebas Walther sebas.walt...@googlemail.com wrote: Hi, I am trying to write a plugin for an osg-based application with an TrackballManipultor for the camera. It is no problem to get und set the camera's viewmatrix of the main application if I do not use a camera manipulator like the TrackballManipulator. But how is it possible to change the viewmatrix every frame WITH an attached camera manipulator? I was wondering if this is possible without writing an own camera manipulator. My idea is to change the viewmatrix AFTER the camera manipulator sets the viewmatrix, so that my changed viewmatrix is used for rendering instead of the viewMatrix the camera manipulator sets. Therefore I tried to attach callbacks to the camera. Problem is I am not sure which callback I have to use. I already tried an initialDrawCallback and an updateCallback. Both callbacks are called and they also change the viewMatrix but the cameraManipulator seems to overwrite the viewMatrix every frame. The callbacks are attached to the camera with the methods setUpdateCallback() or setInitialDrawCallback. Code: ...-getViewerCamera()-setUpdateCallback(new MyNodeCallback()); ...-getViewerCamera()-setInitilDrawCallback(new MyInitialDrawCallback()); I am sure that my callbacks are working. Did I try the wrong callbacks? Which callback is the right one for my purpose? Thank you very much! Cheers, Sebas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44542#44542 ___ 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] What callback for setting the viewMatrix of the camera every frame?
Hi, I used a class derived from osgGA:StandardManipulator and in the handle() i caught the FRAME event type. Thank you! Cheers, Bob -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44590#44590 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] What callback for setting the viewMatrix of the camera every frame?
Hi, I am trying to write a plugin for an osg-based application with an TrackballManipultor for the camera. It is no problem to get und set the camera's viewmatrix of the main application if I do not use a camera manipulator like the TrackballManipulator. But how is it possible to change the viewmatrix every frame WITH an attached camera manipulator? I was wondering if this is possible without writing an own camera manipulator. My idea is to change the viewmatrix AFTER the camera manipulator sets the viewmatrix, so that my changed viewmatrix is used for rendering instead of the viewMatrix the camera manipulator sets. Therefore I tried to attach callbacks to the camera. Problem is I am not sure which callback I have to use. I already tried an initialDrawCallback and an updateCallback. Both callbacks are called and they also change the viewMatrix but the cameraManipulator seems to overwrite the viewMatrix every frame. The callbacks are attached to the camera with the methods setUpdateCallback() or setInitialDrawCallback. Code: ...-getViewerCamera()-setUpdateCallback(new MyNodeCallback()); ...-getViewerCamera()-setInitilDrawCallback(new MyInitialDrawCallback()); I am sure that my callbacks are working. Did I try the wrong callbacks? Which callback is the right one for my purpose? Thank you very much! Cheers, Sebas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44542#44542 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org