[osg-users] Crash on some machines while rendering a progressive line strip
Hi, I have a code which renders a progressive line strip. When the line strip is unmasked to display it crashes on some machines. I use osg 3.6.4 with MFC Visual Studio 2019 with V142. The same problem was observed on osg 3.4.0 with MFC and Visual Studio 2013 v120. I am completely clueless as why it would crash since its not on my machine. I dont have the crash stack and other variable values. I have some observations.I will list my code and try to explain as best as possible. I migrated from osg 3.4.0 hoping 3.6.4 will resolve the issue. createHUDClubHdPts is called to create the scenegraph with the arrays. After which every frame AddCurPtToHandClubPath is called. This function updates the point in the array. As the frames are rendered a line that progressed based on the coordinates is displayed. The render target is a MFC MDI client window. The render frames are called from a thread of class OpenThreads::Thread While trying to debug the issue using logs. I found that when the numPtsinHandClubPath value goes to 199 it crashes. We can see that the array size is 2000. Everytime it used to crash after 200 values were updated into the coordinate vector and color vector. It has never crashed on two of my machines so I dont have the stack and variable values. Few remote machines it has crashed. Do let me know if there is any query or clarity required. ... Thank you! Cheers, Rakesh Code: //following variables are defined in COSGViewer osg::MatrixTransform* mtClubHandPath; osg::ref_ptr osgGeodeHandClubPath; unsigned int MaxPtsInHandCLubPath; osg::ref_ptr geomHandPath; osg::ref_ptr geomClubPath; osg::ref_ptr coordsHandPath; osg::ref_ptr coordsClubPath; osg::ref_ptr coloursHandPath; osg::ref_ptr coloursClubPath; osg::ref_ptr drawArrayHandPath; osg::ref_ptr drawArrayClubPath; osg::MatrixTransform* COSGViewer::createHUDClubHdPts(int X0, int Y0, int X1, int Y1, int textYOffset) { mtClubHandPath = new osg::MatrixTransform(); osg::Matrix m; m.makeTranslate(0, 0, 0); mtClubHandPath->setMatrix(m); RECT rect; ::GetWindowRect(m_hWnd, ); osg::ref_ptr linesGeom = new osg::Geometry(); osgGeodeHandClubPath = new osg::Geode(); osg::ref_ptr stateset = osgGeodeHandClubPath->getOrCreateStateSet(); stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); osg::ref_ptr linewidth = new osg::LineWidth(); linewidth->setWidth(4.0f); stateset->setAttributeAndModes(linewidth, osg::StateAttribute::ON); unsigned int n_points = 2000; MaxPtsInHandCLubPath = n_points; numPtsinHandClubPath = 0; geomHandPath = new osg::Geometry(); geomClubPath = new osg::Geometry(); coordsHandPath = new osg::Vec3Array;// (n_points); coordsClubPath = new osg::Vec3Array;// (n_points); coloursHandPath = new osg::Vec4Array;// (n_points); coloursClubPath = new osg::Vec4Array;// (n_points); for (unsigned int j = 0; j < n_points; ++j) { coordsHandPath->push_back(osg::Vec3(0, 0, 0)); coordsClubPath->push_back(osg::Vec3(0, 0, 0)); coloursHandPath->push_back(osg::Vec4(1.0, 0, 0, 1.0)); coloursClubPath->push_back(osg::Vec4(0, 0, 1.0, 1.0)); } geomHandPath->setVertexArray(coordsHandPath); geomClubPath->setVertexArray(coordsClubPath); drawArrayHandPath = new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP); //geomHandPath->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0, n_points)); geomHandPath->addPrimitiveSet(drawArrayHandPath); drawArrayClubPath = new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP); geomClubPath->addPrimitiveSet(drawArrayClubPath); geomHandPath->setColorArray(coloursHandPath, osg::Array::BIND_PER_VERTEX); geomClubPath->setColorArray(coloursClubPath, osg::Array::BIND_PER_VERTEX); geomHandPath->setDataVariance(osg::Object::DYNAMIC); geomClubPath->setDataVariance(osg::Object::DYNAMIC); osgGeodeHandClubPath->addDrawable(geomHandPath); osgGeodeHandClubPath->addDrawable(geomClubPath); mtClubHandPath->addChild(osgGeodeHandClubPath); return mtClubHandPath; } void COSGViewer::AddCurPtToHandClubPath(int ccurFr, int cPrevFr) { if (ccurFr != -1) { if (ccurFr == cPrevFr) return; } osg::Vec3Array * lcoordsHandPath = dynamic_cast(geomHandPath->getVertexArray()); osg::Vec3Array * lcoordsClubPath = dynamic_cast(geomClubPath->getVertexArray()); osg::Vec4Array * lcolorHandPath =
Re: [osg-users] Real time Strobing effect for on screen animation
Hi Robert, I did go through the osgmotionblurr example. But I guess I need to look at the problem from the render to texture view point. I looked at it from blur point of view and was trying to figure out a way to selectively read and write pixels in the GL accumulator. Will go in detail through the osgprerender and osgdistortion. Thanks for referring to these relevant examples and the steps for render to texture. Will revert back with my findings and test results. Regards, Rakesh robertosfield wrote: > Hi Rakesh, > > On 19 October 2017 at 17:56, Rakesh Prasad < ()> wrote: > > > Hi Robert, > > The human model is comprised of independent 3DS max models of each body > > part like head, arms pelvis, thorax. The way animation is being done is by > > moving through code the position and orientation of these body parts. The > > background is fixed to RGB(80,80,80) . > > Hope this clarifies. > > > > > Yes, this information is what was missing form the original post message. > The solution depends entirely on the nature of what you are doing so need > this clarification. > > > > > I was hoping if there is a way to get the final render buffer (for read > > and write)for each frame just before it is displayed to the screen. I could > > create another buffer which will be a superposition of all past buffer. > > Only the model > > part will be superposed since I know the background color RGB(80,80,80). I > > don't expect RGB(80,80,80) to occur in the model and animation render. > > The new superposed buffer could be overwritten onto the final render buffer > > to be rendered to screen.--- > > > > > In OpenGL and OSG you can either use a accumulation buffer or render to > texture. The osgmotionblur example illustrates how to do motion blur use a > GL accumulation buffer, not all hardware support this though. The > render to texture approach is similar to the accumulation buffer approach but > implements the functionality use render to texture. The osgprerender and > osgdistortion examples illustrate how to render to texture, with modern > graphics cards this would be the way I'd suggest doing it. > > > To do render to texture you'll need to render the 3D model into a texture by > using an osg::Camera with a Texture assigned as the colour buffer to provide > the Render to Texture (RTT) , with the subgraph of the Camera being the 3D > model you want to render to it. You can accumulate successive frames into > this texture by disabling the clear of the RTT Camera using the > Camera::setClearMaks(0x0). > > > > You then just render this texture to the whole screen as per the > osgdistortion example. > > > > There are variations on this approach, but the above approach should be > simple enough. > > > Robert. > > > > > > -- > Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72207#72207 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Real time Strobing effect for on screen animation
Hi Robert, The human model is comprised of independent 3DS max models of each body part like head, arms pelvis, thorax. The way animation is being done is by moving through code the position and orientation of these body parts. The background is fixed to RGB(80,80,80) . Hope this clarifies. I was hoping if there is a way to get the final render buffer (for read and write)for each frame just before it is displayed to the screen. I could create another buffer which will be a superposition of all past buffer. Only the model part will be superposed since I know the background color RGB(80,80,80). I don't expect RGB(80,80,80) to occur in the model and animation render. The new superposed buffer could be overwritten onto the final render buffer to be rendered to screen. Thanks, Rakesh robertosfield wrote: > Hi Rakesh, > > > Is the figure something you animating and rendering in 3D? Or are you playing > a video on a textured quad for the animation? > > > Robert. > > > On 19 October 2017 at 14:12, Rakesh Prasad < ()> wrote: > > > Hi, > > I am trying to achieve the strobing effect with OSG for an animation that I > > play on screen. > > I have the animation of a moving human. I want to have all past frames > > displayed along with the current frame. This will show the motion path as > > the human moves on screen. > > I tried to do a screen capture and superpose a buffer with the latest > > render buffer. I also take care that the background pixel are not > > superposed. Only the areas where the human animation is there those pixels > > are superposed. > > This gives me a final static image with strobing effect. This image is > > overlayed on the window. > > > > I want to see the strobing effect as the animation plays. > > The attached picture shows what I am trying to achieve the screen will keep > > updating with the new motion frames. > > > > Is there any way to achieve this. Any thought would very much appreciated. > > ... > > > > Thank you! > > > > Cheers, > > Rakesh > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=72203#72203 > > (http://forum.openscenegraph.org/viewtopic.php?p=72203#72203) > > > > > > > > > > ___ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > > > -- > Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72205#72205 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Real time Strobing effect for on screen animation
Hi, I am trying to achieve the strobing effect with OSG for an animation that I play on screen. I have the animation of a moving human. I want to have all past frames displayed along with the current frame. This will show the motion path as the human moves on screen. I tried to do a screen capture and superpose a buffer with the latest render buffer. I also take care that the background pixel are not superposed. Only the areas where the human animation is there those pixels are superposed. This gives me a final static image with strobing effect. This image is overlayed on the window. I want to see the strobing effect as the animation plays. The attached picture shows what I am trying to achieve the screen will keep updating with the new motion frames. Is there any way to achieve this. Any thought would very much appreciated. ... Thank you! Cheers, Rakesh -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72203#72203 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] MFC mdi child windows show the scene with different lighting
Hi, I have a MFC MDI osg project. Every child window has the same model and ligthing and teh sequence of initialization. I have attached a screenshot to show how it looks as we open more child windows. The structure of the project is as below. View.cpp doc.cpp mainframe.cpp childframe.cpp myosgviewer.cpp The sequence of operations are as below. A new instance of myOSGViewer is created in OnCreate() of the view class. In OnInitialUpdate() of view class myOSGViewer is initialized as below. osg::ref_ptr keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; keyswitchManipulator->addMatrixManipulator('1', "Trackball", new osgGA::TrackballManipulator()); keyswitchManipulator->addMatrixManipulator('2', "Flight", new osgGA::FlightManipulator()); keyswitchManipulator->addMatrixManipulator('3', "Drive", new osgGA::DriveManipulator()); keyswitchManipulator->addMatrixManipulator('4', "Terrain", new osgGA::TerrainManipulator()); keyswitchManipulator->addMatrixManipulator('5', "Orbit", new osgGA::OrbitManipulator()); keyswitchManipulator->addMatrixManipulator('6', "FirstPerson", new osgGA::FirstPersonManipulator()); keyswitchManipulator->addMatrixManipulator('7', "Spherical", new osgGA::SphericalManipulator()); viewer = new osgViewer::Viewer(); viewer->setCameraManipulator(keyswitchManipulator.get()); viewer->addEventHandler(new osgViewer::WindowSizeHandler); viewer->addEventHandler(new osgViewer::StatsHandler); mEvents = new KeyboardEventHandler(this); viewer->addEventHandler(mEvents); viewer->setLightingMode(osg::View::HEADLIGHT); ConstructModel(); //scene is created. light transform is also created added to the scene graph osg::ref_ptr traits = new osg::GraphicsContext::Traits; osg::ref_ptr windata = new osgViewer::GraphicsWindowWin32::WindowData(m_hWnd); osg::GraphicsContext* gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr camera = viewer->getCamera(); camera->setGraphicsContext(gc); camera->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); camera->setProjectionMatrixAsPerspective( 30.0f, static_cast(traits->width) / static_cast(traits->height), 1.0, 1000.0); viewer->setCamera(camera.get()); viewer->setCameraManipulator(keyswitchManipulator.get()); viewer->realize(); viewer->getCameraManipulator()->setHomePosition(eyeP, centreP, upP); viewer->home(); Then mThreadHandle1 = new CRenderingThread1(myOSGViewer); mThreadHandle1->start(); For every OnFileNew the above steps happen. I find that the child windows dont have the same level of brightness. I have attached a screenshot of the problem. Hope I have been clear in putting the problem. In case any more detail is required I will be happy to provide. Any thought or idea is will be appreciated. ... Thank you! Cheers, Rakesh -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70986#70986 Attachments: http://forum.openscenegraph.org//files/mdiscreen1_228.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org