[osg-users] Threading Problem after transfering application from osg 2.0 to osg 2.2
Hello at all osg-users I have an application with two graphical output windows which are running each in an own thread. Using OSG 2.0 there isnt any problem. Using OSG 2.2 to compile the project, the second output window suffers from enormous performance loss and produces only small framerates (1fps). When I minimize the first window, the second window runs with full performance. I think it is a thread-management-problem in windows XP (SP2) based on specific settings in OSG 2.2. Does anybody know a solution? Thanks, Tobias ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to remove/disable a PostDrawCallback
I'm using PostDrawCallback to make a screenshot in a realtime environment with CompositeViewer. Therefor I add this callback when user wants to make the screenshot. But after adding this callback to the camera, a screenshot is taken after each new frame. I just want to have a screenshot of the current frame and then the callback should be automatically removed. I can't find a method to remove the callback from the camera after successfully taking a screenshot. Who knows how to solve this problem? The code follows: class ScreenShotCallback: public osg::Camera::DrawCallback { private: double _w,_h; char* _filename; public: ScreenShotCallback(double w,double h,char* f) { _w = w; _h = h; _filename = f; } ~ScreenShotCallback() {}; void operator() (const osg::Camera camera) const { osg::ref_ptrosg::Image frame = new osg::Image; frame-readPixels(0, 0, _w, _h, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*frame, _filename); } } }; in the main: viewer-getView(viewer-getNumViews()-1)-getCamera()-setPostDrawCallback(new ScreenShotCallback(_twidth,_theight,filename)); ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::Matrixd -- How to remove rotation for a certainaxis?
This works, but only partially. All Object that are near the coordinate axes where fixed in rotation. But everything with a certain height above the axis zero level will be rotated. So the final images gets ugly distorted (Looks like it is sheared). I played a little bit with the values and indces, but couldn't improve it. Tobias On Feb 4, 2008 7:23 PM, Thrall, Bryan [EMAIL PROTECTED] wrote: Sorry, hit send too soon, updated below... Thrall, Bryan wrote on Monday, February 04, 2008 12:21 PM: Tobias Münch wrote on Monday, February 04, 2008 11:29 AM: Hello at all, I have osg::Matrixd view matrix and want to remove the rotation around x- and y-axis. Only rotation around z-axis should stay in the matrix. I try a lot of possibilties but couldn't find a solution. When I make the following steps, the rotation around all axis is removed, not only the two specified axis. The same with osg::Matrixd::makeRotate(..); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(0,1,0)); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(1,0,0)); I also tried to set the matrix with complete new values and to take given value for z-rotation, but therefore I miss a function to read the one rotation part (around the z-axis). How can help me? Both of those lines *set* matrix to a non-rotating matrix; what you want is to *modify* the matrix to remove the X and Y rotations. The easiest way is to modify the matrix directly: matrix(0,0) = 1; matrix(0,1) = 0; matrix(0,2) = 0; matrix(1,0) = 0; matrix(1,1) = 1; matrix(1,2) = 0; If I didn't mess up my indices, this zeroes out the X and Y rotations while leaving the Z intact. HTH, -- Bryan Thrall FlightSafety International [EMAIL PROTECTED] ___ 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] osg::Matrixd -- How to remove rotation for a certain axis?
Hello at all, I have osg::Matrixd view matrix and want to remove the rotation around x- and y-axis. Only rotation around z-axis should stay in the matrix. I try a lot of possibilties but couldn't find a solution. When I make the following steps, the rotation around all axis is removed, not only the two specified axis. The same with osg::Matrixd::makeRotate(..); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(0,1,0)); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(1,0,0)); I also tried to set the matrix with complete new values and to take given value for z-rotation, but therefore I miss a function to read the one rotation part (around the z-axis). How can help me? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::Matrixd -- How to remove rotation for a certainaxis?
I found a very easy and intuitiv way to remove inclination (y-axis) and rolling (x-axis) from a view matrix: osg::Vec3deye,center,up; matrix.getLookAt(eye,center,up,1); center.set(center.x(),center.y(),eye.z()); //removes inclination up.set(0,0,1); //removes rolling matrix.makeLookAt(eye,center,up); At first I request eye, center and up vector from the matrix. Then I set the heigt from center-vector to the height of eye-vector, which removes the inclination (y-axis rotation). Then I set a new up-vector to (0,0,1) which removes the rolling (x-axis rotation) from the matrix. Finally I create a new view matrix with the manipulated vectors. It works 100% fine. Thanks for all hints, Tobias On Feb 4, 2008 10:37 PM, Thrall, Bryan [EMAIL PROTECTED] wrote: John Kelso wrote on Monday, February 04, 2008 2:31 PM: Won't this also remove the scale? Yes, but only for the X and Y axes :) On Mon, 4 Feb 2008, Thrall, Bryan wrote: Sorry, hit send too soon, updated below... Thrall, Bryan wrote on Monday, February 04, 2008 12:21 PM: Tobias M?nch wrote on Monday, February 04, 2008 11:29 AM: Hello at all, I have osg::Matrixd view matrix and want to remove the rotation around x- and y-axis. Only rotation around z-axis should stay in the matrix. I try a lot of possibilties but couldn't find a solution. When I make the following steps, the rotation around all axis is removed, not only the two specified axis. The same with osg::Matrixd::makeRotate(..); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(0,1,0)); matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0), osg::Vec3(1,0,0)); I also tried to set the matrix with complete new values and to take given value for z-rotation, but therefore I miss a function to read the one rotation part (around the z-axis). How can help me? Both of those lines *set* matrix to a non-rotating matrix; what you want is to *modify* the matrix to remove the X and Y rotations. The easiest way is to modify the matrix directly: matrix(0,0) = 1; matrix(0,1) = 0; matrix(0,2) = 0; matrix(1,0) = 0; matrix(1,1) = 1; matrix(1,2) = 0; If I didn't mess up my indices, this zeroes out the X and Y rotations while leaving the Z intact. -- Bryan Thrall FlightSafety International [EMAIL PROTECTED] ___ 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] Difference in osg::Matrixd.getTrans() and osg::Matrixd.getLookAt(..)
Hello I have a osg::Matrixd view matrix and want to get origin of the camera. I know two different methods: getTrans() and getLookAt(eye,center,up,dist). But both return different results. For example: getTrans() -- (-0.6, -5, -2322) eye (from getLookAt(..)) -- ( 0.6, -2322, 5) The values are the same, but order and signs are interchanged. I need both vectors in the same format. How can I make this? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to ADD rotation to a matrix
Hello I have matrix that is placed somewhere in space. Now I want to add rotation of few degrees to the existing rotation. Therefor I create a new matrix that is placed in the origin and set the additional part of rotation. Then I move the first matrix also to origin (remove translation) and multiply it with the new matrix (m1 * m2) to get the new total rotation. After that I move the matrix back to its place. I thinks this is a correct process but in reality, the rotation and also translation aren't the expected ones. The x and z axis are interchanged for both. When I display the first or the additional matrix alone, everythin looks fine, so the problem isn't a false convertion between camera and world coordinates. Am I using a good way to add rotation of matrices or is there a general problem? How can I fix it? Thank you a lot, Tobias ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] how to find out which CameraMainpulator was used when having multiple views and manipulators
Hello to all osg-users I have an application with several parallel views on one scene. Each view has it's own CameraManipulator (UfoManipulator). When one view is changed through user interaction by the manipulator, it should also have an effect on the other views. For realizing this, I need a feedback on each frame, which of the installed CameraManipulators in the several views was used for interaction. (Mostly the one manipulator is active on whose view the mouse cursor is placed.) Afterwards I can get the matrix of this one CameraManipulator and can calculate the influence on the other inactive views and manipulators. Is there allready a solution for this problem? regards, Tobias ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Searcing for raytracer implementation based on OSG
Hello to all OSG developers. Does anybody has developed a raytracer based on OSG or OpenGL which is free to use on other applications? It is important for me that no changes are necessary to the OSG-framework like the raytracer of Amit Ben-David, who modified the osg:Vec3f class. I need it for my thesis and unfortunately I have not enough time to code one by my own. best regards, Tobias p.s.: The source of Ben-Davids raytracer: http://www.cs.technion.ac.il/~cs234326/projects/GLSLRayTracer/main.htm ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Searcing for raytracer implementation based on OSG
Hello Adrian If I get you right, you think that the OSG data representation is not optimized for use within a raytracer application. So it will be possible to code a raytracer with OSG but results won't be very efficient and powerful? regards, Tobias On 10/2/07, Adrian Egli [EMAIL PROTECTED] wrote: Hi Tobias, Greate would be to get a RayTracer attached to the OSG scene. With option to trace or not. Normally OSG won't trace, but if we like to get high quality screens, we can just turn on the tracing. But i was thinking about this still more then once. What we should get or what i like to integrate as soon as i have some hours to analyse the osg core, we should store the triangles, trianglesfan, ... (GL geometries) in a accelerated spatial data structure, best kd-Tree like data organisation. Even the intersection test could be boosted, also futures animations, collision checks and so on, boosting of depth sorting for transparency pre triangles should become possible. Also haptic-rendering could be an option for future application. This integration would be an essential topic. I am not yet sure how we should change the osg internal data structure, at the moment we store vertices in simple arrays. I feel like to remap them into an kd-tree. then the whole scenegraph is organised in a spatial data structure. and the once we have a fast internal data representation, we may are really close to render the scene no longer as face rendering also ray casted, ray traced parts would be an futur options. what would be really greate. May we will get small parts raytraced, others not. what are others thinking about this topic. /Adegli 2007/10/2, Tobias Münch [EMAIL PROTECTED]: Hello to all OSG developers. Does anybody has developed a raytracer based on OSG or OpenGL which is free to use on other applications? It is important for me that no changes are necessary to the OSG-framework like the raytracer of Amit Ben-David, who modified the osg:Vec3f class. I need it for my thesis and unfortunately I have not enough time to code one by my own. best regards, Tobias p.s.: The source of Ben-Davids raytracer: http://www.cs.technion.ac.il/~cs234326/projects/GLSLRayTracer/main.htm http://www.cs.technion.ac.il/%7Ecs234326/projects/GLSLRayTracer/main.htm ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Adrian Egli ___ 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] Render multiple views within one frame
Hello Robert, hello at all This is a topic posted a few weeks ago. I want to render several views (up to 90 views) within one frame and combine the results in a single RenderSurface or OSG window for instance. (the purpose is to generate multiperspective images) Robert recommended me to use OSG 2.0 CompositeViewer instead of osgProducer::Viewer because of better performance on dealing with multiple views. After realizing prototypes for both viewers I cannot notice any performance improvement with CompositeViewer. To set up my CompositeViewer I created a lot of independet osgViewer::Views. The master camera of each view renders its content to the dedicated area in the viewer window. An Example: Using 45 different views there are 45 master cameras and 45 different areas in the viewer window. Is there a possibilty to get better performance with OSG 2.0 CompositeViewer when using such a large quantity of views and cameras? Maybe I do something wrong because I got no performance improvment with CompositeViewer. Best regards, Tobias On 8/2/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Tobias, One shouldn't attempt to using a single camera between multiple views within one frame. If you want an application with multiple views then the best place to look for an example and classes supporting it 2.0. There is a new osgViewer library that has a CompositeViewer class dedicated to role of managing multiple views, its performance is excellent - there is no additional performance hit with going with multiple views, and the class itself provide the ability to share scene between different views, or have different scenes in each view. There is also an osgcompositeviewer example that illustrates how one manage the different Views. Try to do multiple independent views 1.2/osgProducer/Producer is technically possible for certain constrained usage models, but its awkward and not well supported. Please go and try out 2.x and the osgcompositeviewer, it should just solve your multiple view problems and do so in clean and logical way. Robert. On 8/2/07, Tobias Münch [EMAIL PROTECTED] wrote: Hello osg users I have a single camera that should render different views of a scene within ONE FRAME. As result every frame should contain all rendered views side by side. Therefor I set different projection rectangles and render views (setViewByMatrix) to the camera while processing a frame. The problem is, that the function viewer.frame() or camera.frame() always render only for the last adjusted camera setting. Is there a solution to render the scene with one camera several times within one frame? For instance by using the FrameBuffer...? I allready tried to solve the problem by using a couple of cameras to render different views within one frame, but with very poor performance and framerate. Thanks to all... Regards, Tobias ___ 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] Render multiple views within one frame
Thanks for your answer Robert. The images I want to render are not bigger than normal images captured with a single camera. But in my special case I use several cameras (beginning from 16 up to 90) that render each only a small vertical strip of the scene. The width of each strip depends on the quantity of cameras and differs between 15 and 1 pixel. Finnally each frame is a combination of all the small vertical strips. I think the number of calculations by rendering a lot of thin strips of a scene with several cameras is not so much higher than to render a normal-width image just with on camera. An Example: Rendering 90 strips with 1x700 pixel = 90x700 and Rendering 1 strip with 90x700 pixel = 90x700. I know that in reality it won't work so easy. But can you explain what exactly is the problem for the performance loss of the viewer. Is the CPU load to render each of the small strips compareable to the CPU load on rendering one big strip? So the CPU load increases with each camera assigned to the viewer no matter how wide the rendered stripe is? Anyway, if its not possible to get a large number of cameras work with OSG, I have to design a new concept of creating multiperspective images. Best regards, Tobias On 8/24/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Tobias, If you are generating 90 views all within on frame then you have 90 cull traversals and 90 draw traversals, unless you scene is very simple I would expect performance to be poor and will be particularly CPU limited. What CompositeViewer provides is not so much performance improvement across the board, but rather far better granularity of design. Thrashing one camera 90 times in one frame just isn't good and will preclude some attempts at optimization. On extra detail you added in your recent reply was the multiperspective images, this suggest to me that actually you don't necessarily want 90 logical views, and perhaps want you are after is one logical view with a single master camera, and the actual rendering composed of 90 slave cameras that provide the multiperspectives. Is this right? Then osgViewer::Viewer is probably more appropriate. One advantage of osgViewer::Viewer is that at present its further ahead on the multi-threading curve than CompositeViewer in that it supports CullThreadPerCameraDrawThreadPerContext, in your case this would map to 90 threads for each camera cull, and one draw thread. It would be rather overkill, but the Viewer class could easily be adapted to also do the culls via a OperationQueue that is shared by a set of thread - such as as having 3 threads handling 90 camera culls, and one thread handling the draw. One further reflection perhaps the biggest bottleneck will be CPU cache... Anyway not mentioning 90 views is a big thing... what you are expecting gunning for is rather a tall order for a single CPU and GPU. Robert. On 8/24/07, Tobias Münch [EMAIL PROTECTED] wrote: Hello Robert, hello at all This is a topic posted a few weeks ago. I want to render several views (up to 90 views) within one frame and combine the results in a single RenderSurface or OSG window for instance. (the purpose is to generate multiperspective images) Robert recommended me to use OSG 2.0 CompositeViewer instead of osgProducer::Viewer because of better performance on dealing with multiple views. After realizing prototypes for both viewers I cannot notice any performance improvement with CompositeViewer. To set up my CompositeViewer I created a lot of independet osgViewer::Views. The master camera of each view renders its content to the dedicated area in the viewer window. An Example: Using 45 different views there are 45 master cameras and 45 different areas in the viewer window. Is there a possibilty to get better performance with OSG 2.0CompositeViewer when using such a large quantity of views and cameras? Maybe I do something wrong because I got no performance improvment with CompositeViewer. Best regards, Tobias On 8/2/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Tobias, One shouldn't attempt to using a single camera between multiple views within one frame. If you want an application with multiple views then the best place to look for an example and classes supporting it 2.0. There is a new osgViewer library that has a CompositeViewer class dedicated to role of managing multiple views, its performance is excellent - there is no additional performance hit with going with multiple views, and the class itself provide the ability to share scene between different views, or have different scenes in each view. There is also an osgcompositeviewer example that illustrates how one manage the different Views. Try to do multiple independent views 1.2/osgProducer/Producer is technically possible for certain constrained usage models, but its awkward and not well supported. Please
[osg-users] Render multiple views within one frame
Hello osg users I have a single camera that should render different views of a scene within ONE FRAME. As result every frame should contain all rendered views side by side. Therefor I set different projection rectangles and render views (setViewByMatrix) to the camera while processing a frame. The problem is, that the function viewer.frame() or camera.frame() always render only for the last adjusted camera setting. Is there a solution to render the scene with one camera several times within one frame? For instance by using the FrameBuffer...? I allready tried to solve the problem by using a couple of cameras to render different views within one frame, but with very poor performance and framerate. Thanks to all... Regards, Tobias ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org