[osg-users] RTT Cameras for computer vision simulation
Hi, I am looking to use OpenSceneGraph to simulate multi-camera images in real time, but my frame rates are not great with the number of cameras I need. I currently have 6 cameras rendering to 640x480 images and I see ~8fps max, with a lot of jitter. The osg examples have been a great help, but I wanted to ask for general advice before I dig too much deeper. Everything I have read indicates that GPU->CPU is a very slow operation, but I am wondering if I am actually maxed out or just doing something dumb. Here is my setup for N cameras: 0. Populate the scene with objects 1. Create the N osg::Cameras with RenderTargetImplementation of FRAME_BUFFER_OBJECT (PIXEL_BUFFER doesn't work for me yet) 2. Create N rgb 640x480 osg::Images and attach to the cameras 3. Add my scene to each camera 4. Add draw callbacks to each camera. 5. Add each camera to a root scene. 6. Create a viewer with the root scene. Now in a custom main loop, I do the following: 0. Read the requested camera poses from a message queue 1. Adjust the pose of each camera 2. Viewer.frame() 3. Each camera callback will fire 4. When all camera callbacks have fired, I read .data() from each Image. 5. Publish the N images in a single message, which gets serialized and sent over UDP to other processes. I still need to profile this to see where the bottleneck is, but my hunch is that I can speed up by rendering and reading the data from each camera independently instead of simultaneously. I am not sure how to do it yet, but I assume "Pixel Buffer Objects" will be part of the answer. Any suggestions on where to start would be appreciated! Cheers, Matt -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63398#63398 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [SOLVED] PNG Library Crashing - 32 vs 64 bit mismatch possible
Hi Dave Yes, I linked to those libraries intentionally, since cmake seemed to detect a 32-bit architecture. Since I have a 64-bit OS, I'd like to figure out how to get cmake to detect the appropriate architecture. >Thats a low priority for me right now, and I posted the real reason for the crash above. Thanks for your response. You will have to pick the compiler and thus the architecture you want to build for. After cleaning a cmake-cache the GUI will ask you which compiler you prefer. (so use 64bit if you like too) Unfortunately you still have to pick the correct 3rd-party lib depending on you target architecture. The only important thing is to use 64bit external libraries if you're building for 64bit. From there everything is automatic ... Cheers Sebastian -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63396#63396 ___ 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] OSG RECIPES Data
Hi Dave, One of the purpose of the osgRecipes project is to provide all source code used in the book OpenSceneGraph 3.0 Cookbook, published by Packt Publishing. And what you found is just corresponding to the second example in Chapter 5. And it should be a mistake... The correct code snippet, as shown in the book, is as below: image = osgDB::readImageFile( "0.ffmpeg", new osgDB::Options("format=vfwcap frame_rate=25") ); It in fact uses the FFmpeg plugin to load video stream from the webcam using the VFW option. You may change the filename to some other disk files like "c:/path/file.avi.ffmpeg" and then ignore the option string. But there is no "animate PNG" support in OSG... so sorry for the misdirection. :-) Also thank you for supporting the osgRecipes project. Wang Rui -- Original -- From: "Dave Sargrad";; Date: Wed, Apr 15, 2015 05:42 AM To: "osg-users"; Subject: [osg-users] OSG RECIPES Data Hi, I've found the osgRecipes (https://github.com/xarray/osgRecipes) to be quite useful. However most of the data is missing from these, and there is no proper reference to the location of the data. I stumbled on this (https://github.com/openscenegraph/osg-data) data. It seems to be a close fit to the recipes. However some data files are missing. For example right now I'm in cookbook_05_02. This cookbook is looking for one of two datafiles (in my case pic.png). I think this is just a placeholder, and I'm expected to drop my own "animated PNG" into place. I've tried several such png's found on the web, but none seem to do what one might expect. Code: osg::ref_ptr image; if ( arguments.argc()>1 ) image = osgDB::readImageFile( arguments[1] ); else { #ifdef WIN32 image = osgDB::readImageFile( "Images/bouncing_beach_ball.png" ); #else image = osgDB::readImageFile( "/dev/video0.ffmpeg" ); #endif } osg::ImageStream* imageStream = dynamic_cast( image.get() ); if ( imageStream ) imageStream->play(); I've never used animated png's before so I'm not sure how best to find a compatible image. In this code snippet, I replaced pic.png with a bouncing_beach_ball.png found here (http://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png). Thank you for any insights. Cheers, Dave -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63394#63394 ___ 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] [SOLVED] PNG Library Crashing - 32 vs 64 bit mismatch possible
SMesserschmidt wrote: > Hi Dave, > > C:/osg/OpenSceneGraph-3.2.2-rc2/3rdParty/x86/lib/libpng16.lib (found version > "1.6.7") > -> you are linking the 32bit libraries .. > > > > > > Hi, > > > > I've been struggling to get the PNG plugin working. I've built it, but the > > cookbook_02_7 is crashing down inside libpng16.dll. > > > > > > I have a couple of questions. > > 1] I would have thought that I am doing a 64-bit build, since I have a > > 64-bit OS. However when I run cmake/configure I see it report 32-bit > > architecture detected. > > > > > > > > > 32 bit architecture detected > > > 3rdParty-Package ENV variable > > > found:C:\osg\OpenSceneGraph-3.2.2-rc2\3rdParty/x86 > > > Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) > > > Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) > > > Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) > > > Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR) > > > Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) > > > Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) > > > Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) > > > Found unsuitable Qt version "" from NOTFOUND > > > Could NOT find Qt3 (missing: QT_QT_LIBRARY QT_INCLUDE_DIR > > > QT_MOC_EXECUTABLE) > > > Could NOT find GLUT (missing: GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) > > > Could NOT find wxWidgets (missing: wxWidgets_FOUND) > > > Found PNG: > > > optimized;C:/osg/OpenSceneGraph-3.2.2-rc2/3rdParty/x86/lib/libpng16d.lib;debug;C:/osg/OpenSceneGraph-3.2.2-rc2/3rdParty/x86/lib/libpng16.lib > > > (found version "1.6.7") > > > Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) > > > Configuring done > > > Generating done > > > > > > > > > > So I have been pointing my cookbooks (osgrecipes) to the x86 versions found > > in the 3rdParty folder: example > > C:/osg/OpenSceneGraph-3.2.2-rc2/3rdParty/x86/lib/libpng16.lib is the value > > I have set PNG_LIBRARY to. > > > > The current callstack I see when I crash is as follows: > > > > > > > 005dd4a8() Unknown > > > [Frames below may be incorrect and/or missing] > > > libpng16.dll!004dba8c() Unknown > > > > > > > > > > > osgdb_pngd.dll!ReaderWriterPNG::readPNGStream(std::basic_istream > > > > > & fin) Line 202 C++ > > > > > > > osgdb_pngd.dll!ReaderWriterPNG::readImage(const > > > std::basic_string,std::allocator > & > > > file, const osgDB::Options * options) Line 381 C++ > > > > > > osg100-osgDBd.dll!osgDB::Registry::ReadImageFunctor::doRead(osgDB::ReaderWriter > > > & rw) Line 915 C++ > > > osg100-osgDBd.dll!osgDB::Registry::read(const > > > osgDB::Registry::ReadFunctor & readFunctor) Line 1175 C++ > > > osg100-osgDBd.dll!osgDB::Registry::readImplementation(const > > > osgDB::Registry::ReadFunctor & readFunctor, > > > osgDB::Options::CacheHintOptions cacheHint) Line 1278 C++ > > > osg100-osgDBd.dll!osgDB::Registry::readImageImplementation(const > > > std::basic_string,std::allocator > & > > > fileName, const osgDB::Options * options) Line 1360 C++ > > > osg100-osgDBd.dll!osgDB::Registry::readImage(const > > > std::basic_string,std::allocator > & > > > fileName, const osgDB::Options * options) Line 221C++ > > > osg100-osgDBd.dll!osgDB::readImageFile(const > > > std::basic_string,std::allocator > & > > > filename, const osgDB::Options * options) Line 43 C++ > > > cookbook_02_07d.exe!osgDB::readImageFile(const > > > std::basic_string,std::allocator > & > > > filename) Line 82 C++ > > > cookbook_02_07d.exe!main(int argc, char * * argv) Line 16 C++ > > > [External Code] > > > > > > > > > > > > > > > > > Any suggestions would be appreciated. > > Cheers, > > Dave > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=63354#63354 > > > > > > > > > > > > ___ > > osg-users mailing list > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > > ___ > osg-users mailing list > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- > Post generated by Mail2Forum Yes, I linked to those libraries intentionally, since cmake seemed to detect a 32-bit architecture. Since I have a 64-bit OS, I'd like to figure out how to get cmake to detect the appropriate architecture. Thats a low priority for me right now, and I posted the real reason for the crash above. Thanks for your response. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63396#63396 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Thoughts on Vulkan
I think OSG is a bad fit for Vulkan. OSG has so much code to support FFP dataflows that Vulkan doesn't have. I personally think a Vulkan scenegraph could be made from the components of OSG (OSG 4.x?) but bringing along all of OSG's legacy code into a Vulkan space would be counterproductive. As far a stability of Vulkan, you are correct, it will have rough edges. But it's being built on the designs of Metal and Mantle and those already have a pretty good track record. And part of the point of Vulkan is to make a much smaller footprint, so driver stability is much easier to achieve. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OSG RECIPES Data
Hi, I've found the osgRecipes (https://github.com/xarray/osgRecipes) to be quite useful. However most of the data is missing from these, and there is no proper reference to the location of the data. I stumbled on this (https://github.com/openscenegraph/osg-data) data. It seems to be a close fit to the recipes. However some data files are missing. For example right now I'm in cookbook_05_02. This cookbook is looking for one of two datafiles (in my case pic.png). I think this is just a placeholder, and I'm expected to drop my own "animated PNG" into place. I've tried several such png's found on the web, but none seem to do what one might expect. Code: osg::ref_ptr image; if ( arguments.argc()>1 ) image = osgDB::readImageFile( arguments[1] ); else { #ifdef WIN32 image = osgDB::readImageFile( "Images/bouncing_beach_ball.png" ); #else image = osgDB::readImageFile( "/dev/video0.ffmpeg" ); #endif } osg::ImageStream* imageStream = dynamic_cast( image.get() ); if ( imageStream ) imageStream->play(); I've never used animated png's before so I'm not sure how best to find a compatible image. In this code snippet, I replaced pic.png with a bouncing_beach_ball.png found here (http://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png). Thank you for any insights. Cheers, Dave -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63394#63394 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Thoughts on Vulkan
Well Chris, I don't think that anyone has ruled out using Vulkan on OSG, it just that the verdict is out about adoption. Besides, as I have learned from my resent VR experience, sometimes early adoption is not the wise course of action. As for me, I will adopt Vulkan when I have a good understanding of how it works and the standards are stable. It took awhile before the standards for GLSL to be ironed out. I'm worried about it being the same way for Vulkan. D Glenn Chris Hanson wrote: > Personally, my thought on Vulkan is that it present an opportunity to solve a > number of long-standing problems that history has shown OpenGL now has as a > result of graphics software and hardware evolving. > > > OpenGL was intended as standardized moderately high-level abstraction layer. > Today, applications want to be able to choose and customize their high level > abstraction (which is what scene graphs like OSG and game engines like Unity > are) and those engines want a lower-level of the actual hardware. Vulkan > seeks to address this change. > > > > -- > Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/ > (http://www.alphapixel.com/) > Training • Consulting • Contracting > 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • > GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL > Legal/IP • Code Forensics • Digital Imaging • GIS • GPS • osgEarth • Terrain > • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • > Android > @alphapixel (https://twitter.com/alphapixel) facebook.com/alphapixel > (http://facebook.com/alphapixel) (775) 623-PIXL [7495] > > -- > Post generated by Mail2Forum David Glenn --- D Glenn 3D Computer Graphics Entertainment. www.dglenn.com -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63393#63393 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Noobie Problem of the Day - Cookbook Surface/Object Picking Not Working
Sure enough the Pick System works just fine if I disable 2 of my monitors. At least I've isolated, I'll figure out exactly why later. For now I'll stick with a single monitor. Cheers, Dave -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63392#63392 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT Camera does not render anything
Hi, thanks for the idea and the respond cbuchner1 =) I checked it to be sure. But I added the rtt camera to the scene graph. The structure is something like this. Ignore the "-", I wanted to create the diagram fast ;): root / \ (rtt cam) ( main scene with quad for texture from rtt cam) | (object from main scene) So it must be something else, I am trying to debug it. If I find the answer I will post it ;). In the meantime I am open for ideas as well ;). ... Thank you! Cheers, Andreas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63391#63391 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Best practice for dynamic StateSets & Geometry
Hi OSG friends, A common challenge for OSG users are the implications of the viewer threading model - by default the viewer.frame() will return before the draw dispatch is complete, meaning users (and the OSG) can start preparing the next frame before the current frame has completed. However, if you attempt to change a StateSet or Drawable in the frame update, you run the risk of modifying data that the OSG is still working with in a background thread, resulting in crashes. Often times you will see code dealing with this by setting the DataVariance of the object to DYNAMIC. Unfortunately as result the draw dispatch has to complete before the frame() returns, for me this dropped the frame rate in half. Recently I developed a more efficient solution for dealing with this and would like to hear your thoughts. The idea is similar to "double buffering" with the framebuffer - you create two copies of the data on start, one copy is write only, another copy is read only, and when the frame completes the roles are swapped. You can implement this idea for both Drawables and StateSets: - Dynamic Drawables (RigGeometry, MorphGeometry, etc): create a deep copy of the Drawable, decorate both Drawables with a FrameSwitch node. A FrameSwitch node is a variant of Group that only traverses even or non-even children based on the current FrameStamp. Code (https://github.com/OpenMW/openmw/blob/f7da9796692e14c79632cb85fa75a90b082cd863/components/nifosg/nifloader.cpp#L179) - Dynamic StateSets: Create two copies of the StateSet on start, then every frame in a NodeCallback swap the roles of these StateSets, apply changes to the first StateSet, then set the currently active StateSet on the Node. Code (https://github.com/scrawl/openmw/blob/osg/components/sceneutil/statesetupdater.cpp#L8) There are some downsides to this approach (mostly that for data that is just rarely changing, you have to apply every change twice), but other than that it works beautifully and now I've got 2x the framerate again. I'm curious how the OSG veterans are dealing with this. Anything I've missed? Cheers Jannik -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63390#63390 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] Qt Form integration
osgQt doesn't have a Qt Designer plugin for its GLWidget-derived class, so you can't plug it into your edited layouts directly. You could probably try to create your own one, using the guidelines here: http://doc.qt.io/qt-4.8/designer-creating-custom-widgets.html But a far easier option is just to leave a blank widget in the space where you want your osgQt widget to go and add it as a child after you've loaded your form in code. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: Сell multiplication
well, i trying to create the 3D model of crystal structure on atomic level, because the crystal structure is periodical i think it is right way to use one geode (which stores 3D model of elementary cell). But if i use the cycle for creating crystal lattice, the MatrixTransform's pointer rewrited every cycle and i think it is bad. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63387#63387 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] Qt Form integration
Hi, I´m also interested in this topic. Is there a way to use the forms editor of the qt creator to display and integrate a OSG Scene? Link seems to go on the same thread...? I already looked into the example osgviewerQt. Has anyone a link to deeper examples of Qt and OSG integration? ... Thank you! Cheers, Christian[/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63380#63380 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Сell multiplication
Hi Grigory, Could you explain what you mean by "Crystal Lattice". Knowing what you are actually trying to achieve help others guide you in the right direction. Robert. On 14 April 2015 at 07:38, Grigory Krivyakin wrote: > Hello > > I try to create a simple crystal lattice and dont know how make it better. > I create a original geode cell and use matrix translations: > > > Code: > > osg::ref_ptr root = new osg::Group; > osg::ref_ptr cell = Cell(); > > osg::ref_ptr transform = new osg::MatrixTransform; > transform->addChild(cell); > root->addChild(transform); > > for(int i = 0; i < 10; i++) { > for(int j=0; j < 10; j++) { > for(int k=0; k < 2; k++) { > osg::ref_ptr transform = new > osg::MatrixTransform; > transform->setMatrix(osg::Matrix::translate(i*4.0f, j*4.0f, k*4.0f)); > transform->addChild(cell); > root->addChild(transform); > } > } > } > > > > > this code creates the crystal lattice with 10 periods along axis X and Y, > and 2 periods along Z, but i think it is bad way, can some one give me some > advice, how make it right? > > > Sorry for my english. Thank you! > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=63376#63376 > > > > > > ___ > 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] [forum] add/remove nodes when rendering
Thank you both for your answers ! Robert : Having databases in the background could be a good solution, I had not thought about it. However I have looked at the functioning of osgDB::DatabasePager but as I'm not very familiar with its use I can't see clearly how it could be incorporated in my application. I currently ask the user to specify which files he wants to load (through a file browser) and then use readNodeFile to get the osg::Nodes associated to each file. From what I saw, in the DatabasePager, readNode is called internally from the filecache and I don't really see how it can be integrated. To remove/hide specified data from the scenegraph is it necessary to specify an expiryTime or is it possible to point out the node that must be remove (as in removeChild(osg::Node*)) ? I didn't find a lot of examples of use of the DatabasePager, do you think of one I could use to gain a better understanding of that tool ? Jan : OpenSceneGraph is actually included in another application, which have its own openGl parameters that's why I get back some view parameters and matrices. At first I called setUpViewerAsEmbeddedInWindow and getCamera inside the singleton when I created the viewer as it seemed logical but it didn't work. I tried several configurations and surprisingly realised that with those calls at each frame() it seemed to work properly (at least I can load several files and display them in my viewer) but I don't understand why it works that way and it is obviously not very efficient. Thanks, Sophie -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63383#63383 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Сell multiplication
Hello I try to create a simple crystal lattice and dont know how make it better. I create a original geode cell and use matrix translations: Code: osg::ref_ptr root = new osg::Group; osg::ref_ptr cell = Cell(); osg::ref_ptr transform = new osg::MatrixTransform; transform->addChild(cell); root->addChild(transform); for(int i = 0; i < 10; i++) { for(int j=0; j < 10; j++) { for(int k=0; k < 2; k++) { osg::ref_ptr transform = new osg::MatrixTransform; transform->setMatrix(osg::Matrix::translate(i*4.0f, j*4.0f, k*4.0f)); transform->addChild(cell); root->addChild(transform); } } } this code creates the crystal lattice with 10 periods along axis X and Y, and 2 periods along Z, but i think it is bad way, can some one give me some advice, how make it right? Sorry for my english. Thank you! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63376#63376 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RTT Camera does not render anything
Maybe you forgot to add the camera to the main scene graph? An addChild() into the scene graph root should do the trick. 2015-04-14 15:16 GMT+02:00 Andreas Schreiber : > Hi > > > I'm trying to generate a texture with a rtt-camera, so I can use this > texture later in my main scene. > To verify if the texture is correct I'm trying to put the texture on a > quad in my main scene. > > I use the following method for the rtt-camera, the red clearColor I used > to test what the camera renders, but it did not help me out. > > > Code: > osg::Camera *createRTTCamera(osg::Camera::BufferComponent buffer, > osg::Texture *tex, bool isAbsolute) > { > osg::ref_ptr camera = new osg::Camera; > osg::Vec4f textureStartColor = osg::Vec4f(1.0, 0.0, 0.0, 0.0); > camera->setClearColor(textureStartColor); > camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > > camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); > camera->setRenderOrder(osg::Camera::PRE_RENDER); > > if (tex) > { > tex->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); > tex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); > camera->setViewport(0, 0, tex->getTextureWidth(), > tex->getTextureHeight()); > camera->attach(buffer, tex); > } > if (isAbsolute) > { > camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); > camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0, 1.0, > 0.0, 1.0)); > camera->setViewMatrix(osg::Matrix::identity()); > osg::Vec3 corner = osg::Vec3(); > camera->addChild(createScreenQuad(1.0f, 1.0f, 1, corner)); > } > return camera.release(); > } > > > > In the main part I do the following: > > 1. I initialize the global texture2D variable with an image > > 2. Create the rrt camera with color_buffer, the texture (which is global), > and 1 for absolute > > 3. load geometry > > 4. Setup Light, here an example > > Code: > osg::ref_ptr sunLight = new osg::LightSource(); > sunLight.get()->setLight(createLightSpot(osg::Vec4(0, 1, 0, 0), > osg::Vec4(0, 1, 0, 1))); > sunLight.get()->setReferenceFrame(osg::LightSource::ABSOLUTE_RF); > sunLight.get()->setLocalStateSetModes(osg::StateAttribute::ON); > > > > 5. Add the light and the geometry to the rtt camera > 6. Add the light and the geometry to the main scene > > Now there should be the scene on the quad geometry which I generated, but > this is always rendered with the color of the light and nothing else on it. > It isn't even a mix of the light color and the clear color of the rtt > camera, its just the light color. > > Here is my quad generation as well: > > Code: > osg::ref_ptr planeRTT = new osg::Geode(); > osg::ref_ptr geometry = new osg::Geometry(); > planeRTT->addDrawable(geometry); > > osg::ref_ptr vertexArray = new osg::Vec3Array(); > vertexArray->push_back(osg::Vec3(1, -0.25, -1)); > vertexArray->push_back(osg::Vec3(1, 0.75, -1)); > vertexArray->push_back(osg::Vec3(1, 0.75, 1)); > vertexArray->push_back(osg::Vec3(1, -0.25, 1)); > geometry->setVertexArray(vertexArray); > > osg::ref_ptr colorArray = new osg::Vec4Array(); > colorArray->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); > geometry->setColorArray(colorArray); > geometry->setColorBinding(osg::Geometry::BIND_OVERALL); > > osg::ref_ptr texCoordArray = new osg::Vec2Array(); > texCoordArray->push_back(osg::Vec2(0.0f, 0.0f)); > texCoordArray->push_back(osg::Vec2(1.0f, 0.0f)); > texCoordArray->push_back(osg::Vec2(1.0f, 1.0f)); > texCoordArray->push_back(osg::Vec2(0.0f, 1.0f)); > geometry->setTexCoordArray(0, texCoordArray); > > geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_FAN, 0, > 4)); > > > planeRTT.get()->getOrCreateStateSet()->setTextureAttributeAndModes(0, > rttTexture.get(), osg::StateAttribute::ON); > > > > Did I miss something or did I mixed up some order?! > Would be grateful for any help! > > ... > > Thank you! > > Cheers, > Andreas > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=63381#63381 > > > > > > ___ > 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] RTT Camera does not render anything
Hi I'm trying to generate a texture with a rtt-camera, so I can use this texture later in my main scene. To verify if the texture is correct I'm trying to put the texture on a quad in my main scene. I use the following method for the rtt-camera, the red clearColor I used to test what the camera renders, but it did not help me out. Code: osg::Camera *createRTTCamera(osg::Camera::BufferComponent buffer, osg::Texture *tex, bool isAbsolute) { osg::ref_ptr camera = new osg::Camera; osg::Vec4f textureStartColor = osg::Vec4f(1.0, 0.0, 0.0, 0.0); camera->setClearColor(textureStartColor); camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); camera->setRenderOrder(osg::Camera::PRE_RENDER); if (tex) { tex->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); tex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); camera->setViewport(0, 0, tex->getTextureWidth(), tex->getTextureHeight()); camera->attach(buffer, tex); } if (isAbsolute) { camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0)); camera->setViewMatrix(osg::Matrix::identity()); osg::Vec3 corner = osg::Vec3(); camera->addChild(createScreenQuad(1.0f, 1.0f, 1, corner)); } return camera.release(); } In the main part I do the following: 1. I initialize the global texture2D variable with an image 2. Create the rrt camera with color_buffer, the texture (which is global), and 1 for absolute 3. load geometry 4. Setup Light, here an example Code: osg::ref_ptr sunLight = new osg::LightSource(); sunLight.get()->setLight(createLightSpot(osg::Vec4(0, 1, 0, 0), osg::Vec4(0, 1, 0, 1))); sunLight.get()->setReferenceFrame(osg::LightSource::ABSOLUTE_RF); sunLight.get()->setLocalStateSetModes(osg::StateAttribute::ON); 5. Add the light and the geometry to the rtt camera 6. Add the light and the geometry to the main scene Now there should be the scene on the quad geometry which I generated, but this is always rendered with the color of the light and nothing else on it. It isn't even a mix of the light color and the clear color of the rtt camera, its just the light color. Here is my quad generation as well: Code: osg::ref_ptr planeRTT = new osg::Geode(); osg::ref_ptr geometry = new osg::Geometry(); planeRTT->addDrawable(geometry); osg::ref_ptr vertexArray = new osg::Vec3Array(); vertexArray->push_back(osg::Vec3(1, -0.25, -1)); vertexArray->push_back(osg::Vec3(1, 0.75, -1)); vertexArray->push_back(osg::Vec3(1, 0.75, 1)); vertexArray->push_back(osg::Vec3(1, -0.25, 1)); geometry->setVertexArray(vertexArray); osg::ref_ptr colorArray = new osg::Vec4Array(); colorArray->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); geometry->setColorArray(colorArray); geometry->setColorBinding(osg::Geometry::BIND_OVERALL); osg::ref_ptr texCoordArray = new osg::Vec2Array(); texCoordArray->push_back(osg::Vec2(0.0f, 0.0f)); texCoordArray->push_back(osg::Vec2(1.0f, 0.0f)); texCoordArray->push_back(osg::Vec2(1.0f, 1.0f)); texCoordArray->push_back(osg::Vec2(0.0f, 1.0f)); geometry->setTexCoordArray(0, texCoordArray); geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_FAN, 0, 4)); planeRTT.get()->getOrCreateStateSet()->setTextureAttributeAndModes(0, rttTexture.get(), osg::StateAttribute::ON); Did I miss something or did I mixed up some order?! Would be grateful for any help! ... Thank you! Cheers, Andreas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63381#63381 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] add/remove nodes when rendering
Hello, On Tue, Apr 14, 2015 at 9:57 AM, Sophie Audonneau < sophie.audonne...@etu.univ-lorraine.fr> wrote: > In my draw function I have to do the following : > viewer_->setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2] > ,viewParams[3]); > viewer_->getCamera()->setProjectionMatrix( osg::Matrix(glMat_projection) ); > viewer_->getCamera()->setViewMatrix( osg::Matrix(glMat_modelview) ); > viewer_->frame(); > You are not supposed to do this on every frame, unless you are changing them all time. Are you doing some sort of augmented reality where they are provided by the tracking system? In a typical OSG application the matrices are typically set only once (or not at all - use the default!), the view matrix is often driven using a camera manipulator. The only thing you should do periodically is viewer_->frame(). I think your problem is that you are calling setUpViewerAsEmbeddedInWindow() on every frame - this sets the viewer up from scratch each time. There is no need to do that - you do it only once when you are creating the window. Please, have a look at the examples that ship with OSG. They show how to use OSG and how to integrate it with other libraries (which is what I assume you are doing, since you are calling setUpViewerAsEmbeddedInWindow() yourself). Re adding/removing nodes - that is perfectly fine, just do it before or after running the viewer_->frame() call, not in some sort of callback or separate thread. J. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] add/remove nodes when rendering
Hi Sophie, Are you simply looking to load databases in a background thread whilst the main thread and rendering threads get on with update, culling and rendering the scene? The OSG has an database paging class call osgDB::DatabasePager that is built into the osgViewer::Viewer/CompositeViewer that will automatically load databases and merge them with the main scene graph during the update traversal. This is built around the osg::PagedLOD class, but you can also use the osg::ProxyNode. Robert. On 14 April 2015 at 08:57, Sophie Audonneau < sophie.audonne...@etu.univ-lorraine.fr> wrote: > Hi, > > I work on a project for witch I need to remove/add nodes while > OpenSceneGraph is rendering. > I created a rendering window with OpenScenegraph and then I would like to > be able to load/unload objects in it. > I make the calls for OSG frame() function inside a draw function and I use > a singleton to manage the creation of the viewer. That way I managed to > have a single viewer and then load my OpenSceneGraph objects inside that > same viewer. > It seems fine but the problem is that I have to set camera and viewer > parameters each time I call frame(). If I don't nothing is displayed, > except OSG font colour. > Ideally I would like to set the viewer parameters only when I load an OSG > object for the first time. > > Currently when I load an OSG object I use my singleton to find the viewer > and to add the loaded node to the root associated to my viewer. > instance()->find_or_create_viewer(); //creates a viewer if none have been > created yet > instance()->addChild(loadedNode); > viewer_ = instance()->viewer(); // return a pointer to the unique > osgViewer::Viewer > > In my draw function I have to do the following : > viewer_->setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2] > ,viewParams[3]); > viewer_->getCamera()->setProjectionMatrix( osg::Matrix(glMat_projection) ); > viewer_->getCamera()->setViewMatrix( osg::Matrix(glMat_modelview) ); > viewer_->frame(); > > I have read that for dynamical rendering there was something to do about > object's variance so I tried a few things but I didn't find how to solve my > problem. > > Thank you! > > Cheers, > Sophie > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=63377#63377 > > > > > > ___ > 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] [forum] add/remove nodes when rendering
Hi, I work on a project for witch I need to remove/add nodes while OpenSceneGraph is rendering. I created a rendering window with OpenScenegraph and then I would like to be able to load/unload objects in it. I make the calls for OSG frame() function inside a draw function and I use a singleton to manage the creation of the viewer. That way I managed to have a single viewer and then load my OpenSceneGraph objects inside that same viewer. It seems fine but the problem is that I have to set camera and viewer parameters each time I call frame(). If I don't nothing is displayed, except OSG font colour. Ideally I would like to set the viewer parameters only when I load an OSG object for the first time. Currently when I load an OSG object I use my singleton to find the viewer and to add the loaded node to the root associated to my viewer. instance()->find_or_create_viewer(); //creates a viewer if none have been created yet instance()->addChild(loadedNode); viewer_ = instance()->viewer(); // return a pointer to the unique osgViewer::Viewer In my draw function I have to do the following : viewer_->setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2] ,viewParams[3]); viewer_->getCamera()->setProjectionMatrix( osg::Matrix(glMat_projection) ); viewer_->getCamera()->setViewMatrix( osg::Matrix(glMat_modelview) ); viewer_->frame(); I have read that for dynamical rendering there was something to do about object's variance so I tried a few things but I didn't find how to solve my problem. Thank you! Cheers, Sophie -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63377#63377 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org