Re: [osg-users] different materials for a geometry and highlight

2016-09-30 Thread Gianni Ambrosio
Hi Sebastian, thanks for the example. The roads I use may have from 600K to a maximum of 9 milion elements (=triangles). Maybe a mean of 2 milions. Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68830#68830

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Sebastian Messerschmidt
There you go: The example without vertex sharing. Am 9/28/2016 um 4:57 PM schrieb Gianni Ambrosio: Hi Sebastian, I would like to adopt you solution if possible but I was not able to implement with textures the same behaviour of the example I did with primitive sets. I know that on

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Sebastian Messerschmidt
Am 9/28/2016 um 4:57 PM schrieb Gianni Ambrosio: Hi Sebastian, I would like to adopt you solution if possible but I was not able to implement with textures the same behaviour of the example I did with primitive sets. I know that on windows the example crashes in debug mode because of an

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Gianni Ambrosio
Hi Sebastian, I would like to adopt you solution if possible but I was not able to implement with textures the same behaviour of the example I did with primitive sets. I know that on windows the example crashes in debug mode because of an assertion inside Microsoft implementaition of

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Sebastian Messerschmidt
Just pointing out, that you might have been lucky: Your example is crashing on my machine, due to the empty primitive-sets ;) There isn't even picking involved. Hi Gianni. Hi Sebastian, in attachment you can find a movie of what I implemented with primitive sets. That's exactly what I

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Sebastian Messerschmidt
Hi Gianni. Hi Sebastian, in attachment you can find a movie of what I implemented with primitive sets. That's exactly what I need. The "road" is initially gray. Then the user choose a color (pushing in my example 1,2,3 or 4 key) and picking the road surface triangles are coloured with the

Re: [osg-users] different materials for a geometry and highlight

2016-09-28 Thread Gianni Ambrosio
Hi Sebastian, after looking at your example I understood a shader is not needed, right? The solution you suggest is to apply a texture instead of changing color. In my case the image of the texture would be a monochromatic image. If all that is correct, then I have few questions. I modified my

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Gianni Ambrosio
SMesserschmidt wrote: > Do you need to place the curbs > etc. also dynamically? > The road geometry is fixed, I mean, the user can only assign/change a material to each triangle without adding or removing triangles from the road surface. SMesserschmidt wrote: > > Are there any restrictions

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Sebastian Messerschmidt
Hi Gianni, attached you find a quick example using a simple texture to let the user "draw" different colors at different positions. Basically it modifies the image data and samples it back when drawing. I've created a mesh, but basically this would work with a simple quad too. Is this maybe

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Gianni Ambrosio
SMesserschmidt wrote: > I can try to make a > minimal example, if you give me some time (I can do this after work). > Sebastian, yes thanks, when you have time is fine. In the meanwhile I try to understand the solutions you suggested. Regards, Gianni -- Read this topic

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Sebastian Messerschmidt
Hi Gianni, Trajce Nikolov NICK wrote: Maybe better idea then these email iterations is to write us what is your goal with this code since I see no smart logic in there (sorry :-) ) OK, I try to explain in detail. The object I visualize on 3D is a road. A road can have different "materials":

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Gianni Ambrosio
Trajce Nikolov NICK wrote: > > you should call geometry->dirtyDisplayList(); at the end of your move function Nick, I confirm my first example now works adding that line. At least I undestood what was missing. Waiting for an opinion about the overall scenario, thanks again! Gianni

Re: [osg-users] different materials for a geometry and highlight

2016-09-27 Thread Gianni Ambrosio
Trajce Nikolov NICK wrote: > Maybe better idea then these email iterations is to write us what is your > goal with this code since I see no smart logic in there (sorry :-) ) > OK, I try to explain in detail. The object I visualize on 3D is a road. A road can have different "materials":

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Trajce Nikolov NICK
Gianni, you should call geometry->dirtyDisplayList(); at the end of your move function ... Not sure about the rest of the logic of your code now though Maybe better idea then these email iterations is to write us what is your goal with this code since I see no smart logic in there (sorry

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Sebastian Messerschmidt
Hi Gianni, A very simplistic solution using a outline triangle: #include #include #include #include #include #include #include #include #include #include //#include #include const osg::Vec4 selectedColor(1.0f, 1.0f, 1.0f, 0.5f); const osg::Vec4 color1(1.0f, 0.0f, 0.0f, 1.0f);

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Sebastian Messerschmidt
Hi Gianni, One question, why should I use a "vertex" shader/attribute when I need to colour a triangle uniformly? Long story short: There is no such thing as per-primitive colors. Long story long: In order to color your primitives you need to assign a color to each vertex. That is how modern

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Gianni Ambrosio
One question, why should I use a "vertex" shader/attribute when I need to colour a triangle uniformly? Regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68753#68753 ___ osg-users

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Gianni Ambrosio
Well, Nick, I have to say I didn't understand what Sebastian suggested since I'm not familiar with shaders. As far as I understood a shader can not be debugged and I don't know if they are testable. Moreover the code is in a place different from the usual code, so something that has effect in

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Trajce Nikolov NICK
Hi Gianni, I have stopped looking at the issue since Sebastian's suggestion is really better (more modern approach and really easier to implement and maintain once you get a handle of it). If you still want to continue your way I will have a look later today if I can spot anything .. Will ping

Re: [osg-users] different materials for a geometry and highlight

2016-09-26 Thread Gianni Ambrosio
Dear Nick, I'm not sure to use the solution suggested by Sebastian (I've never worked with shaders so it is quite difficult to understand). So I would like to know if you foud a reason of the problem in my example? Regards, Gianni -- Read this topic online here:

Re: [osg-users] different materials for a geometry and highlight

2016-09-22 Thread Sebastian Messerschmidt
Am 9/22/2016 um 12:23 PM schrieb Gianni Ambrosio: SMesserschmidt wrote: So basically you are raping the primitive sets to color the primitive? Yes, that's why at the beginning I asked help to suggest me the best way to implement this. Nobody replied so I found this way. Maybe your questions

Re: [osg-users] different materials for a geometry and highlight

2016-09-22 Thread Gianni Ambrosio
SMesserschmidt wrote: > So basically you are raping the primitive sets to color the primitive? Yes, that's why at the beginning I asked help to suggest me the best way to implement this. Nobody replied so I found this way. SMesserschmidt wrote: > > That is certainly a complicated way in case

Re: [osg-users] different materials for a geometry and highlight

2016-09-22 Thread Sebastian Messerschmidt
Hi Gianni, Hi Nick, the triangle shown in white has just being added to highlight the selection. We can discard it for a while. For that reason I completly removed the selection highlight in my example. Please see attached code. If you run the example and select a triangle pushing

Re: [osg-users] different materials for a geometry and highlight

2016-09-22 Thread Gianni Ambrosio
Hi Nick, the triangle shown in white has just being added to highlight the selection. We can discard it for a while. For that reason I completly removed the selection highlight in my example. Please see attached code. If you run the example and select a triangle pushing CTRL+LEFTMOUSE you will

Re: [osg-users] different materials for a geometry and highlight

2016-09-21 Thread Gianni Ambrosio
Hi Nick, the problem I have is that I change the content of primitive sets but the color does not change in the 3D view. Regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68681#68681

Re: [osg-users] different materials for a geometry and highlight

2016-09-21 Thread Trajce Nikolov NICK
Hi Gianni, I am having the same results as in the video and I thought that is what is expected - I thought your main problem was updating the selection area with colors. Let me see if I can spot something else in your code ... I am doing this in breaks :-) On Wed, Sep 21, 2016 at 8:48 AM, Gianni

Re: [osg-users] different materials for a geometry and highlight

2016-09-21 Thread Gianni Ambrosio
Hi Nick, thanks for the support but even with that line I can't see the result I expected. Basically, when the application starts, if I select a green triangle then it should be shown in red, while now it ramains green. (please see attached movie). In fact the triangle after picking is moved

Re: [osg-users] different materials for a geometry and highlight

2016-09-20 Thread Trajce Nikolov NICK
Hi Gianni, I give it a shot. Your code actually works. Only one little line to add in doUserOperations - you should dirty the vertex buffer object selVertices->dirty(); selVertices->getBufferObject()->dirty(); <--- this is the thing _selector->dirtyBound(); Cheers! Nick On Tue, Sep 20, 2016

Re: [osg-users] different materials for a geometry and highlight

2016-09-20 Thread Gianni Ambrosio
Trajce Nikolov NICK wrote: > Hi Gianni, > > if you make Qt free example I can have a look > Sorry, this example "was" with Qt, now it is Qt-free. Just remove the includes on top: they are not used in this code. Gianni -- Read this topic online here:

Re: [osg-users] different materials for a geometry and highlight

2016-09-20 Thread Trajce Nikolov NICK
Hi Gianni, if you make Qt free example I can have a look On Tue, Sep 20, 2016 at 12:33 PM, Gianni Ambrosio wrote: > Hi All, > I'm attaching the updated code where you can see the problem: even if I > call dirty() for primitive sets and dirtyBounds() on the related

Re: [osg-users] different materials for a geometry and highlight

2016-09-20 Thread Gianni Ambrosio
Hi All, I'm attaching the updated code where you can see the problem: even if I call dirty() for primitive sets and dirtyBounds() on the related geometry, the graphics is not updated. Cheers, Gianni -- Read this topic online here:

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
Trajce Nikolov NICK wrote: > Maybe you dirty your color array too? > Thanks Nikolov, in my code the color array don't change. Anyway I tried as you suggested and I can confirm that's not the point. Regards, Gianni -- Read this topic online here:

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
OK, I found a way to move a triangle from a primitive set to another. Debugging the code primitive sets are updated correctly but the color remains the same. I call sourcePrimitiveSet->dirty(); destinationPrimitiveSet->dirty(); geometry->dirtyBound(); What's wrong with it? Isn't enough?

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
Hi Sebastian, SMesserschmidt wrote: > I might be wrong, but I think the intersector.primitiveIndex might yield > the number you are looking for > thanks for the reply but unfortunately it seems to return a number from 0 to 7 that is the number of triangles in my example geometry. While the

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Sebastian Messerschmidt
Hi Gianni, I browsed the LineSegmentIntersector code and it seems, the intersector is using a triangleFunctor to traverse your primitive sets as triangles anyways. So the Ifnromation So basically you cannot find out which primitive set was affected without reverse-engineering which primitive

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Sebastian Messerschmidt
Hi Gianni, Code: osg::Geometry* buildGeometry() { osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(buildVertices()); geometry->setColorArray(buildColors(), osg::Array::BIND_PER_PRIMITIVE_SET); std::vector elements =

Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
Hi All, I've attached an example. Hope this helps to have a reply from somebody (Robert?). Part of that example is from the OSG 3 Cookbook. Suppose I have geometry build of triangles. I would like to understand which is the better way to change the color of a selected triangle. And if there is

Re: [osg-users] different materials for a geometry and highlight

2016-09-16 Thread Gianni Ambrosio
Code: osg::Geometry* buildGeometry() { osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(buildVertices()); geometry->setColorArray(buildColors(), osg::Array::BIND_PER_PRIMITIVE_SET); std::vector elements = buildElements();

[osg-users] different materials for a geometry and highlight

2016-09-06 Thread Gianni Ambrosio
Dear All, I currently draw graphics with: osg::Geometry* geometry = getGeometry(); geometry->setVertexArray(vertices); geometry->addPrimitiveSet(elements); where: osg::Vec3Array* vertices = new osg::Vec3Array; osg::DrawElementsUInt* elements = new