Re: [osg-users] [build] OpenGLES2.0 build error
Okay another update: I managed to successfully build OSG using Jordi's cmake toolchain. I still needed to do another few things: - build my own universal freetype library for iOS and set the proper variables in the toolchain - add the CoreGraphics and ImageUI frameworks to the linker flags - enable code signing So I can successfully build the example_osgViewerIPhone target, and it runs on my device, but I don't see anything - just a blank viewer with the standard blue background. There are some errors related to shaders not being attached properly: Code: Warning: detected OpenGL error 'invalid enumerant' at Before Renderer::compile VERTEX glCompileShader "" FAILED VERTEX Shader "" infolog: ERROR: 0:8: Use of undeclared identifier 'gl_FrontColor' FRAGMENT glCompileShader "" FAILED FRAGMENT Shader "" infolog: ERROR: 0:4: 'vec4' : declaration must include a precision qualifier for type ERROR: 0:5: Use of undeclared identifier 'base' ERROR: 0:6: Use of undeclared identifier 'color' ERROR: 0:6: Use of undeclared identifier 'gl_Color' ERROR: 0:7: Use of undeclared identifier 'color' glLinkProgram "" FAILED Program "" infolog: ERROR: One or more attached shaders not successfully compiled I don't see any shaders in the example... I guess this is something upstream in OSG? Does anyone have an idea of why the example isn't working? Are there any OpenGL ES 2.0 examples out there? Thanks, Mike[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46605#46605 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] I made the libRocket GUI library usable with OSG
Hi, I can't read that last comment (not approved), but whatever the question: I am still improving osgLibRocket, subversion address: https://dtentity.googlecode.com/svn/trunk/source/osgLibRocket Recent improvements: * No longer re-adding osg geometry every frame, instead increasing/decreasing reference count on geometry, only removing geometry when not referenced during the frame * static compiling now possible * No longer holding geometries in a std::map for storage, instead using libRocket handles to hold geometry * Experimental: Use a shader to do screen transformation of libRocket geometries. No real performance gain, also scissoring does not work yet. Commented out in RenderInterface.cpp * Integration with dtEntity system: Use JavaScript in libRocket RML files; use libRocket elements as HUDs over osg scene elements to attach text, energy bars etc Thank you! Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46604#46604 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] simplifier tristripifier
Hi Robert and all users, I was wondering if it still makes sense to use the stripifier like in the osgUtils::simplifier, in the end it generates a lot of draw calls and make the geometry slow. To fix this I disabled the stripifier in my osgconv bin when using simplifier. I was curious if it makes sense for some other usage ? in the osgjs I use it but at the end I generate dummy vertexes to make one big strip without that it just drains performance. I mean if everybody feels the same we could start to submit patch to avoid it or as a standalone operation. Any other thoughts about it ? Cedric Pinson Provide OpenGL, WebGL services +33 659 598 614 - http://cedricpinson.com - http://osgjs.org - http://showwebgl.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Passing dae data in shader.
Hi Christian, I would think that modifying the reader might be easier than processing its generated output. I would say the opposite - creating a NodeVisitor that you run over the loaded graph, which will massage the data to suit your needs, would be easier than modifying the reader plugin. The NodeVisitor you can write knowing only OSG and OpenGL. The reader plugin you need to also know the source format and idiosyncracies of it, which in the case of DAE could be opening a whole can of worms. As an added benefit, you can even write your NodeVisitor such that it will be as general as you want. It could be able to post-process any loaded scene graph, independently of the original format, because it takes as input any OSG graph. Whereas modifying the reader would give you the expected result only with one file format; if you want to get the same results with another format you need to re-do all your modifications in that other reader plugin... In the past I've written a NodeVisitor that eventually gave data structures renderable in DirectX, and in pure OpenGL without using OSG as the render backend. Writing such a visitor is not too hard, and it's easy to debug too. Hope this helps, J-S -- __ Jean-Sebastien Guay jean_...@videotron.ca http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Text Class Sizing Issue!
Greetings! One of the issues that were brought up by my partner out here John Markano was that when the text is set to screen mode, the tendency is that the text stays static in zoom in and then it will reach a point that it will start to shrink. My understanding is that is not supposed to happen. He handed me a test program that uses the existing way to play text and a new way - that doesn’t have that problem. John has expressed to me that he would like me to share the code for this if you all like! I studied it over and it works for me! ... D Glenn David Glenn --- D Glenn 3D Computer Graphics & Media Systems. www.dglenn.com -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46600#46600 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Cleanup of (trailing) whitespace in OSG code (commit 13041)
Hi Robert, On 26-03-2012, at 17:37, Robert Osfield wrote: > I didn't do all the files as I wanted to make sure nothing broke in > the process. So far no complaints... When I first started reading > your post I did initial think oh uh something must have gone wrong... No complaints from me :-). Removing trailing whitespace from a text based file is in general a safe operation. Many text editors even offer it as a default option to perform upon saving. I think it is less likely to bite you than converting tabs to spaces. > Point me in the direction of files/directories that still have > training spaces would be useful. For the complete list of non-binary files that still contain trailing spaces, see the attached file; There's a lot of them! (Approximately 570 files, with a few debatable) Library Interface Code == include/osgShadow/ShadowSettings include/osgViewer/api/Carbon/GraphicsHandleCarbon include/osgViewer/api/Carbon/GraphicsWindowCarbon include/osgViewer/api/Carbon/PixelBufferCarbon include/osgViewer/api/Cocoa/GraphicsHandleCocoa include/osgViewer/api/Cocoa/GraphicsWindowCocoa include/osgViewer/api/Cocoa/PixelBufferCocoa include/osgViewer/api/IOS/GraphicsWindowIOS include/osgViewer/api/Win32/GraphicsHandleWin32 include/osgViewer/api/Win32/GraphicsWindowWin32 include/osgViewer/api/Win32/PixelBufferWin32 include/osgViewer/api/X11/GraphicsHandleX11 include/osgViewer/api/X11/GraphicsWindowX11 include/osgViewer/api/X11/PixelBufferX11 Library Implementation Code === src/OpenThreads/common/Config.in src/OpenThreads/common/Atomic.cpp src/OpenThreads/common/Version.cpp src/OpenThreads/pthreads/PThread.cpp src/OpenThreads/pthreads/PThreadBarrier.cpp src/OpenThreads/pthreads/PThreadBarrierPrivateData.h src/OpenThreads/pthreads/PThreadCondition.cpp src/OpenThreads/pthreads/PThreadConditionPrivateData.h src/OpenThreads/pthreads/PThreadMutex.cpp src/OpenThreads/pthreads/PThreadMutexPrivateData.h src/OpenThreads/pthreads/PThreadPrivateData.h src/OpenThreads/qt/QtBarrier.cpp src/OpenThreads/qt/QtBarrierPrivateData.h src/OpenThreads/qt/QtCondition.cpp src/OpenThreads/qt/QtConditionPrivateData.h src/OpenThreads/qt/QtMutex.cpp src/OpenThreads/qt/QtMutexPrivateData.h src/OpenThreads/qt/QtThread.cpp src/OpenThreads/qt/QtThreadPrivateData.h src/OpenThreads/sproc/SharedArena.c++ src/OpenThreads/sproc/SharedArena.h src/OpenThreads/sproc/SprocBarrier.c++ src/OpenThreads/sproc/SprocBarrierPrivateData.h src/OpenThreads/sproc/SprocCondition.c++ src/OpenThreads/sproc/SprocConditionPrivateData.h src/OpenThreads/sproc/SprocMutex.c++ src/OpenThreads/sproc/SprocMutexPrivateData.h src/OpenThreads/sproc/SprocThread.c++ src/OpenThreads/sproc/SprocThreadPrivateActions.h src/OpenThreads/sproc/SprocThreadPrivateData.h src/OpenThreads/win32/HandleHolder.h src/OpenThreads/win32/Win32BarrierPrivateData.h src/OpenThreads/win32/WIN32Condition.cpp src/OpenThreads/win32/Win32ConditionPrivateData.h src/OpenThreads/win32/Win32Mutex.cpp src/OpenThreads/win32/Win32MutexPrivateData.h src/OpenThreads/win32/Win32Thread.cpp src/OpenThreads/win32/Win32ThreadBarrier.cpp src/OpenThreads/win32/Win32ThreadPrivateData.h src/osg/Config.in src/osg/dxtctool.h src/osg/GLStaticLibrary.h src/osg/glu/libtess/dict-list.h src/osg/glu/libtess/dict.h src/osg/glu/libtess/geom.cpp src/osg/glu/libtess/mesh.cpp src/osg/glu/libtess/mesh.h src/osg/glu/libtess/priorityq-heap.cpp src/osg/glu/libtess/priorityq-heap.h src/osg/glu/libtess/priorityq-sort.h src/osg/glu/libtess/priorityq.cpp src/osg/glu/libtess/priorityq.h src/osg/glu/libtess/render.cpp src/osg/glu/libtess/tess.cpp src/osg/glu/libtess/tess.h src/osg/glu/libtess/tessmono.cpp src/osg/glu/libtess/tessmono.h src/osg/glu/libutil/error.cpp src/osg/glu/libutil/mipmap.cpp src/osgSim/LightPointDrawable.h src/osgSim/LightPointSpriteDrawable.h src/osgText/DefaultFont.h src/osgUtil/tristripper/include/detail/cache_simulator.h src/osgUtil/tristripper/include/detail/graph_array.h src/osgUtil/tristripper/include/detail/heap_array.h src/osgUtil/tristripper/include/detail/types.h src/osgUtil/tristripper/include/tri_stripper.h src/osgUtil/tristripper/src/connectivity_graph.cpp src/osgUtil/tristripper/src/policy.cpp src/osgUtil/tristripper/src/tri_stripper.cpp src/osgViewer/DarwinUtils.h src/osgViewer/DarwinUtils.mm src/osgViewer/GraphicsWindowCocoa.mm src/osgViewer/GraphicsWindowIOS.mm src/osgViewer/IOSUtils.h src/osgViewer/IOSUtils.mm src/osgViewer/PixelBufferCocoa.mm Plugin Code === src/osgPlugins/3ds/lib3ds/lib3ds_atmosphere.c src/osgPlugins/3ds/lib3ds/lib3ds_background.c src/osgPlugins/
[osg-users] Set object attitude using a normal and a heading
Hi, I want to set an object attitude (represented by a quaternion) using two parameters : - a normal vector (to set rotation around X and Y axis) - a heading angle (rotation around non-transformed Z axis) I tried to set the attitude quaternion : 1/ using the normal vector : Code: osg::Vec3d myNormal(0.0, 1.0, 1.0); myNormal.normalize(); osg::Quat attitudeNormal; attitudeNormal.makeRotate(osg::Vec3d(0.0, 0.0, 1.0), myNormal) 2/ using the heading angle : Code: double heading = osg::PI_2; osg::Quat attitudeHeading; attitudeHeading.makeRotate(heading, osg::Vec3d(0.0, 0.0, 1.0)) But how can I combine the two parameters ? If I do : Code: attitude = attitudeHeading*attitudeNormal the normal constraint is no more valid because X and Y axis are transformed by the attitudeHeading and affect attitudeNormal If I do : Code: attitude = attitudeNormal*attitudeHeading the heading constraint s no more valid because Z is transformed by the attitudeNormal and affect attitudeHeading Did I miss something ? Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46598#46598 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Wiki
On 03/26/2012 12:44 PM, Robert Osfield wrote: Hi Jason, On 26 March 2012 16:43, Jason Daly wrote: On 03/22/2012 04:29 PM, Robert Osfield wrote: I sent these to you last week (off-list). No rush it getting it posted, but I just wanted to make sure that you did actually receive them. I got it thanks. Presently trying to work where is the best place for it. We have Applications page liked to off the Community section: http://www.openscenegraph.org/projects/osg/wiki/Community/Applications I'm open to suggestions. That's the page that the customer suggested, too. If you're OK with it, that would be perfect. Thanks! --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Wiki
Hi Jason, On 26 March 2012 16:43, Jason Daly wrote: > On 03/22/2012 04:29 PM, Robert Osfield wrote: > I sent these to you last week (off-list). No rush it getting it posted, but > I just wanted to make sure that you did actually receive them. I got it thanks. Presently trying to work where is the best place for it. We have Applications page liked to off the Community section: http://www.openscenegraph.org/projects/osg/wiki/Community/Applications I'm open to suggestions. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Getting animations initial frame bones matrix
Hi, For those who need to know how to do ... Code: std::map\std::string,osg::Matrix> desiredMatrixs; osg::ref_ptr\osgAnimation::Animation> anim = _AnimationManager->getAnimation(name); if(anim.valid()){ osgAnimation::ChannelList channelList = anim->getChannels(); for(int i=0;i\_boneChains_index.size();i++) { std::string targetName = _boneChains_index[i].back().first; std::string actualBoneName = targetName; osg::Matrix desiredMatrix; osg::ref_ptr\osgAnimation::Bone> actualBone = _AnimationManager->getSkeletonBone(actualBoneName); while(actualBone->getParents().size()>0) { float rotateX, rotateY, rotateZ; osg::Vec3 pos; for(int j=0;j\channelList.size();j++) { osgAnimation::Channel* channel = channelList[j]; if(!channel->getTargetName().compare(actualBoneName)) { channel->update(channel->getStartTime(),1.0,1.0); if(!channel->getName().compare("translate")){ osg::ref_ptr\osgAnimation::Vec3Target> posTarget = dynamic_cast\osgAnimation::Vec3Target*>(channel->getTarget()); pos = posTarget->getValue(); } else if(!channel->getName().compare("rotateX")){ osg::ref_ptr\osgAnimation::FloatTarget> xTarget = dynamic_cast\osgAnimation::FloatTarget*>(channel->getTarget()); rotateX = xTarget->getValue(); } else if(!channel->getName().compare("rotateY")){ osg::ref_ptr\osgAnimation::FloatTarget> yTarget = dynamic_cast\osgAnimation::FloatTarget*>(channel->getTarget()); rotateY = yTarget->getValue(); } else if(!channel->getName().compare("rotateZ")){ osg::ref_ptr\osgAnimation::FloatTarget> zTarget = dynamic_cast\osgAnimation::FloatTarget*>(channel->getTarget()); rotateZ = zTarget->getValue(); break; } } } osg::Quat rot(rotateZ,osg::Vec3(0,0,1), rotateY,osg::Vec3(0,1,0), rotateX,osg::Vec3(1,0,0)); osg::Matrix mat(osg::Matrix::rotate(rot)); mat.setTrans(pos); desiredMatrix.postMult(mat); actualBoneName = actualBone->getParent(0)->getName(); actualBone = _AnimationManager->getSkeletonBone(actualBoneName); if(!actualBone.valid()) break; } desiredMatrixs[targetName] = desiredMatrix; } } else return; Thank you! Cheers, Aitor -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46593#46593 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegra
Re: [osg-users] constant size overlay
On 03/26/2012 09:03 AM, Michael Schanne wrote: Hi, I want to use OSG to create an overlay where I have different symbols marking certain points in my scene. I want these symbols to remain a constant size in screen coordinates until crossing certain thresholds (for example, they are size A when at a distance< X from the camera, then change to size B once distance> X). It’s a little different than a HUD because I want the symbols to move as I pan the camera, so that they stay at the same world coordinates. I am using an orthographic projection where the camera is directly overhead in the Z direction, and it will only pan in the X-Y plane. I took a look at the OverlayNode class, but the description didn’t sound like what I wanted. The LOD class sounded more like what I need, so I could switch between multiple sized children based on the camera distance, but I’m still not quite sure how to make each child have a constant size within its camera distance range. Does anyone have any suggestions for me? Hi, Michael, There's not an existing OSG construct that will do exactly what you want, but you might take a look at AutoTransform to see if you can build what you want based on that. --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Wiki
On 03/22/2012 04:29 PM, Robert Osfield wrote: I can also just submit the app if that's the preferred way of doing it. You could just send the entry text and link to me and I could add it for you. Hi, Robert, I sent these to you last week (off-list). No rush it getting it posted, but I just wanted to make sure that you did actually receive them. Thanks again, --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Cleanup of (trailing) whitespace in OSG code (commit 13041)
HI Erik, On 26 March 2012 15:50, Erik den Dekker wrote: > I see that you have recently run a script over the OSG code to (from commit > message 13041) 'remove trailing spaces and tabs'. While I am a proponent of > this effort and greatly appreciate the move, I do have some questions about > it: > > 1) Does the 'trailing' in this case also apply to tabs, or does it > mean you want to eradicate all tabs (replace them with spaces)? For the recent check in the script I used removed trailing spaces and tabs. When I do a graphical merge I run a script that converts tabs to four spaces, although sometimes I have to tweak things to fix things. There are some older parts of bits that have been merged without me running the script than have tabs that I haven't yet converted. > 2) In current SVN head, I still encounter many files that contain > trailing whitespace, as well as files that contain tabs. Is it still work in > progress, are they forgotten, or is there a specific reason why you did not > apply the script to these particular parts of the codebase? I didn't do all the files as I wanted to make sure nothing broke in the process. So far no complaints... When I first started reading your post I did initial think oh uh something must have gone wrong... What parts are still spotting the training spaces? > I would like to offer you my assistance in this cause, if in any way you > would wish to use it. Point me in the direction of files/directories that still have training spaces would be useful. This is generally a low priority task though, it doesn't fix any bugs or make the code more readable. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Cleanup of (trailing) whitespace in OSG code (commit 13041)
Hi Robert, I see that you have recently run a script over the OSG code to (from commit message 13041) 'remove trailing spaces and tabs'. While I am a proponent of this effort and greatly appreciate the move, I do have some questions about it: 1) Does the 'trailing' in this case also apply to tabs, or does it mean you want to eradicate all tabs (replace them with spaces)? 2) In current SVN head, I still encounter many files that contain trailing whitespace, as well as files that contain tabs. Is it still work in progress, are they forgotten, or is there a specific reason why you did not apply the script to these particular parts of the codebase? I would like to offer you my assistance in this cause, if in any way you would wish to use it. Cheers, Erik den Dekker ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Passing dae data in shader.
Hello. Is there any Sample/Example for this ? Thank you again. On 26 March 2012 15:00, Christian Buchner wrote: > I'd say you would have to modify the DAE reader according to your > shader's needs, or alternatively you'd need to do some postprocessing > on the returned geometry. > > I would think that modifying the reader might be easier than > processing its generated output. > > Christian > ___ > 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] constant size overlay
Hi, I want to use OSG to create an overlay where I have different symbols marking certain points in my scene. I want these symbols to remain a constant size in screen coordinates until crossing certain thresholds (for example, they are size A when at a distance < X from the camera, then change to size B once distance > X). It’s a little different than a HUD because I want the symbols to move as I pan the camera, so that they stay at the same world coordinates. I am using an orthographic projection where the camera is directly overhead in the Z direction, and it will only pan in the X-Y plane. I took a look at the OverlayNode class, but the description didn’t sound like what I wanted. The LOD class sounded more like what I need, so I could switch between multiple sized children based on the camera distance, but I’m still not quite sure how to make each child have a constant size within its camera distance range. Does anyone have any suggestions for me? Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46587#46587 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Passing dae data in shader.
I'd say you would have to modify the DAE reader according to your shader's needs, or alternatively you'd need to do some postprocessing on the returned geometry. I would think that modifying the reader might be easier than processing its generated output. Christian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Passing dae data in shader.
Hello. Is there any way using the dae plugin in osg, to pass the vertices in shader code as attributes? What i do now for simple geometry shapes (lets assume we have a quad), is to use setAttributeValues( ... ); passing the vertices' positions, colors normals etc. How can i get this information from a dae file and use the same shader? Thank you. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Questions on AutoTransform
Hi, I'm having to views, one normal 3d view and one top view with an camera icon, that represents the camera of the 3d view (orientation and position). The top view (with an orthogonal projection) kann be zoomed in and zoomed out. Of course, zooming out the top view will scale the camera icon, which I want to prevent. The camera icon shall have the same size at all times. Therefore I want to use the Autotransform, but I do not get the expected results. Here's how I set up the icon geometry with the AutoTransform: MatrixTransform | | AutoTransform | | IconGeometry (several Geodes) The MatrixTransform controls the orientation an position of the icon. The AutoTransform shall do the automatic scaling, so that the icon always stays the same size. Here's an excerpt from the initialization code: cameraIcon = new osg::MatrixTransform; cameraIcon->setMatrix(DsTOsgMatrix4::translate(2, g_fCameraIconHeight, 0)); osg::ref_ptr camAutoScale = new osg::AutoTransform; camAutoScale->setAutoScaleToScreen(true); cameraIcon->addChild(camAutoScale); camAutoScale->addChild(camBody); camAutoScale->addChild(camMoveHandle); camAutoScale->addChild(camRotateHandle); The effect I'm getting is that the icon is not visible. If I comment out the line where I set the autoscaletoscreen as true, display of the icon is normal. I guess I'm missing something in the setup of the AutoTransform. I'm using Osg 3.0.0. Zooming is done by changing the orthogonal projection matrix of the view's camera appriately. I'm using a right handed coordinate system with the z-axis as up-axis. Do I have to set special axis in the AutoTransform? Does the position has to be set in the AutoTransform, when the icon's position changes? Can somebody help me out? Any hints are welcome. Cheers, Carsten _ Carsten Scharfe Software Developer Experiment Software ESIM dSPACE GmbH Rathenaustraße 26 33102 Paderborn Germany Tel.: +49 5251 1638-1920 http://www.dspace.com mailto:cscha...@dspace.de _ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG + Qt + threading.
Hi Aurelien, It seems that already works! I attached code... Code: _qtViewer = new osgGenerals::ViewerQT(this); ui.OSGRenderLayout->addWidget(_qtViewer); _qtViewer->updateCamera(center,eye,up); _qtViewer->setSceneData(_mainLogic->getRootGroup()); _qtViewer->startRendering(); Thank you! Cheers, Aitor -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46582#46582 #ifndef _OSG_QT_RENDER_H_ #define _OSG_QT_RENDER_H_ #include #include #include #include #include #include #define USE_QT4 1 #if USE_QT4 #include #include #include #include #include #include using Qt::WindowFlags; #else class QWidget; #include #include #include #define WindowFlags WFlags #endif #include namespace osgGenerals{ class LogFileHandler : public osg::NotifyHandler { public: LogFileHandler( const std::string& file ) { _log.open( file.c_str() ); } virtual ~LogFileHandler() { _log.close(); } virtual void notify(osg::NotifySeverity severity, const char* msg) { _log << msg; } protected: std::ofstream _log; }; class ViewerQT; class GLPainter : public QObject { Q_OBJECT public: GLPainter(ViewerQT *widget); void stop(); void resizeViewport(const QSize &size); void updateCamera(osg::Vec3f center, osg::Vec3f eye, osg::Vec3f up); public slots: void start(); protected: void timerEvent(QTimerEvent *event); private: QMutex mutex; ViewerQT *glWidget; bool doRendering; }; class AdapterWidget : public QGLWidget { public: AdapterWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 ); virtual ~AdapterWidget() {} osgViewer::GraphicsWindow* getGraphicsWindow() { return _gw.get(); } const osgViewer::GraphicsWindow* getGraphicsWindow() const { return _gw.get(); } protected: void init(); virtual void resizeGL( int width, int height ); virtual void keyPressEvent( QKeyEvent* event ); virtual void keyReleaseEvent( QKeyEvent* event ); virtual void mousePressEvent( QMouseEvent* event ); virtual void mouseReleaseEvent( QMouseEvent* event ); virtual void mouseMoveEvent( QMouseEvent* event ); virtual void wheelEvent(QWheelEvent *event); osg::ref_ptr _gw; }; class ViewerQT : public osgViewer::Viewer, public AdapterWidget { public: ViewerQT(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0); ~ViewerQT(); void startRendering(); void stopRendering(); virtual void paintGL(); void updateCamera(osg::Vec3f center, osg::Vec3f eye, osg::Vec3f up); protected: void resizeEvent(QResizeEvent *evt); void paintEvent(QPaintEvent *); void closeEvent(QCloseEvent *evt); GLPainter glPainter; QThread glThread; }; } #endifÿþ# i n c l u d e " O S G Q t R e n d e r . h " u s i n g n a m e s p a c e o s g G e n e r a l s ; G L P a i n t e r : : G L P a i n t e r ( V i e w e r Q T * w i d g e t ) : g l W i d g e t ( w i d g e t ) , d o R e n d e r i n g ( t r u e ) { } v o i d G L P a i n t e r : : s t a r t ( ) { g l W i d g e t - > A d a p t e r W i d g e t : : m a k e C u r r e n t ( ) ; s t a r t T i m e r ( 1 0 ) ; } v o i d G L P a i n t e r : : s t o p ( ) { Q M u t e x L o c k e r l o c k e r ( &