Re: [osg-users] flickering with live video feed
robertosfield wrote: It is starting to sound a bit like a driver bug. Does the texture get applied to the whole scene? One thing you could try is to only apply the problem texture to a specific geometry and make sure the texture unit it's applied is disabled for the rest of the scene. The texture is not applied to the entire scene, only to certain geometries. Both kinds of geometries are showing this flickering behavior. I tried downloading the latest driver from Intel's web site, but it made no difference. I will try adding a video card to see if that helps. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57244#57244 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] flickering with live video feed
Hi, I am having a problem with flickering in my application. I have a scene that includes a live video texture that I project into the scene using a TexGen node. The texture uses an ImageStream object on which I call setData with the pointer to the raw image data. This image is provided by another subsystem that I do not have control over. The image is updated approximately every 20 ms. When I recently tested my application with a different physical camera and a different version of the image capture subsystem, I would see flickering after the application is running for 5-10 minutes or so. The flicker would stop if I shut off the video feed (so that Image::setData is no longer called). This would make me suspect a bug in the image capture code; however, the entire graphics window flickers, not just the area with the video projection. In fact, I can move the scene so that the video is no longer in the view frustum and the flickering continues. Other than the camera, the hardware is identical. This is a Qt application and the 3D window is just one panel of a larger GUI window. The OSG widget is set up along the lines of the osgViewerQt example. I tried setting OSG_NOTIFY_LEVEL to DEBUG to see if there were any errors but I didn’t see anything suspicious. I am using OSG 3.0.0, Qt 4.8.4, and Windows XP. The video driver is Intel HD Graphics. Does anyone have a suggestion on what could be the cause of this flickering and how to fix it? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57201#57201 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] flickering with live video feed
robertosfield wrote: Hi Michael, You don't say what you mean by flicker or what it relates too. Is just the video texturing flickering? What does the flicker look like? Robert. Hi Robert, What it looks like is different geometry in the scene will turn black for a split second, then change back to their normal color. This will happen to random geometry at random intervals, but the interval is short (less than a second). It is not limited to the video texture. In fact it will occur even if the video is not visible (i.e. it is outside the view frustum) and it also affects geometry that the video texture is not applied to, whether or not they are within the boundary of the video projection. I also have a StatsHandler attached to my viewer; when turned on, the statistics will disappear for a split second and then reappear. Thanks, Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57206#57206 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] anyone have experience with OSG on Intel HD Graphics 4000 hardware?
Hi, Does anyone have experience with using OSG on the Intel HD Graphics 4000 hardware? I am having performance problems in my application with fairly simple scenes. I have several different models which are simple shapes like boxes, tubes, X's, etc. that are duplicated about 40 times each using MatrixTransforms. The bottleneck is in the Draw traversal. With this scene I am seeing a draw time of 55 ms on the HD Graphics, while on another PC with a Radeon X1550 card the draw time is 3.8 ms. I've used OpenGL Extensions Viewer (http://www.realtech-vr.com/glview/) on both machines and according to that the HD Graphics only supports OpenGL 3.0/3.1, with no support for earlier versions. My development PC with the Radeon card supports 1.1-2.1. I'm currently using OSG 3.0.0, with a build that turned on OSG_GL1_AVAILABLE and OSG_GL2_AVAILABLE, but not OSG_GL3_AVAILABLE. Is it possible that using only GL3 would give better performance? One other thing I should mention is that I used gDebugger and their Teapot sample application performs better on the Intel HD Graphics than the Radeon card, which suggests to me that I'm not using the hardware correctly. Using alternate hardware is not an option at this time. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52393#52393 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgManipulator serializers not working
Hi, Thanks Robert! The .osgt format worked just fine. I didn't know about the new formats. Guess I should have read the Beginner's Guide more carefully :) ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51974#51974 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] stl plugin and BIND_PER_PRIMITIVE
Hi, I have some models in my application that were provided to me in the .stl file format, that I converted into .osg format using osgconv. I was looking at the .osg file and I noticed it contained BIND_PER_PRIMITIVE for the normals. I read elsewhere on the forum that this mode should be avoided as it forces the app onto a slow path in OpenGL. I looked over the source code for the stl plugin and it looks like everything is imported as TRIANGLES. If this is the case, couldn't the normal vectors each be duplicated 3 times in order to use BIND_PER_VERTEX instead? If this works, would it be worthwhile for me to submit this change? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51715#51715 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgManipulator serializers not working
Sorry for the thread bump, but has anybody ever gotten the osgManipulator serializers to work? They would be helpful to me in debugging my application. Thanks, Mike mschan01 wrote: Hi, I am trying to write my scene containing Draggers to an .osg file in order to debug my application. However, the Draggers in the graph are skipped over and do not appear in the file. I set the OSG_NOTIFY_LEVEL to DEBUG and I saw this console output: FindFileInPath() : trying C:\OpenSceneGraph\3.0.0\src\x86-win32-msvc\lib\osgPlugins-3.0.0\osgdb_osgmanipulatord.dll ... DynamicLibrary::failed loading osgPlugins-3.0.0/osgdb_osgmanipulatord.dll But, there is no osgdb_osgmanipulatord.dll. The closest I have is osgdb_serializers_osgmanipulatord.dll. I tried renaming that dll but it still didn't work, it just complained about another file. What do I need to do to get the osgManipulator serializers working? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51716#51716 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Using osgManipulator Dragger to drag a circle
Never mind; I solved this problem by overriding Dragger::handle (GUIEventAdapter , GUIActionAdapter )and using a PolytopeIntersector in place of the LineSegmentIntersector it was using before. This picks up my line geometry so I no longer need the triangle strip, and I can specify the polytope in screen coordinates. Cheers, Michael mschan01 wrote: Hi, I am trying to add a circle to my application that the user can resize by dragging. I subclassed osgManipulator::Dragger, and in setupDefaultGeometry() I draw a circle with lines, then another circle with a triangle strip which is then hidden (this is used as the draggable area, since the intersection doesn't work too well with lines). So if my visible circle has radius R, then the triangle strip has a width W and its vertices are two circles of radius R+W/2 and R-W/2. Then on a mouse drag I calculate the new radius, and apply a uniform scaling on the dragger. This works, but it has a disadvantage in that the draggable area (W) scales as well. I'd like the draggable area to be a constant size from the visible circle. That is, I would like W to be constant in screen coordinates. I could probably accomplish this by recalculating all of the vertices after each mouse release, but this seems inefficient. Is there a better way to do what I am describing? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51353#51353 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Using osgManipulator Dragger to drag a circle
Hi, I am trying to add a circle to my application that the user can resize by dragging. I subclassed osgManipulator::Dragger, and in setupDefaultGeometry() I draw a circle with lines, then another circle with a triangle strip which is then hidden (this is used as the draggable area, since the intersection doesn't work too well with lines). So if my visible circle has radius R, then the triangle strip has a width W and its vertices are two circles of radius R+W/2 and R-W/2. Then on a mouse drag I calculate the new radius, and apply a uniform scaling on the dragger. This works, but it has a disadvantage in that the draggable area (W) scales as well. I'd like the draggable area to be a constant size from the visible circle. That is, I would like W to be constant in screen coordinates. I could probably accomplish this by recalculating all of the vertices after each mouse release, but this seems inefficient. Is there a better way to do what I am describing? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51327#51327 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] question about RotateCylinderDragger
Hi, In my application I am trying to create a box that the user can resize and rotate. I have a CompositeDragger that works similar to the TabPlaneDragger class (without the translation). I would like to use the RotateCylinderDragger for the rotation but it doesn't do quite what I want. I would like to have a handle sticking out from the cylinder that the user could drag to rotate. To illustrate: ...o ...| []---[]---[] || || []..[] || || []---[]---[] In this illustation the [] symbols are the scale dragger handles and the o is the rotation handle (the periods are just for spacing). I want to drag on the o handle to rotate an invisible cylinder whose center is the center of the box, and whose radius extends to the o handle. However the RotateCylinderDragger rotates when dragging the side of the cylinder, not the top. In other words, if my camera is directly over the end of the cylinder (pointed toward the center of the circle) then dragging the cylinder has no effect, which is not what I want. Is is possible to use RotateCylinderDragger to do what I described, or do I need to write my own Dragger? ... Thank you! Cheers, Michael[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50986#50986 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] custom CompositeDragger and AntiSquish
Hi, Please disregard my first question about AntiSquish... I had a bug where a NodeCallback which mistakenly did not call traverse() was attached to a node above the Dragger. This meant the update traversal never reached the AntiSquish. However, I am still open to suggestions about my second question... how to make the 1D dragger handles' length scale with the box length, but remain a constant width in screen coordinates ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50819#50819 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] question about Optimizer and FLATTEN_STATIC_TRANSFORMS
lyceel wrote: Hi, Michael, The structure of the scene itself can sometimes prevent the transform from being flattened away. What happens if you try FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS (sometimes, you just need a bigger hammer :-) ). That worked, thanks. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50820#50820 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] custom CompositeDragger and AntiSquish
Hi, I am trying to add a 2D box to my scene (consisting of lines 1 pixel wide) that a user can resize by dragging the sides or corners, or rotate by dragging a handle. I'm attempting to use the osgManipulator Dragger classes for this purpose. I created a subclass of CompositeDragger and added to it a Scale2DDragger (for the corners) and two Scale1DDraggers (for each pair of sides). Basically the code is a copy of the TabPlaneDragger without the TranslatePlaneDragger child dragger. I added the dragger to my scene using the osgManipulator example as a guide. My scene looks like this: Group | \ MatrixTransform CustomDragger | Geode (containing box geometry) and I call addTransformUpdating() on CustomDragger passing the MatrixTransform. The box resizes correctly when I drag the handles. A problem I am having is that the drag handles will not stay a constant size. If I drag the box so that one side is longer than the other, the handle boxes will have the same non-uniform scaling. I am using AutoTransform and AntiSquish in my code exactly the way TabPlaneDragger does to prevent this from happening, but for some reason it doesn't work in my code (although it works in the osgManipulator example). The only real difference in my code is that I set a rotation matrix in the CustomDragger, in order to draw the drag boxes in the XY plane (it seems to default to the XZ plane). What could be causing the drag handles to scale instead of staying a constant screen size? What I ultimately want is for the entire box to be draggable. So I want the handles to cover the box, and be a constant few pixels wide in screen coordinates regardless of the zoom level. Then I will make the handles invisible so only the 1-pixel wide box is visible. Any advice on how to do this? (I am using OSG 3.0.0.) ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50761#50761 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] question about Optimizer and FLATTEN_STATIC_TRANSFORMS
Hi, I have a model that I converted from an .stl file to .osg. I wanted to apply a scaling to the model, so I added a MatrixTransform with a scaling matrix above the model's root node. For maximum efficiency I wanted to apply the transform directly to the vertices, so I tried to run the .osg file through osgconv a second time, with the OSG_OPTIMIZER env variable set to FLATTEN_STATIC_TRANSFORMS. However, the new file was identical to the previous file, with the parent MatrixTransform still in place. I set the DataVariance of the transform to STATIC, and it had no effect. Is there something else that could interfere with the Optimizer flattening the transform, or am I expecting FLATTEN_STATIC_TRANSFORMS to do something that it's not intended to do? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50676#50676 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to create glow effect in OSG
I've seen that there is a glow example in osgPPU. Are there any examples using just OSG that would give an effect similar to the attachment in my previous post? I would prefer not to bring another library into my project if at all possible. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50353#50353 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to create glow effect in OSG
Hi, I would like to create a glow or halo effect around my geometry. What is the most efficient way to create this effect in OSG? The attached screenshot shows the effect I am trying to achieve. The left X is the original geometry and the right X has the glow effect. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50067#50067 Attachments: http://forum.openscenegraph.org//files/glow_162.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to exclude LOD-disabled nodes from PolytopeIntersector results?
Hi, I have a CAD app in which I am using LOD nodes to hide features at different zoom levels. I have also implemented picking using PolytopIntersector similar to the example in the Quick Start Guide. I have noticed that the PolytopeIntersector returns intersections that include nodes which are turned off by the LOD. I would like to exclude these from the intersections. Does OSG provide a way to do this? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49652#49652 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to exclude LOD-disabled nodes from PolytopeIntersector results?
I solved my problem... For reference, the code I am referencing from the OSG Quick Start Guide is this: Code: double w( .05 ), h( .05 ); osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, x-w, y-h, x+w, y+h ); osgUtil::IntersectionVisitor iv( picker ); viewer-getCamera()-accept( iv ); Shortly after I posted, I saw that osgUtil::IntersectionVisitor contains a function setLODSelectionMode(). I tried setting this to USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION but it had no effect. I did a bit more investigating and saw that this enum is referenced in IntersectionVisitor::getDistanceToEyePoint(). However, LOD::traverse() calls NodeVisitor::getDistanceToViewPoint(), which is not implemented in IntersectionVisitor. I was able to derive from IntersectionVisitor and implement getDistanceToViewPoint() similarly to getDistanceToEyePoint(): Code: if (_lodSelectionMode==USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION) { return (pos-getViewPoint()).length(); } else { return 0.0f; } then used the subclass in my picking code, after which I got the desired effect. Is this something that should be added to osgUtil::IntersectionVisitor? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49653#49653 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with GUIEventAdapter mouse wheel event in Qt
Hi Robert, After debugging a bit more it appears that the issue begins when the event is taken off the event queue inside CompositeViewer. There is the following case statement inside CompositeViewer::eventTraversal() (line 755 in version 3.0.0): Code: case(osgGA::GUIEventAdapter::PUSH): case(osgGA::GUIEventAdapter::RELEASE): case(osgGA::GUIEventAdapter::DOUBLECLICK): case(osgGA::GUIEventAdapter::DRAG): case(osgGA::GUIEventAdapter::MOVE): { pointerEvent = true; Note that SCROLL is not included in these cases. If I force the scroll event through this code path in the debugger then the input range and y orientation are correct when the event is passed to my GUIEventHandler. Is this a bug, or is there some reason that scroll events need to be treated differently here? In any case, I was able to work around this in my application, but maybe this will help out the next person. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49603#49603 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with GUIEventAdapter mouse wheel event in Qt
Hi, I'm seeing something strange with mouse wheel (SCROLL) events in GUIEventAdapter. My app is a Qt app set up following the osgviewerQt example. I am trying to implement zooming with the mouse where the zoom follows the mouse cursor. In some cases I want to zoom with mouse clicks, and in other cases I want to use the mouse wheel. Zooming was not working correctly when I used the mouse wheel. I noticed that for SCROLL events, the x and y min/max were always -1 / +1, which caused GUIEventAdapter::getX/Ynormalized() to return the wrong values. So, I figured I would just use getX/Y() instead and use inverse viewport matrix to get the normalized device coordinates. But, then I noticed I was still getting inconsistent values for the Y coordinate. For a RELEASE event, the GUIEventAdapter has Y_INCREASING_DOWNWARDS for the y orientation, and getY() returns 0 in the top left corner of the window. For a SCROLL event, it has Y_INCREASING_UPWARDS and getY() returns 0 in the bottom left corner. Why are the two event types inconsistent? Is there some attribute I am forgetting to set somewhere? I am using OSG 3.0.0 and Qt 4.7. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49332#49332 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem using AutoTransform with LOD node
Hi, I am trying to create a scene for a CAD-type app where I have objects that should be a constant screen size as I zoom in and out, but when I cross a certain zoom threshold it should change to a different size (for example half its original size). I tried to implement this using a combination of AutoTransform and LOD nodes. Here is a sample graph of two objects: AutoTransform AutoTransform \ / LOD / \ MatrixTransform MatrixTransform \ / Geode The problem I have is that when I have the AutoTransforms set to autoScaleToScreen=true, then the level of detail does not change when it should. It always stays at whatever level it started at regardless of how much I move the camera in or out. If I set autoScaleToScreen to false, then the LOD behaves as I expect (meaning it changes when I move the camera from one range to another). What might be causing this to happen? Is there another way to get the effect I want? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49272#49272 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
It turns out that using point sprites is not an option for me as I now have a requirement that the objects must rotate with the world. I could use AutoTransform with setAutoScaleToScreen(true) and setAutoRotateMode(NO_ROTATION), but it's still not quite fast enough for my application. I am holding at around 19 fps, but I'd like to get it to at least 25 fps. My scene graph contains several thousand MatrixTransforms arranged like this: Root | ... MT ( x 2000) / \ MT MT / \ / \ MT MT MT MT \ | | / AutoTransform | Geode At my default zoom level, only about 32 objects are visible at a time. Is there anything else I try to improve performance while maintaining the constant screen size and rotate-with-world properties? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48779#48779 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
Alpha to coverage didn't have any visible effect, but using alpha testing instead seems to work: Code: osg::AlphaFunc *af = new osg::AlphaFunc(); af-setFunction(osg::AlphaFunc::GEQUAL, 0.75f); ss-setAttributeAndModes(af, osg::StateAttribute::ON); Cheers, Michael[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48719#48719 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
Thanks! My other mistake was using DECAL instead of REPLACE in my TexEnv. I didn't realize DECAL was keeping the point's original alpha, which made the entire point sprite transparent, not just the X. I still don't quite have the visual effect I want yet. When the X's are close enough to overlap, the topmost ones appear to be cutting a gap or casting a shadow on the X's beneath, even though alpha is 0 for every black texel (see attachment ps.jpg). I'd like to just have the white overlap (as in attachment at.jpg, from my AutoTransform implementation). Is there anything I can do to fix it? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48694#48694 Attachments: http://forum.openscenegraph.org//files/at_303.jpg http://forum.openscenegraph.org//files/ps_140.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
My initial implementation with AutoTransform is not fast enough for my application. I have thousands of MatrixTransforms sharing a single AutoTransform with a child Geode, containing a geometry with two lines. I was getting around 17 fps. Removing the AutoTransforms improved the framerate to 20-25 fps (20 is sufficient for my application). Since I still need the constant size, I am attempting to use an alternate implementation with PointSprites to see if that performs any better. I used the osgpointsprite example as a guide. However, I'm having trouble getting transparency to work. I want a white 'X' to overlay the rest of the scene at each point. What I am getting is a black opaque box at each point, with the white X inside the box. I've set the alpha to 0 in the point color array, and in the texture outside the X. Can someone help me figure out what I'm doing wrong? Here's the code: Code: osg::ref_ptrosg::Geode geode = new osg::Geode; osg::ref_ptrosg::Geometry geom = new osg::Geometry; osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array; vertices-push_back(osg::Vec3(0.0, 0.0, 10.0)); osg::ref_ptrosg::Vec4Array colors = new osg::Vec4Array; colors-push_back(osg::Vec4(0.0, 0.0, 0.0, 0.0)); geom-setVertexArray(vertices); geom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 1)); geom-setColorArray(colors); geom-setColorBinding(osg::Geometry::BIND_PER_VERTEX); geode-addDrawable(geom); // Give it an initial bound so it doesn't get culled (osg can't calculate a bounding volume for a single point) geode-setInitialBound( osg::BoundingSphere( osg::Vec3(0.0, 0.0, 0.0), 100.0 ) ); const int pixelsX = 50; const int pixelsY = 50; const int bytesPerPixel = 4; unsigned char *buf = new unsigned char[pixelsX * pixelsY * bytesPerPixel]; memset(buf, 0x00, pixelsX*pixelsY*bytesPerPixel); for (int i = 0; i pixelsX; i++) { for (int j = 0; j pixelsY; j++) { if (i == j || pixelsX - i - 1 == j) { for (int k = 0; k bytesPerPixel; k++) { buf[i * pixelsY * bytesPerPixel + j * bytesPerPixel + k] = 0xFF; } } } } osg::ref_ptrosg::Image img = new osg::Image; img-setImage(pixelsX, pixelsY, 1, GL_RGBA8,// internal format GL_RGBA, // pixel format GL_UNSIGNED_INT_8_8_8_8_REV, // pixel data type buf, // data buffer osg::Image::USE_NEW_DELETE); // allocation mode osg::ref_ptrosg::Texture2D tex = new osg::Texture2D; tex-setImage(img); tex-setBorderColor(osg::Vec4(0.0, 0.0, 0.0, 0.0)); osg::ref_ptrosg::PointSprite sprite = new osg::PointSprite; osg::ref_ptrosg::Point point = new osg::Point; point-setSize(100.0); osg::ref_ptrosg::StateSet ss = geode-getOrCreateStateSet(); ss-setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON); ss-setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON); ss-setAttribute(point); ss-setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::ref_ptrosg::TexEnv texenv = new osg::TexEnv; texenv-setMode(osg::TexEnv::DECAL); ss-setTextureAttribute(0, texenv); Thanks, Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48668#48668 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to draw a tube connecting two geometries
Hi, I am creating a scene in which there will be two geometries connected by a tube. The geometries can move around in between frames, so the tube must also move and resize. The way I am trying to do this is to have a geometry for a tube of unit length and diameter. Then, if the position of either endpoint changes, I recalculate the midpoint and use a translation matrix to move the tube there, and give it the correct scaling and rotation to connect the two endpoint geometries. The graph would look something like this: Root /| \ Matrix MatrixMatrix \/\ Geode Geode (Tube Geometry) (Endpoint Geometry) Is this the most efficient way to do this? Is there some way I could tie in to the two MatrixTransforms for the endpoints to automatically update the tube's location? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48165#48165 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] problem with seams while drawing quads and quad strips
You're right, the normals were the problem. My mistake was using the QUAD_STRIPS and setting the normals for the shared vertices to the combined normals of the adjacent faces. I changed everything to QUADS and used the face's normal as each vertex's normal, and then it looked correct. Thanks! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48137#48137 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] problem with seams while drawing quads and quad strips
Hi, I am trying to draw a shape that is basically a hollow box with a tick mark on one side extending into the center (screenshot attached). I attempted to do it by drawing QUAD_STRIPS for the outer and inner faces, and QUADS for the top and bottom faces. My problem is, seams are clearly visible on the top of the model where the quads join together. At first I thought I made a mistake with the normal vectors, but I double checked them and I think the math is correct. Is there a better way to accomplish what I am trying to do? Here's the code: Code: osg::Node* drawModel() { osg::Geode *myGeode = new osg::Geode; osg::Geometry *myGeom = new osg::Geometry; myGeode-addDrawable(myGeom); // VERTICES osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array; // sides vertices-push_back( osg::Vec3( -1.0, -1.0, 0.0)); vertices-push_back( osg::Vec3( -1.0, -1.0, 0.1)); vertices-push_back( osg::Vec3( 1.0, -1.0, 0.0)); vertices-push_back( osg::Vec3( 1.0, -1.0, 0.1)); vertices-push_back( osg::Vec3( 1.0, 1.0, 0.0)); vertices-push_back( osg::Vec3( 1.0, 1.0, 0.1)); vertices-push_back( osg::Vec3( -1.0, 1.0, 0.0)); vertices-push_back( osg::Vec3( -1.0, 1.0, 0.1)); vertices-push_back( osg::Vec3( -1.0, -1.0, 0.0)); vertices-push_back( osg::Vec3( -1.0, -1.0, 0.1)); // top face vertices-push_back( osg::Vec3( -1.0, -1.0, 0.1)); vertices-push_back( osg::Vec3( -1.0, 1.0, 0.1)); vertices-push_back( osg::Vec3( -0.8, 1.0, 0.1)); vertices-push_back( osg::Vec3( -0.8, -1.0, 0.1)); vertices-push_back( osg::Vec3( -0.8, 0.8, 0.1)); vertices-push_back( osg::Vec3( -0.8, 1.0, 0.1)); vertices-push_back( osg::Vec3( 0.8, 1.0, 0.1)); vertices-push_back( osg::Vec3( 0.8, 0.8, 0.1)); vertices-push_back( osg::Vec3( 0.8, 1.0, 0.1)); vertices-push_back( osg::Vec3( 1.0, 1.0, 0.1)); vertices-push_back( osg::Vec3( 1.0, -1.0, 0.1)); vertices-push_back( osg::Vec3( 0.8, -1.0, 0.1)); vertices-push_back( osg::Vec3( -0.8, -1.0, 0.1)); vertices-push_back( osg::Vec3( -0.8, -0.8, 0.1)); vertices-push_back( osg::Vec3( 0.8, -0.8, 0.1)); vertices-push_back( osg::Vec3( 0.8, -1.0, 0.1)); vertices-push_back( osg::Vec3( -0.1, -0.8, 0.1)); vertices-push_back( osg::Vec3( -0.1, 0.0, 0.1)); vertices-push_back( osg::Vec3( 0.1, 0.0, 0.1)); vertices-push_back( osg::Vec3( 0.1, -0.8, 0.1)); // bottom face vertices-push_back( osg::Vec3( -1.0, -1.0, 0.0)); vertices-push_back( osg::Vec3( -1.0, 1.0, 0.0)); vertices-push_back( osg::Vec3( -0.8, 1.0, 0.0)); vertices-push_back( osg::Vec3( -0.8, -1.0, 0.0)); vertices-push_back( osg::Vec3( -0.8, 0.8, 0.0)); vertices-push_back( osg::Vec3( -0.8, 1.0, 0.0)); vertices-push_back( osg::Vec3( 0.8, 1.0, 0.0)); vertices-push_back( osg::Vec3( 0.8, 0.8, 0.0)); vertices-push_back( osg::Vec3( 0.8, 1.0, 0.0)); vertices-push_back( osg::Vec3( 1.0, 1.0, 0.0)); vertices-push_back( osg::Vec3( 1.0, -1.0, 0.0)); vertices-push_back( osg::Vec3( 0.8, -1.0, 0.0)); vertices-push_back( osg::Vec3( -0.8, -1.0, 0.0)); vertices-push_back( osg::Vec3( -0.8, -0.8, 0.0)); vertices-push_back( osg::Vec3( 0.8, -0.8, 0.0)); vertices-push_back( osg::Vec3( 0.8, -1.0, 0.0)); vertices-push_back( osg::Vec3( -0.1, -0.8, 0.0)); vertices-push_back( osg::Vec3( -0.1, 0.0, 0.0)); vertices-push_back( osg::Vec3( 0.1, 0.0, 0.0)); vertices-push_back( osg::Vec3( 0.1, -0.8, 0.0)); // inner faces vertices-push_back( osg::Vec3( -0.8, -0.8, 0.0)); vertices-push_back( osg::Vec3( -0.8, -0.8, 0.1)); vertices-push_back( osg::Vec3( -0.8, 0.8, 0.0)); vertices-push_back( osg::Vec3( -0.8, 0.8, 0.1)); vertices-push_back( osg::Vec3( 0.8, 0.8, 0.0)); vertices-push_back( osg::Vec3( 0.8, 0.8, 0.1)); vertices-push_back( osg::Vec3( 0.8, -0.8, 0.0)); vertices-push_back( osg::Vec3( 0.8, -0.8, 0.1)); vertices-push_back( osg::Vec3( 0.1, -0.8, 0.0)); vertices-push_back( osg::Vec3( 0.1, -0.8, 0.1)); vertices-push_back( osg::Vec3( 0.1, 0.0, 0.0)); vertices-push_back( osg::Vec3( 0.1, 0.0, 0.1)); vertices-push_back( osg::Vec3( -0.1, 0.0, 0.0)); vertices-push_back( osg::Vec3( -0.1, 0.0, 0.1)); vertices-push_back( osg::Vec3( -0.1, -0.8, 0.0)); vertices-push_back( osg::Vec3( -0.1, -0.8, 0.1)); vertices-push_back( osg::Vec3( -0.8, -0.8, 0.0)); vertices-push_back( osg::Vec3( -0.8, -0.8, 0.1)); myGeom-setVertexArray(vertices); myGeom-addPrimitiveSet(new osg::DrawArrays( osg::PrimitiveSet::QUAD_STRIP, 0, 10 ));
[osg-users] Lines not showing when zoomed in orthographic projection
Hi, We have a scene with one osg-loaded object. When we load our scene, our camera projection (ortho) is zoomed such that the object is not visible in the graphic window. Our code then dynamically adds 2 new lines to the scene at a location corresponding to the center of the screen, but these lines are not visible. Only when we zoom out (by changing the camera ortho projection) to a level where the pre-loaded object appears, then the 2 lines appear on the screen. We also noticed a second scenario similar to this, in which we will first pan our camera far to the left, then zoom out, but the pre-loaded osg object does not show. It will only appear when we pan back near to the object location, and zoom in again. We are using AutoTransforms for our drawn objects to have them be a constant size and rotation as we pan and zoom the camera. We are not sure if this is a culling issue or something else. What could be causing this behavior? Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47733#47733 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] problem with handleMouseRelease using custom camera manipulator
Hi, I’m using OSG with Qt. I want to change the mouse cursor when I press and release a mouse button over my QGLWidget. I’ve created a custom camera manipulator by subclassing TrackballManipulator, and overriding handleMousePush() and handleMouseRelease(), in which I call QWidget::setCursor(). However, the cursor does not change immediately when I click or release the button. It only changes after the first mouse movement after the click or release. When I debugged my code I saw that handleMouseRelease() is not being called until the first movement after I release the mouse button. What do I need to do to be able to take action immediately when the button is pressed/released? I’ve set up the Qt widget similar to the osgViewerQt example. I am using OSG version 3.0.0 and Qt version 4.7.1. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47032#47032 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
AutoTransform was exactly what I needed; thanks :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46638#46638 ___ 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
[osg-users] live video texture performance
Hi, I am trying to create a scene which contains a texture displaying a live video image. The image is sent as a buffer of raw data from an attached camera. I was able to get something working but the performance is terrible: about 1.42 frames per second. I need to get to at least 20 fps. I am dealing with an image that is 640x480 pixels with 32 bits per pixel. I have stripped down my scene to contain only a geode with a quad geometry, and an attached texture, and I still see the performance problem. The texture has an attached StateAttributeCallback, in which I fetch the buffer of data for the next video frame, and then call setImage: img-setImage( 640, // width 480, // height 1, // depth GL_RGB8, // internal texture format GL_BGRA, // pixel format GL_UNSIGNED_INT_8_8_8_8_REV, // data type data, // raw data pointer osg::Image::NO_DELETE); I also experimented with another technique that I found on another post where someone is doing something very similar to what I’m trying to do: Re: Update a texture's pixels contents, using apply or glTexSubImage2D Robert Osfield Fri, 26 Sep 2008 01:33:52 -0700 Hi Guillaume, The way to integrate a live video stream is to subclass from osg::ImageStream (which is subclass from osg::Image), as is done in the OSG's quicktime and xine-lib plugins. The ImageStream is then attached to Texture be it a Texture1D, 2D, 3D or TextureRectangle. This approach means that you don't ever subclass from the Texture objects as the image data is encapsulated complete by osg::Image/ImageStream. The way I'd tackle your task is to subclass from osg::ImageStream and then allocate the image data then copy over this in your background thread and then call dirty() on the ImageStream, this will tell the Texture::apply() that the image data has changed and it'll then automatically subload the data for you. ImageStream also by default provides a PixelBufferObject which means upload performance will be the best you can get. Robert. To make this technique work, in my video frame producer thread I was calling ImageStream::data() to get the pointer to the raw data, then doing a memcpy to write the new frame, then calling dirty(). I no longer used a StateAttributeCallback in this method. Unfortunately, I did not see any noticeable change in performance using this technique. Do I need to use another function in order to write directly to the pixel buffer object? Also what thread synchronization do I need here? My hardware specs are as follows: Intel Celeron 550 CPU (2.0 GHz) 1.0 GB RAM Mobile Intel GME965 Express Chipset with integrated graphics Upgrading hardware is not an option for me. Please let me know what I can do to maximize performance in this situation. Thanks, Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45922#45922 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] live video texture performance
Thanks for the responses. Using a PixelBufferObject did not appear to make any difference in performance for me. My video hardware only supports OpenGL 1.5, so that is probably the reason. I suspect the power of two issue is the cause of my performance problem. When I create a 640x480 image I get a console message that it is being scaled to 512x512. However, when I try to create a 512x512 image instead, I get an error message Detected OpenGL error 'invalid enumerant' at After Renderer::compile. This is before I even attempt to load any video data into the image. What does this error mean? Here is the code: int pixelsX = 640; int pixelsY = 480; int bytesPerPixel = 4; rawData = new unsigned char[pixelsX * pixelsY * bytesPerPixel]; memset(rawData, 0xFF, (pixelsX * pixelsY * bytesPerPixel)); setImage( pixelsX,// width pixelsY,// height 1, // depth GL_RGB8, // internal texture format GL_BGRA, // pixel format GL_UNSIGNED_INT_8_8_8_8, // data type rawData,// raw data osg::Image::NO_DELETE); // memory allocation mode Using 640x480 (which gets scaled to 512x512) I get a white quad, as I expect. However, if I use 512x512 image, I see distorted green lines with a black background on the quad, along with the error. If I try to load any video data at this point, the program crashes. I also have the option of using a video frame of 8 bits per pixel (for a greyscale image) but I have not been able to see the image at all in that case. I tried using the GL_LUMINANCE pixel format and GL_UNSIGNED_BYTE data type, along with a few other combinations, but nothing has worked so far. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45956#45956 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] projective texture mapping and lighting
Never mind; I was able to figure out a solution by studying the osgpackeddepthstencil example and some OpenGL stencil buffer tutorials I found online. What I did was add a node to the root where I created a geometry the same size as my video projection, and added a Stencil. I also turned off depth testing and set the ColorMask to false. This became my stencil mask. Then, I added two more nodes to the root. Each had a stencil. One was set to draw if the stencil was equal to 1, the other if not equal to 1. To the first node's StateSet I also added the texture I am projecting. To each of these, I added the node which was the root of my model geometry. This caused the video projection to be drawn inside the mask, and the rest of the scene without the projection outside the mask. -Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45638#45638 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] projective texture mapping and lighting
Apparently I spoke too soon; the method I described in my last post doesn’t work when I rotate the viewer. If I had an object outside the texture projection area and rotated it so it should obscure the image, I could see the image through the object. Likewise, if I had an object inside the projection and rotated so that the top appeared to be outside the projection area, I would not see the projection on the part of the object outside the projection area. Another technique I tried was to use clipping planes. I used two nodes that each added the rest of my scene as a child. One node did not use the texture projection, and the other did use it but also added a ClipNode in order to clip everything but the desired texture projection area. This resulted in Z-fighting between my image and the color of the underlying geometry. Finally I tried a hybrid of the two methods, where I took my stencil mask node and added a child ClipNode, then added my model as a child of the ClipNode. I wanted the stencil to “wrap” exactly the model, but only within the borders of my image. However, the ClipNode had no effect. The appearance was that the texture was applied to my entire scene, and everything outside my image boundary was dark, like my original problem. Can anyone please help? Thanks, Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45665#45665 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] projective texture mapping and lighting
Hi, I am new to OSG and OpenGL. I am attempting to create a scene where an image from a real camera is projected onto a 3d model of the object being photographed. I used the projective texture mapping technique following the osgspotlight example, substituting my image for the spotlight image in the texture, and using an orthographic projection. This gave me the desired effect I wanted within the projection area, but it made the rest of my scene black. I would like the rest of the scene to have normal lighting. Basically, I want to take the osgspotlight example and give some ambient light to the rest of the scene. I tried adding an additional light node as a child of a root above the node containing the texture (which is the root in the osgspotlight example) but scene outside the texture projection remained black. Some of my reading suggested that using the stencil buffer with multipass rendering might be the solution, but I was hoping a simpler solution might work. Is there another way to do this? If not, where could I find a simple example of using stencils and multipass rendering? Thanks, Mike -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45559#45559 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org