Re: [osg-users] Problems port OSG 1.0 - 2.8.2; Can't embed viewer in external app
Hi, does the osgviewerGTK example work? jp Natasha Westland wrote: Hello, I am having difficulties upgrading from OSG 1.0 to 2.8.2 (on CentOS) and was hoping to tap into this wealth of knowledge after failing miserably poking around the source code and attempting to retrofit the example applications into my own. Using OSG 1.0, I have an application which used an osgProducer to embed a viewer in another (GTK+ based) application. Using the below approach, I am able to successfully render images in the external application. In my attempt to port to OSG 2.8.2, I am able to embed the viewer in the external application but I can't seem to render any images. (I've tried simply changing the background color and that doesn't work either.) Based on observations in the debugger, it appears that my viewer may not be integrated properly with the gtk redrawing thread of the external application due to the fact that the visible (black) view is overdrawn by the external application at random times, and it is never seen again. Any pointers would be greatly appreciated. Thanks! Natasha westl...@ll.mit.edu _ Initialization of osgProducer viewer using OSG 1.0: _ osgProducer::Viewer viewer (BuildConfig()); viewer.setUpViewer (osgProducer::Viewer::SKY_LIGHT_SOURCE | osgProducer::Viewer::HEAD_LIGHT_SOURCE | osgProducer::Viewer::STATE_MANIPULATOR | osgProducer::Viewer::STATS_MANIPULATOR | osgProducer::Viewer::VIEWER_MANIPULATOR ); gtk_init (argc, argv); // set the xid of the GtkSocket and connect the GtkPlug guint32 xid = wGtkPlug;// gtksocket of external application GtkWidget *plug = gtk_plug_new(xid); gtk_signal_connect(GTK_OBJECT(plug), destroy-event, GTK_SIGNAL_FUNC(destroy_event), viewer); // set the viewer to display in the plug viewer.getCamera(0)-getRenderSurface()-setWindow(gtk_plug_get_id(GTK_PLUG(plug))); // create a new thread to handle GTK events pthread_create(gtk_thread, NULL, gtk_thread_loop, NULL); // create the windows and run the threads. viewer.realize(); while( !viewer.done() ) { viewer.sync(); viewer.update(); // fire off the cull and draw traversals of the scene. viewer.frame(); usleep(50); } Producer::CameraConfig* BuildConfig(void) { Producer::RenderSurface *rs1 = new Producer::RenderSurface; rs1-setScreenNum(0); rs1-setWindowName(external-app); rs1-setWindowRectangle (0,0,640,480); Producer::Camera *camera1 = new Producer::Camera; camera1-setRenderSurface(rs1); camera1-setOffset( 0.0, 0.0 ); rs1-setInputRectangle (Producer::RenderSurface::InputRectangle(0.0,1.0,0.0,1.0)); Producer::InputArea *ia = new Producer::InputArea; ia-addRenderSurface(rs1); Producer::CameraConfig *cfg = new Producer::CameraConfig; cfg-addCamera(Camera 1,camera1); cfg-setInputArea(ia); return cfg; } void *gtk_thread_loop(void *arg) { gtk_main(); return NULL; } _ Rendering the images in OSG 1.0 is implemented as follows (same for OSG 2.8.2): _ _loadedModel = osgDB::readNodeFile(sName); if (!_loadedModel) { viewer.setClearColor( osg::Vec4( 0.9f, 0.9f, 0.9f, 1.0) ); return 1; } viewer.setClearColor( osg::Vec4( 0.701961f, 0.862745f, 0.949020f, 1.0) ); // optimize the scene graph, remove rendundent nodes and state etc. osgUtil::Optimizer optimizer; optimizer.optimize(_loadedModel.get()); //add the model to the transform. _modelTransform.get()-addChild(_loadedModel.get()); // set the scene to render viewer.setSceneData(_rootNode.get()); _ Initialization in OSG 2.8.2 is below: HELP - what am I doing wrong? _ osgViewer::Viewer viewer; osg::ref_ptrosg::GraphicsContext::Traits traits = new osg::GraphicsContext::Traits; traits-screenNum = 0; traits-x = 0; traits-y = 0; traits-width = 640; traits-height = 480; traits-red = 8; traits-blue = 8; traits-green = 8; traits-alpha = 0; traits-windowDecoration = false; traits-pbuffer = false; traits-doubleBuffer = true; traits-sharedContext = 0; traits-windowName = external-app; gtk_init (argc, argv); // set the xid of the GtkSocket and connect the GtkPlug guint32 xid = wGtkPlug; GtkWidget *plug = gtk_plug_new(xid); gtk_signal_connect(GTK_OBJECT(plug), destroy-event, GTK_SIGNAL_FUNC(destroy_event), viewer); // Hike logging up osg::setNotifyLevel (osg::NOTICE); // set the viewer to display in the plug traits-inheritedWindowData = new osgViewer::GraphicsWindowX11::WindowData(gtk_plug_get_id(GTK_PLUG(plug))); viewer.getCamera()-setGraphicsContext
Re: [osg-users] NodeCallBack vs accept
OK, good optimization :) So Maybe using the apply function is only a good point when defining custom visitors, no ? Due to the updateVisitor behavior, seems that it's better using NodeCallbacks on predefined visitors... is it correct ? Where do you think I can find info about visitors application order in OSG ? I'm looking from the OcclusionQueryNode.cpp coming from you, and just to understand OSG design, could it possible to create an apply function in your node instead of create an accept one in the CullVisitor.cpp ? Just to know if when I create my own nodes, I must modify the cullvisitor.cpp because is not a good point for me. Thanks Eric -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17040#17040 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [vpb] virtual reality builder
Lanmeivr company is superior in solving system simulation problems,specializing system simulation research and development under OSG platform. Lanmeivr’s has owned 30 patents and our simulator and system simulation products has been popular among more than 20 foreign countries such as France, America, Holand, Hinland, Russia, India, Egypt, Saudi Arabia, Malaysia, Indonesia, Costarica, Argentina, Chile,etc. Lanmeivr Company undertake the following virtual reality projects: 1. training system VR for cars, racing cars, special vehicles, aircraft (multi-DOF) 2.system simulation for industrial production units (single / multipeople ) 3.system simulation for weapons and equipment 4.3D digital city system development; (Stand alone / Network Version) 5.3D digital factory system development (Stand alone / Network Version) 6.3D science fiction film production services. www.lanmeivr.com [Image: http://i911.photobucket.com/albums/ac315/lanmeivr/3screensimulator.jpg ][/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17041#17041 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgIntrospection / gen_wrapper - How to use ist?
Hi Torben, I'm not the author of genwrapper, just the maintainer of the OSG side, and as yet I haven't tried using genwrapper outside the OSG, but it should be possible to get it to build wrappers for your own C++ classes. As inspiration I would suggest having a look at how OpenSceneGraph/CMakeLists.txt invokes genwrapper - it's done as two passes, one to generate the doxygen generated xml files for your classes, then a second pass to parse this into wrappers. The script looks like: # # Provide target for generating wrappers # SET(GENWRAPPER genwrapper) ADD_CUSTOM_TARGET(wrappers COMMAND ${GENWRAPPER} -c ${OpenSceneGraph_SOURCE_DIR}/src/osgWrappers/genwrapper.conf -t ${OpenSceneGraph_SOURCE_DIR}/src/osgWrappers/Doxyfile.template -d ${OpenSceneGraph_SOURCE_DIR} | doxygen - COMMAND ${GENWRAPPER} -c ${OpenSceneGraph_SOURCE_DIR}/src/osgWrappers/genwrapper.conf -l ${OpenSceneGraph_SOURCE_DIR} ) Note the two files OpenSceneGraph/src/osgWrappers/genwrapper.conf and OpenSceneGarph/src/osgWrappers/Doxyfile.template that guide what genwrapper should do when building the wrappers. The Doxyfile.template is the part that will point to the C++ headers to parse. Robert. On Thu, Sep 3, 2009 at 5:42 PM, Torben Dannhauerz...@saguaro-fight-club.de wrote: Hi, I'm building an osg based visual system for simulators ( e.g. flight simulators). I want to use the osgLua Nodekit for scripting support and discovered that it is build on osgIntrospection. Now I'd like to know how to enable osgIntrospection for my own classes. I have read that modification of my osg classes are not requiered, because the osgIntrospection framework is able to do it automaticaly via gen_wrapper. Unfortunalety i've only found documantation for an old osg version here: http://www.openscenegraph.org/projects/osg/wiki/GenWrapper . What have I to do to make my osg (2.8.2) classes osgIntrospection ready? Thank you very much! Cheers, Torben -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17022#17022 ___ 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] GraphicsContext resizedCallback/resizedImplementation bug
Hi Steven, I think that this issue might have been resolved in 2.8.2. I would strongly recommend upgrading to 2.8.2. The API changes should be pretty isolated w.r.t 2.2 so porting should be quite straight forward and you'll get lots and lots of bug fixes as well as general improvements. And.. you'll be far easier to support as trying to remember little details of old code is beyond my meager brain is capable of. Robert. On Thu, Sep 3, 2009 at 7:56 PM, Steven Powersstevenapow...@gmail.com wrote: Hi, OSG 2.2 The original issue: I have a graphics context with multiple cameras. Some of which are rendering to an attached image. When I resize the graphics context ALL of the camera's viewports are resized. I did not want this to happen so I defined my own ResizedCallback which will only resize Cameras that I tell it to. Issue with ResizedCallback: I can resize the camera's I want to and leave the others the way they are just fine. But since I defined my own ResizedCallback GraphicsContext no longer updates the following values as it would normally do in GraphicsContext::resizedImplementation(). Code: _traits-x = x; _traits-y = y; _traits-width = width; _traits-height = height; Now when I query these values from GraphicsContext they no longer equate to the values I set by resizing the context. This is because GraphicsContext::resizedImplementation() is not called when a ResizedCallback is set. It is impossible to set the traits values in the ResizedCallback since the values are private. To repair this I would change: Code: void resized(int x, int y, int width, int height) { if (_resizedCallback.valid()) _resizedCallback-resizedImplementation(this, x, y, width, height); else resizedImplementation(x, y, width, height); } to Code: void resized(int x, int y, int width, int height) { if (_resizedCallback.valid()) _resizedCallback-resizedImplementation(this, x, y, width, height); else resizedImplementation(x, y, width, height); _traits-x = x; _traits-y = y; _traits-width = width; _traits-height = height; } Or something similar. Thank you! Cheers, Steven[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17030#17030 ___ 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] [vpb] virtual reality builder
Is this spam? The website looks plain dodgy Kim. 2009/9/4 Lulin Wang osgfo...@tevs.eu: Lanmeivr company is superior in solving system simulation problems,specializing system simulation research and development under OSG platform. Lanmeivr’s has owned 30 patents and our simulator and system simulation products has been popular among more than 20 foreign countries such as France, America, Holand, Hinland, Russia, India, Egypt, Saudi Arabia, Malaysia, Indonesia, Costarica, Argentina, Chile,etc. Lanmeivr Company undertake the following virtual reality projects: 1. training system VR for cars, racing cars, special vehicles, aircraft (multi-DOF) 2.system simulation for industrial production units (single / multipeople ) 3.system simulation for weapons and equipment 4.3D digital city system development; (Stand alone / Network Version) 5.3D digital factory system development (Stand alone / Network Version) 6.3D science fiction film production services. www.lanmeivr.com [Image: http://i911.photobucket.com/albums/ac315/lanmeivr/3screensimulator.jpg ][/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17041#17041 ___ 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] [osgPlugins] bmp load vertically flipped
On 3/09/09 9:32 PM, stefan nortd wrote: Granted that different image types store pixels differently I would still assume that the image loader should nevertheless be consistent across different image format. I guess this is an assumption that depends how low-level one approaches pixel data. So I record it is not a bug in the image loader. correct? Agreed, it's not a bug but a missing feature. Could you run your code with OSG_NOTIFY_LEVEL=DEBUG_INFO and grep the output for 'BMP Image is upside-down' (which indicates 'height0')? The models I have do not have negative height so if your BMP does we could expose it and flip the Image automatically. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How do I create/update uniform struct?
Hi Wyatt, I don't know where to start as I don't understand your point of confusion. The best thing you can do is go look at the include/osg/Unform header, and the examples that use uniforms, just do a search through the OSG sources for osg::Uniform to see how it's used. Robert. On Thu, Sep 3, 2009 at 4:51 PM, Wyatt Earpwyattbsearp1...@gmail.com wrote: I want to use a struct in my glsl shader. osg::StateSet::getOrCreateUniform allows for the specification of Uniform::Type, but I don't see an enumeration for struct. How would I create/set the uniform struct? WE ___ 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] Question regarding rtt
Hi Brett, On Fri, Sep 4, 2009 at 6:47 AM, Brett Thomas Leebrettle...@hotmail.com wrote: Thank you very much for the reply sir.If I dont want to use viewer in my run can I update the camera??If so how can i?? If you don't have a viewer then you won't be able to render anything. It's the viewer that dispatches the update, events and rendering traversals. If you don't use the osgViewer classes then you are welcome to roll your own viewer classes, if you do this you are on your own. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [vpb] virtual reality builder
Yes I agree you about this is spammer :) Ümit Uzun 2009/9/4 Kim Bale kcb...@googlemail.com Is this spam? The website looks plain dodgy Kim. 2009/9/4 Lulin Wang osgfo...@tevs.eu: Lanmeivr company is superior in solving system simulation problems,specializing system simulation research and development under OSG platform. Lanmeivr’s has owned 30 patents and our simulator and system simulation products has been popular among more than 20 foreign countries such as France, America, Holand, Hinland, Russia, India, Egypt, Saudi Arabia, Malaysia, Indonesia, Costarica, Argentina, Chile,etc. Lanmeivr Company undertake the following virtual reality projects: 1. training system VR for cars, racing cars, special vehicles, aircraft (multi-DOF) 2.system simulation for industrial production units (single / multipeople ) 3.system simulation for weapons and equipment 4.3D digital city system development; (Stand alone / Network Version) 5.3D digital factory system development (Stand alone / Network Version) 6.3D science fiction film production services. www.lanmeivr.com [Image: http://i911.photobucket.com/albums/ac315/lanmeivr/3screensimulator.jpg][/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17041#17041 ___ 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] Generate example solution with osg Examples
Hi All, Is there a way to generate a solution that only contains the osg Example projects with the current CMakeLists.txt configuration? I've looked through the mailing list and the CMakeLIst files without finding an answer. I'm working on MSVC80 and find that a solution containing all the osg Core projects, applications and examples is a bit cumbersome to work with. I don't have a hole lot experience with CMake yet, but if there are no objections, I might have wack at setting up the CMakeLists to support a standalone example project. Filip ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Generate example solution with osg Examples
Hi Filip; This is impossible because all example uses generated library, includes and dll's on your own platform so you have to compile OSG Core library too. Or if you have latest OSG binary installed your system before and create related environment variables you can create your sln normally and when compiling step in VisualStudio you may exclude core libraries and build only examples. I haven't tried but it would work. HTH. Regards. Ümit Uzun 2009/9/4 Filip Holm filip.h...@gmail.com Hi All, Is there a way to generate a solution that only contains the osg Example projects with the current CMakeLists.txt configuration? I've looked through the mailing list and the CMakeLIst files without finding an answer. I'm working on MSVC80 and find that a solution containing all the osg Core projects, applications and examples is a bit cumbersome to work with. I don't have a hole lot experience with CMake yet, but if there are no objections, I might have wack at setting up the CMakeLists to support a standalone example project. Filip ___ 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] Generate example solution with osg Examples
Hi Ümit, I don't see why it should be imposible to have two side by side solutions generated by Cmake where one contains the osg Core projects and one contains the Example projects (of course depending on the core libs). I'm not trying to address the solution build time, but rather the size of it with regards to the amount of projects it containes. Thanks for the response. Filip On 9/4/09, Ümit Uzun umituzu...@gmail.com wrote: Hi Filip; This is impossible because all example uses generated library, includes and dll's on your own platform so you have to compile OSG Core library too. Or if you have latest OSG binary installed your system before and create related environment variables you can create your sln normally and when compiling step in VisualStudio you may exclude core libraries and build only examples. I haven't tried but it would work. HTH. Regards. Ümit Uzun 2009/9/4 Filip Holm filip.h...@gmail.com Hi All, Is there a way to generate a solution that only contains the osg Example projects with the current CMakeLists.txt configuration? I've looked through the mailing list and the CMakeLIst files without finding an answer. I'm working on MSVC80 and find that a solution containing all the osg Core projects, applications and examples is a bit cumbersome to work with. I don't have a hole lot experience with CMake yet, but if there are no objections, I might have wack at setting up the CMakeLists to support a standalone example project. Filip ___ 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] [vpb] virtual reality builder
Hi guys, Since this is already the third message by this user with the same content I consider it a spammer too. I am sorry for this because I initially accepted him/her on the forum, because he/she actually changed the profile after a request by me. User is now under moderation again which means his/her messages must be approved by one of the moderator before it is sent to the forum and ML. kind regards, Roland Smeenk (Forum moderator) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17052#17052 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] world space to screen space matrices understanding
Hi all, I'm trying to simply project any 3D point ,which is already in world space, into screen space. I know how to do it without osg : screen space coords = bias matrix * camera projection matrix * camera view matrix * world space coordinates Those coordinates are in [0, 1] range, so multiply by viewport dimensions to get window coordinates. but i do not succeed doing it with osg because i m still not familiar with it... My current code is * osg::Camera * cam = _view-getCamera(); osg::Matrix viewMatrix = cam-getViewMatrix(); osg::Matrix projectionMatrix = cam-getProjectionMatrix(); osg::Matrix windowMatrix = cam-getViewport()-computeWindowMatrix(); osg::Vec4d screenCoords = windowMatrix.postMult (projectionMatrix.postMult (viewMatrix.postMult (_refPoint)));* I saw windowMatrix is the bias matrix and the viewport scale. refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen space ) and as operator * is not defined to multiply a Matrix with an Vec4d, i use postMult function. But i dont get a valid result... what did i missed ? :-x Thanks for your attention Regards, Harold ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] world space to screen space matrices understanding
Hi Harold, OSG uses standard C arrays to store matrices. Which means these are row major matrices. This changes order of operands. You should multiply point by matrix not matrix by point. In your code you should rather preMultiply the matrices. example: osg::Matrix viewMatrix = camera-getViewMatrix(); osg::Vec3d viewSpacePoint = worldSpacePoint * viewMatrix; Cheers, Wojtek Lewandowski - Original Message - From: Harold Comere To: osg-users@lists.openscenegraph.org Sent: Friday, September 04, 2009 1:30 PM Subject: [osg-users] world space to screen space matrices understanding Hi all, I'm trying to simply project any 3D point ,which is already in world space, into screen space. I know how to do it without osg : screen space coords = bias matrix * camera projection matrix * camera view matrix * world space coordinates Those coordinates are in [0, 1] range, so multiply by viewport dimensions to get window coordinates. but i do not succeed doing it with osg because i m still not familiar with it... My current code is osg::Camera * cam = _view-getCamera(); osg::Matrix viewMatrix = cam-getViewMatrix(); osg::Matrix projectionMatrix = cam-getProjectionMatrix(); osg::Matrix windowMatrix = cam-getViewport()-computeWindowMatrix(); osg::Vec4d screenCoords = windowMatrix.postMult (projectionMatrix.postMult (viewMatrix.postMult (_refPoint))); I saw windowMatrix is the bias matrix and the viewport scale. refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen space ) and as operator * is not defined to multiply a Matrix with an Vec4d, i use postMult function. But i dont get a valid result... what did i missed ? :-x Thanks for your attention Regards, Harold -- ___ 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] world space to screen space matrices understanding
Hi Wojciech, Thanks for your answer. I did what you suggest at my first try following an old topic about this subject. But as i had not understand why it uses a premult i changed it, thanks for explanation. If i use this code, i get near good result, using Vec3d instead of Vec4d with homogeneous coordinates * osg::Vec3d screenCoords = _refPoint * viewMatrix * projectionMatrix * windowMatrix;* i get screen coords ( 1069, 970, 1. ) but my viewport is ( 0, 0, 1024, 768 ). The refPoint is in the view frustum so this result is not valid too :-x If i use a Vec4d to have homogeneous coordinates, i get a worth result ... i'm a bit confused. Regards, Harold 2009/9/4 Wojciech Lewandowski lewandow...@ai.com.pl Hi Harold, OSG uses standard C arrays to store matrices. Which means these are row major matrices. This changes order of operands. You should multiply point by matrix not matrix by point. In your code you should rather preMultiply the matrices. example: osg::Matrix viewMatrix = camera-getViewMatrix(); osg::Vec3d viewSpacePoint = worldSpacePoint * viewMatrix; Cheers, Wojtek Lewandowski - Original Message - *From:* Harold Comere harold.com...@gmail.com *To:* osg-users@lists.openscenegraph.org *Sent:* Friday, September 04, 2009 1:30 PM *Subject:* [osg-users] world space to screen space matrices understanding Hi all, I'm trying to simply project any 3D point ,which is already in world space, into screen space. I know how to do it without osg : screen space coords = bias matrix * camera projection matrix * camera view matrix * world space coordinates Those coordinates are in [0, 1] range, so multiply by viewport dimensions to get window coordinates. but i do not succeed doing it with osg because i m still not familiar with it... My current code is * osg::Camera * cam = _view-getCamera(); osg::Matrix viewMatrix = cam-getViewMatrix(); osg::Matrix projectionMatrix = cam-getProjectionMatrix(); osg::Matrix windowMatrix = cam-getViewport()-computeWindowMatrix(); osg::Vec4d screenCoords = windowMatrix.postMult (projectionMatrix.postMult (viewMatrix.postMult (_refPoint)));* I saw windowMatrix is the bias matrix and the viewport scale. refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen space ) and as operator * is not defined to multiply a Matrix with an Vec4d, i use postMult function. But i dont get a valid result... what did i missed ? :-x Thanks for your attention Regards, Harold -- ___ 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] [vpb] virtual reality builder
Dude enough already, one post about your company is enough __ Gordon Tomlinson gor...@gordontomlinson.com IM: gordon3db...@3dscenegraph.com www.vis-sim.com www.gordontomlinson.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Lulin Wang Sent: Friday, September 04, 2009 4:40 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] [vpb] virtual reality builder Lanmeivr company is superior in solving system simulation problems,specializing system simulation research and development under OSG platform. Lanmeivr’s has owned 30 patents and our simulator and system simulation products has been popular among more than 20 foreign countries such as France, America, Holand, Hinland, Russia, India, Egypt, Saudi Arabia, Malaysia, Indonesia, Costarica, Argentina, Chile,etc. Lanmeivr Company undertake the following virtual reality projects: 1. training system VR for cars, racing cars, special vehicles, aircraft (multi-DOF) 2.system simulation for industrial production units (single / multipeople ) 3.system simulation for weapons and equipment 4.3D digital city system development; (Stand alone / Network Version) 5.3D digital factory system development (Stand alone / Network Version) 6.3D science fiction film production services. www.lanmeivr.com [Image: http://i911.photobucket.com/albums/ac315/lanmeivr/3screensimulator.jpg ][/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17041#17041 ___ 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] GraphicsContext resizedCallback/resizedImplementation bug
Hi, I suspected that as well ... but I browsed the source code for 2.8.2 and it looked like it would exhibit the same problem. It might be a couple months before I am able to upgrade to 2.8.2. Thank you! Cheers, Steven -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17058#17058 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie plugin missing?
Hi, thanks for your reply. I tryied to install quicktime sdk for windows how ever I has not able to download it from https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=19910 . I need to have a specific account to do it. I used the following link to get the link for quicktime sdk for window: http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio/VisualStudioPlugins Is there any other way to get this? Thank you! Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17059#17059 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie plugin missing?
Hi Alex; You only create an account that's it. And also I have already send SDK to your mail address. HTH. Ümit Uzun 2009/9/4 Alex Malhao franciskovi...@gmail.com Hi, thanks for your reply. I tryied to install quicktime sdk for windows how ever I has not able to download it from https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=19910. I need to have a specific account to do it. I used the following link to get the link for quicktime sdk for window: http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio/VisualStudioPlugins Is there any other way to get this? Thank you! Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17059#17059 ___ 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] world space to screen space matrices understanding
Hi Harold, osg::Vec3d screen Coords = _refPoint * viewMatrix * projectionMatrix * windowMatrix; If model matrix is identity, above formula should work. Are you sure your point is in the frustum ? Do you see it ? If you do, then maybe you skipped model matrix (are there any Transforms set as ancestors?) Or maybe one of the matrices in your formula (most probably view or projection) has changed since you retrieved it ? View matrix is updated by manipulators in event traversal, if you read it before there is a chance it got updated. I guess auto NEAR/FAR projection adjustment should not matter here, but to be really safe, check if DO_NOT_COMPUTE_NEAR_FAR camera flag changes anything. Also, to be 100% sure I would check windowMatrix under debugger if it really corresponds to your expected viewport. You should get the same results with vec4 and vec3. If you use 4d coords make sure to divide xyz by w before retrieving 3d coord part. Wojtek - Original Message - From: Harold Comere To: OpenSceneGraph Users Sent: Friday, September 04, 2009 2:45 PM Subject: Re: [osg-users] world space to screen space matrices understanding Hi Wojciech, Thanks for your answer. I did what you suggest at my first try following an old topic about this subject. But as i had not understand why it uses a premult i changed it, thanks for explanation. If i use this code, i get near good result, using Vec3d instead of Vec4d with homogeneous coordinates osg::Vec3d screenCoords = _refPoint * viewMatrix * projectionMatrix * windowMatrix; i get screen coords ( 1069, 970, 1. ) but my viewport is ( 0, 0, 1024, 768 ). The refPoint is in the view frustum so this result is not valid too :-x If i use a Vec4d to have homogeneous coordinates, i get a worth result ... i'm a bit confused. Regards, Harold 2009/9/4 Wojciech Lewandowski lewandow...@ai.com.pl Hi Harold, OSG uses standard C arrays to store matrices. Which means these are row major matrices. This changes order of operands. You should multiply point by matrix not matrix by point. In your code you should rather preMultiply the matrices. example: osg::Matrix viewMatrix = camera-getViewMatrix(); osg::Vec3d viewSpacePoint = worldSpacePoint * viewMatrix; Cheers, Wojtek Lewandowski - Original Message - From: Harold Comere To: osg-users@lists.openscenegraph.org Sent: Friday, September 04, 2009 1:30 PM Subject: [osg-users] world space to screen space matrices understanding Hi all, I'm trying to simply project any 3D point ,which is already in world space, into screen space. I know how to do it without osg : screen space coords = bias matrix * camera projection matrix * camera view matrix * world space coordinates Those coordinates are in [0, 1] range, so multiply by viewport dimensions to get window coordinates. but i do not succeed doing it with osg because i m still not familiar with it... My current code is osg::Camera * cam = _view-getCamera(); osg::Matrix viewMatrix = cam-getViewMatrix(); osg::Matrix projectionMatrix = cam-getProjectionMatrix(); osg::Matrix windowMatrix = cam-getViewport()-computeWindowMatrix(); osg::Vec4d screenCoords = windowMatrix.postMult (projectionMatrix.postMult (viewMatrix.postMult (_refPoint))); I saw windowMatrix is the bias matrix and the viewport scale. refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen space ) and as operator * is not defined to multiply a Matrix with an Vec4d, i use postMult function. But i dont get a valid result... what did i missed ? :-x Thanks for your attention Regards, Harold -- ___ 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] osgmovie plugin missing?
Hi thanks again for the file! Now that I installed quicktime sdk, I used CMake to configure and generate, with the new quicktime links (like exposed in http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio/VisualStudioPlugins). Then I open the project in VisualStudio and build it. However the same error percists: Code: Warning: Could not find plugin to read objects form file xpto.mov. Unable to read file xpto.mov Do I need to Rebuild the whole project? Thank you! Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17062#17062 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie plugin missing?
Hi Alex; Yes you should rebuild OSG to use the QuickTime because to generate qt osg plugin. Regards. Ümit Uzun 2009/9/4 Alex Malhao franciskovi...@gmail.com Hi thanks again for the file! Now that I installed quicktime sdk, I used CMake to configure and generate, with the new quicktime links (like exposed in http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio/VisualStudioPlugins). Then I open the project in VisualStudio and build it. However the same error percists: Code: Warning: Could not find plugin to read objects form file xpto.mov. Unable to read file xpto.mov Do I need to Rebuild the whole project? Thank you! Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17062#17062 ___ 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 do I create/update uniform struct?
Wyatt Earp schrieb: How would I create/set the uniform struct? You don't create/set the whole struct at once, but the individual members of the struct. OpenGL recognizes struct members by the typical dot notation name of struct.name of member. regards Ralph ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie plugin missing?
Ok thank you again! Using this qt plugin am I going to hear any sound? Or just the video without any sound? Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17068#17068 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] world space to screen space matrices understanding
Hi again, I did my test a application initialisation, i guess before any matrice initialization or first update. I got good results doing it after the application has been fully initialized, so it's okay.. Thank you for your advices :) Regards, Harold 2009/9/4 Wojciech Lewandowski lewandow...@ai.com.pl *Hi Harold,* ** * osg::Vec3d screen **Coords = _refPoint * viewMatrix * projectionMatrix * windowMatrix;* ** If model matrix is identity, above formula should work. Are you sure your point is in the frustum ? Do you see it ? If you do, then maybe you skipped model matrix (are there any Transforms set as ancestors?) Or maybe one of the matrices in your formula (most probably view or projection) has changed since you retrieved it ? View matrix is updated by manipulators in event traversal, if you read it before there is a chance it got updated. I guess auto NEAR/FAR projection adjustment should not matter here, but to be really safe, check if DO_NOT_COMPUTE_NEAR_FAR camera flag changes anything. Also, to be 100% sure I would check windowMatrix under debugger if it really corresponds to your expected viewport. You should get the same results with vec4 and vec3. If you use 4d coords make sure to divide xyz by w before retrieving 3d coord part. Wojtek - Original Message - *From:* Harold Comere harold.com...@gmail.com *To:* OpenSceneGraph Users osg-users@lists.openscenegraph.org *Sent:* Friday, September 04, 2009 2:45 PM *Subject:* Re: [osg-users] world space to screen space matrices understanding Hi Wojciech, Thanks for your answer. I did what you suggest at my first try following an old topic about this subject. But as i had not understand why it uses a premult i changed it, thanks for explanation. If i use this code, i get near good result, using Vec3d instead of Vec4d with homogeneous coordinates * osg::Vec3d screenCoords = _refPoint * viewMatrix * projectionMatrix * windowMatrix;* i get screen coords ( 1069, 970, 1. ) but my viewport is ( 0, 0, 1024, 768 ). The refPoint is in the view frustum so this result is not valid too :-x If i use a Vec4d to have homogeneous coordinates, i get a worth result ... i'm a bit confused. Regards, Harold 2009/9/4 Wojciech Lewandowski lewandow...@ai.com.pl Hi Harold, OSG uses standard C arrays to store matrices. Which means these are row major matrices. This changes order of operands. You should multiply point by matrix not matrix by point. In your code you should rather preMultiply the matrices. example: osg::Matrix viewMatrix = camera-getViewMatrix(); osg::Vec3d viewSpacePoint = worldSpacePoint * viewMatrix; Cheers, Wojtek Lewandowski - Original Message - *From:* Harold Comere harold.com...@gmail.com *To:* osg-users@lists.openscenegraph.org *Sent:* Friday, September 04, 2009 1:30 PM *Subject:* [osg-users] world space to screen space matrices understanding Hi all, I'm trying to simply project any 3D point ,which is already in world space, into screen space. I know how to do it without osg : screen space coords = bias matrix * camera projection matrix * camera view matrix * world space coordinates Those coordinates are in [0, 1] range, so multiply by viewport dimensions to get window coordinates. but i do not succeed doing it with osg because i m still not familiar with it... My current code is * osg::Camera * cam = _view-getCamera(); osg::Matrix viewMatrix = cam-getViewMatrix(); osg::Matrix projectionMatrix = cam-getProjectionMatrix(); osg::Matrix windowMatrix = cam-getViewport()-computeWindowMatrix(); osg::Vec4d screenCoords = windowMatrix.postMult (projectionMatrix.postMult (viewMatrix.postMult (_refPoint)));* I saw windowMatrix is the bias matrix and the viewport scale. refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen space ) and as operator * is not defined to multiply a Matrix with an Vec4d, i use postMult function. But i dont get a valid result... what did i missed ? :-x Thanks for your attention Regards, Harold -- ___ 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
Re: [osg-users] osgmovie plugin missing?
Hi Alex; If your mov type video has sound, you will hear sound too. Regards. Ümit Uzun 2009/9/4 Alex Malhao franciskovi...@gmail.com Ok thank you again! Using this qt plugin am I going to hear any sound? Or just the video without any sound? Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17068#17068 ___ 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 do I create/update uniform struct?
This is what I was getting at... So if I have a struct in my app struct MyStruct { float fMember; int iMember; } _myStruct; And in my shader struct MyStruct { float fMember; int iMember; } myStruct; Then in my osg code I would do this... stateset-getOrCreateUniform(myStruct.fMember,osg::Uniform::FLOAT)-set(myStruct.fMember); stateset-getOrCreateUniform(myStruct.iMember,osg::Uniform::INT)-set(_myStruct.iMember); And then to access the updated data, just use the struct as usual? something = somethinelse * myStruct.fMember; Wyatt On Fri, Sep 4, 2009 at 9:47 AM, Ralph Kern usene...@rk-se.de wrote: Wyatt Earp schrieb: How would I create/set the uniform struct? You don't create/set the whole struct at once, but the individual members of the struct. OpenGL recognizes struct members by the typical dot notation name of struct.name of member. regards Ralph ___ 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] Generate example solution with osg Examples
I would suggest first make installing OSG somewhere. Then create a small CMakeLists.txt file that uses the FindOpenSceneGraph.cmake that is released with CMake 2.6.4 (see example in file). It should be quite easy to make most of the examples compile outside of the OSG's build system. For those with external dependencies like SDL or QT it will take a bit more work. .. Original Message ... On Fri, 4 Sep 2009 11:08:36 +0200 Filip Holm filip.h...@gmail.com wrote: Hi All, Is there a way to generate a solution that only contains the osg Example projects with the current CMakeLists.txt configuration? I've looked through the mailing list and the CMakeLIst files without finding an answer. I'm working on MSVC80 and find that a solution containing all the osg Core projects, applications and examples is a bit cumbersome to work with. I don't have a hole lot experience with CMake yet, but if there are no objections, I might have wack at setting up the CMakeLists to support a standalone example project. Filip ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Philip Lowman ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie plugin missing?
Hi, You can watch my old underwater simulation video which has quicktime plugin and play video in it from http://umituzun84.blogspot.com/2009/06/deepworker-submarine-simulator.html Regards. Ümit Uzun 2009/9/4 Ümit Uzun umituzu...@gmail.com Hi Alex; If your mov type video has sound, you will hear sound too. Regards. Ümit Uzun 2009/9/4 Alex Malhao franciskovi...@gmail.com Ok thank you again! Using this qt plugin am I going to hear any sound? Or just the video without any sound? Cheers, Alex -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17068#17068 ___ 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] none
http://www.codenamezero.org/sites/default/files/20090901%20-%20vidports.txt greetz, michael ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Dynamic projective textures (Applies to ShadowMaps too)
Hi, I have a small problem. Imagine the following scene: The viewer/cam can see two objects. One is very near and the other is very far away from the viewpoint. Both will be textured using the same projection source. The object that is very far away from the viewer is very near to the projection source and will therefor be textured very good. The other object which is very near to the viewer is very far away from the projection source and will therefor be textured not very well. I thought i could solve this issue by splitting the projection into chunks. Instead of using one huge projection and projection texture i would use a number of textures and projection sources. For example if the full projection source would cover a viewangle of about 90°x90° it could be split into four seamlessly attached segments with each about 22,5°x22,5°. Each segment/projection source could now use a projective texture which could be adapted to the distance of the objects that the chunk would cover. I thought i could also use midmap textures for each chunk to determine the level of datail of the texture that should be used for the projection. Any maybe i could use a depth map to determine the distance of the objects. I would do this before i apply the projective texture to determine the level of detail that i would use for each chunk. These images should illustrate the process. Here you can see two light sources instead of one large that casts a shadow map shadow. [Image: http://www.jotschi.de/wp-content/uploads/2009/09/512_1024_split_shadowmap.png ] This is the scene: [Image: http://www.jotschi.de/wp-content/uploads/2009/09/shadow_scene.png ] Do you think this i a good approach? I know this is not directly a osg related problem but perhaps you could give me some feedback about this approach. Thank you! Cheers, Johannes -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17077#17077 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] NodeCallBack vs accept
Eric Pouliquen wrote: OK, good optimization :) So Maybe using the apply function is only a good point when defining custom visitors, no ? Due to the updateVisitor behavior, seems that it's better using NodeCallbacks on predefined visitors... is it correct ? In the case of the UpdateVisitor, it's sole purpose is to call callbacks. There is no way to interact with it other than to add a callback. Where do you think I can find info about visitors application order in OSG ? I'm looking from the OcclusionQueryNode.cpp coming from you, and just to understand OSG design, could it possible to create an apply function in your node instead of create an accept one in the CullVisitor.cpp ? Just to know if when I create my own nodes, I must modify the cullvisitor.cpp because is not a good point for me. Your question is a little confusing. Referring to OcclusionQueryNode itself, it already has an apply() method (which it gets from META_Node). And the CullVisitor also has an apply(OcclusionQueryNode), which is where the cull visitor determines whether or not to traverse the OcclusionQueryNode children. When I was developing the OQN and it was not yet part of OSG, I was unable to modify the CullVisitor to do this work (of course), so I was doing the same work current in CullVisitor::apply(OcclusionQueryNode) inside of OcclusionQueryNode::traverse() instead. Once integrated into core OSG, I deleted the OcclusionQueryNode::traverse() function and moved its code into the CullVisitor. I'm not sure what, exactly, you're trying to do, so I'm not sure how to advise you. But I hope this info is helpful to you. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] none
What/Why ? also this has gone to the submission list __ Gordon Tomlinson gor...@gordontomlinson.com IM: gordon3db...@3dscenegraph.com www.vis-sim.com www.gordontomlinson.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of osg-us...@cyberfiber.org Sent: Friday, September 04, 2009 1:27 PM To: osg-users@lists.openscenegraph.org Subject: [osg-users] none http://www.codenamezero.org/sites/default/files/20090901%20-%20vidports.txt greetz, michael ___ 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] Derived classes and ref_ptr
Hi, I have a class derived from PositionAttitudeTransform. It's simply an Adapter it contains no new variables but fixes up some methods for osg::PAT to be used in an existing design for some navigation routines. The existing navigation library is fixed I can't change it to understand osg::ref_ptr,=. Objects of the Adapter class need to be created on the stack in the library. Is there any way to define such a class so that it can be used as a regular class with objects on the stack in my library but still be reference counted in OSG? Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17080#17080 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Derived classes and ref_ptr
Martin Beckett wrote on Friday, September 04, 2009 5:20 PM: Hi, I have a class derived from PositionAttitudeTransform. It's simply an Adapter it contains no new variables but fixes up some methods for osg::PAT to be used in an existing design for some navigation routines. The existing navigation library is fixed I can't change it to understand osg::ref_ptr,=. Objects of the Adapter class need to be created on the stack in the library. Is there any way to define such a class so that it can be used as a regular class with objects on the stack in my library but still be reference counted in OSG? It's really not a good idea to mix stack-created objects with reference counting (when the reference count hits zero and the stack-created object is deleted, bad things happen), but if you're *REALLY SURE* that you can be careful about it, *still don't do it*, because eventually someone else will modify your code (it might even be a future you) who won't be as careful. HTH :) -- Bryan Thrall FlightSafety International bryan.thr...@flightsafety.com P.S. You must be *REALLY REALLY SURE* to read this far, and if you are, I'll tell you the secret: all you have to do is declare a public destructor for your Adapter class to allow it to be created on the stack. See http://visualcpp.net/index.php?qID=65 for example. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Derived classes and ref_ptr
Don't think so, __ Gordon Tomlinson gor...@gordontomlinson.com IM: gordon3db...@3dscenegraph.com www.vis-sim.com www.gordontomlinson.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Martin Beckett Sent: Friday, September 04, 2009 6:20 PM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Derived classes and ref_ptr Hi, I have a class derived from PositionAttitudeTransform. It's simply an Adapter it contains no new variables but fixes up some methods for osg::PAT to be used in an existing design for some navigation routines. The existing navigation library is fixed I can't change it to understand osg::ref_ptr,=. Objects of the Adapter class need to be created on the stack in the library. Is there any way to define such a class so that it can be used as a regular class with objects on the stack in my library but still be reference counted in OSG? Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17080#17080 ___ 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] Derived classes and ref_ptr
[quote=Paul Martz]If you can (obviously) change your code to understand instances of your new custom class, then I don't understand why you can't change your code to understand instances of ref_ptrs to your new custom class. Please explain this restriction further. I have a complicated navigation library with a few objects representing a position fix, GPS location, range+bearing observation etc. This library works ! I want to re-use this in an OSG app. So I have written an adapter class where a position is now represented underneath by a PAT (which can be used directly in my OSG scene) but has the same name and implements the same set/get position operations as the existing position class. But since it is ultimately derived from Referenced it has a virtual dtor, cannot be create on the stack and cannot be copied with '=' I can make the dtor public, but the more complicated part is implementing the copy operator - since it has to handle copying all the parent class of PAT. The alternative of having a bunch of interface functions to copy parameters to/from the scenegraph nodes into existing 'position' objects seemed a poor design. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17084#17084 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Derived classes and ref_ptr
2009/9/5 Martin Beckett m...@mgbeckett.com: [quote=Paul Martz]If you can (obviously) change your code to understand instances of your new custom class, then I don't understand why you can't change your code to understand instances of ref_ptrs to your new custom class. Please explain this restriction further. I have a complicated navigation library with a few objects representing a position fix, GPS location, range+bearing observation etc. This library works ! I want to re-use this in an OSG app. So I have written an adapter class where a position is now represented underneath by a PAT (which can be used directly in my OSG scene) but has the same name and implements the same set/get position operations as the existing position class. But since it is ultimately derived from Referenced it has a virtual dtor, cannot be create on the stack and cannot be copied with '=' I can make the dtor public, but the more complicated part is implementing the copy operator - since it has to handle copying all the parent class of PAT. The alternative of having a bunch of interface functions to copy parameters to/from the scenegraph nodes into existing 'position' objects seemed a poor design. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17084#17084 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org Hi Martin, pimpl idiom may help you. That means you won't derive publicly from PositionAttitudeTransform but have pointer to its implementation. This is sometimes called a has-a relationship, rather than is-a relationship. You may expose the same function interface with PositionAttitudeTransform to outside world. Your methods will call PAT's methods. class MyAdapter { osg::ref_ptrosg::PositionAttitudeTransform m_sppat; public: MyAdapter() throw(std::bad_alloc) : m_sppat(new osg::PositionAttitudeTransform) { } // Transform methods inline void setReferenceFrame(osg::ReferenceFrame rf) { m_sppat-setReferenceFrame(rf); } ... // PositionAttitudeTransform methods inline void setPivotPoint(const osg::Vec3d pivot) { m_sppat-setPivotPoint(pivot); } .. }; you may need to implement all methods you need. I don't think you will need all public methods available in a PositionAttitudeTransform (including those are inherited). I didn't compile it but something like that should work. Does this help you? The constructor may throw. try { MyAdapter adapter; // call your library function } // PAT dies here catch (std::bad_alloc) { // out of memory } Ismail ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Derived classes and ref_ptr
Thanks but not really - then I can't use the new class in the scene graph. The idea was to have a 'location' object in the scenegraph which is a PAT as far as OSG is concerned but has methods which reflect the interface I'm used to and fit the needs of my problem domain. That I can do with an Adapter derived class It looks like the only way is to have a set of converter functions. Unfortunately the naming gets a bit complex because I have an osg::location class and a my::location class with the same interface but different internals. I think this is one of those areas where C++ falls behind Java or C# Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17086#17086 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Derived classes and ref_ptr
Hi Martin, 2009/9/5 Martin Beckett m...@mgbeckett.com: Thanks but not really - then I can't use the new class in the scene graph. Yes, you can, can't you? Pass your objects to constructor. I wouldn't do it, but you want if you want to. class MyAdapter { typedef osg::ref_ptrosg::PAT osg_pat_type; osg_pat_type m_sppat; public: // we'll you use explicit MyAdapter(osg_pat_type pat) : m_sppat(pat) { } explicit MyAdapter(PAT* pat) : m_sppat(pat) { } MyAdapter() : m_sppat(new osg::PAT) { } osg::PAT* release() { m_sppat.release(); } osg::ref_ptrosg::PAT GetPAT() /*const*/ { return m_sppat; } // if you want conversions, provide conversion operators... operator PAT*() { return m_sppat.get(); } }; Pass your object to constructor and call release before scope ends. You may automate this by adding a flag and checking that in destructor. e.g. const bool m_fShouldRelease; public: explicit MyAdapter(osg_pat_type pat) : m_sppat(pat), m_fShouldRelease(true) { } explicit MyAdapter(PAT* pat) : m_sppat(pat), m_fShouldRelease(true) { } MyAdapter() : m_sppat(new osg::PAT), m_fShouldRelease(false) { } ~MyAdapter() { if (m_fShouldRelease) release(); } The idea was to have a 'location' object in the scenegraph which is a PAT as far as OSG is concerned but has methods which reflect the interface I'm used to and fit the needs of my problem domain. That I can do with an Adapter derived class It looks like the only way is to have a set of converter functions. Unfortunately the naming gets a bit complex because I have an osg::location class and a my::location class with the same interface but different internals. You can use namespace aliases, or, typedef your my::location to something else; it may help. namespace my = AdapterNS; typedef AdapterNS::location AdapterLocation; or namespace AdapterNS { typedef ::my::location AdapterLocation; } // use AdapterNS::AdapterLocation. I think this is one of those areas where C++ falls behind Java or C# Martin How would you do it in C#? You can do a lot of strange-looking things in C++, which you can't do in a managed language, because run-time will not allow you (unless you explicitly express your intent is a non-verifiable code). -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17086#17086 ___ 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] Derived classes and ref_ptr
It appears that I forgot comments in constructors. 2009/9/5 Ismail Pazarbasi pazarb...@gmail.com: [snip] class MyAdapter { typedef osg::ref_ptrosg::PAT osg_pat_type; osg_pat_type m_sppat; public: // here is missing part // you will use this constructor to pass a osg::ref_ptrosg::PAT explicit MyAdapter(osg_pat_type pat) : m_sppat(pat) { } // you will use this constructor to pass a raw PAT* explicit MyAdapter(PAT* pat) : m_sppat(pat) { } // default constructor will create a new one. // you may alternatively set default value of pat to NULL in above // constructor and instantiate the object when pat is NULL. MyAdapter() : m_sppat(new osg::PAT) { } osg::PAT* release() { m_sppat.release(); } osg::ref_ptrosg::PAT GetPAT() /*const*/ { return m_sppat; } // if you want conversions, provide conversion operators... operator PAT*() { return m_sppat.get(); } }; [snip] ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] none
Gordon Tomlinson wrote: What/Why ? also this has gone to the submission list I thought you could use the information __ Gordon Tomlinson gor...@gordontomlinson.com IM: gordon3db...@3dscenegraph.com www.vis-sim.com www.gordontomlinson.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of osg-us...@cyberfiber.org Sent: Friday, September 04, 2009 1:27 PM To: osg-users@lists.openscenegraph.org Subject: [osg-users] none http://www.codenamezero.org/sites/default/files/20090901%20-%20vidports.txt greetz, michael ___ 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