[osg-users] Double precision tessellator, optimizer, and such
Hi Robert, hi all, I need double precision things in my app, and had to code things like Tessellatord, a double precision version of Tessellator (already submitted). However, I would like to have something cleaner to submit, such as a unique tesselator class that handle both single and double precision values. I need your advice: according to you, what is the best way to code this? Some ideas: - Duplicate code (VERY ugly) - Make the class templated (ugly) - Make a templated class that would be used by the Tessellator (still ugly) - Create/use an array adapter (Vec*Array would be encapsulated, and Tessellator would use it instead of direclty reading the array) - ... other ideas? Thanks. I'll try to apply this to other classes after. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Hi Sukender, I single Tessellator class is the right way to go, one could possible make parts of the implementation templated but keep the interface the same for both cases. One other thing to bare in mind is that OpenGL ES and for OpenGL 3.x/4.x GLU is no longer available so we need to replace all the OSG's GLU code for the OSG to be fully functionality across all OpenGL targets. Robert. On Mon, Jul 26, 2010 at 8:32 AM, Sukender suky0...@free.fr wrote: Hi Robert, hi all, I need double precision things in my app, and had to code things like Tessellatord, a double precision version of Tessellator (already submitted). However, I would like to have something cleaner to submit, such as a unique tesselator class that handle both single and double precision values. I need your advice: according to you, what is the best way to code this? Some ideas: - Duplicate code (VERY ugly) - Make the class templated (ugly) - Make a templated class that would be used by the Tessellator (still ugly) - Create/use an array adapter (Vec*Array would be encapsulated, and Tessellator would use it instead of direclty reading the array) - ... other ideas? Thanks. I'll try to apply this to other classes after. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Hi Robert, Thanks for the answer. However, I won't be able to write the non-GLU code. I guess making it work with GLU first would be nice... Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ - Robert Osfield robert.osfi...@gmail.com a écrit : Hi Sukender, I single Tessellator class is the right way to go, one could possible make parts of the implementation templated but keep the interface the same for both cases. One other thing to bare in mind is that OpenGL ES and for OpenGL 3.x/4.x GLU is no longer available so we need to replace all the OSG's GLU code for the OSG to be fully functionality across all OpenGL targets. Robert. On Mon, Jul 26, 2010 at 8:32 AM, Sukender suky0...@free.fr wrote: Hi Robert, hi all, I need double precision things in my app, and had to code things like Tessellatord, a double precision version of Tessellator (already submitted). However, I would like to have something cleaner to submit, such as a unique tesselator class that handle both single and double precision values. I need your advice: according to you, what is the best way to code this? Some ideas: - Duplicate code (VERY ugly) - Make the class templated (ugly) - Make a templated class that would be used by the Tessellator (still ugly) - Create/use an array adapter (Vec*Array would be encapsulated, and Tessellator would use it instead of direclty reading the array) - ... other ideas? Thanks. I'll try to apply this to other classes after. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ ___ 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Hi Sukender, On Mon, Jul 26, 2010 at 9:24 AM, Sukender suky0...@free.fr wrote: Thanks for the answer. However, I won't be able to write the non-GLU code. I guess making it work with GLU first would be nice... I have wondered about whether we could use the osgUtil::DelaunayTriangulator to implement osgUtil::Tessellator. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Going to check. Thanks for the info. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ - Robert Osfield robert.osfi...@gmail.com a écrit : Hi Sukender, On Mon, Jul 26, 2010 at 9:24 AM, Sukender suky0...@free.fr wrote: Thanks for the answer. However, I won't be able to write the non-GLU code. I guess making it work with GLU first would be nice... I have wondered about whether we could use the osgUtil::DelaunayTriangulator to implement osgUtil::Tessellator. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Maybe a good idea, but DelaunayTriangulator is single precision only, and there is a lot of code. I must admit I don't have enough time for porting DelaunayTriangulator yet. Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ - Robert Osfield robert.osfi...@gmail.com a écrit : Hi Sukender, On Mon, Jul 26, 2010 at 9:24 AM, Sukender suky0...@free.fr wrote: Thanks for the answer. However, I won't be able to write the non-GLU code. I guess making it work with GLU first would be nice... I have wondered about whether we could use the osgUtil::DelaunayTriangulator to implement osgUtil::Tessellator. Robert. ___ 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] Intersection with a ray
Hi, I use osgUtil::LineSegmentIntersector to obtain the intersections between a mouse or a ray starting from a wand and a terrain generated with VirtualPlanetBuilder and to display the latitude, longitude and height of the intersection point. When I use the LineSegmentIntersector with the mouse and I use the camera which accept the IntersectionVisitor, the values of latitude, longitude and height are correct. Here is my code : osg::ref_ptr osgUtil::LineSegmentIntersector picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y); osgUtil::IntersectionVisitor iv(picker.get()); view-getCamera()-accept(iv); if (picker-containsIntersections()) { intersections = picker-getIntersections(); for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) { osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode; csn-setEllipsoidModel(new osg::EllipsoidModel()); csn-addChild(group); point = hitr-getWorldIntersectPoint(); double latitude; double longitude; double height; csn-getEllipsoidModel()-convertXYZToLatLongHeight(point.x(),point.y(),point.z(),latitude,longitude,height); latitude = osg::RadiansToDegrees(latitude); longitude = osg::RadiansToDegrees(longitude); std::cout lat,long,height( latitude , longitude , height ) std::endl; } } But, my goal is to obtain the intersections of the terrain with a ray starting from a wand. I use here LineSegmentIntersector with the start point of a wand and the end point and I use the rootNode which accept the IntersectionVisitor. But in this case, the values of latitude, longitude and height are false. Here is my code : osg::Vec3 wandp1; osg::Vec3 wandp2; osg::ref_ptr osgUtil::LineSegmentIntersector picker = new osgUtil::LineSegmentIntersector(wandp1,wandp2); osgUtil::LineSegmentIntersector::Intersections intersections; osgUtil::IntersectionVisitor iv(line.get()); rootNode-accept(iv); if(picker-containsIntersections()){ //same code as before } In red are the differences between the two methods. I don't understand what is the problem. Can you help me, please? Thank you! Cheers, lucie -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30262#30262 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Double precision tessellator, optimizer, and such
Hi Sukender, On Mon, Jul 26, 2010 at 10:30 AM, Sukender suky0...@free.fr wrote: Maybe a good idea, but DelaunayTriangulator is single precision only, and there is a lot of code. I must admit I don't have enough time for porting DelaunayTriangulator yet. I think porting Tessellator to doubles when we have to replace it soon is a wasted effort. We do at least know that DelaunayTriangulator while it has flaws is deprecated by lack of GLU. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] (no subject)
This is a spam and spam link, Gordon Tomlinson Product Manager 3d Technology Project Wyvern Overwatch® An Operating Unit of Textron Systems __ WARNING: Documents that can be viewed, printed or retrieved from this E-Mail may contain technical data whose export is restricted by the Arms Export Control Act (Title 22, U.S.C., Sec 2751, et seq,) or the Export Administration Act of 1979, as amended, Title 50, U.S.C., App. 2401 et seq. and which may not be exported, released or disclosed to non-U.S. persons (i.e. persons who are not U.S. citizens or lawful permanent residents [green card holders]) inside or outside the United States, without first obtaining an export license. Violations of these export laws are subject to severe civil, criminal and administrative penalties. -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Yurii Monakov Sent: Saturday, July 24, 2010 9:21 PM To: osg-users@lists.openscenegraph.org; pavelpel...@ya.ru Subject: [osg-users] (no subject) http://sites.google.com/site/gGtjM8SvxU11/yhhyksvy ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] (no subject)
On Mon, Jul 26, 2010 at 12:39 PM, Tomlinson, Gordon gtomlin...@overwatch.textron.com wrote: This is a spam and spam link, I spotted it too, and don't know how it got into osg-users list. The mailing addresses on the post aren't subscribed and the mailing list is set to reject all posts from non subscribed members. The only exception to this is ones sent via the forum which get sent through the forums subscribed account, but this spam post didn't seem to come through this route. Any ideas? Has mailman been hacked? Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSGExp/OSG (64 bit) problem with osg::ref_ptr
Hi all, can anyone tell where i can get the 64-Bit Version of the OpenSceneGraph Exporter for Max 2010 ? Cheers, Oliver -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30257#30257 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPPU] camera order and PPU
Hi Art and All, by checking the glow example of osgPPU I was wondering if it's possible to render the glow (but in general any special fx ) camera AFTER the main one. As a child unit waits for all parent to be drawn it should be possible, isn't it? The reason I'm asking is that I don't understand how the glow camera can perform the depth test against the main depth_buffer, as it is rendered *before *the main one. Is the depth_buffer of the main camera coming from the previous frame? Thanks, Ricky ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Intersection with a ray
Hi Lucie, When you make a line segment intersector with just two Vec3s as input arguments, the line segment runs from one point to the other in model coordinates. How are you finding wandp1 and wandp2? In your code it looks like they are uninitialized in which case they are both (0, 0, 0). If you actually do have the values for the two points, would you expect that line to intersect your terrain? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30273#30273 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] 2D RenderBin vs depth test
Hi Robert, Thanks for the answer :) So I guess as a rule of thumb I should use a Geode per each object that might need to be hidden. I was interested to know if there is an expert opinion of Geode as opposed to drawable; how many drawable should be bundled into a Geode. ... Thank you! Cheers, dashesy -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30274#30274 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] setUseVertexBufferObjects(true) has no effect
Hi, setUseVertexBufferObjects(true) has no effect for me with the code below: Code: osg::Geode* geode = new osg::Geode(); geode-addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(4.4f,0.0f,0.0f),1.0f,1.4f))); geode-getDrawable(0)-setUseVertexBufferObjects(true); When I run this code with an OpenGL API tracer, I can see display lists are still being used (glNewList to build the display list, then glCallList to use it). This test is easy to reproduce with the osgShaders sample, in GL2Scene.cpp, CreateModel() can be changed to reflect the above code. I guess I must be doing something wrong to make use of VBOs. Any idea? Cheers, Fred [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30275#30275 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] a limit of osg::ReaderWriter interface
Hi, also, .ive.gz apparently cannot be read from the file system? have: a.ive gzip a.ive Now have: a.ive.gz Trying osgDB::readNodeFile(a.ive.gz) yields an error: DataInputStream::readUInt(): Failed to read unsigned int value. (which is part of the IVE plugin). This is using 2.8.3. Cheers, Florian -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30278#30278 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] setUseVertexBufferObjects(true) has no effect
Hi Fred, ShapeDrawable does not support vertex buffer objects as the vertex data is created on demand. Robert. On Mon, Jul 26, 2010 at 4:02 PM, Fred Smith osgfo...@tevs.eu wrote: Hi, setUseVertexBufferObjects(true) has no effect for me with the code below: Code: osg::Geode* geode = new osg::Geode(); geode-addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(4.4f,0.0f,0.0f),1.0f,1.4f))); geode-getDrawable(0)-setUseVertexBufferObjects(true); When I run this code with an OpenGL API tracer, I can see display lists are still being used (glNewList to build the display list, then glCallList to use it). This test is easy to reproduce with the osgShaders sample, in GL2Scene.cpp, CreateModel() can be changed to reflect the above code. I guess I must be doing something wrong to make use of VBOs. Any idea? Cheers, Fred [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30275#30275 ___ 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] SetColorArray in Geo
Hi, I would like to color a Geometry using gray scale to save memory on the graphics card (my images are gray scale anyway). Using osg::Vec4Array is 4 times what I need. Is it possible to use osg::UIntArray instead? The Api seems to allow for it but my program crashes. Cheers, avram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30271#30271 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Intersection with a ray
Hi, Thank you for your reply. I have initialized my two points depending on the position of my wand into space so the error was not this. In fact, I found an error in my code and now it works. Cheers, lucie -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30283#30283 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] setUseVertexBufferObjects(true) has no effect
Hi Fred -- If you want some basic shape support combined with use of buffer objects, you should consider osgworks.googlecode.com, which contains convenience functions to create some basic shapes using osg::Geometry objects (which supports use of buffer objects). If you need shape metadata (sphere radius, box extents, etc) you can store that information as UserData on the Geometry objects. -Paul Fred Smith wrote: Hi, setUseVertexBufferObjects(true) has no effect for me with the code below: Code: osg::Geode* geode = new osg::Geode(); geode-addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(4.4f,0.0f,0.0f),1.0f,1.4f))); geode-getDrawable(0)-setUseVertexBufferObjects(true); When I run this code with an OpenGL API tracer, I can see display lists are still being used (glNewList to build the display list, then glCallList to use it). This test is easy to reproduce with the osgShaders sample, in GL2Scene.cpp, CreateModel() can be changed to reflect the above code. I guess I must be doing something wrong to make use of VBOs. Any idea? Cheers, Fred [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30275#30275 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SetColorArray in Geo
HI Avram, Use a Vec4ubArray. Robert. On Mon, Jul 26, 2010 at 3:55 PM, avram jerusalem avramjerusa...@hotmail.com wrote: Hi, I would like to color a Geometry using gray scale to save memory on the graphics card (my images are gray scale anyway). Using osg::Vec4Array is 4 times what I need. Is it possible to use osg::UIntArray instead? The Api seems to allow for it but my program crashes. Cheers, avram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30271#30271 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Filed loading FFMPEG
Hello J-S. I ran dependency checker on my app and I got the same errors. Funny thing is that I was only forcing osgmovie to play the video using the ffmpeg plugin, but not my app. When I forced the app to load the ffmpeg library it worked just fine! Still, osgmovie doesn't work, even if I run it on the same directory as my app and force it to load the same video with ffmpeg. Don't know why. The thing is I'm really on a deadline with this project. As soon as I can I'll investigate further on this matter and try to find out why osgmovie is not working. At least my app is ok. Thank you, J-S. Cheers, Theo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30288#30288 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] PreRender Rendering
Why is this in RenderStage::draw(): Code: // note, SceneView does call to drawPreRenderStages explicitly // so there is no need to call it here. drawPreRenderStages(renderInfo,previous); Seems to be a strange cpairing of comment and code. This seems to mean that the Pre Render scene portion of the scene graph is being rendered twice. Once in SceneView and another time in RenderStage Am I missing something? Paul P. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30293#30293 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PreRender Rendering
Okay... a better question... I'm attempting to put a callback between the CULL and DRAW phases (using DrawThreadPerContext threading model). I'm currently using the PreDrawCallback to do this but this callback seems to be called AFTER the drawPreRenderStages() in RenderStage::draw call. I'm rendering to a texture and therefore have marked part of my scene graph as a PreRender scene graph. Then, I figured I could use the InitialDrawCallback in RenderStage::draw but this callback gets called AFTER the SceneView call to RenderStage-drawPreRenderStages(). I don't see a Post Cull callback nor do I see a PreDraw Callback that is actually before all the Drawing takes place. I'm using OSG 2.8.3. Any help would be appreciated. Thanks, Paul P. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30294#30294 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] TriangleFunctor/TriangleIndexFunctor with Vertex Attributes?
Thank you Robert for the detailed explanation of TriangleFunctor and TriangleIndexFunctor. Those classes have proven to be very useful to me. I'm curious to know if there is a good way to use those classes in a manner that allows you to also access attributes for each vertex. In particular, I'm interested in accessing texture coordinate and/or color attributes (for v1, v2 and v3) inside of my 'operator()(const int v1, const int v2, const int v3)' implementation. I have had some limited success using a custom ConstAttributeFunctor subclass to accumlate attributes inside of a ' NodeVisitor::apply( osg::Geode)' override, but I'm struggling with devising the best plan for mapping each vertex back to the appropriate attribute. My current solution is very messy and I doublt it's very robust. Is there a prescribed way to do this? Thanks, Rob Radtke -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 12 March 2010 10:57 To: OpenSceneGraph Users Subject: Re: [osg-users] Need help to understand this code snippet withaccept and operator Hi Fred, The TriangleIndexFunctor is a template helper class for making it easier to access the triangles held in osg::Drawable. The actual geometry primitives held within different osg::Drawable subclasses could be of any type and any arrangement, so casting osg::Drawable to osg::Geometry etc. and then accessing the primitives directly and then working out how to interpret the triangles from this is rather complex, tedious and prone to poor performance unless you are very careful. To address the tight coupling of accessors to implementations, the osg::Drawable has an accept(osg::Drawable::PrimitiveFunctor) method exists to allow a subclass from osg::Drawable to pass details on the geometry primitives that it has to the functor in a generic way - thus hiding the local implementation details of that Drawable and enabling your own custom PrimitiveFunctor to work with a wide range of Drawable without needing to know the implementation details. While this achieves good decoupling the PrimitiveFunctor still has to handle all the different types of primitives - polygons, tri strips, quads, qaud strips, lines etc, which is still pretty complicated to implement. To address the complexity of handling all the different types of primitives the TriangleIndexFunctor template class exists to decompose all the descriptions of generic primitives into the simple triangles marked by their corner indices. For you the app developer all you then need to do is create you little functor that implements the void operator()(const int v1, const int v2, const int v3) method as per the example, and then pass the resulting templated class to the drawable to get all the triangle information. The use of templates also ensures good performance. If it wasn't for PrimtiiveFunctor and TriangleFunctor/TriangleIndexFunctor accessing geometry would be very tedious and error prone task - lots of casts, switch statements and book keeping. These helper classes might seem a bit convoluted at first look, they really make life much easier. Go have a search through the OSG code base, there are plenty of examples of TriangleFunctor/TriangleIndexFunctor in action - especially in src/osgUtil. Cheers, Robert. smime.p7s Description: S/MIME Cryptographic Signature ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] TriangleFunctor/TriangleIndexFunctor with Vertex Attributes?
Thank you Robert for the detailed explanation of TriangleFunctor and TriangleIndexFunctor. Those classes have proven to be very useful to me. I'm curious to know if there is a good way to use those classes in a manner that allows you to also access attributes for each vertex. In particular, I'm interested in accessing texture coordinate and/or color attributes (for v1, v2 and v3) inside of my 'operator()(const int v1, const int v2, const int v3)' implementation. I have had some limited success using a custom ConstAttributeFunctor subclass to accumlate attributes inside of a ' NodeVisitor::apply( osg::Geode)' override, but I'm struggling with devising the best plan for mapping each vertex back to the appropriate attribute. My current solution is very messy and I doublt it's very robust. Is there a prescribed way to do this? Thanks, Rob Radtke -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: 12 March 2010 10:57 To: OpenSceneGraph Users Subject: Re: [osg-users] Need help to understand this code snippet withaccept and operator Hi Fred, The TriangleIndexFunctor is a template helper class for making it easier to access the triangles held in osg::Drawable. The actual geometry primitives held within different osg::Drawable subclasses could be of any type and any arrangement, so casting osg::Drawable to osg::Geometry etc. and then accessing the primitives directly and then working out how to interpret the triangles from this is rather complex, tedious and prone to poor performance unless you are very careful. To address the tight coupling of accessors to implementations, the osg::Drawable has an accept(osg::Drawable::PrimitiveFunctor) method exists to allow a subclass from osg::Drawable to pass details on the geometry primitives that it has to the functor in a generic way - thus hiding the local implementation details of that Drawable and enabling your own custom PrimitiveFunctor to work with a wide range of Drawable without needing to know the implementation details. While this achieves good decoupling the PrimitiveFunctor still has to handle all the different types of primitives - polygons, tri strips, quads, qaud strips, lines etc, which is still pretty complicated to implement. To address the complexity of handling all the different types of primitives the TriangleIndexFunctor template class exists to decompose all the descriptions of generic primitives into the simple triangles marked by their corner indices. For you the app developer all you then need to do is create you little functor that implements the void operator()(const int v1, const int v2, const int v3) method as per the example, and then pass the resulting templated class to the drawable to get all the triangle information. The use of templates also ensures good performance. If it wasn't for PrimtiiveFunctor and TriangleFunctor/TriangleIndexFunctor accessing geometry would be very tedious and error prone task - lots of casts, switch statements and book keeping. These helper classes might seem a bit convoluted at first look, they really make life much easier. Go have a search through the OSG code base, there are plenty of examples of TriangleFunctor/TriangleIndexFunctor in action - especially in src/osgUtil. Cheers, Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OSG Uniform Array Setup [SEC=UNCLASSIFIED]
Hi All, I've been trying out geometry instancing however am experiencing OpenGL errors. I'm using NV 8800GTX with latest 256.35 Linux drivers so it should work. I am thinking it is my set up. I have set up everything correctly as per osgdrawinstanced example so i'm thinking it is the way I'm passing the uniform to the shader? maybe the use of Vec4Array? If someone could pass a casual eye over the relevant code below and see something noticeable I would be grateful. I was also wondering if it is a driver bug - if there are alternate solutions to pass array data to the vertex shader? - Regards //Set up osg::ref_ptrosg::Vec4Array m_positions = new osg::Vec4Array; // Fill up the Array etc ... size: 10 //v-push_back(osg::Vec4(position,1.0)); osg::Uniform* centres = new osg::Uniform( centres, m_positions ); osg::Uniform* centres = new osg::Uniform(); centres-setName(centres); centres-setType(osg::Uniform::FLOAT_VEC4); centres-setNumElements(m_positions-size()); stateset-addUniform(centres); //Vertex shader uniform vec4[10] centres; vec3 centre = centres[gl_InstanceID].xyz; vec3 pos = gl_Vertex + centre; gl_Position = gl_ModelViewProjectionMatrix * vec4(pos,1.0); IMPORTANT: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org