[osg-users] problem getting texture image from a model
Hi everyone. I'm experiencing an issue with texture images. I am using line segment intersectors in a manner similar to picking. With a couple of models, the texture retrieving algorithm works fine, however, with one model it fails. This is the extract of the code: Code: osg::Drawable *collisionDrawable = intersection.drawable.get(); osg::StateSet *collisionStateSet = collisionDrawable ? collisionDrawable-getStateSet() : null; osg::Geometry *collisionGeometry = collisionDrawable ? collisionDrawable-asGeometry() : null; ... osg::Texture* texture = dynamic_castosg::Texture* (collisionStateSet-getTextureAttribute(0, osg::StateAttribute::TEXTURE)); osg::Image *textureImage = texture ? texture-getImage(osg::Material::FRONT) : null; the textureImage equals to NULL after this sequence, while the texture does not. so why does the texture-getImage() method not return expected texture ? I checked the model, it seems to be all right. this is an example Code: ... Geode { ... num_drawables 1 Geometry { DataVariance STATIC StateSet { DataVariance STATIC ... textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file .\\textures\\102.jpg wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter LINEAR_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE shadowComparison FALSE shadowCompareFunc GL_LEQUAL shadowTextureMode GL_LUMINANCE } TexEnv { UniqueID TexEnv_4 mode MODULATE } } } the other model, where it works, looks alike, when exported to osg format. so why is it, that for this model, the algorithm fails ? can anyone tell? Thank you very much, and i mean it, for anything useful! Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47080#47080 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting eye position / direction
Hi, this post is for those reading this thread wondering how i solved the issue. I solved it by creating the line segment intersectors in model coordinate space, transforming the starting/ending point using this matrix: Code: osg::Matrixd matrix; matrix.preMult(_masterCamera-getViewport()-computeWindowMatrix()); matrix.preMult(_masterCamera-getProjectionMatrix()); matrix.preMult(_masterCamera-getViewMatrix()); _renderMatrixInverse-invert(matrix); This way the lineSegmentIntersector gets initialized correctly and the intersections are computed well. The problem itself originated elsewhere - i was using the camera as the ROOT node for intersectionVisitor, which did not behave the way expected. I encountered another issue when using the camera as the root - the invisible parts of the scene got culled away (as expected for rendering), however, while computing reflected rays, this caused serious issues, as these rays did not hit the expected objects, because they 'were not there'. I had to use own matrix transformation for the primary rays and let all the rest compute in the model coordinate space, the scene being the root (without any other transformations). take care, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47056#47056 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] making a copy of camera root node or whole scene graph
Hi guys, I solved the issue NOT using a osg::Camera at all. It caused a series of other fatal issues (culling away some geometry, that was then missing in reflections). anyone doing ray-tracing, do not use osg::Camera as a root of your scene for intersectionVisitor ! it will fail with secondary rays. take care, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47057#47057 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] default lighting
Hi, just a guess - try global ambient intensity. i'm using this code: Code: osg::LightModel *lightModel = collisionStateSet ? dynamic_castosg::LightModel* (collisionStateSet-getAttribute(osg::StateAttribute::LIGHTMODEL)) : NULL; if (lightModel) { globalAmbientIntensity = lightModel-getAmbientIntensity(); } Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47058#47058 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting correct light position
Hi, update: working! ... almost correctly I have recently realized, that the problem may be caused by me not treating the fourth vector component (w) well - but if i use .project() method of either osg::Vec4d or osg::Vec4dH, it produces infinity for directional lights, which is expected, but how do i treat such values ? :? the light is finally positioned well :D if i alter the fourth component not to be zero, but some small value close to zero, just before using .project() method on the light's position. but i do not want to keep using this kind of hack. is there another way? i need to get the light's position to be able to compute precise vectors for lighting equations ... Thank you for suggestions! Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47011#47011 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multiple views
Hi, i'm not really an experienced user, i have issues of my own, but i have a couple of suggestions for you: check the osgCompositeViewer example and its source code - there you can find a way to open several views in one window as well as open several windows, as you please. for having several cameras with different offset move at the same time, use osg::view's method addSlave. actually, you do not have to specify any offset, if you want the cameras to behave exactly the same. an example of creating a slave camera (with an ABSOLURE_RF reference frame though) is in osgHud example. What you need is RELATIVE_RF, which is default. hope this helps. Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46820#46820 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] making a copy of camera root node or whole scene graph
Hello everyone! I am using line segment intersectors to do ray-tracing. i trace rays from the window into the scene and then the consequent rays. This will be a no-time answer for those fluent with scene graph, i'm sure. i have a scene and a osgViewer::View, in which the scene is displayed. i use the camera from the View to accept the line segment intersectors. The camera becomes the root of the scene: Code: _tracer-getScene()-accept(intersectionVisitor); where the scene is actually the camera retreived from the osgViewer::View this way Code: wm-getSceneView()-getCamera() With this setup, i'm getting pretty intersections and this part works fine. However, i need the rendering camera to stay fixed while the View's camera moves around. So i tried making a copy of the View's camera when the tracer is initialized, but i'm getting black screen computed in a fraction of the computation time needed for the correct picture. I thought there was some problem with matrices, but i compared them and they appear to be the same. With this camera Code: wm-getSceneView()-getCamera()// this is passed to the tracer object as a _masterCamera I'm getting correct rendering results. It is the _masterCamera in the tracer object. Now, I tried these 3 approaches: (this is a code snippet from the tracer object's constructor) Code: // 1) _renderCamera = dynamic_castosg::Camera* (_masterCamera-clone(osg::CopyOp::DEEP_COPY_ALL)); // this really should be working // 2) _renderCamera = dynamic_castosg::Camera* (_masterCamera-clone(osg::CopyOp::SHALLOW_COPY)); // 3) _renderCamera = new osg::Camera; _renderCamera-addChild(_scene); before every rendering, updateCamera() is called, it copies the matrices from the _master camera into the _render camera Code: _renderCamera-setViewMatrix(_masterCamera-getViewMatrix()); _renderCamera-setProjectionMatrix(_masterCamera-getProjectionMatrix()); Doing this check for matrix equity Code: if(_masterCamera-getViewMatrix() == _renderCamera-getViewMatrix() _masterCamera-getProjectionMatrix() == _renderCamera-getProjectionMatrix()){ std::cout equal matrices std::endl; } I get the string printed out every time i start rendering, meaning the matrices should be equal. So why am I not getting any result ? neither of the three approaches work. if the problem was having two root cameras, why does not the DEEP copy work, at least ? i am not concerned about memory usage for now. Is there a special way I have to copy the scene or the camera? also, please, anyone looking at this thread, please take a look at my posts in thread number 10149 (http://forum.openscenegraph.org/viewtopic.php?t=10149), I really need these issues solved this week. I appreciate any suggestions. Thank you very much in advance. Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46844#46844 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting eye position / direction
update: Code: // get matrices osg::Matrix matrix; matrix.preMult(_tracer-getCamera()-getViewport()-computeWindowMatrix()); matrix.preMult(_tracer-getCamera()-getProjectionMatrix()); matrix.preMult(_tracer-getCamera()-getViewMatrix()); // invert osg::Matrix inverse; inverse.invert(matrix); // set results _startWorldPoint = getStart() * inverse; _endWorldPoint = getEnd() * inverse; ... Code: osg::Vec3d eyeDirection = collisionPoint - _tracer-getEye(); eyeDirection.normalize(); // this vector is correct, but the starting point (the eye) is not sufficient for my application osg::Vec3d newDirection = getReverseDirection(); // _reverseDirectionVector = (getEndWorldPoint() - getStartWorldPoint()).getVectorPart(); newDirection.normalize(); // this vector is slightly different, i suppose the points are not correctly positioned this approach results in similar, but not the same vectors. definitely not correct though, according to visual results. any suggestions? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46702#46702 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting eye position / direction
Hello again! I've just realized i do need to be able to translate the starting and ending points of a LineSegmentIntersector created in WINDOW coordinate frame into the WORLD coordinate space. is there any simple method to do so ? by retrieving them from the intersector or its intersection. i couldn't find any. my guess is to take matrices, make an inverse and multiply: Code: osg::Matrix matrix; matrix.preMult( somehow.getWindowMatrix() ); matrix.preMult( somehow.getProjectionMatrix() ); matrix.preMult( somehow.getViewMatrix() ); osg::Matrix inverse; inverse.invert(matrix); startPointInWorldCoordinates = startPoint * inverse; but this seems computation-wise lengthy and i am not sure how to get all these matrices ... maybe the window matrix from viewport and the other two from camera. but I see this is done in the lineSegmentIntersector, the matrices are retrieved from the visitor, yet neither the matrices, nor the points are stored. my second guess would be inheriting the LineSegmentIntersector itself and modify the descendant to store those translated points. I found out that having a wall (or any other object) close behind the projection pane (e.g. looking into a room from a corner or from a point close to the wall) is fine in the osg::viewer, but if i take the camera as the starting point of the rays, the rays end up hitting the wall, which is not actually seen. that's why i need to start the rays not from the camera, but from the projection pane and to do so i need to be able to translate the points on it into the WORLD coordinate space. Thank you for any pointers! Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46698#46698 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting correct light position
Hi and thank you for the quick suggestion. i double checked. i treat all three types of the light equally, in terms of vector mathematics. the only difference is the attenuation stuff, but these values are scalar. Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46651#46651 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting eye position / direction
again, thank you, robert. now i know i'm getting correct results. regards, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46391#46391 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] getting eye position / direction
Hi, i am trying to get eyePosition and direction, more precisely, the direction of a ray for the purpose of ray tracing. this is what i am doing: Code: const osg::Vec3d collisionPoint = intersection.getWorldIntersectPoint(); ... osg::Vec3d eyeDirection = collisionPoint - _tracer-getEye(); eyeDirection.normalize(); where the _tracer-getEye() method returns the position of the eye (computed once for a frame): Code: if (!_eye_set) { osg::Vec3d center, up; getCamera()-getViewMatrixAsLookAt(_eye, center, up); _eye_set = true; } i am not sure whether this is the correct way to get the eye position/direction. i was thinking there has to be a way to get the direction from an intersection itself, but i am not confident using the start/end points (transforming them into appropriate coordinates) considering i create the rays (line segment intersectors) in WINDOW and also MODEL coordinate frames. can anyone tell me whether my method is correct or i should rather try getting the start/end points from the intersector, transforming them and this way getting the ray (==eye) direction ? Thank you! Cheers, Andrey[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46123#46123 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getting eye position / direction
i am trying to compute the direction of an osg::LineSegmentIntersector object. i can get the collision point and i am trying to get the starting point - i need the vector of the intersector's direction. i do this for the purpose of ray tracing (or ray casting). i create the intersectors this way Code: new osgUtil::LineSegmentIntersector(cf, x, y); where cf is 'WINDOW' (this is for the primary rays). i am not sure how to transform the starting/end point of the intersector into model (world) space. that's why i am trying to get the position of the camera as the starting point. i looked at the code of the linesegmentintersector thoroughly, but still am confused about the matrices, so i decided it could be less difficult to use the camera. i need the vector to calculate the specular color. robert, thank you very much for your help. andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46129#46129 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] request new frame manually
Thank you, Robert! it worked well. for the record, the correct call is made on osg::View Code: _view-requestRedraw() I am puzzled how i could have missed the method in the sources :? Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45791#45791 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] request new frame manually
Hello world! Until recently i had been using Code: _viewer-setRunFrameScheme(osgViewer::ViewerBase::CONTINUOUS); but then i switched to Code: _viewer-setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND); and now i have a minor problem with window refresh. This should be fairly simple to do, i think, i just can't find the proper method to do so - how do i request a osg::View to refresh ? (or it's camera, or whole composite viewer - i don't care) i've been searching the documentation as well as this forum with no success. There is a GLUT method that i am familiar with - glutPostRedisplay() - is there any OSG equivalent? I am running some lengthy ray tracing computation and when it finishes, i need the window that the result is displayed in to refresh. Thank you in advance! Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45774#45774 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OpenThreads reference manual, documentation or tutorial
Hello all the OSG enthusiasts and gurus! Is there any tutorial for OpenThreads? or at least a reference manual for the current OSG version, preferably with some comments? all i have is a reference manual lacking almost any comments (i mean descriptions of classes, methods and parameters, data structures etc.), downloaded from 3draum.ch, and it's for the OSG 2.9.6 :? This is a problem of the OSG as such. How come, such a great framework lacks reasonable documentation ? It's not enough to just name methods in a reasonable way. At least some explanation of methods/classes/parameters is needed. I started using OSG about 6 months ago and so far every little thing i wanted to do had been preceeded with massive forum reading, trials to understand the example apps (which also lack comments), other apps i found online and the source of the OSG itself. I am literally spending hours to do a simple thing. All because there is no documentation that could be used. Yes, i am a self-student and i have no one to teach me OSG ways. Now my patience is over after i have been searching for days for anything that could give me hand with the OpenThreads, which are not even included in the OSG documentation, although being a part of it... :O Or is it just me being blind [Question] [Question] [Question] Thank you very much for providing any information on the OpenThreads (or OSG) documentation. And thank you for this forum, it's the only light in my osg-darkness. Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45109#45109 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenThreads reference manual, documentation or tutorial
hi there! my post was NOT in any way a criticism of the developers. i am only frustrated ... well you read it anyway. what i wanted to say - maybe, a couple of lines, a single sentence - it helps a LOT. i really think this is the biggest downside of the OSG. i can't say anything else than good job for the rest. also i have experience with programming for free and i do know what you are saying. it's just ... i always comment my code, it's better even for me if i happen to come across it once again some time later. if i happen to be an expert in OSG and graphics, i will start with the OSG documentation for sake of other beginners like me :) i heared of that book and now i think i'm buying it this week. hope it helps. thank you, Torben. andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45113#45113 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] IntersectionVisitor - low performance and NO performance boost with KdTrees enabled.
Hi, i finally got to cast some rays with my ray-casting application and i found out the perforamce is terribly low. i am not sure how fast the intersections should be counted, but i am pretty sure that an image 160x120 pixels (which is 19200 points) should be computed in less than 5.5 seconds ... which is the time i am getting when measuring. i literally copied the part of the osgintersection example that is using the intersectorGroup. i am using the intersectionGroup and intersectionVisitor. Code: osgUtil::LineSegmentIntersector* intersector = new osgUtil::LineSegmentIntersector(osgUtil::LineSegmentIntersector::WINDOW, osg::Vec3(x, y, 0), osg::Vec3(x, y, 1)); intersectorGroup-addIntersector(intersector); this way i add intersectors to the group for each pixel of my window. this way i try to compute the intersections and measure time Code: osgUtil::IntersectionVisitor intersectionVisitor(intersectorGroup.get()); intersectionVisitor.setUseKdTreeWhenAvailable(true); osg::Timer_t startTick = osg::Timer::instance()-tick(); osg::Camera *cam = _wm-getSceneView()-getCamera(); cam-accept(intersectionVisitor); osg::Timer_t endTick = osg::Timer::instance()-tick(); std::cout Frame in osg::Timer::instance()-delta_s(startTick, endTick) sec. std::endl; the time varies from 4.9 to 6 seconds for 160x120 pixel image, for 320x240 the time increases 4 times to roughly 22 seconds ... though i am using a notebook it is NOT any 86286 computer :) this way i won't be able to compute full screen app window in reasonable time :( i tried the built-in KdTree support by calling Code: osgDB::Registry::instance()-setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES); as the first command in my main() function. As i didn't record any changes in the computing time, i even tried running the KdTreeBuilder on my loaded model manually Code: osg::KdTreeBuilder *kdtb = new osg::KdTreeBuilder; loadedModel-accept(*kdtb); still with NO preformance change. And by NO i mean NOthing, i am getting the same runing time. i also tried limiting the amount o intersections by setting the intersection limit for each intersector calling Code: intersector-setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST); in the loop that creates one for every pixel of the window (the first code snippet in this post). only the LIMIT_ONE option decreased the computing time by roughly 0.3 seconds (which is still unacceptable), but the result i got was not accurate. what am i doing wrong? why are the Kd-Trees not working properly? the documentation says the performance should improve from tens to thousands times. then why not for me? Thank you for any tips that may help me. Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44655#44655 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] starting with stencil buffer to achieve ray tracing
Thank you, Robert. I won't implement this then. i realized later that this might be just a minor optimization, if the Kd-Trees were working properly. Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44666#44666 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] IntersectionVisitor - low performance and NO performance boost with KdTrees enabled.
Hello, Robert and thank you for the swift reply. The scene is quite simple, it's actually just a room with a mirror, table and a couple of spherical objects. There are 126 drawables (all are fast drawables), 16k vertices and 5.3k triangles. I have just tried building the app with -O3 -DNDEBUG instead of -g3 -ggdb with the same app running time result. Can there be something wrong with my compiler / OSG libraries ? i am using OSG 3.x and GCC 4.5.0 (mingw on windows). i do not know where to look for the problem, that is my problem :) Cheers, Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44667#44667 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] IntersectionVisitor - low performance and NO performance boost with KdTrees enabled.
hello! here is the scene [Image: http://img441.imageshack.us/img441/6236/sceneviewwireframe.png ] so what do you think? and here i was thinking the built-in kd tree support will save me the time of implementing kd-trees, eh thanks Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44670#44670 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] IntersectionVisitor - low performance and NO performance boost with KdTrees enabled.
now this is strange - i loaded a much more complex model with 250k vertices and 83k triangles, but with only 13 primitive sets / drawables, and given the same resolution (160*120 px) i get a frame in 0.6 seconds with KdTrees enabled and in approx. 10 - 12 seconds if they are disabled. now i at least know where the bottleneck resides and that the Kd-Trees are working :) thank you, Robert, for the idea! i might be able to implement a kdtree for all the triangles to solve the issue. regards, andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44671#44671 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] simple window manager to reopen a window
another update: now i got rid of the error by setting the start tick timer of the viewer to be equal to the timer on the existing main scene view this way Code: osg::Timer_t timer = _sceneView-getStartTick(); _viewer-realize(); _viewer-setStartTick(timer); i can even omit the command with ON_DEMAND from my previous post. however, the occasional problem with closing whole application by closing the secondary window described in my previous post persists. thanks ahead for any tips. Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44521#44521 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] simple window manager to reopen a window
thank you sth! i am now able to store the state of the window. never the less, with the error going on i am still not able to move forward. i forgot to mention, that if i try to open the window and run the realize() method on my compositeViewer - in say 5 seconds from launching the application - and the error about time going backwards is issued, the view does not receive or discards any event until the run time after the realize() is at least 5 seconds again. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44516#44516 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] simple window manager to reopen a window
update: i found this thread http://forum.openscenegraph.org/viewtopic.php?t=9176 and using this command Code: _viewer-setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND); i got rid of the annoying irresponsivness. i am still getting the error though. however, i bumped into another issue - sometimes when i close the secondary RTT window my application terminates. i am using a handler to terminate the application if the MAIN (scene) window is closed. Code: bool WindowCloseHandler::handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter aa) { if (!ea.getHandled() ea.getEventType() == osgGA::GUIEventAdapter::CLOSE_WINDOW) { osgViewer::View *view = dynamic_castosgViewer::View * (aa); if (view == _wm-getRTTView()) { // save window state _wm-saveRTTViewState(); } else if (view == _wm-getSceneView()) { // terminate the app _wm-getViewer()-setDone(true); } } return false; } _wm is an instance of my window manager that stores the composite viewer and its two views and other stuff. how come my app terminates from time to time when closing the RTT window ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44517#44517 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] simple window manager to reopen a window
Hi, i'm trying to create some kind of window manager, which would allow me to open a certain pop-up window with RTT camera on request and later reopen it if it has been closed. i was looking for some kind of window onClose callback function to allow me to store the current window state (graphics contexts' traits) with position and size, but i couldn't find any. my RTT camera is stored in the window manager along with whole scene graph. i create the pop-up window at startup, as usual, then i test if it has been closed, which i can do using rttCamera-getGraphicsContext()-valid() method. i conditionally create a new context for the camera when the old one is invalid. then i call viewer-realize() and i get the window i wanted. but i am getting this error: Code: invalid contextStandardManipulator::handleFrame(): Event error - Time going back ward! Current event time: 0.0671157 previous event time: 6.60098 i need to get rid of this error. if i do not call the -realize() method, i get tons of openGL errors and no window pops' up. btw, i am using a composite viewer instance with a main view of the scene and a secondary pop-up window with rtt camera. so my two questions - how do i get rid of the error and is there a way of storing information that would allow me to reopen a closed window in it's previous state? thank you guys very much in advance! Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44502#44502 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] starting with stencil buffer to achieve ray tracing
thank you filip! this might just be what i was looking for :) but i'm getting OpenGL errors here ... Code: Warning: detected OpenGL error 'invalid operation' at end of SceneView::draw() Warning: detected OpenGL error 'invalid operation' at start of State::apply() the letter one keeps piling up as the app runs. i wrote this code into the main function just before calling the optimizer and viewer.run(); Code: osg::ref_ptrosg::Group rootNode = new osg::Group; { osg::Stencil* stencil = new osg::Stencil; stencil-setFunction(osg::Stencil::ALWAYS, 1, ~0u); stencil-setOperation(osg::Stencil::ZERO, osg::Stencil::ZERO, osg::Stencil::REPLACE); osg::StateSet* ssb1 = new osg::StateSet(); ssb1-setMode(GL_CULL_FACE, osg::StateAttribute::OFF); ssb1-setAttributeAndModes(stencil, osg::StateAttribute::ON); rootNode-setStateSet(ssb1); } rootNode-addChild(loadedModel.get()); viewer.getCamera()-setPostDrawCallback(new PostDrawCallback()); and then the callback Code: class PostDrawCallback : public osg::Camera::DrawCallback { virtual void operator () (osg::RenderInfo renderInfo) const { osg::ref_ptrosg::Image img = new osg::Image; osg::View *view = renderInfo.getView(); int width = view-getCamera()-getViewport()-width(); int height = view-getCamera()-getViewport()-height(); img-readPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE); } }; if i comment out the readpixels method, the errors do not apear. what am i missing [Question] [Arrow] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44186#44186 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] starting with stencil buffer to achieve ray tracing
filip, that line of code solved the problem! thank you so much! now i have to bend the code i have a bit for my purpose. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44189#44189 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] png plugin - problem loading images
hi laurence! i have got zlib1.dll in my path env.. it is the one i used for building the libpng15.dll dynamic library. both libs i used to build the OSG. i kept every single dynamic library i built during the process of compiling the osg in my compiler's bin folder, which is in my system PATH env. the same way i kept static libs in the libs dir and include files in the compiler's include dir. again i tried the trick with renaming (i also kept a copy with the original name) with no difference in the app's behaviour. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44163#44163 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] png plugin - problem loading images
thank you for the tip. i tried locating the libpng library and i found there was a file libpng15.dll in the system path. i don't really know how this library file-name-thing really works so i renamed it to libpng.dll and tried running my osg app again, but without any success. i will try the program you suggested shortly and report the result, though i have all the libraries that i needed to compile the libpng and the osg in the system path variable. Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44139#44139 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] starting with stencil buffer to achieve ray tracing
hello good people! i need a bit of advice ragarding some more advanced rendering techniques. advanced for me, anyway. i am trying to build a simple ray tracing application on top of the basic osgviewer program. to start off, i am trying to look at the loaded model and decide where to cast rays, e.g. i don't want to cast any rays where the model would be missed. i was thinking of using the stencil buffer and the first thing i need is to draw say white pixels where the model is and say black pixels where the model is not. then display this buffer as the frame buffer, you know what i mean. is this possible? i remember doing something similar with GLUT long, long time ago. //if i was able to do this kind of evaluation on the per-pixel basis, i think, i could add some more advanced features like the color of the first hit object (instead of white) and then maybe continue with some real ray tracing, as i mention in the following lines.// later on, according to where the model would be hit (the white pixels), i would cast rays using line intersectors. haven't thought about details here yet. it would be kind of any of you if you could give me some pointers, especially for the first part with the buffers that i am currently dealing with - is it even possible? is my concept good? - for my knowledge in this area has gotten very poor :( and i am also new to the osg. thank you very much in advance. Andrey -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44140#44140 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] starting with stencil buffer to achieve ray tracing
basically, what i want to do is to cast primary rays from the camera (for each pixel on the screen) into the scene using line intersectors. then i want to retrieve normal of the intersection to be able to compute the direction of the secondary ray and then to cast it the way i cast the primary rays. i want to continue recursively until a certain point. with the buffer i want to optimize the number of the primary rays casted. ultimately, my goal is to render the scene normally using opengl pipeline into FBO, then turn on ray tracing for certain objects/materials in the scene. i need to know whether this is possible and in what ways can osg help. what i see as the greatest advantage are the intersetors and the osg's ability to compute the intersections automatically. i don't get the connection between the octree, which if i am not mistaken is a way of organizing the data or the scene, and my goal. neither i get the reason why this buffer thing would not work on perspective projection, if that's what you meant. thanks -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44147#44147 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] png plugin - problem loading images
Hello good ppl! i am quite new to OSG, though i managed to build it from source with several plugins. now one of them is not working - PNG. and i do need it. i am using MinGW gcc compiler suite and w7/x64 system. i built osg 3.xy from sources, with libpng, zlib, libjpg and coin plugins, which i also built from sources. i have a model that is supposed to load .png files as textures, but i'm getting this message with all the files Code: Warning: Could not find plugin to read objects from file .\textures\13.png. [Arrow] i tried renaming the png file to some nonsense and the program screamed that the file does not exist - so i guess the file path in the model is all right. [Arrow] i also tried putting the folder with osg plugins into the system path, as suggested in one of the threads. [Arrow] then i tried renaming the texture to load in the model then saving the texture into .jpg file - it worked. so the plugins themselves DO work. so where is or can the prblem be? [Question] why does the plugin not work? [Question] i do have mingw_osgdb_png.dll in the plugins folder, which is accessible from the console i run my applcation, or the osgviewer program. you may ask why do i need png textures when i am able to use .jpg textures - the answer is easy - i need transparent textures. Thank you for your time! Cheers, Andrey [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44012#44012 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org